コード例 #1
0
        public override object GetInitializer(LogicalMethodInfo methodInfo)
        {
            LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo(methodInfo.DeclaringType);

            object[]         ats  = methodInfo.ReturnTypeCustomAttributeProvider.GetCustomAttributes(typeof(XmlRootAttribute), true);
            XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;

            return(new XmlSerializer(methodInfo.ReturnType, null, null, root, sti.GetWebServiceLiteralNamespace(sti.WebServiceNamespace)));
        }
コード例 #2
0
        public SoapTypeStubInfo(LogicalTypeInfo logicalTypeInfo)
            : base(logicalTypeInfo)
        {
            xmlImporter  = new XmlReflectionImporter();
            soapImporter = new SoapReflectionImporter();

            if (typeof(SoapHttpClientProtocol).IsAssignableFrom(Type))
            {
                if (Bindings.Count == 0 || ((BindingInfo)Bindings[0]).WebServiceBindingAttribute == null)
                {
                    throw new InvalidOperationException("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
                }
                if (Bindings.Count > 1)
                {
                    throw new InvalidOperationException("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
                }
            }

            object [] o = Type.GetCustomAttributes(typeof(SoapDocumentServiceAttribute), false);
            if (o.Length == 1)
            {
                SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute)o [0];

                ParameterStyle   = a.ParameterStyle;
                SoapBindingStyle = SoapBindingStyle.Document;
            }
            else
            {
                o = Type.GetCustomAttributes(typeof(SoapRpcServiceAttribute), false);
                if (o.Length == 1)
                {
                    SoapRpcServiceAttribute srs = (SoapRpcServiceAttribute)o [0];

                    ParameterStyle   = SoapParameterStyle.Wrapped;
                    SoapBindingStyle = SoapBindingStyle.Rpc;
                }
                else
                {
                    ParameterStyle   = SoapParameterStyle.Wrapped;
                    SoapBindingStyle = SoapBindingStyle.Document;
                }
            }

            if (ParameterStyle == SoapParameterStyle.Default)
            {
                ParameterStyle = SoapParameterStyle.Wrapped;
            }

            xmlImporter.IncludeTypes(Type);
            soapImporter.IncludeTypes(Type);

#if MONOTOUCH
            SoapExtensions = new SoapExtensionRuntimeConfig [2][];
#else
            SoapExtensions = SoapExtension.GetTypeExtensions(Type);
#endif
        }
コード例 #3
0
ファイル: XmlReturnWriter.cs プロジェクト: pmq20/mono_forked
        public override object GetInitializer(LogicalMethodInfo methodInfo)
        {
            LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo(methodInfo.DeclaringType);

            object[]         ats  = methodInfo.ReturnTypeCustomAttributeProvider.GetCustomAttributes(typeof(XmlRootAttribute), true);
            XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;

            XmlReflectionImporter importer = new XmlReflectionImporter();

            importer.IncludeTypes(methodInfo.CustomAttributeProvider);
            XmlTypeMapping map = importer.ImportTypeMapping(methodInfo.ReturnType, root, sti.GetWebServiceLiteralNamespace(sti.WebServiceNamespace));

            return(new XmlSerializer(map));
        }
コード例 #4
0
        //
        // This needs to be thread safe
        //
        static internal LogicalTypeInfo GetLogicalTypeInfo(Type t)
        {
            lock (type_to_manager)
            {
                LogicalTypeInfo tm = (LogicalTypeInfo)type_to_manager [t];

                if (tm != null)
                {
                    return(tm);
                }

                tm = new LogicalTypeInfo(t);
                type_to_manager [t] = tm;

                return(tm);
            }
        }
コード例 #5
0
        public TypeStubInfo(LogicalTypeInfo logicalTypeInfo)
        {
            this.logicalType = logicalTypeInfo;

            object [] o = Type.GetCustomAttributes(typeof(WebServiceBindingAttribute), false);

            bool isClientSide = typeof(SoapHttpClientProtocol).IsAssignableFrom(Type);
            bool defaultAdded = false;

            string defaultBindingName = logicalType.WebServiceName + ProtocolName;

            if (o.Length > 0)
            {
                foreach (WebServiceBindingAttribute at in o)
                {
                    AddBinding(new BindingInfo(at, defaultBindingName, LogicalType.WebServiceNamespace));
                    if ((at.Name == null || at.Name.Length == 0) || (at.Name == defaultBindingName))
                    {
                        defaultAdded = true;
                    }
                }
            }

            if (!defaultAdded && !isClientSide)
            {
                AddBindingAt(0, new BindingInfo(null, defaultBindingName, logicalType.WebServiceNamespace));
            }

#if NET_2_0
            foreach (Type ifaceType in Type.GetInterfaces())
            {
                o = ifaceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false);
                if (o.Length > 0)
                {
                    defaultBindingName = ifaceType.Name + ProtocolName;
                    foreach (WebServiceBindingAttribute at in o)
                    {
                        AddBinding(new BindingInfo(at, defaultBindingName, LogicalType.WebServiceNamespace));
                    }
                }
            }
#endif
        }
コード例 #6
0
        public override object[] GetInitializers(LogicalMethodInfo[] methodInfos)
        {
            XmlReflectionImporter importer = new XmlReflectionImporter();

            XmlMapping[] sers = new XmlMapping [methodInfos.Length];
            for (int n = 0; n < sers.Length; n++)
            {
                LogicalMethodInfo metinfo = methodInfos[n];
                if (metinfo.IsVoid)
                {
                    sers[n] = null;
                }
                else
                {
                    LogicalTypeInfo  sti  = TypeStubManager.GetLogicalTypeInfo(metinfo.DeclaringType);
                    object[]         ats  = methodInfos[n].ReturnTypeCustomAttributeProvider.GetCustomAttributes(typeof(XmlRootAttribute), true);
                    XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
                    sers[n] = importer.ImportTypeMapping(methodInfos[n].ReturnType, root, sti.GetWebServiceLiteralNamespace(sti.WebServiceNamespace));
                }
            }
            return(XmlSerializer.FromMappings(sers));
        }
コード例 #7
0
		public TypeStubInfo (LogicalTypeInfo logicalTypeInfo)
		{
			this.logicalType = logicalTypeInfo;

			object [] o = Type.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);

			bool isClientSide = typeof (SoapHttpClientProtocol).IsAssignableFrom (Type);
			bool defaultAdded = false;

			string defaultBindingName = logicalType.WebServiceName + ProtocolName;
			if (o.Length > 0)
				foreach (WebServiceBindingAttribute at in o) {
					AddBinding (new BindingInfo (at, defaultBindingName, LogicalType.WebServiceNamespace));
					if ((at.Name == null || at.Name.Length == 0) || (at.Name == defaultBindingName))
						defaultAdded = true;
				}

			if (!defaultAdded && !isClientSide)
				AddBindingAt (0, new BindingInfo (null, defaultBindingName, logicalType.WebServiceNamespace));

#if NET_2_0
			foreach (Type ifaceType in Type.GetInterfaces ()) {
				o = ifaceType.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
				if (o.Length > 0) {
					defaultBindingName = ifaceType.Name + ProtocolName;
					foreach (WebServiceBindingAttribute at in o)
						AddBinding (new BindingInfo (at, defaultBindingName, LogicalType.WebServiceNamespace));
				}
			}
#endif
		}
コード例 #8
0
		//
		// This needs to be thread safe
		//
		static internal LogicalTypeInfo GetLogicalTypeInfo (Type t)
		{
			lock (type_to_manager)
			{
				LogicalTypeInfo tm = (LogicalTypeInfo) type_to_manager [t];
	
				if (tm != null)
					return tm;

				tm = new LogicalTypeInfo (t);
				type_to_manager [t] = tm;

				return tm;
			}
		}
コード例 #9
0
 public Soap12TypeStubInfo(LogicalTypeInfo logicalTypeInfo)
     : base(logicalTypeInfo)
 {
 }
コード例 #10
0
		public ServerType (Type type)
		{
			this.type = TypeStubManager.GetLogicalTypeInfo (type);
		}
コード例 #11
0
 public HttpSimpleTypeStubInfo(LogicalTypeInfo logicalTypeInfo) : base(logicalTypeInfo)
 {
 }
コード例 #12
0
		public TypeStubInfo (LogicalTypeInfo logicalTypeInfo)
		{
			this.logicalType = logicalTypeInfo;

			defaultBinding = logicalType.WebServiceName + ProtocolName;
			BindingInfo binfo = new BindingInfo (defaultBinding, logicalType.WebServiceNamespace);
			Bindings.Add (binfo);
		}
コード例 #13
0
ファイル: HttpSimpleTypeStubInfo.cs プロジェクト: nobled/mono
		public HttpSimpleTypeStubInfo (LogicalTypeInfo logicalTypeInfo): base (logicalTypeInfo)
		{
		}
コード例 #14
0
        static internal TypeStubInfo GetTypeStub(Type t, string protocolName)
        {
            LogicalTypeInfo tm = GetLogicalTypeInfo(t);

            return(tm.GetTypeStub(protocolName));
        }
コード例 #15
0
		public SoapTypeStubInfo (LogicalTypeInfo logicalTypeInfo)
		: base (logicalTypeInfo)
		{
			xmlImporter = new XmlReflectionImporter ();
			soapImporter = new SoapReflectionImporter ();
			
			object [] o;

			o = Type.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
			
			if (typeof (SoapHttpClientProtocol).IsAssignableFrom (Type))
			{
				if (o.Length == 0)
					throw new InvalidOperationException ("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
				if (o.Length > 1)
					throw new InvalidOperationException ("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
					
				// Remove the default binding, it is not needed since there is always
				// a binding attribute.
				Bindings.Clear ();
			}
				
			foreach (WebServiceBindingAttribute at in o)
				AddBinding (new BindingInfo (at, LogicalType.WebServiceNamespace));

			o = Type.GetCustomAttributes (typeof (SoapDocumentServiceAttribute), false);
			if (o.Length == 1){
				SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute) o [0];

				ParameterStyle = a.ParameterStyle;
				RoutingStyle = a.RoutingStyle;
				Use = a.Use;
				SoapBindingStyle = SoapBindingStyle.Document;
			} else {
				o = Type.GetCustomAttributes (typeof (SoapRpcServiceAttribute), false);
				if (o.Length == 1){
					SoapRpcServiceAttribute srs = (SoapRpcServiceAttribute) o [0];
					
					ParameterStyle = SoapParameterStyle.Wrapped;
					RoutingStyle = srs.RoutingStyle;
					Use = SoapBindingUse.Encoded;
					SoapBindingStyle = SoapBindingStyle.Rpc;
				} else {
					ParameterStyle = SoapParameterStyle.Wrapped;
					RoutingStyle = SoapServiceRoutingStyle.SoapAction;
					Use = SoapBindingUse.Literal;
					SoapBindingStyle = SoapBindingStyle.Document;
				}
			}
			
			if (ParameterStyle == SoapParameterStyle.Default) ParameterStyle = SoapParameterStyle.Wrapped;
			if (Use == SoapBindingUse.Default) Use = SoapBindingUse.Literal;
			
			xmlImporter.IncludeTypes (Type);
			soapImporter.IncludeTypes (Type);

			SoapExtensions = SoapExtension.GetTypeExtensions (Type);
		}
コード例 #16
0
ファイル: Methods.cs プロジェクト: ItsVeryWindy/mono
		public SoapTypeStubInfo (LogicalTypeInfo logicalTypeInfo)
		: base (logicalTypeInfo)
		{
			xmlImporter = new XmlReflectionImporter ();
			soapImporter = new SoapReflectionImporter ();
				
			if (typeof (SoapHttpClientProtocol).IsAssignableFrom (Type))
			{
				if (Bindings.Count == 0 || ((BindingInfo)Bindings[0]).WebServiceBindingAttribute == null)
					throw new InvalidOperationException ("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
				if (Bindings.Count > 1)
					throw new InvalidOperationException ("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
			}

			object [] o = Type.GetCustomAttributes (typeof (SoapDocumentServiceAttribute), false);
			if (o.Length == 1){
				SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute) o [0];

				ParameterStyle = a.ParameterStyle;
				SoapBindingStyle = SoapBindingStyle.Document;
			} else {
				o = Type.GetCustomAttributes (typeof (SoapRpcServiceAttribute), false);
				if (o.Length == 1){
					ParameterStyle = SoapParameterStyle.Wrapped;
					SoapBindingStyle = SoapBindingStyle.Rpc;
				} else {
					ParameterStyle = SoapParameterStyle.Wrapped;
					SoapBindingStyle = SoapBindingStyle.Document;
				}
			}
			
			if (ParameterStyle == SoapParameterStyle.Default) ParameterStyle = SoapParameterStyle.Wrapped;
			
			xmlImporter.IncludeTypes (Type);
			soapImporter.IncludeTypes (Type);

#if MOBILE || XAMMAC_4_5
			SoapExtensions = new SoapExtensionRuntimeConfig [2][];
#else
			SoapExtensions = SoapExtension.GetTypeExtensions (Type);
#endif
		}
コード例 #17
0
ファイル: Methods.cs プロジェクト: ItsVeryWindy/mono
		public Soap12TypeStubInfo (LogicalTypeInfo logicalTypeInfo)
		: base (logicalTypeInfo)
		{
		}
コード例 #18
0
 public ServerType(Type type)
 {
     this.type = TypeStubManager.GetLogicalTypeInfo(type);
 }