コード例 #1
0
        /// <summary>
        /// attach pull-link event handler to the destination object
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="data"></param>
        private void onAttachHabdler(object instance, object data)
        {
            IDataFlowDestionation destinationObject = instance as IDataFlowDestionation;

            if (destinationObject == null)
            {
                if (instance is RAIS_R)
                {
                    destinationObject = ((RAIS_R)instance).Instance as IDataFlowDestionation;
                }
            }
            if (destinationObject != null)
            {
                destinationObject.OnPullProperty += (DelegateSinkPullValue)data;
            }
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        /// <summary>
        /// the event handler to be attached to every IDataFlowDestionation object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="propertyName"></param>
        /// <param name="parameters"></param>
        private void SinkPullValue(IDataFlowDestionation sender, string propertyName, object[] parameters)
        {
            Dictionary <string, Dictionary <DL_Indexer, DL_DataSource> > 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 (_dataDestinations == null)
                {
                    _dataDestinations = new Hashtable();
                }
                if (_dataDestinations.ContainsKey(sender))
                {
                    return;
                }
                _dataDestinations.Add(sender, v1);
                try
                {
                    Dictionary <DL_Indexer, DL_DataSource> v2;
                    if (v1.ContainsKey(propertyName))
                    {
                        v2 = v1[propertyName];
                        DL_DataSource v3 = null;
                        Dictionary <DL_Indexer, DL_DataSource> .Enumerator e2 = v2.GetEnumerator();
                        while (e2.MoveNext())
                        {
                            if (e2.Current.Key.IsSameSignature(parameters))
                            {
                                v3 = e2.Current.Value;
                                break;
                            }
                        }
                        if (v3 != null)
                        {
                            object value     = null;
                            bool   bGotValue = false;
                            if (v3.SourceObject is string)
                            {
                                if (_objectManager != null)
                                {
                                    object       objSource = _objectManager.CurrentItem(v3.SourceObject.ToString());
                                    PropertyInfo piSource  = objSource.GetType().GetProperty(v3.PropertyName);
                                    value     = piSource.GetValue(objSource, parameters);
                                    bGotValue = true;
                                }
                            }
                            else
                            {
                                PropertyInfo piSource = v3.SourceObject.GetType().GetProperty(v3.PropertyName);
                                value     = piSource.GetValue(v3.SourceObject, parameters);
                                bGotValue = true;
                            }
                            if (bGotValue)
                            {
                                PropertyInfo piDest = sender.GetType().GetProperty(propertyName);
                                piDest.SetValue(sender, value, parameters);
                            }
                        }
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    _dataDestinations.Remove(sender);
                }
            }
        }