/// <summary> /// Receiving a notification about child being changed /// </summary> /// <param name="aObject"> /// Child of this object has changed <see cref="IObserveable"/> /// </param> /// <param name="aIdx"> /// Path of the changed child <see cref="System.Int32"/> /// </param> public virtual void ChildChanged(IObserveable aObject, int[] aIdx) { if (aObject == this) { return; } }
/// <summary> /// Receiving a notification about child being changed /// </summary> /// <param name="aObject"> /// Called when observeable child changes <see cref="IObserveable"/> /// </param> /// <param name="aIdx"> /// Path index to child <see cref="System.Int32"/> /// </param> public virtual void ChildChanged(IObserveable aObject, int[] aIdx) { // Notify all parents about this change if (parents != null) { foreach (WeakReference wr in parents) { if (wr != null) { if (wr.Target != null) { if (wr.Target is IObserveable) { if (wr.Target is IObserveableList) { (wr.Target as IObserveableList).ListChildChanged(aObject, EListAction.Change, null); } else if (wr.Target is IObserveable) { (wr.Target as IObserveable).ChildChanged(aObject, aIdx); } } } } } } }
/// <summary> /// Assigns data or disqualifies validity if needed /// </summary> public void CheckControl() { if (destroyed == true) { return; } if (Activated == false) { return; } if (checkup == true) { return; } if (IsControllingWidget == false) { return; } checkup = true; bool canuse = adaptor.IsValidMapping; IObserveable observer = null; IObserveable boundaryobserver = null; if (Adaptor != null) { observer = DataSourceController.GetInfoFor(Adaptor.FinalTarget); } if (Adaptor != null) { boundaryobserver = DataSourceController.GetInfoFor(BoundaryAdaptor.FinalTarget); } if ((canuse == true) && (Control != null)) { if (Control is IChangeableControl) { if (observer != null) { if (observer.CanGet == true) { InvokeAdapteeDataChange((Control as IChangeableControl), Adaptor.FinalTarget); } } if (boundaryobserver != null) { if (boundaryobserver.CanGet == true) { if (TypeValidator.IsCompatible(Control.GetType(), typeof(IBoundedContainer)) == true) { InvokeBoundaryDataChange((Control as IBoundedContainer), this); } } } } } observer = null; boundaryobserver = null; checkup = false; }
/// <summary> /// Adds object to registry or connects events with Adaptor if object is /// supporting interface IObserveable /// /// If DataSource is IObserveable then it will be bypassing registry all the time /// </summary> public static bool Add(object aDataSource, IAdaptor aAdaptor, EApplyMethod aInstant) { if (aDataSource is IDataAdaptor) { return(Add((aDataSource as IDataAdaptor).FinalTarget, aAdaptor, aInstant)); } if (aDataSource is IObserveable) { // If target is IObserveable then there's no need to enter it into the registry // it can handle all on its own, so connection is made to him directly if (aAdaptor.IsBoundaryAdaptor == false) { (aDataSource as IObserveable).PostRequested += aAdaptor.PostMethod; (aDataSource as IObserveable).DataChanged += aAdaptor.AdapteeDataChanged; } else { (aDataSource as IObserveable).DataChanged += aAdaptor.BoundaryAdapteeDataChanged; } } else { IObserveable ob = GetInfoFor(aDataSource); if (ob != null) { DataSourceInfo ds = (DataSourceInfo)ob; if (aAdaptor.IsBoundaryAdaptor == false) { ds.PostRequested += aAdaptor.PostMethod; ds.DataChanged += aAdaptor.AdapteeDataChanged; } else { ds.DataChanged += aAdaptor.BoundaryAdapteeDataChanged; } // Count direct adaptors only, ignore indirect if ((aAdaptor.Target is IAdaptor) == false) { ds.RefCount += 1; } ds = null; return(true); } DataSourceInfo nds = new DataSourceInfo(aDataSource, aInstant); if (aAdaptor.IsBoundaryAdaptor == false) { nds.PostRequested += aAdaptor.PostMethod; nds.DataChanged += aAdaptor.AdapteeDataChanged; } else { nds.DataChanged += aAdaptor.BoundaryAdapteeDataChanged; } datasources.Add(nds); nds = null; } return(true); }
/// <summary> /// Sets object state to changed and calls for update of controls after posting stops /// </summary> public static void CallChangedFor(object aObj) { IObserveable observer = GetInfoFor(aObj); if (observer == null) { return; } observer.HasChanged = true; }
/// <summary> /// Checks if Get request is possible in this moment /// </summary> /// <param name="aState"> /// State <see cref="EObserveableState"/> /// </param> /// <returns> /// true if successful <see cref="System.Boolean"/> /// </returns> public bool SetState(EObserveableState aState) { IObserveable observer = DataSourceController.GetInfoFor(adaptor.FinalTarget); if (observer == null) { return(false); } bool res = observer.SetState(aState); observer = null; return(res); }
protected void Debug() { Console.WriteLine("Setting cursor DataSource count: " + DataSourceController.Count); IObserveable observer = null; for (int i = 0; i < DataSourceController.Count; i++) { observer = DataSourceController.GetInfo(i); if (observer != null) { //Console.WriteLine (observer); if (observer is System.Data.Bindings.DataSourceInfo) { DataSourceInfo DS = (observer as System.Data.Bindings.DataSourceInfo); //Console.WriteLine ((observer as System.Data.Bindings.DataSourceInfo).Target); if (DS.Target is Person) { Person p = (Person)(observer as System.Data.Bindings.DataSourceInfo).Target; Console.WriteLine(p.Name + " " + p.Surname + " RefCount:" + DS.RefCount); } } } } }