private void InitAdditionalProperties(HttpWebClientProtocol proxy)
 {
     if (proxyTypeHandlers == null)
     {
         proxyTypeHandlers = new Hashtable();
         CustomHandler[] proxyProperties = Configuration.MasterConfig.ProxyProperties;
         if ((proxyProperties != null) && (proxyProperties.Length > 0))
         {
             foreach (CustomHandler handler in proxyProperties)
             {
                 string typeName = handler.TypeName;
                 string str2     = handler.Handler;
                 if (((typeName != null) && (typeName.Length != 0)) && ((str2 != null) && (str2.Length != 0)))
                 {
                     Type key = Type.GetType(typeName);
                     if (key == null)
                     {
                         MainForm.ShowMessage(this, MessageType.Warning,
                                              string.Format(typeNotFoundMessage, typeName));
                     }
                     else
                     {
                         Type type = Type.GetType(str2);
                         if (type == null)
                         {
                             MainForm.ShowMessage(this, MessageType.Warning,
                                                  string.Format(typeNotFoundMessage, str2));
                         }
                         else
                         {
                             proxyTypeHandlers.Add(key, type);
                         }
                     }
                 }
             }
         }
     }
     for (Type type3 = proxy.GetType(); type3 != typeof(object); type3 = type3.BaseType)
     {
         var type4 = proxyTypeHandlers[type3] as Type;
         if (type4 != null)
         {
             AdditionalProperties = (IAdditionalProperties)Activator.CreateInstance(type4, new object[] { proxy });
             break;
         }
     }
 }
 private void InitAdditionalProperties(HttpWebClientProtocol proxy)
 {
     if (proxyTypeHandlers == null)
     {
         proxyTypeHandlers = new Hashtable();
         CustomHandler[] handlerArray1 = Configuration.MasterConfig.ProxyProperties;
         if ((handlerArray1 != null) && (handlerArray1.Length > 0))
         {
             foreach (CustomHandler handler1 in handlerArray1)
             {
                 string text1 = handler1.TypeName;
                 string text2 = handler1.Handler;
                 if (((text1 != null) && (text1.Length != 0)) && ((text2 != null) && (text2.Length != 0)))
                 {
                     Type type1 = Type.GetType(text1);
                     if (type1 == null)
                     {
                         MainForm.ShowMessage(this, MessageType.Warning,
                                              string.Format(typeNotFoundMessage, text1));
                     }
                     else
                     {
                         Type type2 = Type.GetType(text2);
                         if (type2 == null)
                         {
                             MainForm.ShowMessage(this, MessageType.Warning,
                                                  string.Format(typeNotFoundMessage, text2));
                         }
                         else
                         {
                             proxyTypeHandlers.Add(type1, type2);
                         }
                     }
                 }
             }
         }
     }
     for (Type type3 = proxy.GetType(); type3 != typeof(object); type3 = type3.BaseType)
     {
         Type type4 = proxyTypeHandlers[type3] as Type;
         if (type4 != null)
         {
             AdditionalProperties = (IAdditionalProperties)Activator.CreateInstance(type4, new object[] { proxy });
             return;
         }
     }
 }
示例#3
0
        private CodeExpression BuildProxy(CodeStatementCollection statements, MethodInfo method)
        {
            Type   type = proxy.GetType();
            string name = CodeIdentifier.MakeCamel(type.Name);

            if (proxySetting == ProxySettings.AllProperties)
            {
                return(BuildClass(statements, name, proxy));
            }
            var statement = new CodeVariableDeclarationStatement(type.Name, name);

            statement.InitExpression = new CodeObjectCreateExpression(type.FullName, new CodeExpression[0]);
            statements.Add(statement);
            CodeExpression targetObject = new CodeVariableReferenceExpression(name);

            FieldInfo[] soapHeaders = null;
            if (proxySetting == ProxySettings.RequiredHeaders)
            {
                soapHeaders = MethodProperty.GetSoapHeaders(method, true);
            }
            else
            {
                soapHeaders = type.GetFields();
            }
            for (int i = 0; i < soapHeaders.Length; i++)
            {
                FieldInfo info = soapHeaders[i];
                if (typeof(SoapHeader).IsAssignableFrom(info.FieldType))
                {
                    CodeExpression left  = new CodeFieldReferenceExpression(targetObject, info.Name);
                    CodeExpression right = BuildObject(statements, info.Name, info.GetValue(proxy));
                    statements.Add(new CodeAssignStatement(left, right));
                }
            }
            return(targetObject);
        }