Esempio n. 1
0
        private void Write(ScriptWriter writer)
        {
            // write namespace
            if (!string.IsNullOrEmpty(Namespace))
            {
                writer.WriteFullLineFormat("namespace {0}", Namespace);
                writer.BeginScope();
            }

            // write class definition
            writer.BeginWrite();
            writer.Write("public ");
            if (IsStatic)
            {
                writer.Write("static ");
            }
            if (IsPartial)
            {
                writer.Write("partial ");
            }
            writer.Write("class " + Name);
            writer.EndWrite();

            writer.BeginScope();

            // write fields and properties
            for (int x = 0; x < fields.Count; x++)
            {
                fields[x].Write(writer);
            }

            for (int x = 0; x < properties.Count; x++)
            {
                properties[x].Write(writer);
            }

            // write methods
            for (int x = 0; x < methods.Count; x++)
            {
                methods[x].Write(writer);
            }

            // write child classes
            for (int x = 0; x < classes.Count; x++)
            {
                classes[x].Write(writer);
            }

            writer.EndScope();
        }
        public void Write(ScriptWriter writer)
        {
            // method signature
            {
                writer.BeginWrite();

                writer.Write("public ");

                if (IsStatic)
                {
                    writer.Write("static ");
                }

                if (!IsConstructor)
                {
                    writer.WriteFormat("{0} ", ReturnType);
                }

                writer.Write(Name);

                // write parameters
                writer.Write("(");
                for (int x = 0; x < parameters.Count; x++)
                {
                    writer.WriteFormat("{0} {1}", parameters[x].TypeName, parameters[x].Name);

                    if (x + 1 < parameters.Count)
                    {
                        writer.Write(", ");
                    }
                }
                writer.Write(")");
                writer.EndWrite();
            }

            // write method definition
            instructions.Write(writer);

            writer.WriteFullLine(string.Empty);
        }