Exemple #1
0
            // Prints all the types in the namespace
            internal void PrintCSC(WriterStream writerStream)
            {
                Util.Log("URTNamespace.PrintCSC Entry "+Name);               
                Debug.Assert(!IsEmpty, "Empty namespace " + Name + " being printed");
                TextWriter textWriter = writerStream.OutputStream;
                // Check to see if there is anything to print for this namespace
                bool bprint = false;
                if (_numURTComplexTypes > 0)
                {
                    for (int i=0;i<_URTComplexTypes.Count;i++)
                    {
                        URTComplexType type = (URTComplexType) _URTComplexTypes[i];
                        if (type != null && type.IsPrint)
                            bprint = true;
                    }
                }

                if (_numURTSimpleTypes > 0)
                {
                    for (int i=0;i<_URTSimpleTypes.Count;i++)
                    {
                        URTSimpleType type = (URTSimpleType) _URTSimpleTypes[i];
                        if (type != null)
                            bprint = true;
                    }
                }

                if (_URTInterfaces.Count > 0)
                    bprint = true;


                if (!bprint)
                    return;
                // End of check to see if there is anything to print


                String indentation = String.Empty;

                Stream stream = ((StreamWriter)textWriter).BaseStream;
                if (!writerStream.GetWrittenTo())
                {
                    // Only print when new output file is used
                    textWriter.WriteLine("using System;");
                    textWriter.WriteLine("using System.Runtime.Remoting.Messaging;");
                    textWriter.WriteLine("using System.Runtime.Remoting.Metadata;");
                    textWriter.WriteLine("using System.Runtime.Remoting.Metadata.W3cXsd2001;");
                    textWriter.WriteLine("using System.Runtime.InteropServices;");
                    writerStream.SetWrittenTo();
                }

                if ((Namespace != null) &&
                    (Namespace.Length != 0))
                {
                    textWriter.Write("namespace ");
                    textWriter.Write(WsdlParser.IsValidCS(EncodedNS));
                    textWriter.WriteLine(" {");
                    indentation = "    ";
                }


                StringBuilder sb = new StringBuilder(256);
                if (_numURTComplexTypes > 0)
                {
                    for (int i=0;i<_URTComplexTypes.Count;i++)
                    {
                        URTComplexType type = (URTComplexType) _URTComplexTypes[i];
                        if (type != null && type.IsPrint)
                        {
                            Util.Log("URTNamespace.PrintCSC Invoke Complex type PrintCSC");                                                                                                             
                            type.PrintCSC(textWriter, indentation, _encodedNS, sb);
                        }
                    }
                }

                if (_numURTSimpleTypes > 0)
                {
                    for (int i=0;i<_URTSimpleTypes.Count;i++)
                    {
                        URTSimpleType type = (URTSimpleType) _URTSimpleTypes[i];
                        if (type != null)
                        {
                            Util.Log("URTNamespace.PrintCSC Invoke Simple type PrintCSC");                                                                                                                                          
                            type.PrintCSC(textWriter, indentation, _encodedNS, sb);
                        }
                    }
                }

                for (int i=0;i<_URTInterfaces.Count;i++)
                {
                    Util.Log("URTNamespace.PrintCSC Invoke Interfaces PrintCSC");                                                                                                                                   
                    ((URTInterface)_URTInterfaces[i]).PrintCSC(textWriter, indentation, _encodedNS, sb);
                }

                if ((Namespace != null) &&
                    (Namespace.Length != 0))
                    textWriter.WriteLine('}');

                return;
            }