public bool WorkOnAllInstances(Type t, delegateOnGetInstance handler, object data)
        {
            bool bFound = false;
            int  n      = this.SubTypeCount;

            if (n > 0)
            {
                IObjectManager[] subType = SubTypes;
                for (int i = 0; i < n; i++)
                {
                    if (t.Equals(subType[i].InstanceType) || subType[i].InstanceType.IsSubclassOf(t))
                    {
                        subType[i].WorkOnAllInstances(handler, data);
                        bFound = true;
                        break;
                    }
                    else
                    {
                        bFound = subType[i].WorkOnAllInstances(t, handler, data);
                        if (bFound)
                        {
                            break;
                        }
                    }
                }
            }
            return(bFound);
        }
Exemplo n.º 2
0
        public void Assign(string propertyName, object value, object[] indexer)
        {
            OM_Assign             data = new OM_Assign(propertyName, value, indexer);
            delegateOnGetInstance eh   = new delegateOnGetInstance(onAssign);

            WorkOnAllInstances(eh, data);
        }
Exemplo n.º 3
0
        public void RemoveEventHandler(string eventName, object methodOwner, string methodName)
        {
            EventInfo             ei = _type.GetEvent(eventName);
            object                v  = DotNetUtilEvent.CreateDelegate(ei.EventHandlerType, methodOwner, methodName);
            OM_EventData          e  = new OM_EventData(eventName, (Delegate)v);
            delegateOnGetInstance eh = new delegateOnGetInstance(onRemoveEventHandler);

            WorkOnAllInstances(eh, e);
        }
Exemplo n.º 4
0
        public virtual bool WorkOnAllInstances(string xtPath, delegateOnGetInstance handler, object data)
        {
            RAIS rais = this.GetItemByXTPath(xtPath);

            if (rais != null)
            {
                rais.WorkOnAllInstances(handler, data);
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        public void Invoke(string methodName, object[] ps)
        {
            MethodInfo mi = _type.GetMethod(methodName);

            if (mi.IsStatic)
            {
                mi.Invoke(null, ps);
            }
            else
            {
                OM_Invoke             data = new OM_Invoke(methodName, ps);
                delegateOnGetInstance eh   = new delegateOnGetInstance(onInvoke);
                WorkOnAllInstances(eh, data);
            }
        }
 public void RemoveEventHandler(string eventName, object methodOwner, string methodName)
 {
     if (methodOwner == null)
     {
         methodOwner = Container;
     }
     if (methodOwner != null)
     {
         EventInfo             ei = _type.GetEvent(eventName);
         object                v  = Activator.CreateInstance(ei.EventHandlerType, new object[] { methodOwner, methodName });
         OM_EventData          e  = new OM_EventData(eventName, (Delegate)v);
         delegateOnGetInstance eh = new delegateOnGetInstance(onRemoveEventHandler);
         WorkOnAllInstances(eh, e);
     }
 }
Exemplo n.º 7
0
 public virtual void WorkOnAllInstances(delegateOnGetInstance handler, object data)
 {
     if (_r != null)
     {
         for (int i = 0; i < _r.Count; i++)
         {
             handler(_r[i], data);
         }
     }
     if (_a != null)
     {
         for (int i = 0; i < _a.Count; i++)
         {
             _a[i].WorkOnAllInstances(handler, data);
         }
     }
 }
Exemplo n.º 8
0
 public override void WorkOnAllInstances(delegateOnGetInstance handler, object data)
 {
     if (_i != null)
     {
         for (int i = 0; i < _i.Count; i++)
         {
             handler(_i[i], data);
         }
     }
     if (_s != null)
     {
         for (int i = 0; i < _s.Count; i++)
         {
             _s[i].WorkOnAllInstances(handler, data);
         }
     }
 }
 public virtual void AddEventHandler(Type t, string eventName, object methodOwner, string methodName)
 {
     if (methodOwner == null)
     {
         methodOwner = Container;
     }
     if (methodOwner != null)
     {
         EventInfo             ei = _type.GetEvent(eventName);
         object                v  = Activator.CreateInstance(ei.EventHandlerType, new object[] { methodOwner, methodName });
         OM_EventData          e  = new OM_EventData(eventName, (Delegate)v);
         delegateOnGetInstance eh = new delegateOnGetInstance(onAddEventHandler);
         WorkOnAllInstances(t, eh, e);
         if (_assignedToTypes == null)
         {
             _assignedToTypes = new Dictionary <Type, OM_EventData>();
         }
         _assignedToTypes.Add(t, e);
     }
     //bool bFound = false;
     //int n = this.SubTypeCount;
     //if (n > 0)
     //{
     //    IObjectManager[] subType = SubTypes;
     //    for (int i = 0; i < n; i++)
     //    {
     //        if (t.Equals(subType[i].InstanceType))
     //        {
     //            subType[i].AddEventHandler(eventName, methodOwner, methodName);
     //            bFound = true;
     //            break;
     //        }
     //        else
     //        {
     //            bFound = subType[i].AddEventHandler(t, eventName, methodOwner, methodName);
     //            if (bFound)
     //                break;
     //        }
     //    }
     //}
     //return bFound;
 }
        public void WorkOnAllInstances(delegateOnGetInstance handler, object data)
        {
            if (_instances != null)
            {
                for (int i = 0; i < _instances.Count; i++)
                {
                    handler(_instances[i], data);
                }
            }
            int n = this.SubTypeCount;

            if (n > 0)
            {
                IObjectManager[] subType = SubTypes;
                for (int i = 0; i < n; i++)
                {
                    subType[i].WorkOnAllInstances(handler, data);
                }
            }
        }
        public void AddLink(object sourceObject,
                            string sourcePropertyName,
                            Type[] indexer,
                            object destinationObject,
                            string destinationPropertyName)
        {
            Dictionary <string, Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > > v1 = null;
            object src = sourceObject;

            if (sourceObject is string && _objectManager != null)
            {
                src = _objectManager.FindElement(sourceObject.ToString());
            }
            if (this.ContainsKey(src))
            {
                v1 = this[src];
            }
            if (v1 == null)
            {
                v1 = new Dictionary <string, Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > >();
                this.Add(src, v1);
                IDataFlowSource source = sourceObject as IDataFlowSource;
                if (source != null)
                {
                    source.OnPushProperty += new DelegateSinkPushValue(SinkPushValue);
                }
                else
                {
                    if (_objectManager != null && sourceObject is string)
                    {
                        string path = sourceObject.ToString();
                        if (path.Length > 1)
                        {
                            delegateOnGetInstance eh = new delegateOnGetInstance(onAttachHabdler);
                            _objectManager.WorkOnAllInstances(path, eh, new DelegateSinkPushValue(SinkPushValue));
                        }
                    }
                }
            }
            Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > v2;

            if (v1.ContainsKey(sourcePropertyName))
            {
                v2 = v1[sourcePropertyName];
            }
            else
            {
                v2 = new Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > >();
                v1.Add(sourcePropertyName, v2);
            }
            Dictionary <object, Dictionary <string, DL_DataDestination> > v3 = null;

            Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > .Enumerator e2 = v2.GetEnumerator();
            while (e2.MoveNext())
            {
                if (e2.Current.Key.IsSameSignature(indexer))
                {
                    v3 = e2.Current.Value;
                    break;
                }
            }
            if (v3 == null)
            {
                v3 = new Dictionary <object, Dictionary <string, DL_DataDestination> >();
                v2.Add(new DL_Indexer(indexer), v3);
            }
            Dictionary <string, DL_DataDestination> v4;

            if (v3.ContainsKey(destinationObject))
            {
                v4 = v3[destinationObject];
            }
            else
            {
                v4 = new Dictionary <string, DL_DataDestination>();
                v3.Add(destinationObject, v4);
            }
            if (!v4.ContainsKey(destinationPropertyName))
            {
                v4.Add(destinationPropertyName, new DL_DataDestination());
            }
        }
        /// <summary>
        /// push value from source to destination
        /// </summary>
        /// <param name="sender">data source</param>
        /// <param name="propertyName">source property</param>
        /// <param name="parameters">indexer</param>
        /// <param name="value">value to send</param>
        public void SinkPushValue(IDataFlowSource sender, string propertyName, object[] parameters, object value)
        {
            Dictionary <string, Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > > v1 = null;

            if (this.ContainsKey(sender))
            {
                v1 = this[sender];
            }
            else
            {
                foreach (object v in this.Keys)
                {
                    if (v is RAIS_A)
                    {
                        if (((RAIS_A)v).IsInstance(sender))
                        {
                            v1 = this[v];
                            break;
                        }
                    }
                }
            }
            if (v1 != null)
            {
                if (_dataSources == null)
                {
                    _dataSources = new Hashtable();
                }
                if (_dataSources.ContainsKey(sender))
                {
                    return;
                }
                _dataSources.Add(sender, v1);
                try
                {
                    Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > v2;
                    if (v1.ContainsKey(propertyName))
                    {
                        v2 = v1[propertyName];
                        Dictionary <object, Dictionary <string, DL_DataDestination> > v3 = null;
                        Dictionary <DL_Indexer, Dictionary <object, Dictionary <string, DL_DataDestination> > > .Enumerator e2 = v2.GetEnumerator();
                        while (e2.MoveNext())
                        {
                            if (e2.Current.Key.IsSameSignature(parameters))
                            {
                                v3 = e2.Current.Value;
                                break;
                            }
                        }
                        if (v3 != null)
                        {
                            Dictionary <object, Dictionary <string, DL_DataDestination> > .Enumerator e3 = v3.GetEnumerator();
                            while (e3.MoveNext())
                            {
                                Dictionary <string, DL_DataDestination> .Enumerator e4 = e3.Current.Value.GetEnumerator();
                                while (e4.MoveNext())
                                {
                                    if (e3.Current.Key is Type)
                                    {
                                        EventInfo ei = ((Type)e3.Current.Key).GetEvent("OnVOBStaticSetValue", BindingFlags.Static);
                                        if (ei != null)
                                        {
                                            MethodInfo mi = ei.GetRaiseMethod(true);
                                            mi.Invoke(null, new object[] { sender, e4.Current.Key, parameters, value });
                                        }
                                    }
                                    else
                                    {
                                        if (e3.Current.Key is string)
                                        {
                                            OM_Assign             oa = new OM_Assign(e4.Current.Key, value, parameters);
                                            delegateOnGetInstance h  = new delegateOnGetInstance(onSetValue);
                                            _objectManager.WorkOnAllInstances(e3.Current.Key.ToString(), h, oa);
                                        }
                                        else
                                        {
                                            setValue(e3.Current.Key, e4.Current.Key, parameters, value);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    _dataSources.Remove(sender);
                }
            }
        }
        public void AddLink(object destinationObject,
                            string destinationPropertyName,
                            Type[] indexers,
                            object sourceObject,
                            string sourcePropertyName)
        {
            Dictionary <string, Dictionary <DL_Indexer, DL_DataSource> > v1 = null;
            object tgt = destinationObject;

            if (destinationObject is string && _objectManager != null)
            {
                tgt = _objectManager.FindElement(destinationObject.ToString());
            }
            if (this.ContainsKey(tgt))
            {
                v1 = this[tgt];
            }
            if (v1 == null)
            {
                v1 = new Dictionary <string, Dictionary <DL_Indexer, DL_DataSource> >();
                this.Add(tgt, v1);
                IDataFlowDestionation dest = destinationObject as IDataFlowDestionation;
                if (dest != null)
                {
                    dest.OnPullProperty += new DelegateSinkPullValue(SinkPullValue);
                }
                else
                {
                    if (_objectManager != null && destinationObject is string)
                    {
                        string path = destinationObject.ToString();
                        if (path.Length > 1)
                        {
                            delegateOnGetInstance eh = new delegateOnGetInstance(onAttachHabdler);
                            _objectManager.WorkOnAllInstances(path, eh, new DelegateSinkPullValue(SinkPullValue));
                        }
                    }
                }
            }
            Dictionary <DL_Indexer, DL_DataSource> v2;

            if (v1.ContainsKey(destinationPropertyName))
            {
                v2 = v1[destinationPropertyName];
            }
            else
            {
                v2 = new Dictionary <DL_Indexer, DL_DataSource>();
                v1.Add(destinationPropertyName, v2);
            }
            DL_DataSource v3 = null;

            Dictionary <DL_Indexer, DL_DataSource> .Enumerator e2 = v2.GetEnumerator();
            while (e2.MoveNext())
            {
                if (e2.Current.Key.IsSameSignature(indexers))
                {
                    v3 = e2.Current.Value;
                    break;
                }
            }
            if (v3 == null)
            {
                v3 = new DL_DataSource();
                v2.Add(new DL_Indexer(indexers), v3);
            }
            v3.SourceObject = sourceObject;
            v3.PropertyName = sourcePropertyName;
        }