Ejemplo n.º 1
0
			internal void Resolve(StringBuilder sb)
			{
				Util.Log("RealSchemaType.Resolve");             
				sb.Length = 0;

				// Check if this is a suds type
				bool bSUDSType = IsSUDSType;

				// Resolve base type eliminating system defined roots of the class heirarchy
				if (!_type.IsInterface &&
					  !_type.IsValueType &&
					  (_type.BaseType.BaseType != null) &&
					  (_type.BaseType != SdlGenerator.s_marshalByRefType) &&
					  (_type.BaseType != SdlGenerator.s_contextBoundType) &&
					  (_type.BaseType != SdlGenerator.s_remotingClientProxyType) &&
					  ((_type.IsCOMObject == false) ||
					   (_type.BaseType.BaseType.IsCOMObject == true)))
				{
					String ns;
					Assembly assem;
					Util.Log("RealSchemaType.Resolve Not System Defined root "+_type.BaseType);                                 
					bool InteropType = SdlGenerator.GetNSAndAssembly(_type.BaseType, out ns, out assem);
					XMLNamespace xns = _xns.LookupSchemaNamespace(ns, assem);
					Debug.Assert(xns != null, "Namespace should have been found");
					sb.Append(xns.Prefix);
					sb.Append(':');
					sb.Append(_type.BaseType.Name);
					BaseName = sb.ToString();
					if (bSUDSType)
						_xns.DependsOnSUDSNS(xns);
				}

				// The element definition of this type depends on itself
				_xns.DependsOnSchemaNS(_xns);

				if (bSUDSType)
				{
					Util.Log("RealSchemaType.Resolve AddRealSUDSType  "+_type);                                                     
					_xns.AddRealSUDSType(this);

					// Resolve interfaces introduced by this type
					if (_iFaces.Length > 0)
					{
						_implIFaces = new String[_iFaces.Length];
						for (int i=0;i<_iFaces.Length;i++)
						{
							String ns;
							Assembly assem;
							Util.Log("RealSchemaType.Resolve iFace  "+_iFaces[i].Name);                                                                                     
							bool bInteropType = SdlGenerator.GetNSAndAssembly(_iFaces[i], out ns, out assem);
							XMLNamespace xns = _xns.LookupSchemaNamespace(ns, assem);
							Debug.Assert(xns != null, "SchemaType should have been found");
							sb.Length = 0;
							sb.Append(xns.Prefix);
							sb.Append(':');
							sb.Append(_iFaces[i].Name);
							_implIFaces[i] = sb.ToString();
							_xns.DependsOnSUDSNS(xns);
						}
					}

					// Resolve methods introduced by this type
					if (_methods.Length > 0)
					{
						String useNS = null;
						if (_xns.IsInteropType)
							useNS = _xns.Name;
						else
						{
							sb.Length = 0;
							sb.Append(_xns.Name);
							sb.Append('.');
							sb.Append(Name);
							useNS = sb.ToString();
						}
						XMLNamespace methodXNS = _xns.LookupSchemaNamespace(useNS, _xns.Assem);
						Debug.Assert(methodXNS != null, "Namespace is null");
						_xns.DependsOnSUDSNS(methodXNS);
						for (int i=0;i<_methods.Length;i++)
						{
							// Process the request
							MethodInfo method = _methods[i];
							String methodRequestName = method.Name;
							Util.Log("RealSchemaType.Resolve Phony  "+methodRequestName);                                                                                                                   
							PhonySchemaType methodRequest = new PhonySchemaType(methodRequestName);
							ParameterInfo[] parameters = method.GetParameters();
							for (int j=0;j<parameters.Length;j++)
							{
								ParameterInfo parameter = parameters[j];
								if (!parameter.IsOut)
									methodRequest.AddParticle(new SchemaElement(parameter.Name,
										parameter.ParameterType,
										false, methodXNS));
							}
							methodXNS.AddPhonySchemaType(methodRequest);
							_methodTypes[2*i] = methodRequest.ElementName;

							if (!RemotingServices.IsOneWay(method))
							{
								// Process response (look at custom attributes to get values

								String returnName = null;
								SoapMethodAttribute soapAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(method);
								if (soapAttribute.ReturnXmlElementName != null)
									returnName = soapAttribute.ReturnXmlElementName;
								else
									returnName = "__return";

								String responseName = null;
								if (soapAttribute.ResponseXmlElementName != null)
									responseName = soapAttribute.ResponseXmlElementName;
								else
									responseName = methodRequestName + "Response";

								Util.Log("RealSchemaType.Resolve Phony  "+responseName);                                                                                                                    
								PhonySchemaType methodResponse = new PhonySchemaType(responseName);
								//  Handle a void method that has an out parameter. This can only
								//         be handled through parameterOrder attribute
								if (method.ReturnType.FullName != "System.Void")
									methodResponse.AddParticle(new SchemaElement(returnName,
										method.ReturnType,
										false, methodXNS));

								for (int j=0;j<parameters.Length;j++)
								{
									ParameterInfo parameter = parameters[j];
									/*if(!parameter.IsIn &&
									(parameter.ParameterType.IsByRef ||
									(!parameter.ParameterType.IsPrimitive &&
									parameter.ParameterType.FullName != "System.String")))*/
									if (parameter.IsOut || parameter.ParameterType.IsByRef)
										methodResponse.AddParticle(new SchemaElement(parameter.Name,
											parameter.ParameterType,
											false, methodXNS));
								}
								methodXNS.AddPhonySchemaType(methodResponse);
								_methodTypes[2*i+1] = methodResponse.ElementName;
							}
						}
					}
				}

				// Resolve fields
				if (_fields != null)
				{
					for (int i=0;i<_fields.Length;i++)
					{
						FieldInfo field = _fields[i];
						Debug.Assert(!field.IsStatic, "Static field");
						Type fieldType = field.FieldType;
						if (fieldType == null)
							fieldType = typeof(Object);
						Util.Log("RealSchemaType.Resolve fields  "+field.Name+" type "+fieldType);                                                                                                              
						AddParticle(new SchemaElement(field.Name, fieldType, false, _xns));
					}
				}

				// Resolve attribute elements
				if (_bStruct == false)
					AddAbstractElement(new SchemaAttribute("id", "xsd:ID"));

				return;
			}