コード例 #1
0
        internal static PropertyInfoFieldInfo InitializePropertyInfo(string nestedPropertyPath, Type type, Type rootClassType)
        {
            string[] splitNestedProperty             = nestedPropertyPath.Split(new char[] { NestedPropertySeparator });
            PropertyInfoFieldInfo nestedPropertyInfo = null;
            PropertyInfo          propertyInfo       = null;

            for (int i = 1; i < splitNestedProperty.Length; i++)
            {
                string propertyName = splitNestedProperty[i];
                propertyInfo = type.GetRuntimeProperty(propertyName);
                if (propertyInfo == null)
                {
                    return(null);
                }

                type = propertyInfo.PropertyType;
            }

            var propertyAccess = Telerik.Data.Core.BindingExpressionHelper.CreateGetValueFunc(rootClassType, nestedPropertyPath);
            var propertySetter = propertyInfo.CanWrite
                ? Telerik.Data.Core.BindingExpressionHelper.CreateSetValueAction(rootClassType, nestedPropertyPath)
                : null;

            nestedPropertyInfo      = new PropertyInfoFieldInfo(propertyInfo, propertyAccess, propertySetter, rootClassType, nestedPropertyPath);
            nestedPropertyInfo.Role = FieldInfoHelper.GetRoleForType(propertyInfo.PropertyType);

            return(nestedPropertyInfo);
        }
コード例 #2
0
        public void IsNumericType_WhenTypeIsDateTime_ReturnsFalse()
        {
            var type = typeof(DateTime);

            var isNumeric = FieldInfoHelper.IsNumericType(type);

            Assert.IsFalse(isNumeric);
        }
コード例 #3
0
        public void IsNumericType_WhenTypeIsNullableUInt64_ReturnsTrue()
        {
            var type = typeof(Nullable <UInt64>);

            var isNumeric = FieldInfoHelper.IsNumericType(type);

            Assert.IsTrue(isNumeric);
        }
コード例 #4
0
        public void IsNumericType_WhenTypeIsString_ReturnsFalse()
        {
            var type = typeof(string);

            var isNumeric = FieldInfoHelper.IsNumericType(type);

            Assert.IsFalse(isNumeric);
        }
コード例 #5
0
        public void IsNumericType_WhenTypeIsUInt16_ReturnsTrue()
        {
            var type = typeof(UInt16);

            var isNumeric = FieldInfoHelper.IsNumericType(type);

            Assert.IsTrue(isNumeric);
        }
コード例 #6
0
        public void IsNumericType_WhenTypeIsDecimal_ReturnsTrue()
        {
            var type = typeof(Decimal);

            var isNumeric = FieldInfoHelper.IsNumericType(type);

            Assert.IsTrue(isNumeric);
        }
コード例 #7
0
        public void GetRoleForType_WhenTypeIsUInt32_ReturnsValueRole()
        {
            var type         = typeof(UInt32);
            var expectedRole = FieldRole.Value;

            var actualRole = FieldInfoHelper.GetRoleForType(type);

            Assert.AreEqual(expectedRole, actualRole);
        }
コード例 #8
0
        public void GetRoleForType_WhenTypeIsBool_ReturnsRowRole()
        {
            var type         = typeof(bool);
            var expectedRole = FieldRole.Row;

            var actualRole = FieldInfoHelper.GetRoleForType(type);

            Assert.AreEqual(expectedRole, actualRole);
        }
コード例 #9
0
        public void GetRoleForType_WhenTypeIsChar_ReturnsColumnRole()
        {
            var type         = typeof(Char);
            var expectedRole = FieldRole.Column;

            var actualRole = FieldInfoHelper.GetRoleForType(type);

            Assert.AreEqual(expectedRole, actualRole);
        }
コード例 #10
0
        /// <inheritdoc />
        internal override IAggregateDescription GetAggregateDescriptionForFieldDescription(IDataFieldInfo description)
        {
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            var aggregateDescription = new PropertyAggregateDescription()
            {
                PropertyName = description.Name
            };

            if (!FieldInfoHelper.IsNumericType(description.DataType))
            {
                ////aggregateDescription.AggregateFunction = AggregateFunctions.Count;
            }

            return(aggregateDescription);
        }
コード例 #11
0
 /// <summary>
 /// 获取一只股票,一个字段的数据
 /// </summary>
 /// <param name="code"></param>
 /// <param name="field"></param>
 /// <returns></returns>
 public object GetFieldData(int code, FieldIndex field)
 {
     return(FieldInfoHelper.GetObjectValue(code, field));
 }