/// <summary>
 /// Converts data to defined string
 /// </summary>
 /// <param name="aData">
 /// Data <see cref="System.Object"/>
 /// </param>
 /// <returns>
 /// String representation <see cref="System.String"/>
 /// </returns>
 private string GetDataText(object aData, string aDestination)
 {
     if (aData == null)
     {
         return("");
     }
     if (TypeValidator.IsNumeric(aData.GetType()) == true)
     {
         System.Type type = aData.GetType();
         if (type == typeof(byte))
         {
             return(((byte)aData).ToString(aDestination));
         }
         if (type == typeof(int))
         {
             return(((int)aData).ToString(aDestination));
         }
         if (type == typeof(Int16))
         {
             return(((Int16)aData).ToString(aDestination));
         }
         if (type == typeof(UInt16))
         {
             return(((UInt16)aData).ToString(aDestination));
         }
         if (type == typeof(Int32))
         {
             return(((Int32)aData).ToString(aDestination));
         }
         if (type == typeof(UInt32))
         {
             return(((UInt32)aData).ToString(aDestination));
         }
         if (type == typeof(Int64))
         {
             return(((Int64)aData).ToString(aDestination));
         }
         if (type == typeof(UInt64))
         {
             return(((UInt64)aData).ToString(aDestination));
         }
         if (type == typeof(float))
         {
             return(((float)aData).ToString(aDestination));
         }
         if (type == typeof(decimal))
         {
             return(((decimal)aData).ToString(aDestination));
         }
         if (type == typeof(double))
         {
             return(((double)aData).ToString(aDestination));
         }
     }
     return("");
 }
예제 #2
0
        /// <summary>
        /// Set only if it simple column mapping, else using sets from Render.
        /// </summary>
        /// <param name="propertyRefExpr">Property Name expr.</param>
        /// <typeparam name="TVMNode">Node type</typeparam>
        public ColumnMapping <TNode> SetDataProperty(Expression <Func <TNode, object> > propertyRefExpr)
        {
            DataPropertyName = PropertyUtil.GetName(propertyRefExpr);
            Type properyType = typeof(TNode).GetProperty(DataPropertyName).PropertyType;

            if (TypeValidator.IsNumeric(properyType))
            {
                AddNumericRenderer(propertyRefExpr);
            }
            else
            {
                throw new NotSupportedException(String.Format("Type {0} isn't supports.", properyType));
            }
            return(this);
        }