internal ReflectSourceBlock(ISourceBlock <T> block, IBlockInitializer propertySetter)
        {
            if (block == null)
            {
                return;
            }

            var targetType = block.GetType();

            FieldInfo m_sourceField = targetType.GetField("m_source", ReflectBlockExtensions.DEFAULT_FLAGS);

            if (m_sourceField == null)
            {
                return;
            }


            _sourceCore = m_sourceField.GetValue(block);

            if (_sourceCore == null)
            {
                return;
            }

            var getDebuggingInformationMethod = _sourceCore.GetType().GetMethod("GetDebuggingInformation", ReflectBlockExtensions.DEFAULT_FLAGS);

            _debugInfo = getDebuggingInformationMethod.Invoke(_sourceCore, new object[0]);

            InitProperties(block, propertySetter);
        }
        protected virtual void InitProperties(ISourceBlock <T> block, IBlockInitializer propertySetter)
        {
            var buffer = block as BufferBlock <T>;
            Func <IEnumerable <string> > outputQueueFactory = () => from item in this.OutputQueue()
                                                              select item.ToString();

            propertySetter.SetOutputQueueFactory(outputQueueFactory);

            FieldInfo fieldSource = block.GetType().GetField("m_source", ReflectBlockExtensions.DEFAULT_FLAGS);
            object    source      = fieldSource.GetValue(block);

            PropertyInfo prop =
                _debugInfo.GetType().GetProperty("DataflowBlockOptions", ReflectBlockExtensions.DEFAULT_FLAGS);

            var options = (DataflowBlockOptions)prop.GetValue(_debugInfo);

            propertySetter.SetBlockOptions(options);

            propertySetter.SetIsLinked(IsLinked);

            SetNextMessageIdProperty(source, propertySetter);
            SetTaskForOutputProcessing(propertySetter);

            propertySetter.AddProperty("Is Completed", () => ReflectBlockExtensions.GetIsCompleted(_debugInfo), 61, Colors.WhiteSmoke);
            propertySetter.AddProperty("Declined Permanently", () => ReflectBlockExtensions.GetIsDecliningPermanently(_debugInfo), 62, Colors.WhiteSmoke);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Connects a source and a target.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <param name="target"></param>
 public void Link <T>(ISourceBlock <IDataflowMessage <T> > source, ITargetBlock <IDataflowMessage <T> > target)
 {
     // TODO: Remove this hack once a proper delaying transform many block is implemented.
     // (And report the bug to M$)
     if (source.GetType().FullName.Contains("Encapsulating"))
     {
         source.LinkTo(target, CreateDefaultLinkOptions());
     }
     else
     {
         source.LinkTo(target, CreateDefaultLinkOptions(), CreateDefaultFilter <T>());
         m_NullLinks.Add(() => LinkNullTarget(source));
     }
 }