public LogicalMethodInfo (LogicalTypeInfo typeInfo, MethodInfo method) {
				_typeInfo = typeInfo;
				_methodInfo = method;

				_wma = (WebMethodAttribute) Attribute.GetCustomAttribute (method, typeof (WebMethodAttribute));

				_sma = (ScriptMethodAttribute) Attribute.GetCustomAttribute (method, typeof (ScriptMethodAttribute));
				if (_sma == null)
					_sma = ScriptMethodAttribute.Default;

				_params = MethodInfo.GetParameters ();

				if (HasParameters) {
					_paramMap = new Dictionary<string, int> (_params.Length, StringComparer.Ordinal);
					for (int i = 0; i < _params.Length; i++)
						_paramMap.Add(_params[i].Name, i);
				}

				if (ScriptMethod.ResponseFormat == ResponseFormat.Xml
					&& MethodInfo.ReturnType != typeof (void)) {
					Type retType = MethodInfo.ReturnType;
					if (Type.GetTypeCode (retType) != TypeCode.String || ScriptMethod.XmlSerializeString)
						_xmlSer = new XmlSerializer (retType);
				}
			}
Example #2
0
            public LogicalMethodInfo(LogicalTypeInfo typeInfo, MethodInfo method)
            {
                _typeInfo   = typeInfo;
                _methodInfo = method;

                _wma = (WebMethodAttribute)Attribute.GetCustomAttribute(method, typeof(WebMethodAttribute));

                _sma = (ScriptMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ScriptMethodAttribute));
                if (_sma == null)
                {
                    _sma = ScriptMethodAttribute.Default;
                }

                _params = MethodInfo.GetParameters();

                if (HasParameters)
                {
                    _paramMap = new Dictionary <string, int> (_params.Length, StringComparer.Ordinal);
                    for (int i = 0; i < _params.Length; i++)
                    {
                        _paramMap.Add(_params[i].Name, i);
                    }
                }

                if (ScriptMethod.ResponseFormat == ResponseFormat.Xml &&
                    MethodInfo.ReturnType != typeof(void))
                {
                    Type retType = MethodInfo.ReturnType;
                    if (Type.GetTypeCode(retType) != TypeCode.String || ScriptMethod.XmlSerializeString)
                    {
                        _xmlSer = new XmlSerializer(retType);
                    }
                }
            }
 internal WebServiceMethodData(WebServiceData owner, MethodInfo methodInfo, WebMethodAttribute webMethodAttribute, ScriptMethodAttribute scriptMethodAttribute) {
     _owner = owner;
     _methodInfo = methodInfo;
     _webMethodAttribute = webMethodAttribute;
     _methodName = _webMethodAttribute.MessageName;
     _scriptMethodAttribute = scriptMethodAttribute;
     if (String.IsNullOrEmpty(_methodName)) {
         _methodName = methodInfo.Name;
     }
 }
 internal WebServiceMethodData(WebServiceData owner, MethodInfo methodInfo, WebMethodAttribute webMethodAttribute, ScriptMethodAttribute scriptMethodAttribute)
 {
     _owner                 = owner;
     _methodInfo            = methodInfo;
     _webMethodAttribute    = webMethodAttribute;
     _methodName            = _webMethodAttribute.MessageName;
     _scriptMethodAttribute = scriptMethodAttribute;
     if (String.IsNullOrEmpty(_methodName))
     {
         _methodName = methodInfo.Name;
     }
 }
Example #5
0
            public AsmxLogicalMethodInfo(LogicalTypeInfo typeInfo, MethodInfo method)
                : base(typeInfo, method)
            {
                _typeInfo = typeInfo;

                _wma = (WebMethodAttribute)Attribute.GetCustomAttribute(method, typeof(WebMethodAttribute));

                _sma = (ScriptMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ScriptMethodAttribute));
                if (_sma == null)
                {
                    _sma = ScriptMethodAttribute.Default;
                }

                if (ScriptMethod.ResponseFormat == ResponseFormat.Xml &&
                    MethodInfo.ReturnType != typeof(void))
                {
                    Type retType = MethodInfo.ReturnType;
                    if (Type.GetTypeCode(retType) != TypeCode.String || ScriptMethod.XmlSerializeString)
                    {
                        _xmlSer = new XmlSerializer(retType);
                    }
                }
            }
Example #6
0
        private void AddMethod(Dictionary <string, WebServiceMethodData> methods, MethodInfo method)
        {
            object[] wmAttribs = method.GetCustomAttributes(typeof(WebMethodAttribute), true);

            // Skip it if it doesn't have the WebMethod attribute
            if (wmAttribs.Length == 0)
            {
                return;
            }

            ScriptMethodAttribute sm = null;

            object[] responseAttribs = method.GetCustomAttributes(typeof(ScriptMethodAttribute), true);
            if (responseAttribs.Length > 0)
            {
                sm = (ScriptMethodAttribute)responseAttribs[0];
            }

            // Create an object to keep track of this method's data
            WebServiceMethodData wmd = new WebServiceMethodData(this, method, (WebMethodAttribute)wmAttribs[0], sm);

            methods[wmd.MethodName] = wmd;
        }
Example #7
0
			public AsmxLogicalMethodInfo (LogicalTypeInfo typeInfo, MethodInfo method)
				: base (typeInfo, method)
			{
				_typeInfo = typeInfo;

				_wma = (WebMethodAttribute) Attribute.GetCustomAttribute (method, typeof (WebMethodAttribute));

				_sma = (ScriptMethodAttribute) Attribute.GetCustomAttribute (method, typeof (ScriptMethodAttribute));
				if (_sma == null)
					_sma = ScriptMethodAttribute.Default;

				if (ScriptMethod.ResponseFormat == ResponseFormat.Xml
					&& MethodInfo.ReturnType != typeof (void)) {
					Type retType = MethodInfo.ReturnType;
					if (Type.GetTypeCode (retType) != TypeCode.String || ScriptMethod.XmlSerializeString)
						_xmlSer = new XmlSerializer (retType);
				}
			}
        public WebMethodDef(WebServiceDef wsDef, MethodInfo method, WebMethodAttribute wmAttribute, ScriptMethodAttribute smAttribute, TransactionalMethodAttribute tmAttribute, ETagMethodAttribute emAttribute)
        {
            this.MethodType = method;
            this.WebMethodAtt = wmAttribute;
            this.ScriptMethodAtt = smAttribute;
            this.TransactionAtt = tmAttribute;

            if( null != emAttribute ) this.IsETagEnabled = emAttribute.Enabled;

            if (wmAttribute != null && !string.IsNullOrEmpty(wmAttribute.MessageName)) this.MethodName = wmAttribute.MessageName;
            else this.MethodName = method.Name;

            // HTTP GET method is allowed only when there's a [ScriptMethod] attribute and UseHttpGet is true
            this.IsGetAllowed = (this.ScriptMethodAtt != null && this.ScriptMethodAtt.UseHttpGet);

            this.ResponseFormat = (this.ScriptMethodAtt != null ? this.ScriptMethodAtt.ResponseFormat : ResponseFormat.Json);

            MethodInfo beginMethod = wsDef.WSType.GetMethod("Begin" + method.Name, BINDING_FLAGS);
            if (null != beginMethod)
            {
                // The BeginXXX method must have the [ScriptMethod] attribute
                object[] scriptMethodAttributes = beginMethod.GetCustomAttributes(typeof(ScriptMethodAttribute), false);
                if (scriptMethodAttributes.Length > 0)
                {
                    // Asynchronous methods found for the function
                    this.HasAsyncMethods = true;

                    this.BeginMethod = new WebMethodDef(wsDef, beginMethod, null, null, null, null);

                    MethodInfo endMethod = wsDef.WSType.GetMethod("End" + method.Name, BINDING_FLAGS);
                    this.EndMethod = new WebMethodDef(wsDef, endMethod, null, null, null, null);

                    // get all parameters of begin web method and then leave last two parameters in the input parameters list because
                    // last two parameters are for AsyncCallback and Async State
                    ParameterInfo[] allParameters = beginMethod.GetParameters();
                    ParameterInfo[] inputParameters = new ParameterInfo[allParameters.Length - 2];
                    Array.Copy(allParameters, inputParameters, allParameters.Length - 2);

                    this.BeginMethod.InputParameters = new List<ParameterInfo>(inputParameters);
                    this.BeginMethod.InputParametersWithAsyc = new List<ParameterInfo>(allParameters);
                }
            }

            this.InputParameters = new List<ParameterInfo>(method.GetParameters());
        }