예제 #1
0
        protected virtual IAnonymousTypeConfig CreateAnonymousType(AnonymousType type)
        {
            var config = new AnonymousTypeConfig();

            config.Name = "Bridge.$AnonymousType$" + (this.Emitter.AnonymousTypes.Count + 1);
            config.Type = type;

            var oldWriter = this.SaveWriter();

            this.NewWriter();

            this.Write("Bridge.define(");
            this.WriteScript(config.Name);
            this.Write(", ");
            this.BeginBlock();
            this.Emitter.Comma = false;
            this.GenereateCtor(type);
            this.GenereateGetters(config);
            this.GenereateEquals(config);
            this.GenereateHashCode(config);
            this.GenereateToJSON(config);

            this.WriteNewLine();
            this.EndBlock();
            this.Write(");");
            config.Code = this.Emitter.Output.ToString();

            this.RestoreWriter(oldWriter);
            return(config);
        }
예제 #2
0
        public virtual IAnonymousTypeConfig CreateAnonymousType(AnonymousType type)
        {
            var config = new AnonymousTypeConfig();

            config.Name = JS.Types.BRIDGE_ANONYMOUS + (this.Emitter.AnonymousTypes.Count + 1);
            config.Type = type;

            var oldWriter = this.SaveWriter();

            this.NewWriter();

            this.Write(JS.Types.Bridge.DEFINE);
            this.WriteOpenParentheses();
            this.WriteScript(config.Name);
            config.Name = JS.Vars.ASM + "." + config.Name;
            this.Write(", " + JS.Vars.ASM + ", ");
            this.BeginBlock();
            this.Emitter.Comma = false;
            this.GenereateCtor(type);

            this.EnsureComma();
            this.Write(JS.Fields.METHODS);
            this.WriteColon();
            this.BeginBlock();

            this.GenereateEquals(config);
            this.GenerateHashCode(config);
            this.GenereateToJSON(config);

            this.WriteNewLine();
            this.EndBlock();

            this.GenereateMetadata(config);

            this.WriteNewLine();
            this.EndBlock();
            this.Write(");");
            config.Code = this.Emitter.Output.ToString();

            this.RestoreWriter(oldWriter);

            return(config);
        }