Example #1
0
        void MakePropertyType()
        {
            if (MemberInfo.MemberType == MemberTypes.Property)
            {
                _PropertyType = (this.MemberInfo as PropertyInfo).PropertyType;
            }
            else if (MemberInfo.MemberType == MemberTypes.Field)
            {
                _PropertyType = (this.MemberInfo as FieldInfo).FieldType;
            }

            _nullable = this.PropertyType.FullName.StartsWith("System.Nullable`1");
            if (_nullable == false)
            {
                _NonullableType = _PropertyType;
            }
            else
            {
                _NonullableType = _PropertyType.GetGenericArguments()[0];
            }
            _nullChecker = CheckNull.GetChecker(_PropertyType);

            if (this._PropertyType.IsAssignableFrom(typeof(IEnumerable)))
            {
                foreach (var ifc in this._PropertyType.GetInterfaces())
                {
                    if (ifc.Name.StartsWith("System.IEnumerable"))
                    {
                        this._IsEnumerable = true;
                    }
                    else if (ifc.Name.StartsWith("System.IEnumerable<"))
                    {
                        this._EnumerableItemType = ifc.GetGenericArguments()[0];
                    }
                    else if (ifc.Name.StartsWith("System.IDictionary<"))
                    {
                        this._IsDictionary = true;
                        var kvts = ifc.GetGenericArguments()[0].GetGenericArguments();
                        this._DictionaryKeyType   = kvts[0];
                        this._DictionaryValueType = kvts[1];
                    }
                }
            }
        }
Example #2
0
        void MakePropertyType()
        {
            if (MemberInfo.MemberType == MemberTypes.Property)
            {
                _PropertyType = (this.MemberInfo as PropertyInfo).PropertyType;
            }
            else if (MemberInfo.MemberType == MemberTypes.Field)
            {
                _PropertyType = (this.MemberInfo as FieldInfo).FieldType;
            }

            _nullable = this.PropertyType.FullName.StartsWith("System.Nullable`1");
            if (_nullable == false)
            {
                _NonullableType = _PropertyType;
            }
            else
            {
                _NonullableType = _PropertyType.GetGenericArguments()[0];
            }
            _nullChecker = CheckNull.GetChecker(_PropertyType);
        }