Skip to content

Commit

Permalink
Various resharper fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannewington committed May 29, 2016
1 parent 1d09575 commit 917cef5
Show file tree
Hide file tree
Showing 27 changed files with 341 additions and 483 deletions.
11 changes: 4 additions & 7 deletions src/Lithnet.Miiserver.AutoSync/ADListenerConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace Lithnet.Miiserver.AutoSync
Expand Down Expand Up @@ -37,22 +34,22 @@ internal void Validate()

if (this.MinimumTriggerIntervalSeconds <= 0)
{
throw new ArgumentOutOfRangeException("MinimumTriggerIntervalSeconds", "The MinimumTriggerIntervalSeconds parameter must be greater than 0");
throw new ArgumentOutOfRangeException(nameof(this.MinimumTriggerIntervalSeconds), "The MinimumTriggerIntervalSeconds parameter must be greater than 0");
}

if (string.IsNullOrWhiteSpace(this.BaseDN))
{
throw new ArgumentNullException("BaseDN", "A BaseDN must be specified");
throw new ArgumentNullException(nameof(this.BaseDN), "A BaseDN must be specified");
}

if (string.IsNullOrWhiteSpace(this.HostName))
{
throw new ArgumentNullException("HostName", "A host name must be specified");
throw new ArgumentNullException(nameof(this.HostName), "A host name must be specified");
}

if (this.ObjectClasses == null || this.ObjectClasses.Length == 0)
{
throw new ArgumentNullException("ObjectClasses", "One or more object classes must be specified");
throw new ArgumentNullException(nameof(this.ObjectClasses), "One or more object classes must be specified");
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions src/Lithnet.Miiserver.AutoSync/AutoSyncService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.ServiceProcess;

namespace Lithnet.Miiserver.AutoSync
{
Expand Down
7 changes: 1 addition & 6 deletions src/Lithnet.Miiserver.AutoSync/Enums/AutoImportScheduling.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lithnet.Miiserver.AutoSync
namespace Lithnet.Miiserver.AutoSync
{
public enum AutoImportScheduling
{
Expand Down
7 changes: 1 addition & 6 deletions src/Lithnet.Miiserver.AutoSync/Enums/MARunProfileType.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lithnet.Miiserver.AutoSync
namespace Lithnet.Miiserver.AutoSync
{
public enum MARunProfileType
{
Expand Down
13 changes: 6 additions & 7 deletions src/Lithnet.Miiserver.AutoSync/EventArgs/ExecutionParameters.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lithnet.Miiserver.AutoSync
{
public class ExecutionParameters
{
public bool Exclusive { get; set; }
public bool Exclusive { get; set; }

public string RunProfileName { get; set; }

Expand Down Expand Up @@ -45,7 +42,7 @@ public override bool Equals(object obj)

if (p2 == null)
{
return base.Equals(obj);
return object.ReferenceEquals(this, obj);
}

return (string.Equals(this.RunProfileName, p2.RunProfileName, StringComparison.OrdinalIgnoreCase) &&
Expand All @@ -55,13 +52,15 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
string hashcode = string.Format("{0}{1}{2}", this.RunProfileName, this.RunProfileType.ToString(), this.Exclusive.ToString());
// ReSharper disable NonReadonlyMemberInGetHashCode
string hashcode = $"{this.RunProfileName}{this.RunProfileType}{this.Exclusive}";
// ReSharper restore NonReadonlyMemberInGetHashCode
return hashcode.GetHashCode();
}

public static bool operator ==(ExecutionParameters a, ExecutionParameters b)
{
if (Object.ReferenceEquals(a, b))
if (object.ReferenceEquals(a, b))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lithnet.Miiserver.Client;

namespace Lithnet.Miiserver.AutoSync
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lithnet.Miiserver.AutoSync
{
Expand Down
10 changes: 0 additions & 10 deletions src/Lithnet.Miiserver.AutoSync/Global.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

Expand All @@ -11,13 +8,6 @@ public static class Global
{
private static Random random = new Random();

//static Global()
//{
// Global.ScriptDirectory = Global.AssemblyDirectory;
//}

//public static string ScriptDirectory { get; set; }

public static string AssemblyDirectory
{
get
Expand Down
11 changes: 2 additions & 9 deletions src/Lithnet.Miiserver.AutoSync/MAConfigDiscovery.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lithnet.Miiserver.Client;
using Lithnet.Logging;
using System.IO;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Host;
using System.Collections.ObjectModel;
using Lithnet.Miiserver.Client;

namespace Lithnet.Miiserver.AutoSync
{
Expand Down
42 changes: 11 additions & 31 deletions src/Lithnet.Miiserver.AutoSync/MAConfigParameters.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Linq;
using System.Text;

namespace Lithnet.Miiserver.AutoSync
{
Expand Down Expand Up @@ -42,40 +40,22 @@ public MAConfigParameters(Hashtable config)
this.ScheduledImportRunProfileName = config["ScheduledImportRunProfileName"] as string;
this.DeltaImportRunProfileName = config["DeltaImportRunProfileName"] as string;
this.ExportRunProfileName = config["ExportRunProfileName"] as string;
this.Disabled = config["Disabled"] == null ? false : Convert.ToBoolean(config["Disabled"]);
this.Disabled = config["Disabled"] != null && Convert.ToBoolean(config["Disabled"]);
this.AutoImportScheduling = config["AutoImportScheduling"] == null ? AutoImportScheduling.Default : (AutoImportScheduling)Enum.Parse(typeof(AutoImportScheduling), config["AutoImportScheduling"].ToString(), true);
this.DisableDefaultTriggers = config["DisableDefaultTriggers"] == null ? false : Convert.ToBoolean(config["DisableDefaultTriggers"]);
this.DisableDefaultTriggers = config["DisableDefaultTriggers"] != null && Convert.ToBoolean(config["DisableDefaultTriggers"]);
this.AutoImportIntervalMinutes = config["AutoImportIntervalMinutes"] == null ? 0 : Convert.ToInt32(config["AutoImportIntervalMinutes"]);
}

internal bool CanExport
{
get
{
return this.ExportRunProfileName != null;
}
}
internal bool CanExport => this.ExportRunProfileName != null;

internal bool CanImport
{
get
{
return this.ScheduledImportRunProfileName != null || this.FullImportRunProfileName != null;
}
}
internal bool CanImport => this.ScheduledImportRunProfileName != null || this.FullImportRunProfileName != null;

internal bool CanAutoRun
{
get
{
return this.DeltaSyncRunProfileName != null ||
this.ConfirmingImportRunProfileName != null ||
this.FullSyncRunProfileName != null ||
this.FullImportRunProfileName != null ||
this.ScheduledImportRunProfileName != null ||
this.ExportRunProfileName != null;
}
}
internal bool CanAutoRun => this.DeltaSyncRunProfileName != null ||
this.ConfirmingImportRunProfileName != null ||
this.FullSyncRunProfileName != null ||
this.FullImportRunProfileName != null ||
this.ScheduledImportRunProfileName != null ||
this.ExportRunProfileName != null;

internal string GetRunProfileName(MARunProfileType type)
{
Expand All @@ -95,7 +75,7 @@ internal string GetRunProfileName(MARunProfileType type)

case MARunProfileType.FullSync:
return this.FullSyncRunProfileName;

default:
case MARunProfileType.None:
throw new ArgumentException("Unknown run profile type");
Expand Down
9 changes: 1 addition & 8 deletions src/Lithnet.Miiserver.AutoSync/MAController.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Host;
using System.Threading.Tasks;
using System.Threading;
using Lithnet.Logging;
using Lithnet.Miiserver.Client;
using System.IO;

namespace Lithnet.Miiserver.AutoSync
{
Expand Down
36 changes: 18 additions & 18 deletions src/Lithnet.Miiserver.AutoSync/MAExecutionTriggerDiscovery.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lithnet.Miiserver.Client;
using Lithnet.Logging;
using System.IO;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Host;
using System.Collections.ObjectModel;
using System.Xml;

namespace Lithnet.Miiserver.AutoSync
Expand Down Expand Up @@ -142,22 +137,27 @@ private static IEnumerable<IMAExecutionTrigger> GetDefaultTriggers(ManagementAge
return triggers;
}

if (ma.Category == "FIM")
switch (ma.Category)
{
FimServicePendingImportTrigger t1 = new FimServicePendingImportTrigger(MAExecutionTriggerDiscovery.GetFimServiceHostName(ma));
triggers.Add(t1);
}
else if (ma.Category == "AD")
{
ADListenerConfiguration listenerConfig = configItems.OfType<ADListenerConfiguration>().FirstOrDefault();
case "FIM":
FimServicePendingImportTrigger t1 = new FimServicePendingImportTrigger(MAExecutionTriggerDiscovery.GetFimServiceHostName(ma));
triggers.Add(t1);
break;

if (listenerConfig == null)
{
listenerConfig = GetADConfiguration(ma);
}
case "AD":
ADListenerConfiguration listenerConfig = configItems.OfType<ADListenerConfiguration>().FirstOrDefault();

ActiveDirectoryChangeTrigger t2 = new ActiveDirectoryChangeTrigger(listenerConfig);
triggers.Add(t2);
if (listenerConfig == null)
{
listenerConfig = MAExecutionTriggerDiscovery.GetADConfiguration(ma);
}

ActiveDirectoryChangeTrigger t2 = new ActiveDirectoryChangeTrigger(listenerConfig);
triggers.Add(t2);
break;

default:
break;
}

return triggers;
Expand Down
Loading

0 comments on commit 917cef5

Please sign in to comment.