private void ProcessMethods(RealSchemaType rsType) { Util.Log("WsdlGenerator.ProcessMethods "+rsType); XMLNamespace xns = rsType.XNS; MethodInfo[] methods = rsType.GetIntroducedMethods(); if (methods.Length > 0) { String methodNSString = null; XMLNamespace methodXNS = null; if (xns.IsInteropType) { methodNSString = xns.Name; methodXNS = xns; } else { StringBuilder sb = new StringBuilder(); WsdlGenerator.QualifyName(sb, xns.Name, rsType.Name); methodNSString = sb.ToString(); methodXNS = AddNamespace(methodNSString, xns.Assem); xns.DependsOnSchemaNS(methodXNS, false); } for (int i=0;i<methods.Length;i++) { MethodInfo method = methods[i]; Util.Log("WsdlGenerator.ProcessMethods methods "+method.Name+" "+methodXNS.Name); AddType(method.ReturnType, methodXNS); ParameterInfo[] parameters = method.GetParameters(); for (int j=0;j<parameters.Length;j++) AddType(parameters[j].ParameterType, methodXNS); } } }
internal void AddRealSchemaType(RealSchemaType rsType){ Util.Log("XMLNamespace.AddRealSchemaType "+rsType.Type); Debug.Assert(LookupRealSchemaType(rsType.Name) == null, "Duplicate Type found"); _realSchemaTypes.Add(rsType); if (rsType.IsUnique) _bUnique = true; //_typeToSchemaType[rsType.Type] = rsType; //_schemaTypeToType[rsType] = rsType.Type; return; }
// Adds types reachable from the given type private void EnqueueReachableTypes(RealSchemaType rsType) { Util.Log("WsdlGenerator.EnqueueReachableTypes "+rsType.Name+" "+rsType.XNS.Name); // Get the XML namespace object XMLNamespace xns = rsType.XNS; // Process base type if (rsType.Type.BaseType != null) { if (rsType.Type.BaseType != s_valueType || rsType.Type.BaseType != s_objectType) AddType(rsType.Type.BaseType, GetNamespace(rsType.Type.BaseType)); } // Check if this is a suds type bool bSUDSType = rsType.Type.IsInterface || s_marshalByRefType.IsAssignableFrom(rsType.Type) || s_delegateType.IsAssignableFrom(rsType.Type); if (bSUDSType) { Util.Log("WsdlGenerator.EnqueueReachableTypes suds type "+rsType.Name+" "+rsType.XNS.Name); // Process fields FieldInfo[] fields = rsType.GetInstanceFields(); for (int i=0;i<fields.Length;i++) { if (fields[i].FieldType == null) continue; AddType(fields[i].FieldType, xns); } // Process implemented interfaces Type[] interfaces = rsType.GetIntroducedInterfaces(); if (interfaces.Length > 0) { for (int i=0;i<interfaces.Length;i++) { Util.Log("WsdlGenerator.EnqueueReachableTypes Interfaces "+interfaces[i].Name+" "+xns.Name); AddType(interfaces[i], xns); } } ProcessMethods(rsType); } else { // Process fields FieldInfo[] fields = rsType.GetInstanceFields(); for (int i=0;i<fields.Length;i++) { if (fields[i].FieldType == null) continue; AddType(fields[i].FieldType, xns); } } return; }
internal void ProcessType(Type type) { // Check if the type was encountered earlier String ns; Assembly assem; bool bInteropType = GetNSAndAssembly(type, out ns, out assem); Util.Log("WsdlGenerator.ProcessType Dequeue "+type+" ns "+ns+" assem "+assem); XMLNamespace xns = LookupNamespace(ns, assem); if (xns != null) { String searchName = WsdlGenerator.RefName(type); if (xns.LookupSchemaType(searchName) != null) { return; } } else { xns = AddNamespace(ns, assem, bInteropType); } _typeToInteropNS[type] = xns; if (!type.IsArray) { // Check if type needs to be represented as a SimpleSchemaType SimpleSchemaType ssType = SimpleSchemaType.GetSimpleSchemaType(type, xns, false); Util.Log("WsdlGenerator.ProcessType simpleType "+ssType); if (ssType != null) { // Add to namespace as a SimpleSchemaType xns.AddSimpleSchemaType(ssType); } else { // Check for the first MarshalByRef type bool bUnique = false; String connectURL = null; Hashtable connectTypeToServiceEndpoint = null; if (_name == null && s_marshalByRefType.IsAssignableFrom(type)) { Util.Log("WsdlGenerator.ProcessType need new type "+type+" typename "+type.Name); _name = type.Name; _targetNS = xns.Namespace; _targetNSPrefix = xns.Prefix; connectURL = _serviceEndpoint; connectTypeToServiceEndpoint = _typeToServiceEndpoint; bUnique = true; } RealSchemaType rsType = new RealSchemaType(type, xns, connectURL, connectTypeToServiceEndpoint, bUnique, this); // Add to namespace as a RealSchemaType xns.AddRealSchemaType(rsType); // Enqueue types reachable from this type EnqueueReachableTypes(rsType); } } }
internal void AddRealSUDSType(RealSchemaType rsType){ Util.Log("XMLNamespace.AddRealSUDSType "+rsType.Type); _realSUDSTypes.Add(rsType); //_typeToSchemaType[rsType.Type] = rsType; //_schemaTypeToType[rsType] = rsType.Type; return; }
private void ProcessMethods(RealSchemaType rsType) { XMLNamespace xNS = rsType.XNS; MethodInfo[] introducedMethods = rsType.GetIntroducedMethods(); if (introducedMethods.Length > 0) { string name = null; XMLNamespace xns = null; if (xNS.IsInteropType) { name = xNS.Name; xns = xNS; } else { StringBuilder sb = new StringBuilder(); QualifyName(sb, xNS.Name, rsType.Name); name = sb.ToString(); xns = this.AddNamespace(name, xNS.Assem); xNS.DependsOnSchemaNS(xns, false); } for (int i = 0; i < introducedMethods.Length; i++) { MethodInfo info = introducedMethods[i]; this.AddType(info.ReturnType, xns); ParameterInfo[] parameters = info.GetParameters(); for (int j = 0; j < parameters.Length; j++) { this.AddType(parameters[j].ParameterType, xns); } } } }
internal void ProcessType(Type type) { string str; Assembly assembly; bool bInteropType = GetNSAndAssembly(type, out str, out assembly); XMLNamespace xns = this.LookupNamespace(str, assembly); if (xns != null) { string name = RefName(type); if (xns.LookupSchemaType(name) != null) { return; } } else { xns = this.AddNamespace(str, assembly, bInteropType); } this._typeToInteropNS[type] = xns; if (!type.IsArray) { SimpleSchemaType ssType = SimpleSchemaType.GetSimpleSchemaType(type, xns, false); if (ssType != null) { xns.AddSimpleSchemaType(ssType); } else { bool bUnique = false; string serviceEndpoint = null; Hashtable typeToServiceEndpoint = null; if ((this._name == null) && s_marshalByRefType.IsAssignableFrom(type)) { this._name = type.Name; this._targetNS = xns.Namespace; this._targetNSPrefix = xns.Prefix; serviceEndpoint = this._serviceEndpoint; typeToServiceEndpoint = this._typeToServiceEndpoint; bUnique = true; } RealSchemaType rsType = new RealSchemaType(type, xns, serviceEndpoint, typeToServiceEndpoint, bUnique, this); xns.AddRealSchemaType(rsType); this.EnqueueReachableTypes(rsType); } } }
private void EnqueueReachableTypes(RealSchemaType rsType) { XMLNamespace xNS = rsType.XNS; if ((rsType.Type.BaseType != null) && ((rsType.Type.BaseType != s_valueType) || (rsType.Type.BaseType != s_objectType))) { this.AddType(rsType.Type.BaseType, this.GetNamespace(rsType.Type.BaseType)); } if ((rsType.Type.IsInterface || s_marshalByRefType.IsAssignableFrom(rsType.Type)) || s_delegateType.IsAssignableFrom(rsType.Type)) { FieldInfo[] instanceFields = rsType.GetInstanceFields(); for (int i = 0; i < instanceFields.Length; i++) { if (instanceFields[i].FieldType != null) { this.AddType(instanceFields[i].FieldType, xNS); } } Type[] introducedInterfaces = rsType.GetIntroducedInterfaces(); if (introducedInterfaces.Length > 0) { for (int j = 0; j < introducedInterfaces.Length; j++) { this.AddType(introducedInterfaces[j], xNS); } } this.ProcessMethods(rsType); } else { FieldInfo[] infoArray2 = rsType.GetInstanceFields(); for (int k = 0; k < infoArray2.Length; k++) { if (infoArray2[k].FieldType != null) { this.AddType(infoArray2[k].FieldType, xNS); } } } }
// Adds types reachable from the given type private void EnqueueReachableTypes(RealSchemaType rsType) { Util.Log("SdlGenerator.EnqueueReachableTypes "); // Get the XML namespace object XMLNamespace xns = rsType.XNS; // Process base type if (rsType.Type.BaseType != null) AddType(rsType.Type.BaseType, xns); // Check if this is a suds type bool bSUDSType = rsType.Type.IsInterface || s_marshalByRefType.IsAssignableFrom(rsType.Type) || s_delegateType.IsAssignableFrom(rsType.Type); if (bSUDSType) { // Process implemented interfaces Type[] interfaces = rsType.GetIntroducedInterfaces(); if (interfaces.Length > 0) { for (int i=0;i<interfaces.Length;i++) { Util.Log("SdlGenerator.EnqueueReachableTypes Interfaces "+interfaces[i].Name+" "+xns.Name); AddType(interfaces[i], xns); } } // Process methods MethodInfo[] methods = rsType.GetIntroducedMethods(); if (methods.Length > 0) { String methodNSString = null; XMLNamespace methodXNS = null; if (xns.IsInteropType) { methodNSString = xns.Name; methodXNS = xns; } else { StringBuilder sb = new StringBuilder(); sb.Append(xns.Name); sb.Append('.'); sb.Append(rsType.Name); methodNSString = sb.ToString(); methodXNS = AddNamespace(methodNSString, xns.Assem); xns.DependsOnSchemaNS(methodXNS); } for (int i=0;i<methods.Length;i++) { MethodInfo method = methods[i]; Util.Log("SdlGenerator.EnqueueReachableTypes methods "+method.Name+" "+methodXNS.Name); AddType(method.ReturnType, methodXNS); ParameterInfo[] parameters = method.GetParameters(); for (int j=0;j<parameters.Length;j++) AddType(parameters[j].ParameterType, methodXNS); } } } else { // Process fields FieldInfo[] fields = rsType.GetInstanceFields(); for (int i=0;i<fields.Length;i++) { if (fields[i].FieldType == null) continue; AddType(fields[i].FieldType, xns); } } return; }
internal void AddRealSchemaType(RealSchemaType rsType) { Debug.Assert(LookupRealSchemaType(rsType.Name) == null, "Duplicate Type found"); _realSchemaTypes.Add(rsType); if (rsType.IsUnique) _bUnique = true; return; }
internal void AddRealSUDSType(RealSchemaType rsType) { Util.Log("XMLNamespace.AddRealSUDSType "); _realSUDSTypes.Add(rsType); return; }
// Generates SUDS internal void Generate() { Util.Log("SdlGenerator.Generate"); // Generate the trasitive closure of the types reachable from // the supplied types while (_queue.Count > 0) { // Dequeue from not yet seen queue Type type = (Type) _queue.Dequeue(); // Check if the type was encountered earlier String ns; Assembly assem; bool bInteropType = GetNSAndAssembly(type, out ns, out assem); Util.Log("SdlGenerator.Generate Dequeue "+type+" ns "+ns+" assem "+assem); XMLNamespace xns = LookupNamespace(ns, assem); if (xns != null) { if (xns.LookupSchemaType(type.Name) != null) { continue; } } else { xns = AddNamespace(ns, assem, bInteropType); } // Check if type needs to be represented as a SimpleSchemaType SimpleSchemaType ssType = SimpleSchemaType.GetSimpleSchemaType(type, xns, false); if (ssType != null) { // Add to namespace as a SimpleSchemaType xns.AddSimpleSchemaType(ssType); } else { // Check for the first MarshalByRef type bool bUnique = false; String connectURL = null; Hashtable connectTypeToServiceEndpoint = null; if ((_name == null) && s_marshalByRefType.IsAssignableFrom(type)) { _name = type.Name; _targetNS = xns.Namespace; connectURL = _serviceEndpoint; connectTypeToServiceEndpoint = _typeToServiceEndpoint; bUnique = true; } RealSchemaType rsType = new RealSchemaType(type, xns, connectURL, connectTypeToServiceEndpoint, bUnique); // Add to namespace as a RealSchemaType xns.AddRealSchemaType(rsType); // Enqueue types reachable from this type EnqueueReachableTypes(rsType); } } // At this point we have the complete list of types // to be processed. Resolve cross references between // them Resolve(); // At this stage, we are ready to print the schemas PrintSdl(); // Flush cached buffers _textWriter.Flush(); return; }