Esempio n. 1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public T New <T>() where T : class
        {
            var key  = new HappilTypeKey(primaryInterface: typeof(T));
            var type = base.GetOrBuildType(key);

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

        private TypeEntry BuildNewTypeEntry(HappilTypeKey key)
        {
            using (key.CreateTypeTemplateScope())
            {
                var classDefinition = DefineNewClass(m_Module, key);
                return(new TypeEntry((IHappilClassDefinitionInternals)classDefinition));
            }
        }
Esempio n. 3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public IHappilClassBody <object> DefineClass(HappilTypeKey key, string namespaceName)
        {
            return(DefineClass(namespaceName + ".ImplOf" + key.PrimaryInterface.Name, key.BaseType));
        }
Esempio n. 4
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public TupleClassBuilder(HappilTypeKey key, IHappilClassBody <object> classBody)
            {
                m_Key             = key;
                m_ClassBody       = classBody;
                m_TupleProperties = TypeMembers.Of(key.PrimaryInterface).ImplementableProperties.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
            }
Esempio n. 5
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        protected override IHappilClassDefinition DefineNewClass(HappilModule module, HappilTypeKey key)
        {
            var classDefinition = Module.DeriveClassFrom <object>(MakeClassNameFrom(key.PrimaryInterface, prefix: "XTupleOf"));
            var builder         = new TupleClassBuilder(key, classDefinition);

            builder.BuildClass();

            return(classDefinition);
        }
Esempio n. 6
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        protected abstract IHappilClassDefinition DefineNewClass(HappilModule module, HappilTypeKey key);
Esempio n. 7
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        protected TypeEntry GetOrBuildType(HappilTypeKey key)
        {
            return(m_BuiltTypes.GetOrAdd(key, valueFactory: BuildNewTypeEntry));
        }