protected override void EmitFactory() { base.EmitFactory(); MetaType.DeclareMethod(typeof(void), "Dispatch", method => { method.DeclareParameter("Ascension.Networking.Event", "ev"); method.DeclareParameter(typeof(object).FullName, "target"); DomBlock block = new DomBlock(method.Statements); var tmp = block.TempVar(); block.Stmts.Expr("{0} {1} = target as {0}", Decorator.ListenerInterface, tmp); block.Stmts.Expr("if ({0} != null) {{ {0}.OnEvent(({1})ev); }}", tmp, Decorator.Name); }).PrivateImplementationType = new CodeTypeReference(Decorator.FactoryInterface); }