//----------------------------------------------------------------------------------------------------------------------------------------------------- public T New <T>() where T : class { var key = new HappilTypeKey(primaryInterface: typeof(T)); var type = base.GetOrBuildType(key); return(type.CreateInstance <T>()); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- private TypeEntry BuildNewTypeEntry(HappilTypeKey key) { using (key.CreateTypeTemplateScope()) { var classDefinition = DefineNewClass(m_Module, key); return(new TypeEntry((IHappilClassDefinitionInternals)classDefinition)); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public IHappilClassBody <object> DefineClass(HappilTypeKey key, string namespaceName) { return(DefineClass(namespaceName + ".ImplOf" + key.PrimaryInterface.Name, key.BaseType)); }
//------------------------------------------------------------------------------------------------------------------------------------------------- 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); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- 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); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- protected abstract IHappilClassDefinition DefineNewClass(HappilModule module, HappilTypeKey key);
//----------------------------------------------------------------------------------------------------------------------------------------------------- protected TypeEntry GetOrBuildType(HappilTypeKey key) { return(m_BuiltTypes.GetOrAdd(key, valueFactory: BuildNewTypeEntry)); }