Esempio n. 1
0
        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);
                    }
                }
            }
        }
Esempio n. 2
0
        public static T ToBusinessObject <T>(AutoObject item) where T : Bus
        {
            T x = (T)Activator.CreateInstance(typeof(T), item);

            x.MakeUnchange();
            return(x);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 public AutoObjectTransaction Add(AutoObject item)
 {
     listAuto.Add(item);
     return(this);
 }