Ejemplo n.º 1
0
        private static object TranslateCmdletProxyDictionaryParameter(object paramValue, ExchangeRunspaceConfigurationSettings.ProxyMethod proxyMethod)
        {
            IDictionary dictionary = (IDictionary)paramValue;

            if (proxyMethod == ExchangeRunspaceConfigurationSettings.ProxyMethod.RPS)
            {
                Dictionary <string, object> dictionary2 = new Dictionary <string, object>();
                foreach (object obj in dictionary.Keys)
                {
                    dictionary2.Add(obj.ToString(), ProxyHelper.TranslateCmdletProxyParameter(dictionary[obj], proxyMethod));
                }
                return(dictionary2);
            }
            int           num           = 0;
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("{");
            foreach (object obj2 in dictionary.Keys)
            {
                num++;
                stringBuilder.Append(obj2.ToString()).Append(" = ");
                object obj3 = dictionary[obj2];
                if (obj3 == null)
                {
                    stringBuilder.Append(ProxyHelper.nullString);
                }
                else
                {
                    object obj4 = ProxyHelper.TranslateCmdletProxyParameter(obj3, proxyMethod);
                    if (obj4.GetType() == typeof(bool))
                    {
                        stringBuilder.Append(((bool)obj4) ? ProxyHelper.trueString : ProxyHelper.falseString);
                    }
                    else
                    {
                        stringBuilder.Append(obj4.ToString());
                    }
                }
                stringBuilder.Append("; ");
            }
            if (num == 0)
            {
                return(null);
            }
            string str = stringBuilder.ToString().Trim().TrimEnd(new char[]
            {
                ';'
            });

            return(str + "}");
        }
Ejemplo n.º 2
0
        private static object TranslateCmdletProxyCollectionParameter(object paramValue, ExchangeRunspaceConfigurationSettings.ProxyMethod proxyMethod)
        {
            ICollection collection = (ICollection)paramValue;

            if (proxyMethod == ExchangeRunspaceConfigurationSettings.ProxyMethod.RPS)
            {
                Collection <object> collection2 = new Collection <object>();
                foreach (object paramValue2 in collection)
                {
                    collection2.Add(ProxyHelper.TranslateCmdletProxyParameter(paramValue2, proxyMethod));
                }
                return(collection2);
            }
            int           num           = 0;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (object paramValue3 in collection)
            {
                num++;
                object obj = ProxyHelper.TranslateCmdletProxyParameter(paramValue3, proxyMethod);
                string arg;
                if (obj == null)
                {
                    arg = ProxyHelper.nullString;
                }
                else if (obj.GetType() == typeof(bool))
                {
                    arg = (((bool)obj) ? ProxyHelper.trueString : ProxyHelper.falseString);
                }
                else
                {
                    arg = obj.ToString().Replace("'", "''");
                }
                stringBuilder.AppendFormat("'{0}',", arg);
            }
            if (num == 0)
            {
                return(null);
            }
            return(stringBuilder.ToString().Trim().TrimEnd(new char[]
            {
                ','
            }));
        }
Ejemplo n.º 3
0
        // Token: 0x06001645 RID: 5701 RVA: 0x00053FB0 File Offset: 0x000521B0
        private PSCommand GenerateProxyCmdlet(CmdletProxyInfo.ChangeCmdletProxyParametersDelegate changeCmdletProxyParameters)
        {
            this.MakeNecessaryChangeOnParametersBeforeProxy(changeCmdletProxyParameters);
            PSCommand pscommand = new PSCommand();
            Command   command   = null;

            if (this.context.InvocationInfo != null)
            {
                command = new Command(this.context.InvocationInfo.CommandName);
            }
            if (this.context.InvocationInfo != null)
            {
                foreach (object obj in this.context.InvocationInfo.UserSpecifiedParameters.Keys)
                {
                    string text = (string)obj;
                    command.Parameters.Add(text, ProxyHelper.TranslateCmdletProxyParameter(this.GetParameterValueToProxy(text), ExchangeRunspaceConfigurationSettings.ProxyMethod.RPS));
                }
            }
            pscommand.AddCommand(command);
            return(pscommand);
        }