Exemplo n.º 1
0
            //-----------------------------------------------------------------------------------------------------------------------------------------------------

            /// <summary>
            /// Each concrete factory is free to define arbitrary public methods according to the need.
            /// </summary>
            /// <typeparam name="T">
            /// In this example, it is the primary interface that will be implemented by the dynamic type.
            /// </typeparam>
            /// <returns>
            /// A new instance of dynamic type implementing specified interface.
            /// </returns>
            public T CreateDemoObject <T>()
            {
                var key  = new HappilTypeKey(baseType: typeof(object), primaryInterface: typeof(T));
                var type = GetOrBuildType(key);

                return(type.CreateInstance <T>());
            }
Exemplo n.º 2
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            protected override IHappilClassDefinition DefineNewClass(HappilModule module, HappilTypeKey key)
            {
                return(Module.DefineClass(key, namespaceName: "ImplementingMethodsDemo")
                       .ImplementInterface(key.PrimaryInterface)
                       .VoidMethods().Implement(m => {
                    var methodName = m.Local <string>();
                    methodName.AssignConst(m.MethodInfo.Name);
                    m.EmitFromLambda(() => Console.WriteLine(methodName));
                }));
            }
Exemplo n.º 3
0
            //-----------------------------------------------------------------------------------------------------------------------------------------------------

            protected override IHappilClassDefinition DefineNewClass(HappilModule module, HappilTypeKey key)
            {
                return(Module.DefineClass(key, namespaceName: "EndToEndDemo")
                       .ImplementInterface(key.PrimaryInterface)
                       .AllProperties().ImplementAutomatic());
            }
Exemplo n.º 4
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            protected override IHappilClassDefinition DefineNewClass(HappilModule module, HappilTypeKey key)
            {
                return(Module.DefineClass(
                           "HappilFactoryBaseTests.Impl" + key.PrimaryInterface.Name, key.BaseType)
                       .ImplementInterface(key.PrimaryInterface)
                       .DefaultConstructor());
            }