internal void PrintCSC(TextWriter textWriter, String indentation, String curNS, StringBuilder sb)
{
Util.Log("URTComplexType.PrintCSC enter name "+Name+" curNS "+curNS+" sudsUse "+((Enum)_sudsUse).ToString()+" bNestedType "+bNestedType+" bNestedTypePrint "+bNestedTypePrint);
// Print only if the type is not an emittable field type
if (IsEmittableFieldType == true)
return;
if (bNestedType && !bNestedTypePrint)
return;
// Handle delegate case
sb.Length = 0;
sb.Append(indentation);
if (_baseTypeName != null)
{
String baseName = _baseType.GetName(curNS);
if ((baseName == "System.Delegate") || (baseName == "System.MulticastDelegate"))
{
sb.Append("public delegate ");
URTMethod invokeMethod = GetMethod("Invoke");
if (invokeMethod == null)
{
throw new SUDSParserException(
CoreChannel.GetResourceString("Remoting_Suds_DelegateWithoutInvoke"));
}
String typeString = invokeMethod.GetTypeString(curNS, true);
sb.Append(WsdlParser.IsValidCSAttr(typeString));
sb.Append(' ');
String printName = Name;
int index = printName.IndexOf('.');
if (index > 0)
{
printName = printName.Substring(index+1);
}
sb.Append(WsdlParser.IsValidCS(printName));
sb.Append('(');
invokeMethod.PrintSignature(sb, curNS);
sb.Append(");");
textWriter.WriteLine(sb);
return;
}
}
bool bURTType = IsURTType;
sb.Length = 0;
sb.Append("\n");
sb.Append(indentation);
sb.Append("[");
if (_sudsType != SUDSType.ClientProxy)
sb.Append("Serializable, ");
sb.Append("SoapType(");
if (_parser._xsdVersion == XsdVersion.V1999)
{
sb.Append("SoapOptions=SoapOption.Option1|SoapOption.AlwaysIncludeTypes|SoapOption.XsdString|SoapOption.EmbedAll,");
}
else if (_parser._xsdVersion == XsdVersion.V2000)
{
sb.Append("SoapOptions=SoapOption.Option2|SoapOption.AlwaysIncludeTypes|SoapOption.XsdString|SoapOption.EmbedAll,");
}
if (!bURTType)
{
sb.Append("XmlElementName=");
sb.Append(WsdlParser.IsValidUrl(GetClassName()));
sb.Append(", XmlNamespace=");
sb.Append(WsdlParser.IsValidUrl(Namespace));
sb.Append(", XmlTypeName=");
if (WireType != null)
sb.Append(WsdlParser.IsValidUrl(WireType));
else
sb.Append(WsdlParser.IsValidUrl(GetClassName()));
sb.Append(", XmlTypeNamespace=");
sb.Append(WsdlParser.IsValidUrl(Namespace));
}
else
{
// Need namespace for clr type because proxy dll might have a different name than server dll
sb.Append("XmlNamespace=");
sb.Append(WsdlParser.IsValidUrl(UrlNS));
sb.Append(", XmlTypeNamespace=");
sb.Append(WsdlParser.IsValidUrl(UrlNS));
if (WireType != null)
{
sb.Append(", XmlTypeName=");
sb.Append(WsdlParser.IsValidUrl(WireType));
}
}
sb.Append(")]");
sb.Append("[ComVisible(true)]");
textWriter.WriteLine(sb);
sb.Length = 0;
sb.Append(indentation);
if (_sudsUse == SudsUse.Struct)
sb.Append("public struct ");
else
sb.Append("public class ");
if (_bNestedType)
sb.Append(WsdlParser.IsValidCS(NestedTypeName));
else
sb.Append(WsdlParser.IsValidCS(GetClassName()));
if (_baseTypeName != null || _sudsUse == SudsUse.ISerializable || _implIFaces.Count > 0)
sb.Append(" : ");
bool bBaseIsURTType = true;
String baseString = null;
bool binherit = false;
bool fClientProxy;
if (_baseTypeName == "RemotingClientProxy")
fClientProxy = true;
else
fClientProxy = false;
if (fClientProxy)
{
sb.Append("System.Runtime.Remoting.Services.RemotingClientProxy");
binherit = true;
}
else if (_baseTypeName != null)
{
bBaseIsURTType = _baseType.IsURTType;
baseString = _baseType.GetName(curNS);
if (baseString == "System.__ComObject")
{
/*textWriter.Write(indentation);
textWriter.WriteLine("[guid(\"cc3bf020-1881-4e44-88d8-39b1052b1b11\")]");
textWriter.Write(indentation);
textWriter.WriteLine("[comimport]"); */
sb.Append("System.MarshalByRefObject");
binherit = true;
}
else
{
sb.Append(WsdlParser.IsValidCSAttr(baseString));
binherit = true;
}
}
else
{
// no base name
if (_sudsUse == SudsUse.ISerializable)
{
sb.Append("System.Runtime.Serialization.ISerializable");
binherit = true;
}
}
if (_implIFaces.Count > 0)
{
for (int i=0;i<_implIFaces.Count;i++)
{
if (binherit)
sb.Append(", ");
sb.Append(WsdlParser.IsValidCS(((BaseInterface) _implIFaces[i]).GetName(curNS)));
binherit = true;
}
}
textWriter.WriteLine(sb);
textWriter.Write(indentation);
textWriter.WriteLine('{');
String newIndentation = indentation + " ";
int newIndentationLength = newIndentation.Length;
//bool fClientProxy = _connectURL != null;
Util.Log("URTComplexType.PrintCSC _sudsType "+((Enum)_sudsType).ToString());
if (fClientProxy)
{
PrintClientProxy(textWriter, indentation, curNS, sb);
}
if (_methods.Count > 0)
{
//textWriter.Write(newIndentation);
//textWriter.WriteLine("// Class Methods");
String bodyPrefix = null;
if (_parser._bWrappedProxy)
{
sb.Length = 0;
sb.Append("((");
sb.Append(WsdlParser.IsValidCS(GetClassName()));
sb.Append(") _tp).");
bodyPrefix = sb.ToString();
}
for (int i=0;i<_methods.Count;i++)
{
Util.Log("URTComplexType.PrintCSC Invoke methods class methods PrintCSC class "+Name+" methodName "+((URTMethod) _methods[i]).Name);
((URTMethod) _methods[i]).PrintCSC(textWriter, newIndentation,
" ", curNS, MethodPrintEnum.PrintBody, bURTType,
bodyPrefix, sb);
}
textWriter.WriteLine();
}
/*
if (_implIFaces.Count > 0)
{
ArrayList printedIFaces = new ArrayList(_implIFaces.Count);
for (int i=0;i<_implIFaces.Count;i++)
((BaseInterface) _implIFaces[i]).PrintClassMethods(textWriter, newIndentation, curNS, printedIFaces, fClientProxy, sb);
textWriter.WriteLine();
}
*/
// Standard class
if (_fields.Count > 0)
{
textWriter.Write(newIndentation);
textWriter.WriteLine("// Class Fields");
for (int i=0;i<_fields.Count;i++)
{
Util.Log("URTComplexType.PrintCS Invoke _fields PrintCSC");
((URTField) _fields[i]).PrintCSC(textWriter, newIndentation, curNS, sb);
}
}
// print nested types
if (_nestedTypes != null && _nestedTypes.Count > 0)
{
foreach (BaseType ctype in _nestedTypes)
{
ctype.bNestedTypePrint = true;
if (ctype is URTSimpleType)
((URTSimpleType)ctype).PrintCSC(textWriter, newIndentation, curNS, sb);
else
((URTComplexType)ctype).PrintCSC(textWriter, newIndentation, curNS, sb);
ctype.bNestedTypePrint = false;
}
}
if (_sudsUse == SudsUse.ISerializable)
PrintISerializable(textWriter, indentation, curNS, sb, baseString);
// Close class
sb.Length = 0;
sb.Append(indentation);
sb.Append("}");
textWriter.WriteLine(sb);
Util.Log("URTComplexType.PrintCSC Exit name "+Name+" curNS "+curNS);
return;
}