Exemple #1
0
        public virtual void Update(BaseProperties newObject, string propertiesToIngnore)
        {
            if (this.PK != newObject.PK)
            {
                return;
            }
            var defaultIgnore = "PK, Inserted, LastModified, TimesStamp";

            if (string.IsNullOrEmpty(propertiesToIngnore.Trim()))
            {
                propertiesToIngnore = "";
            }

            var ignoreList         = (defaultIgnore + propertiesToIngnore).Split(',');
            var existingProperties = this.GetType().GetProperties();
            var newProperties      = newObject.GetType().GetProperties();

            foreach (var existingProp in existingProperties)
            {
                if (ignoreList.Contains(existingProp.Name))
                {
                    continue;
                }

                if (existingProp.CanWrite)
                {
                    var t = existingProp.PropertyType;
                    if (t.IsSubclassOf(typeof(Base)) || t.IsInterface)
                    {
                        continue;
                    }

                    PropertyInfo newProp = null;
                    foreach (var p in newProperties)
                    {
                        if (p.Name == existingProp.Name)
                        {
                            newProp = p;
                            break;
                        }
                    }
                    existingProp.SetValue(this, newProp.GetValue(newObject, null), null);
                }
            }
        }
Exemple #2
0
 public virtual void Update(BaseProperties newObject)
 {
     Update(newObject, "");
 }