public static IProcess CreateProcess(this IProcessFactory factory, string fileName, string arguments, NetworkCredential credentials) { Invariant.ArgumentNotNull((object)factory, "factory"); Invariant.ArgumentNotNullOrEmpty(fileName, "fileName"); Invariant.ArgumentNotNull((object)credentials, "credentials"); return(factory.CreateProcess(fileName, arguments, credentials.UserName, ProcessFactoryExtensions.SecurePassword(credentials.Password), credentials.Domain)); }
public static IProcess CreateProcess(this IProcessFactory factory, string fileName, string arguments, string userName, SecureString password, string domain) { Invariant.ArgumentNotNull((object)factory, "factory"); Invariant.ArgumentNotNullOrEmpty(fileName, "fileName"); return(factory.CreateProcess(new ProcessStartInfo(fileName, arguments) { UseShellExecute = false, UserName = userName, Password = password, Domain = domain })); }
private FormattedMessage(Type resourceType, string resourceKey, params object[] parameters) { Invariant.ArgumentNotNull((object)resourceType, "resourceType"); Invariant.ArgumentNotNullOrEmpty(resourceKey, "resourceKey"); Invariant.ArgumentNotNull((object)parameters, "parameters"); if (parameters.OfType <FormattedMessage>().Any <FormattedMessage>()) { throw new ArgumentOutOfRangeException("FormattedMessage instances are not supported in parameters list", "parameters"); } this.resourceKey = resourceKey; this.parameters = parameters; this.manager = new ResourceManager(resourceType); }
public static string StringJoin(this IEnumerable <string> enumerable, string separator) { Invariant.ArgumentNotNull((object)enumerable, "enumerable"); Invariant.ArgumentNotNullOrEmpty(separator, "separator"); StringBuilder stringBuilder = new StringBuilder(); using (IEnumerator <string> enumerator = enumerable.GetEnumerator()) { if (enumerator.MoveNext()) { stringBuilder.Append(enumerator.Current ?? ""); while (enumerator.MoveNext()) { stringBuilder.Append(separator); stringBuilder.Append(enumerator.Current ?? ""); } } } return(stringBuilder.ToString()); }
public static IEnumerable <IDiskDrive> Query(IComputerSystem host, string cond) { Invariant.ArgumentNotNull((object)host, nameof(host)); Invariant.ArgumentNotNullOrEmpty(cond, nameof(cond)); ManagementObjectCollection moc = new ManagementScope(string.Format("\\\\{0}\\root\\cimv2", (object)((IWMICommon)host).Scope.Path.Server)).Query("Select * from Win32_DiskDrive Where " + cond); try { foreach (ManagementObject instance in moc) { yield return((IDiskDrive) new DiskDrive(instance)); } } finally { if (moc != null) { moc.Dispose(); } } moc = (ManagementObjectCollection)null; }