コード例 #1
0
        internal DbPropertyInfoCache(string name, Action <dynamic, TE> setter = null, Func <dynamic, TE> getter = null,
                                     params AttributeInfoCache[] attributes)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            PropertyName = name;

            if (setter != null)
            {
                Setter = new FakePropertyMethodInfoCache <DbAttributeInfoCache, MethodArgsInfoCache <DbAttributeInfoCache> >(this,
                                                                                                                             (o, objects) =>
                {
                    setter(o, (TE)objects[0]);
                    return(null);
                });
            }

            if (getter != null)
            {
                Getter = new FakePropertyMethodInfoCache <DbAttributeInfoCache, MethodArgsInfoCache <DbAttributeInfoCache> >(this,
                                                                                                                             (o, objects) => getter(o));
            }
        }
コード例 #2
0
        internal DbAutoStaticPropertyInfoCache(string name, Type declaringType, params AttributeInfoCache[] attributes)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            PropertyName = name;

            Setter = new FakePropertyMethodInfoCache <DbAttributeInfoCache, MethodArgsInfoCache <DbAttributeInfoCache> >(this,
                                                                                                                         (o, objects) =>
            {
                Value = (TE)objects[0];
                return(null);
            });

            Getter = new FakePropertyMethodInfoCache <DbAttributeInfoCache, MethodArgsInfoCache <DbAttributeInfoCache> >(this,
                                                                                                                         (o, objects) => { return(Value); });

            //Setter.UseILWrapper = true;
            //Getter.UseILWrapper = true;
        }