예제 #1
0
        public static List <Property> ToProperties(this ContactModel model)
        {
            List <Property> Properties = new List <Property>();
            Type            ClassType  = model.GetType();

            foreach (var property in ClassType.GetProperties())
            {
                Property propertyModel = new Property();
                string   Name          = AttributeUtilities.GetDescription <DescriptionAttribute>(property);
                propertyModel.PropertyName = string.IsNullOrEmpty(Name) ? property.Name : Name;
                propertyModel.Value        = Convert.ToString(property.GetValue(model));
                Properties.Add(propertyModel);
            }
            return(Properties);
        }
예제 #2
0
        public static List <Property> ClassPropertyToDictionary <T>(object classObject)
        {
            List <Property> Properties = new List <Property>();
            Type            ClassType  = classObject.GetType();

            foreach (var property in ClassType.GetProperties())
            {
                Property propertyModel = new Property();
                string   Name          = AttributeUtilities.GetDescription <T>(property);
                propertyModel.PropertyName = string.IsNullOrEmpty(Name) ? property.Name : Name;
                propertyModel.Value        = Convert.ToString(property.GetValue(classObject));
                Properties.Add(propertyModel);
            }
            return(Properties);
        }