Example #1
0
        /// <summary>
        /// GeneratePipeline_DataFlowSource_to_DataFlowDestination generates a TPL-DataFlowPipeline between two vertices of a graph.
        /// v_source.UserDefinedObjects[0] has to be Type of IDataFlowSource
        /// v_dest.UserDefinedObjects[0] has to be Type of IDataFlowDestination
        /// </summary>
        /// <param name="v_source"></param>
        /// <param name="v_dest"></param>
        /// <param name="ToCompleteCollection"></param>
        /// <param name="WatingForCompletitionCollection"></param>
        private void GeneratePipeline_DataFlowSource_to_DataFlowDestination(Vertex v_source, Vertex v_dest, ref List <object> ToCompleteCollection, ref List <object> WatingForCompletitionCollection, ref Dictionary <IDataFlowSource <DS>, object> DataFlowReaderCollection)
        {
            IDataFlowSource <DS>      t_b_source = (IDataFlowSource <DS>)v_source.UserDefinedObjects[0];
            IDataFlowDestination <DS> dest       = (IDataFlowDestination <DS>)v_dest.UserDefinedObjects[0];

            TransformBlock <DS, DS> t_b_dummy = new TransformBlock <DS, DS>(DS => { return(DS); }
                                                                            , new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = this.MaxDegreeOfParallelism
            });

            ToCompleteCollection.Add(t_b_dummy);
            v_dest.UserDefinedObjects.Add(t_b_dummy);
            DataFlowReaderCollection.Add(t_b_source, t_b_dummy);


            var bacthBlock = new BatchBlock <DS>(BatchSize);
            var DataFlowDestinationBlock = new ActionBlock <DS[]>(outp => dest.WriteBatch(outp));

            t_b_dummy.LinkTo(bacthBlock, linkOptions);
            bacthBlock.LinkTo(DataFlowDestinationBlock, linkOptions);

            t_b_dummy.Completion.ContinueWith(t => { bacthBlock.Complete(); });
            bacthBlock.Completion.ContinueWith(t => { DataFlowDestinationBlock.Complete(); });

            WatingForCompletitionCollection.Add(DataFlowDestinationBlock);
        }
        private void onAttachHabdler(object instance, object data)
        {
            IDataFlowSource sourceObject = instance as IDataFlowSource;

            if (sourceObject == null)
            {
                if (instance is RAIS_R)
                {
                    sourceObject = ((RAIS_R)instance).Instance as IDataFlowSource;
                }
            }
            if (sourceObject != null)
            {
                sourceObject.OnPushProperty += (DelegateSinkPushValue)data;
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new pipeline engine ready to run under the <paramref name="context"/> recording events that occur to <paramref name="listener"/>.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="source"></param>
        /// <param name="destination"></param>
        /// <param name="listener"></param>
        /// <param name="pipelineSource"></param>
        public DataFlowPipelineEngine(DataFlowPipelineContext <T> context, IDataFlowSource <T> source,
                                      IDataFlowDestination <T> destination, IDataLoadEventListener listener,
                                      IPipeline pipelineSource = null)
        {
            Source           = source;
            Destination      = destination;
            _context         = context;
            _listener        = listener;
            ComponentObjects = new List <object>();

            if (pipelineSource != null)
            {
                _name = pipelineSource.Name;
            }
            else
            {
                _name = "Undefined pipeline";
            }
        }
Example #4
0
 private void DataFlowReadersExecute(ref Dictionary <IDataFlowSource <DS>, object> DataFlowReaderCollection)
 {
     foreach (KeyValuePair <IDataFlowSource <DS>, object> kvp in DataFlowReaderCollection)
     {
         IDataFlowSource <DS> source = kvp.Key;
         if (kvp.Value.GetType() == typeof(TransformBlock <DS, DS>))
         {
             source.Read((TransformBlock <DS, DS>)kvp.Value);
         }
         else if (kvp.Value.GetType() == typeof(TransformManyBlock <DS, DS>))
         {
             source.Read((TransformManyBlock <DS, DS>)kvp.Value);
         }
         else if (kvp.Value.GetType() == typeof(BroadcastBlock <DS>))
         {
             source.Read((BroadcastBlock <DS>)kvp.Value);
         }
         else
         {
             throw new Exception(string.Format("Type {0} in DoDataFlowReaderCollection is not implemented.", kvp.Value.GetType()));
         }
     }
 }
Example #5
0
 public LookupTransformation(IDataFlowSource <TSourceOutput> lookupSource, Func <TInput, TInput> transformationFunc, List <TSourceOutput> lookupList)
     : this(lookupSource, transformationFunc)
 {
     LookupData = lookupList;
 }
Example #6
0
 public LookupTransformation(IDataFlowSource <TSourceOutput> lookupSource, Func <TInput, TInput> transformationFunc)
     : this(lookupSource)
 {
     TransformationFunc = transformationFunc;
 }
Example #7
0
 public LookupTransformation(IDataFlowSource <TSourceOutput> lookupSource) : this()
 {
     Source = lookupSource;
 }
        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);
                }
            }
        }
Example #10
0
 public Lookup(Func <TTransformationInput, TTransformationOutput> rowTransformationFunc, IDataFlowSource <TSourceOutput> source, List <TSourceOutput> lookupList) : this()
 {
     RowTransformationFunc = rowTransformationFunc;
     Source     = source;
     LookupList = lookupList;
 }
 /// <summary>
 /// Initializes the given <paramref name="component"/> by calling all <see cref="IPipelineRequirement{T}"/> it implements with the appropriate
 /// input object <paramref name="parameters"/>
 /// </summary>
 public void PreInitialize(IDataLoadEventListener listener, IDataFlowSource <T> component, params object[] parameters)
 {
     PreInitializeComponentWithAllObjects(listener, component, parameters);
 }