コード例 #1
0
ファイル: PropertySelectors.cs プロジェクト: bitfringe/Hapil
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public IHappilClassBody <TBase> Implement(
                IHappilAttributes attributes,
                Func <IHappilPropertyBody <TypeTemplate.TProperty>, IHappilPropertyGetter> getter,
                Func <IHappilPropertyBody <TypeTemplate.TProperty>, IHappilPropertySetter> setter = null)
            {
                return(Implement(prop => attributes, getter, setter));
            }
コード例 #2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public IHappilClassBody <TBase> StaticField <T>(string name, IHappilAttributes attributes, out FieldAccessOperand <T> field)
        {
            var fieldMember = DefineField <T>(name, isStatic: true);

            fieldMember.SetAttributes(attributes as HappilAttributes);
            field = fieldMember.AsOperand <T>();
            return(this);
        }
コード例 #3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public IHappilClassBody <TBase> Constructor <TArg1, TArg2, TArg3>(
            Action <IHappilConstructorBody, HappilArgument <TArg1>, HappilArgument <TArg2>, HappilArgument <TArg3> > body,
            IHappilAttributes attributes = null)
        {
            return(DefineConstructor(
                       attributes,
                       (ctor) => body(ctor, new HappilArgument <TArg1>(ctor, 1), new HappilArgument <TArg2>(ctor, 2), new HappilArgument <TArg3>(ctor, 3)),
                       typeof(TArg1), typeof(TArg2), typeof(TArg3)));
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: PropertySelectors.cs プロジェクト: bitfringe/Hapil
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public IHappilClassBody <TBase> Implement(
                IHappilAttributes attributes,
                Func <IHappilPropertyBody <TIndex1, TIndex2, TProperty>, IHappilPropertyGetter> getter,
                Func <IHappilPropertyBody <TIndex1, TIndex2, TProperty>, IHappilPropertySetter> setter = null)
            {
                DefineMembers <TProperty>(body => {
                    body.SetAttributes(attributes as HappilAttributes);

                    if (getter != null)
                    {
                        getter((IHappilPropertyBody <TIndex1, TIndex2, TProperty>)body);
                    }
                    if (setter != null)
                    {
                        setter((IHappilPropertyBody <TIndex1, TIndex2, TProperty>)body);
                    }
                });

                return(OwnerBody);
            }
コード例 #7
0
ファイル: PropertySelectors.cs プロジェクト: bitfringe/Hapil
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public IHappilClassBody <TBase> ImplementAutomatic(IHappilAttributes attributes)
            {
                return(DefineAutomaticImplementation <TypeTemplate.TProperty>(prop => attributes));
            }
コード例 #8
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public IHappilClassBody <TBase> Throw <TException>(IHappilAttributes attributes, string message = null) where TException : Exception
            {
                return(DefineMembers <object>(
                           attributes: m => attributes,
                           invokeBodyDefinition: m => m.Throw <TException>(message)));
            }
コード例 #9
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public IHappilClassBody <TBase> Implement(
                IHappilAttributes attributes,
                Action <IHappilMethodBody <TReturn>, HappilArgument <TArg1>, HappilArgument <TArg2>, HappilArgument <TArg3> > body)
            {
                return(Implement(m => attributes, body));
            }
コード例 #10
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public IHappilClassBody <TBase> Implement(IHappilAttributes attributes, Action <IVoidHappilMethodBody> body)
            {
                return(Implement(m => attributes, body));
            }
コード例 #11
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public IHappilClassBody <TBase> Constructor(
            Action <IHappilConstructorBody> body,
            IHappilAttributes attributes = null)
        {
            return(DefineConstructor(attributes, body));
        }
コード例 #12
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public IHappilClassBody <TBase> DefaultConstructor(IHappilAttributes attributes = null)
        {
            return(DefineConstructor(attributes, ctor => ctor.Base()));
        }