コード例 #1
0
            internal void DependsOnSUDSNS(XMLNamespace xns){
                Util.Log("XMLNamespace.DependsOnSUDSNS "+xns.Name+" "+xns.Assem);
                if (LookupSUDSNamespace(xns.Name, xns.Assem) != null)
                    return;

                _dependsOnSUDSNS.Add(xns);
                return;
            }
コード例 #2
0
        // Adds the given type if it has not been encountered before
        private void AddType(Type type, XMLNamespace xns)
        {
            Util.Log("WsdlGenerator.AddType "+type+" ns "+xns.Namespace);                      
            //  System.Array says that it has element type, but returns null
            //         when asked for the element type.<STRIP> IMO, System.Array should not
            //         say that it has an element type. I have already pointed this
            //         out to David Mortenson</STRIP>


            // Need to get underlying element type
            // For arrays of arrays, want element, not embedded array
            Type elementType = type.GetElementType();
            Type nextelementType = elementType;
            while(nextelementType != null)
            {
                nextelementType = elementType.GetElementType();
                if (nextelementType != null)
                    elementType = nextelementType;
                
            }
            Util.Log("WsdlGenerator.AddType elementType "+type+" elementType "+elementType);                      

            if (elementType != null)
                EnqueueType(elementType, xns);


            if (!type.IsArray && !type.IsByRef)
                EnqueueType(type, xns);

            if (!(type.IsPublic || type.IsNotPublic))
            {
                // nested type, enqueue parent
                String refTypeName = type.FullName;
                int index = refTypeName.IndexOf("+");
                if (index > 0)
                {
                    String parentName = refTypeName.Substring(0, index);
                    Assembly assembly = type.Module.Assembly;
                    Util.Log("WsdlGenerator.AddType parentName "+parentName+" assembly "+assembly);
                    Type parentType = assembly.GetType(parentName, true);
                    Util.Log("WsdlGenerator.AddType parentType "+parentType);
                    if (parentType == null)
                    {
                        //Error nested type
                    }
                    EnqueueType(parentType, xns);
                }
            }
        }
コード例 #3
0
            internal static String TypeName(Type type, bool bEmbedded, XMLNamespace thisxns)
            {
                Util.Log("RealSchemaType.TypeName entry "+type+" bEmbedded "+bEmbedded+" xns "+thisxns.Name);              
                String typeName = null;
                if (type.IsArray)
                    return ProcessArray(type, thisxns);

                String clrTypeName = WsdlGenerator.RefName(type);
                Type clrType = type;

                // If ref type the name ends in &
                if (type.IsByRef)
                {
                    clrType = type.GetElementType(); 
                    clrTypeName = WsdlGenerator.RefName(clrType);
                    if (clrType.IsArray)
                        return ProcessArray(clrType, thisxns);
                }

                typeName = SudsConverter.MapClrTypeToXsdType(clrType);

                if (typeName == null)
                {
                    String ns = type.Namespace;
                    Assembly assem = type.Module.Assembly; 
                    XMLNamespace xns = null;
                    Util.Log("RealSchemaType.TypeName realNS "+ns);
                    xns = (XMLNamespace)thisxns.Generator._typeToInteropNS[type];

                    if (xns == null)
                    {
                        xns = thisxns.LookupSchemaNamespace(ns, assem);
                        if (xns == null)
                        {
                            xns = thisxns.Generator.LookupNamespace(ns,assem);
                            if (xns == null)
                            {
                                xns = thisxns.Generator.AddNamespace(ns, assem);
                            }
                            thisxns.DependsOnSchemaNS(xns, false);
                        }
                        Util.Log("RealSchemaType.TypeName depended NS with assem equals "+xns.Name);
                    }
                    StringBuilder sb = new StringBuilder(256);

                    sb.Append(xns.Prefix);
                    sb.Append(':');
                    sb.Append(clrTypeName);
                    typeName = sb.ToString();
                }

                Util.Log("RealSchemaType.TypeName exit "+typeName);
                return typeName;
            }
コード例 #4
0
            internal void DependsOnSchemaNS(XMLNamespace xns, bool bImport){
                Util.Log("XMLNamespace.DependsOnSchemaNS "+Namespace+" depends on "+xns.Namespace+" bImport "+bImport);                                                              
                if (LookupSchemaNamespace(xns.Name, xns.Assem) != null)
                    return;

                _dependsOnSchemaNS.Add(xns);
                if (bImport && Namespace != xns.Namespace)
                    _xnsImports.Add(xns);
                return;
            }
コード例 #5
0
ファイル: sdlwriter.cs プロジェクト: ArildF/masters
		// Adds the given type if it has not been encountered before
		private void AddType(Type type, XMLNamespace xns)
		{
			Util.Log("SdlGenerator.AddTypes "+type);                        
			//         System.Array says that it has element type, but returns null
			//         when asked for the element type.                                    
			if (type.HasElementType)
			{
				Type eType = type.GetElementType();
				if (eType != null)
				{
					type = eType;
					while (type.HasElementType)
						type = type.GetElementType();
				}
			}

			if (type.IsPrimitive == false)
			{
				String ns;
				Assembly assem;
				bool bInteropType = GetNSAndAssembly(type, out ns, out assem);

				// Lookup the namespace
				XMLNamespace dependsOnNS = LookupNamespace(ns, assem);
				// Create a new namespace if neccessary
				if (dependsOnNS == null)
					dependsOnNS = AddNamespace(ns, assem, bInteropType);

				// The supplied namespace depends directly on the namespace of the type
				xns.DependsOnSchemaNS(dependsOnNS);

				// Enqueue the type if it does not belong to system namespace
				if ((ns == null) || !ns.StartsWith("System"))
				{
					_queue.Enqueue(type);
				}
			}

			return;
		}
コード例 #6
0
            private static String ProcessArray(Type type, XMLNamespace xns)
            {
                Util.Log("RealSchemaType.ProcessArray Enter "+type);
                String qname = null;
                bool bbinary = false;
                Type elementType = type.GetElementType();
                String elementTypeName = "ArrayOf";
                while (elementType.IsArray)
                {
                    elementTypeName = elementTypeName+"ArrayOf";
                    elementType = elementType.GetElementType();
                }

                qname = RealSchemaType.TypeName(elementType, true, xns);
                int index = qname.IndexOf(":");
                String prefix = qname.Substring(0, index);
                String wireName = qname.Substring(index+1);
                Util.Log("RealSchemaType.ProcessArray qname "+qname+" wirename "+wireName);
                int rank =  type.GetArrayRank();
                String rankStr = "";
                if (rank > 1)
                    rankStr = rank.ToString(CultureInfo.InvariantCulture);
                String csname =elementTypeName+wireName.Substring(0,1).ToUpper(CultureInfo.InvariantCulture)+wireName.Substring(1)+rankStr;
                csname = csname.Replace('+','N'); // need to get rid of + in nested classes
                ArraySchemaType ast = xns.LookupArraySchemaType(csname); 
                if (ast == null)
                {
                    ArraySchemaType cstype = new ArraySchemaType(type, csname, SchemaBlockType.ComplexContent, false);
                    Restriction restriction = new Restriction();
                    SchemaAttribute attribute = new SchemaAttribute();
                    if (bbinary)
                        attribute.AddArray(qname);
                    else
                    {
                        String arrayTypeName = type.Name;
                        index = arrayTypeName.IndexOf("[");
                        attribute.AddArray(qname+arrayTypeName.Substring(index));
                    }

                    restriction.AddArray(attribute);
                    cstype.AddParticle(restriction);
                    xns.AddArraySchemaType(cstype);
                }

                String returnStr = xns.Prefix+":"+csname;
                Util.Log("RealSchemaType.ProcessArray Exit "+returnStr);
                return returnStr;
            }
コード例 #7
0
            private SimpleSchemaType(Type type, XMLNamespace xns)
            {
                Util.Log("SimpleSchemaType.SimpleSchemaType "+type+" xns "+((xns != null) ? xns.Name : "Null"));
                _type = type;
                _xns = xns;
                _abstractElms = new ArrayList();

                _fullRefName = WsdlGenerator.RefName(type);
            }
コード例 #8
0
 internal Restriction(String baseName, XMLNamespace baseNS)
 {
     Util.Log("Restriction.Restriction "+baseName+" "+baseNS.Namespace);
     _baseName = baseName;
     _baseNS = baseNS;
 }
コード例 #9
0
 private void AddType(Type type, XMLNamespace xns)
 {
     Type elementType = type.GetElementType();
     Type type3 = elementType;
     while (type3 != null)
     {
         type3 = elementType.GetElementType();
         if (type3 != null)
         {
             elementType = type3;
         }
     }
     if (elementType != null)
     {
         this.EnqueueType(elementType, xns);
     }
     if (!type.IsArray && !type.IsByRef)
     {
         this.EnqueueType(type, xns);
     }
     if (!type.IsPublic && !type.IsNotPublic)
     {
         string fullName = type.FullName;
         int index = fullName.IndexOf("+");
         if (index > 0)
         {
             string name = fullName.Substring(0, index);
             Type type4 = type.Module.Assembly.GetType(name, true);
             bool flag1 = type4 == null;
             this.EnqueueType(type4, xns);
         }
     }
 }
コード例 #10
0
 private void EnqueueType(Type type, XMLNamespace xns)
 {
     if (!type.IsPrimitive || (type == s_charType))
     {
         string str;
         Assembly assembly;
         XMLNamespace namespace2 = null;
         bool bInteropType = GetNSAndAssembly(type, out str, out assembly);
         namespace2 = this.LookupNamespace(str, assembly);
         if (namespace2 == null)
         {
             namespace2 = this.AddNamespace(str, assembly, bInteropType);
         }
         string str2 = SudsConverter.MapClrTypeToXsdType(type);
         if ((type.IsInterface || (str2 != null)) || (type == s_voidType))
         {
             xns.DependsOnSchemaNS(namespace2, false);
         }
         else
         {
             xns.DependsOnSchemaNS(namespace2, true);
         }
         if (!type.FullName.StartsWith("System."))
         {
             this._queue.Enqueue(type);
         }
     }
 }
コード例 #11
0
 private XMLNamespace AddNamespace(string name, Assembly assem, bool bInteropType)
 {
     XMLNamespace namespace2 = new XMLNamespace(name, assem, this._serviceEndpoint, this._typeToServiceEndpoint, "ns" + this._namespaces.Count, bInteropType, this);
     this._namespaces.Add(namespace2);
     return namespace2;
 }
コード例 #12
0
ファイル: sdlwriter.cs プロジェクト: ArildF/masters
			internal RealSchemaType(Type type, XMLNamespace xns, String serviceEndpoint, Hashtable typeToServiceEndpoint, bool bUnique)
					: base(type.Name, type.IsSealed)
			{
				Util.Log("RealSchemaType.RealSchemaType "+type+" xns "+xns.Name+" serviceEndpoint "+serviceEndpoint+" bUnique "+bUnique);               
				_type = type;
				_serviceEndpoint = serviceEndpoint;
				_typeToServiceEndpoint = typeToServiceEndpoint;
				_bUnique = bUnique;
				_bStruct = type.IsValueType;
				_xns = xns;
				_implIFaces = null;
				_iFaces = null;
				_methods = null;
				_fields = null;
				_methodTypes = null;
			}
コード例 #13
0
ファイル: sdlwriter.cs プロジェクト: ArildF/masters
			internal static SimpleSchemaType GetSimpleSchemaType(Type type, XMLNamespace xns, bool fInline)
			{
				Util.Log("SimpleSchemaType.GetSimpleSchemaType "+type+" xns "+xns.Name);                
				SimpleSchemaType ssType = null;
				if (fInline)
				{
					if ((type.IsArray == true) &&
						  (type.GetArrayRank() == 1) &&
						  (type.GetElementType() == typeof(byte)))
					{
						if (_byteArraySchemaType == null)
						{
							_byteArraySchemaType = new SimpleSchemaType(type, null);
							_byteArraySchemaType._baseName = "xsd:binary";
							_byteArraySchemaType._abstractElms.Add(new EncodingElement("base64"));
						}
						ssType = _byteArraySchemaType;
					}
				}
				else
				{
					if (type.IsEnum)
					{
						ssType = new SimpleSchemaType(type, xns);
						ssType._baseName = RealSchemaType.TypeName(Enum.GetUnderlyingType(type), true, null);
						String[] values = Enum.GetNames(type);
						for (int i=0;i<values.Length;i++)
							ssType._abstractElms.Add(new EnumElement(values[i]));
					}
					else
					{
					}
				}

				return(ssType);
			}
コード例 #14
0
        private void EnqueueType(Type type, XMLNamespace xns)
        {
            Util.Log("WsdlGenerator.EnqueueType "+type+" ns "+xns.Namespace);                      
            if (!type.IsPrimitive || type == s_charType) //char is not a xsd type
            {
                String ns;
                Assembly assem;
                XMLNamespace dependsOnNS = null;

                bool bInteropType = GetNSAndAssembly(type, out ns, out assem);

                // Lookup the namespace
                dependsOnNS = LookupNamespace(ns, assem);
                // Creat a new namespace if neccessary
                if (dependsOnNS == null)
                    dependsOnNS = AddNamespace(ns, assem, bInteropType);

                // The supplied namespace depends directly on the namespace of the type
                String typeString = SudsConverter.MapClrTypeToXsdType(type); //see if this is a xsd type
                if (type.IsInterface || typeString != null || type == s_voidType)
                {
                    // Interfaces aren't in schema section
                    // Any xsd type
                    xns.DependsOnSchemaNS(dependsOnNS, false); 
                }
                else
                    xns.DependsOnSchemaNS(dependsOnNS, true);



                // Enqueue the type if does not belong to system namespace
                if (!type.FullName.StartsWith("System."))
                {
                    Util.Log("WsdlGenerator.EnqueueType place on queue "+type+" ns "+xns.Namespace);                      
                    _queue.Enqueue(type);
                }
            }
        }
コード例 #15
0
            internal static SimpleSchemaType GetSimpleSchemaType(Type type, XMLNamespace xns, bool fInline)
            {
                Util.Log("SimpleSchemaType.GetSimpleSchemaType "+type+" xns "+xns.Name);                

                SimpleSchemaType ssType = null;
                if (type.IsEnum)
                {
                    ssType = new SimpleSchemaType(type, xns);
                    String baseName = RealSchemaType.TypeName(Enum.GetUnderlyingType(type), true, xns);
                    ssType._restriction = new Restriction(baseName, xns);
                    String[] values = Enum.GetNames(type);
                    for (int i=0;i<values.Length;i++)
                        ssType._restriction._abstractElms.Add(new EnumElement(values[i]));
                    ssType._restriction._rtype = Restriction.RestrictionType.Enum;
                }
                else
                {
                }
                return(ssType);
            }
コード例 #16
0
        private XMLNamespace AddNamespace(String name, Assembly assem, bool bInteropType)
        {
            Util.Log("WsdlGenerator.AddNamespace "+name);                       
            Debug.Assert(LookupNamespace(name, assem) == null, "Duplicate Type found");

            XMLNamespace xns = new XMLNamespace(name, assem,
                                                _serviceEndpoint,
                                                _typeToServiceEndpoint,
                                                "ns" + _namespaces.Count,
                                                bInteropType, this);
            _namespaces.Add(xns);

            return(xns);
        }
コード例 #17
0
            internal RealSchemaType(Type type, XMLNamespace xns, String serviceEndpoint, Hashtable typeToServiceEndpoint, bool bUnique, WsdlGenerator WsdlGenerator)
            : base(type)
            {
                Util.Log("RealSchemaType.RealSchemaType "+type+" xns "+xns.Name+" serviceEndpoint "+serviceEndpoint+" bUnique "+bUnique);               
                _type = type;
                _serviceEndpoint = serviceEndpoint;
                _typeToServiceEndpoint = typeToServiceEndpoint;
                _bUnique = bUnique;
                _WsdlGenerator = WsdlGenerator;
                _bStruct = type.IsValueType;
                _xns = xns;
                _implIFaces = null;
                _iFaces = null;
                _methods = null;
                _fields = null;
                _methodTypes = null;

                _nestedTypes = type.GetNestedTypes();
                if (_nestedTypes != null)
                {
                    foreach (Type ntype in _nestedTypes)
                    {
                        Util.Log("RealSchemaType.RealSchemaType nested classes"+ntype);
                        _WsdlGenerator.AddType(ntype, xns);
                    }
                }
            }
コード例 #18
0
 internal SchemaElement(String name, Type type, bool bEmbedded, XMLNamespace xns)
 : base(){
     Util.Log("SchemaElement.SchemaElement Particle "+name+" type "+type+" bEmbedded "+bEmbedded);
     _name = name;
     _typeString = null;
     _schemaType = SimpleSchemaType.GetSimpleSchemaType(type, xns, true);                
     _typeString = RealSchemaType.TypeName(type, bEmbedded, xns);
 }
コード例 #19
0
ファイル: sdlwriter.cs プロジェクト: ArildF/masters
			internal static String TypeName(Type type, bool bEmbedded, XMLNamespace thisxns)
			{
				Util.Log("RealSchemaType.TypeName "+type+" bEmbedded "+bEmbedded);              
				String typeName;
				Type uType;
				if (type.HasElementType && ((uType = type.GetElementType()) != null))
				{
					while (uType.HasElementType)
						uType = uType.GetElementType();
					String uTypeName = TypeName(uType, type.IsArray, thisxns);
					String suffix = type.Name.Substring(uType.Name.Length);
					// Escape the compiler warning
					typeName = " suds:refType='";
					if (type.IsArray)
					{
						StringBuilder sb = new StringBuilder(256);
						if (bEmbedded)
							sb.Append("soap:Array'");
						else
							sb.Append("soap:Reference'");
						sb.Append(typeName);
						sb.Append(uTypeName);
						sb.Append(suffix);
						typeName = sb.ToString();
					}
					else if (type.IsByRef)
					{
						typeName = uTypeName;
					}
					else if (type.IsPointer)
					{
						typeName = uTypeName;
					}
					else
					{
						Debug.Assert(false, "Should not have reached here");
					}
				}
				else if (type.IsPrimitive)
				{
					typeName = "xsd:" + MapURTTypesToSchemaTypes(type.Name);
				}
				else if (type.FullName == "System.String")
				{
					typeName = "xsd:string";
				}
				else if (type.FullName == "System.Object")
				{
					if (bEmbedded)
						typeName = "xsd:ur-type"; //null;
					else
						typeName = "soap:Reference' suds:refType='xsd:ur-type";
				}
				else if (type.FullName == "System.Void")
				{
					typeName = "void";
				}
				else
				{
					String ns = type.Namespace;
					Assembly assem = type.Module.Assembly;
					XMLNamespace xns = thisxns.LookupSchemaNamespace(ns, assem);
					StringBuilder sb = new StringBuilder(256);
					if (bEmbedded == false && type.IsValueType == false)
						sb.Append("soap:Reference' suds:refType='");
					sb.Append(xns.Prefix);
					sb.Append(':');
					sb.Append(type.Name);
					typeName = sb.ToString();
				}

				return(typeName);
			}