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

        public IHappilClassBody <TBase> StaticConstructor(
            Action <IHappilConstructorBody> body,
            IHappilAttributes attributes = null)
        {
            var constructorMember = HappilConstructor.CreateStaticConstructor(m_HappilClass);

            constructorMember.SetAttributes(attributes as HappilAttributes);
            constructorMember.AddBodyDefinition(() => {
                body(constructorMember);
            });

            m_HappilClass.AddUndeclaredMember(constructorMember);
            return(this);
        }
Esempio n. 2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private IHappilClassBody <TBase> DefineConstructor(
            IHappilAttributes attributes,
            Action <HappilConstructor> invokeBodyDefinition,
            params Type[] argumentTypes)
        {
            var resolvedArgumentTypes = argumentTypes.Select(TypeTemplate.Resolve).ToArray();
            var constructorMember     = new HappilConstructor(m_HappilClass, resolvedArgumentTypes);

            constructorMember.SetAttributes(attributes as HappilAttributes);
            constructorMember.AddBodyDefinition(() => {
                invokeBodyDefinition(constructorMember);
            });

            m_HappilClass.AddUndeclaredMember(constructorMember);
            m_HappilClass.DefineFactoryMethod(constructorMember.ConstructorInfo, argumentTypes);

            return(this);
        }