public virtual void DataFromAutoObject(AutoObject value) { var obj = this; PropertyInfo[] ObjProperties = obj.GetType().GetProperties(); for (int i = 0; i < ObjProperties.Length; i++) { PropertyInfo property = ObjProperties[i]; AutoItem item = GetValueFromAutoObject(value, property.Name); if (item != null) { //check for nullable property type and handle var propertyType = property.PropertyType; if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { propertyType = propertyType.GetGenericArguments()[0]; } //set property value var objValue = item.Value; if (objValue == null) { ObjProperties[i].SetValue(obj, null); } else { ObjProperties[i].SetValue(obj, Convert.ChangeType(objValue, propertyType, System.Globalization.CultureInfo.CurrentCulture), null); } } } }
public static T ToBusinessObject <T>(AutoObject item) where T : Bus { T x = (T)Activator.CreateInstance(typeof(T), item); x.MakeUnchange(); return(x); }
public virtual AutoObject DataToAutoObject(params AutoItem[] items) { AutoObject item = new AutoObject { SpName = GetSpName(), Items = new List <AutoItem>() }; item.TypeName = this.GetType().FullName; item.State = this.State; item.Items.AddRange(items); return(item); }
AutoItem GetValueFromAutoObject(AutoObject value, string Name) { if (value.Items == null) { return(null); } Name = Name.ToLower(); for (int i = 0; i < value.Items.Count; i++) { if (value.Items[i].Name.ToLower() == Name) { return(value.Items[i]); } } return(null); }
public AutoObjectTransaction Add(AutoObject item) { listAuto.Add(item); return(this); }