예제 #1
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;
            }
예제 #2
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);
			}