コード例 #1
0
 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));
 }
コード例 #2
0
 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
     }));
 }
コード例 #3
0
 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);
 }
コード例 #4
0
        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());
        }
コード例 #5
0
ファイル: DiskDrive.cs プロジェクト: phspies/terodoview_ce
        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;
        }