protected virtual void EmitMeta() { MetaType = Generator.DeclareClass(Decorator.NameMeta); //MetaType.TypeAttributes = TypeAttributes.NestedAssembly; //Needed to change the emitted code to be 'public' instead of 'internal' MetaType.Attributes = MemberAttributes.Public; MetaType.TypeAttributes = TypeAttributes.Public; MetaType.BaseTypes.Add(Decorator.BaseClassMeta); MetaType.BaseTypes.Add(Decorator.FactoryInterface); //MetaType.DeclareField(Decorator.NameMeta, "Instance").Attributes = MemberAttributes.Static | // MemberAttributes.Assembly; MetaType.DeclareField(Decorator.NameMeta, "Instance").Attributes = MemberAttributes.Static | MemberAttributes.Public; MetaType.DeclareConstructorStatic(ctor => { ctor.Statements.Add("Instance".Expr().Assign(Decorator.NameMeta.New())); ctor.Statements.Add("Instance".Expr().Call("InitMeta")); EmitMetaStaticCtor(ctor); }); // initialize object MetaType.DeclareMethod(typeof(void).FullName, "InitObject", method => { //method.Attributes = MemberAttributes.Assembly | MemberAttributes.Override; method.Attributes = MemberAttributes.Public | MemberAttributes.Override; method.DeclareParameter("Ascension.Networking.NetworkObj", "obj"); method.DeclareParameter("Ascension.Networking.NetworkObj_Meta.Offsets", "offsets"); DomBlock block; block = new DomBlock(method.Statements); for (int i = 0; i < Decorator.Properties.Count; ++i) { block.Stmts.Comment(""); block.Stmts.Comment("Property: " + Decorator.Properties[i].Definition.Name); PropertyCodeEmitter.Create(Decorator.Properties[i]).EmitObjectSetup(block); } EmitObjectInit(method); }); // initialize meta class MetaType.DeclareMethod(typeof(void).FullName, "InitMeta", method => { //method.Attributes = MemberAttributes.Assembly | MemberAttributes.Override; method.Attributes = MemberAttributes.Public | MemberAttributes.Override; DomBlock block; block = new DomBlock(method.Statements); block.Stmts.Comment("Setup fields"); block.Stmts.Expr("this.TypeId = new Ascension.Networking.TypeId({0})", Decorator.TypeId); block.Stmts.Expr("this.CountStorage = {0}", Decorator.CountStorage); block.Stmts.Expr("this.CountObjects = {0}", Decorator.CountObjects); block.Stmts.Expr("this.CountProperties = {0}", Decorator.CountProperties); block.Stmts.Expr("this.Properties = new Ascension.Networking.NetworkPropertyInfo[{0}]", Decorator.CountProperties); EmitMetaInit(method); for (int i = 0; i < Decorator.Properties.Count; ++i) { block.Stmts.Comment(""); block.Stmts.Comment("Property: " + Decorator.Properties[i].Definition.Name); PropertyCodeEmitter.Create(Decorator.Properties[i]).EmitMetaSetup(block); } block.Stmts.Expr("base.InitMeta()"); }); // emit factory interface EmitFactory(); }