XSharp.CodeDom.XSharpCodeGenerator.GenerateTypeStart C# (CSharp) Méthode

GenerateTypeStart() protected méthode

protected GenerateTypeStart ( CodeTypeDeclaration e ) : void
e System.CodeDom.CodeTypeDeclaration
Résultat void
        protected override void GenerateTypeStart(CodeTypeDeclaration e)
        {
            if (e.CustomAttributes.Count > 0)
            {
                this.GenerateAttributes(e.CustomAttributes);
            }
            if (!this.IsCurrentDelegate)
            {
                this.OutputTypeAttributes(e);
                if (e.IsStruct)
                {
                    if (e.IsPartial)
                    {
                        base.Output.Write("PARTIAL ");
                    }
                    base.Output.Write("STRUCTURE ");
                }
                else if (e.IsEnum)
                {
                    base.Output.Write("ENUM ");
                }
                else if (e.IsClass)
                {
                    if ((e.TypeAttributes & TypeAttributes.Sealed) == TypeAttributes.Sealed)
                    {
                        base.Output.Write("SEALED ");
                    }
                    if ((e.TypeAttributes & TypeAttributes.Abstract) == TypeAttributes.Abstract)
                    {
                        base.Output.Write("ABSTRACT ");
                    }
                    if (e.IsPartial)
                    {
                        base.Output.Write("PARTIAL ");
                    }
                    base.Output.Write("CLASS ");
                }
                else
                {
                    base.Output.Write("INTERFACE ");
                }
                this.OutputIdentifier(e.Name);
                this.OutputGenericParameters(e.TypeParameters);
                if (e.IsEnum)
                {
                    if (e.BaseTypes.Count > 0)
                    {
                        base.Output.Write(" AS ");
                        this.OutputType(e.BaseTypes[0]);
                    }
                }
                else
                {
                    int count = 0;
                    //
                    foreach (CodeTypeReference reference in e.BaseTypes)
                    {
                        if (e.IsStruct)
                        {
                            if (count == 0)
                            {
                                base.Output.Write(" IMPLEMENTS ");
                            }
                            else
                            {
                                base.Output.Write(", ");
                            }
                        }
                        else if (e.IsInterface)
                        {
                            if (count == 0)
                            {
                                base.Output.WriteLine(" ;");
                                this.Indent++;
                                base.Output.Write("INHERIT ");
                                this.Indent--;
                            }
                            else
                            {
                                base.Output.Write(", ");
                            }
                        }
                        else
                        {
                            // Currently we suppose that the First type will always be a class to INHERIT
                            // but sometimes we may only have interfaces to IMPLEMENTs
                            if (count == 0)
                            {
                                base.Output.WriteLine(" ;");
                                this.Indent++;
                                base.Output.Write("INHERIT ");
                                this.Indent--;
                            }
                            else if (count == 1)
                            {
                                base.Output.WriteLine(" ;");
                                this.Indent++;
                                base.Output.Write("IMPLEMENTS ");
                                this.Indent--;
                            }
                            else
                            {
                                base.Output.Write(", ");
                            }
                        }
                        this.OutputType(reference);
                        count++;
                    }
                }
                base.Output.WriteLine();
                this.Indent++;
            }
            else
            {
                CodeTypeDelegate delegate1 = (CodeTypeDelegate)e;
                base.Output.Write("DELEGATE ");
                this.OutputIdentifier(e.Name);
                base.Output.Write("(");
                this.OutputParameters(delegate1.Parameters);
                base.Output.Write(") AS ");
                this.OutputType(delegate1.ReturnType);
                base.Output.WriteLine();
            }
        }
XSharpCodeGenerator