Exemplo n.º 1
0
 public virtual void ApplySignalChanges(PropertyDiff[] changes, IDiffAdaptor adaptor, object obj)
 {
     foreach (PropertyDiff pdif in changes)
     {
         if (pdif.Operation == DiffOperation.Add)
         {
             adaptor.AddSignal(obj, pdif.Name, pdif.Text);
         }
         else
         {
             adaptor.RemoveSignal(obj, pdif.Name, pdif.Text);
         }
     }
 }
Exemplo n.º 2
0
 public virtual void ApplyPropertyChanges(PropertyDiff[] changes, IDiffAdaptor adaptor, object obj)
 {
     foreach (PropertyDiff pdif in changes)
     {
         if (pdif.Operation == DiffOperation.Add || pdif.Operation == DiffOperation.Update)
         {
             adaptor.SetPropertyValue(obj, pdif.Name, pdif.Text);
         }
         else
         {
             adaptor.ResetPropertyValue(obj, pdif.Name);
         }
     }
 }
Exemplo n.º 3
0
        protected virtual PropertyDiff[] GetPropertyDiff(IDiffAdaptor currentAdaptor, object currentObject, IDiffAdaptor newAdaptor, object newObject)
        {
            ArrayList changes = new ArrayList();
            Hashtable found   = new Hashtable();

            // Look for modified and deleted elements
            if (currentObject != null)
            {
                foreach (object oldProp in currentAdaptor.GetProperties(currentObject))
                {
                    string name    = currentAdaptor.GetPropertyName(oldProp);
                    object newProp = newObject != null?newAdaptor.GetPropertyByName(newObject, name) : null;

                    if (newProp == null)
                    {
                        changes.Add(new PropertyDiff(DiffOperation.Remove, name, null));
                    }
                    else
                    {
                        found [name] = found;
                        string newValue = newAdaptor.GetPropertyValue(newObject, newProp);
                        if (newValue != currentAdaptor.GetPropertyValue(currentObject, oldProp))
                        {
                            changes.Add(new PropertyDiff(DiffOperation.Update, name, newValue));
                        }
                    }
                }
            }

            // Look for new elements
            if (newObject != null)
            {
                foreach (object newProp in newAdaptor.GetProperties(newObject))
                {
                    string name = newAdaptor.GetPropertyName(newProp);
                    if (!found.ContainsKey(name))
                    {
                        changes.Add(new PropertyDiff(DiffOperation.Add, name, newAdaptor.GetPropertyValue(newObject, newProp)));
                    }
                }
            }

            if (changes.Count == 0)
            {
                return(null);
            }
            return((PropertyDiff[])changes.ToArray(typeof(PropertyDiff)));
        }
Exemplo n.º 4
0
        protected virtual PropertyDiff[] GetSignalDiff(IDiffAdaptor currentAdaptor, object currentObject, IDiffAdaptor newAdaptor, object newObject)
        {
            ArrayList changes = new ArrayList();
            Hashtable found   = new Hashtable();

            // Look for modified and deleted elements
            if (currentObject != null)
            {
                foreach (object oldProp in currentAdaptor.GetSignals(currentObject))
                {
                    string name;
                    string handler;
                    currentAdaptor.GetSignalInfo(oldProp, out name, out handler);
                    object newProp = newObject != null?newAdaptor.GetSignal(newObject, name, handler) : null;

                    if (newProp == null)
                    {
                        changes.Add(new PropertyDiff(DiffOperation.Remove, name, handler));
                    }
                    found [name + " " + handler] = found;
                }
            }

            // Look for new elements
            if (newObject != null)
            {
                foreach (object newProp in newAdaptor.GetSignals(newObject))
                {
                    string name;
                    string handler;
                    newAdaptor.GetSignalInfo(newProp, out name, out handler);
                    if (!found.ContainsKey(name + " " + handler))
                    {
                        changes.Add(new PropertyDiff(DiffOperation.Add, name, handler));
                    }
                }
            }

            if (changes.Count == 0)
            {
                return(null);
            }
            return((PropertyDiff[])changes.ToArray(typeof(PropertyDiff)));
        }
Exemplo n.º 5
0
 public DiffGenerator(IDiffAdaptor currentStatusAdaptor, IDiffAdaptor newStatusAdaptor)
 {
     this.currentStatusAdaptor = currentStatusAdaptor;
     this.newStatusAdaptor     = newStatusAdaptor;
 }
Exemplo n.º 6
0
		public virtual void ApplySignalChanges (PropertyDiff[] changes, IDiffAdaptor adaptor, object obj)
		{
			foreach (PropertyDiff pdif in changes) {
				if (pdif.Operation == DiffOperation.Add)
					adaptor.AddSignal (obj, pdif.Name, pdif.Text);
				else
					adaptor.RemoveSignal (obj, pdif.Name, pdif.Text);
			}
		}
Exemplo n.º 7
0
		public virtual void ApplyPropertyChanges (PropertyDiff[] changes, IDiffAdaptor adaptor, object obj)
		{
			foreach (PropertyDiff pdif in changes) {
				if (pdif.Operation == DiffOperation.Add || pdif.Operation == DiffOperation.Update)
					adaptor.SetPropertyValue (obj, pdif.Name, pdif.Text);
				else
					adaptor.ResetPropertyValue (obj, pdif.Name);
			}
		}
Exemplo n.º 8
0
		protected virtual PropertyDiff[] GetSignalDiff (IDiffAdaptor currentAdaptor, object currentObject, IDiffAdaptor newAdaptor, object newObject)
		{
			ArrayList changes = new ArrayList ();
			Hashtable found = new Hashtable ();
			
			// Look for modified and deleted elements
			if (currentObject != null) {
				foreach (object oldProp in currentAdaptor.GetSignals (currentObject)) {
					string name;
					string handler;
					currentAdaptor.GetSignalInfo (oldProp, out name, out handler);
					object newProp = newObject != null ? newAdaptor.GetSignal (newObject, name, handler) : null;
					if (newProp == null)
						changes.Add (new PropertyDiff (DiffOperation.Remove, name, handler));
					found [name + " " + handler] = found;
				}
			}
			
			// Look for new elements
			if (newObject != null) {
				foreach (object newProp in newAdaptor.GetSignals (newObject)) {
					string name;
					string handler;
					newAdaptor.GetSignalInfo (newProp, out name, out handler);
					if (!found.ContainsKey (name + " " + handler))
						changes.Add (new PropertyDiff (DiffOperation.Add, name, handler));
				}
			}
			
			if (changes.Count == 0)
				return null;
			return (PropertyDiff[]) changes.ToArray (typeof(PropertyDiff));
		}
Exemplo n.º 9
0
		public DiffGenerator (IDiffAdaptor currentStatusAdaptor, IDiffAdaptor newStatusAdaptor)
		{
			this.currentStatusAdaptor = currentStatusAdaptor;
			this.newStatusAdaptor = newStatusAdaptor;
		}
Exemplo n.º 10
0
		protected virtual PropertyDiff[] GetPropertyDiff (IDiffAdaptor currentAdaptor, object currentObject, IDiffAdaptor newAdaptor, object newObject)
		{
			ArrayList changes = new ArrayList ();
			Hashtable found = new Hashtable ();
			
			// Look for modified and deleted elements
			if (currentObject != null) {
				foreach (object oldProp in currentAdaptor.GetProperties (currentObject)) {
					string name = currentAdaptor.GetPropertyName (oldProp);
					object newProp = newObject != null ? newAdaptor.GetPropertyByName (newObject, name) : null;
					if (newProp == null)
						changes.Add (new PropertyDiff (DiffOperation.Remove, name, null));
					else {
						found [name] = found;
						string newValue = newAdaptor.GetPropertyValue (newObject, newProp);
						if (newValue != currentAdaptor.GetPropertyValue (currentObject, oldProp))
							changes.Add (new PropertyDiff (DiffOperation.Update, name, newValue));
					}
				}
			}
			
			// Look for new elements
			if (newObject != null) {
				foreach (object newProp in newAdaptor.GetProperties (newObject)) {
					string name = newAdaptor.GetPropertyName (newProp);
					if (!found.ContainsKey (name))
						changes.Add (new PropertyDiff (DiffOperation.Add, name, newAdaptor.GetPropertyValue (newObject, newProp)));
				}
			}
			
			if (changes.Count == 0)
				return null;
			return (PropertyDiff[]) changes.ToArray (typeof(PropertyDiff));
		}