Пример #1
0
        internal static T Clone <T>(object obj) where T : new()
        {
            T des = new T();

            CloneUtils.CloneObject(obj, des, new string[0]);
            return(des);
        }
Пример #2
0
        public virtual T Clone <T>() where T : DbObject, new()
        {
            T local = DbObjectTools.Clone <T>(this);

            CloneUtils.CloneObject <DbObjectState>(this.State, local.State, new Expression <Func <DbObjectState, object> > [0]);
            CloneUtils.CloneObject <DbObjectState>(this.previousState, local.previousState, new Expression <Func <DbObjectState, object> > [0]);
            return(local);
        }
Пример #3
0
        private void OnTranscationRollback(object sender, EventArgs e)
        {
            DbObjectOperator @operator = sender as DbObjectOperator;

            @operator.TranscationRollback -= new EventHandler(this.OnTranscationRollback);
            if (this.previousState != null)
            {
                CloneUtils.CloneObject <DbObjectState>(this.previousState, this.State, new Expression <Func <DbObjectState, object> > [0]);
            }
        }
Пример #4
0
 public virtual void Clone(DbObject srcObj, bool notifyChanged = true)
 {
     if (!notifyChanged)
     {
         this.SuspendNotify();
     }
     CloneUtils.CloneObject <DbObject>(srcObj, this, new Expression <Func <DbObject, object> > [0]);
     CloneUtils.CloneObject <DbObjectState>(this.State, this.State, new Expression <Func <DbObjectState, object> > [0]);
     CloneUtils.CloneObject <DbObjectState>(this.previousState, this.previousState, new Expression <Func <DbObjectState, object> > [0]);
     if (!notifyChanged)
     {
         this.ResumeNotify();
     }
 }
Пример #5
0
 public static DbObjectInfo GetDbObjectInfo(Type type)
 {
     if (structures.ContainsKey(type))
     {
         return(structures[type]);
     }
     object[] customAttributes = type.GetCustomAttributes(true);
     if (customAttributes != null)
     {
         DataTableAttribute attribute = (from a in customAttributes
                                         where a is DataTableAttribute
                                         select a).Cast <DataTableAttribute>().FirstOrDefault <DataTableAttribute>();
         QueryTableAttribute attribute2 = (from a in customAttributes
                                           where a is QueryTableAttribute
                                           select a).Cast <QueryTableAttribute>().FirstOrDefault <QueryTableAttribute>();
         if ((attribute == null) && (attribute2 == null))
         {
             return(null);
         }
         DbObjectInfo info = new DbObjectInfo();
         if (attribute != null)
         {
             info.TableName    = attribute.TableName;
             info.DatabaseName = attribute.DatabaseName;
         }
         if (attribute2 != null)
         {
             info.QueryTable = attribute2.TableName;
         }
         PropertyInfo[] properties = type.GetProperties();
         foreach (PropertyInfo info2 in properties)
         {
             DataFieldAttribute dataFieldAttribute = DbObjectTools.GetDataFieldAttribute(info2);
             if (dataFieldAttribute != null)
             {
                 DynamicPropertyInfo des = new DynamicPropertyInfo();
                 CloneUtils.CloneObject(dataFieldAttribute, des, new string[0]);
                 des.PropertyName = info2.Name;
                 des.PropertyType = info2.PropertyType;
                 info.AddDynamicPropertyInfo(des.PropertyName, des);
             }
         }
         Register(type, info);
         return(info);
     }
     return(null);
 }