예제 #1
0
        /// <summary>
        /// Sets ApplyMethod for the DataSource
        /// </summary>
        public static bool DataSourceSetApplyMethod(object aDataSource, EApplyMethod aMethod)
        {
            if (aDataSource == null)
            {
                return(false);
            }

            if (aDataSource is IDataAdaptor)
            {
                return(DataSourceSetApplyMethod((aDataSource as IDataAdaptor).FinalTarget, aMethod));
            }

            if (aDataSource is IObserveable)
            {
                (aDataSource as IObserveable).ApplyMethod = aMethod;
                return(true);
            }

            foreach (DataSourceInfo ds in datasources)
            {
                if (ds.Target == aDataSource)
                {
                    ds.ApplyMethod = aMethod;
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
 /// <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);
 }
예제 #3
0
 /// <summary>
 /// Resolves if update is needed in some occasion
 /// </summary>
 public static bool DataSourceNeedsUpdateOn(object aDataSource, EApplyMethod aMethod)
 {
     return((int)DataSourceGetApplyMethod(aDataSource) >= (int)aMethod);
 }
예제 #4
0
 /// <summary>
 /// Creates DataSourceInfo object with specified target
 /// </summary>
 /// <param name="aTarget">
 /// Target object <see cref="System.Object"/>
 /// </param>
 /// <param name="aInstant">
 /// Apply method <see cref="EApplyMethod"/>
 /// </param>
 public DataSourceInfo(object aTarget, EApplyMethod aInstant)
 {
     Target      = aTarget;
     ApplyMethod = aInstant;
 }
예제 #5
0
        /// <summary>
        /// Valid for complex controls like TreeView
        /// </summary>

/*		public virtual void ClearBeforeRemapping()
 *              {
 *                      if (Control is IComplexAdaptableControl)
 *                              (Control as IComplexAdaptableControl).ClearBeforeRemapping();
 *              }
 *
 *              /// <summary>
 *              /// Valid for complex controls like TreeView
 *              /// </summary>
 *              public virtual void RemapControl()
 *              {
 *                      if (Control is IComplexAdaptableControl)
 *                              (Control as IComplexAdaptableControl).RemapControl();
 *              }*/

        /// <summary>
        /// Sets method of DataSource update
        /// </summary>
        /// <param name="aMethod">
        /// Method of update <see cref="EApplyMethod"/>
        /// </param>
        /// <returns>
        /// true if succeessful <see cref="System.Boolean"/>
        /// </returns>
        public bool DataSourceNeedsUpdateOn(EApplyMethod aMethod)
        {
            return(DataSourceController.DataSourceNeedsUpdateOn(adaptor.FinalTarget, aMethod));
        }