Beispiel #1
0
 public static void SetBlockOptions(this IBlockInitializer blockInitializer, DataflowBlockOptions dataflowBlockOptions)
 {
     blockInitializer.AddProperty("Bounded Capacity", dataflowBlockOptions.BoundedCapacity, 90, Colors.WhiteSmoke);
     blockInitializer.AddProperty("Max Messages Per Task", dataflowBlockOptions.MaxMessagesPerTask, 91, Colors.WhiteSmoke);
     blockInitializer.AddProperty("Scheduler", dataflowBlockOptions.TaskScheduler.GetType().Name, 92, Colors.WhiteSmoke);
     blockInitializer.AddProperty("IsCancelRequested", () => dataflowBlockOptions.CancellationToken.IsCancellationRequested, 110, Colors.WhiteSmoke);
 }
        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);
        }
        private void InitProperties(IDataflowBlock block, IBlockInitializer propertySetter)
        {
            propertySetter.SetInputQueueFactory(() => ReflectBlockExtensions.GetInputQueue(_debugInfo));
            propertySetter.SetPostponedMessagesFactory(() => ReflectBlockExtensions.GetProsponedQueue(_debugInfo));

            propertySetter.AddProperty("Current Parallelism", () => ReflectBlockExtensions.GetCurrentDegreeOfParallelism(_debugInfo), 60, Colors.WhiteSmoke);
            propertySetter.AddProperty("Is Completed", () => ReflectBlockExtensions.GetIsCompleted(_debugInfo), 61, Colors.WhiteSmoke);
            propertySetter.AddProperty("Declined Permanently", () => ReflectBlockExtensions.GetIsDecliningPermanently(_debugInfo), 62, Colors.WhiteSmoke);


            propertySetter.SetBlockOptions(ReflectBlockExtensions.GetDataflowBlockOptions(_debugInfo));
        }
Beispiel #4
0
        internal ReflectTransformBlock(TransformBlock <TIn, TOut> block, IBlockInitializer propertySetter)
            : base(block, propertySetter)
        {
            if (block == null)
            {
                return;
            }

            #region targetCoreField

            FieldInfo  targetCoreField = block.GetType().GetField("m_target", ReflectBlockExtensions.DEFAULT_FLAGS);
            object     targetCore      = targetCoreField.GetValue(block);
            MethodInfo getTargetDebuggingInformationMethod =
                targetCore.GetType().GetMethod("GetDebuggingInformation", ReflectBlockExtensions.DEFAULT_FLAGS);
            _targetDebugInfo = getTargetDebuggingInformationMethod.Invoke(targetCore, new object[0]);

            #endregion // targetCoreField

            //propertySetter.AddProperty("Input Count", () => block.InputCount, 3, Colors.White);
            //propertySetter.AddProperty("Output Count", () => block.OutputCount, 4, Colors.White);

            propertySetter.SetInputQueueFactory(() => ReflectBlockExtensions.GetInputQueue(_targetDebugInfo));
            //propertySetter.SetOutputQueueFactory(() => ReflectBlockExtensions.GetOutputQueue(_sourceDebugInfo));
            propertySetter.SetPostponedMessagesFactory(() => ReflectBlockExtensions.GetProsponedQueue(_targetDebugInfo));

            propertySetter.AddProperty("Current Parallelism", () => ReflectBlockExtensions.GetCurrentDegreeOfParallelism(_targetDebugInfo), 60, Colors.WhiteSmoke);

            //propertySetter.SetBlockOptions(ReflectBlockExtensions.GetDataflowBlockOptions(_targetDebugInfo));
        }
        private void SetNextMessageIdProperty(object source, IBlockInitializer propertySetter)
        {
            FieldInfo field =
                source.GetType().GetField("m_nextMessageId", ReflectBlockExtensions.DEFAULT_FLAGS);

            propertySetter.AddProperty("Next Header Id", () =>
            {
                object padded        = field.GetValue(source);
                FieldInfo fieldValue =
                    padded.GetType().GetField("Value", ReflectBlockExtensions.DEFAULT_FLAGS);
                return(fieldValue.GetValue(padded));
            }, 5000, Colors.WhiteSmoke);
        }
        //public int OutputCount
        //{
        //    get
        //    {
        //        PropertyInfo prop =
        //            _debugInfo.GetType().GetProperty("OutputCount", ReflectBlockExtensions.DEFAULT_FLAGS);

        //        var result = (int)prop.GetValue(_debugInfo);
        //        return result;
        //    }
        //}

        #endregion // OutputCount

        private void SetTaskForOutputProcessing(IBlockInitializer propertySetter)
        {
            PropertyInfo fieldTaskForInputProcessing =
                _debugInfo.GetType().GetProperty("TaskForOutputProcessing", ReflectBlockExtensions.DEFAULT_FLAGS);

            propertySetter.AddProperty("Is Processing Output",
                                       () =>
            {
                Task taskForInputProcessing = fieldTaskForInputProcessing.GetValue(_debugInfo) as Task;
                if (taskForInputProcessing == null)
                {
                    return(false);
                }
                return(taskForInputProcessing.Status == TaskStatus.Running);
            }, 10, Colors.White);
        }
        private void SetBoundingState(IDataflowBlock block, IBlockInitializer propertySetter)
        {
            FieldInfo field =
                block.GetType().GetField("m_boundingState", ReflectBlockExtensions.DEFAULT_FLAGS);
            object boundingState = field.GetValue(block);

            if (boundingState != null)
            {
                #region TaskForInputProcessing

                FieldInfo fieldTaskForInputProcessing =
                    boundingState.GetType().GetField("TaskForInputProcessing", ReflectBlockExtensions.DEFAULT_FLAGS);
                propertySetter.AddProperty("Is Processing Input",
                                           () =>
                {
                    Task taskForInputProcessing = fieldTaskForInputProcessing.GetValue(boundingState) as Task;
                    if (taskForInputProcessing == null)
                    {
                        return(false);
                    }
                    return(taskForInputProcessing.Status == TaskStatus.Running);
                }, 9, Colors.White);

                #endregion // TaskForInputProcessing

                #region PostponedMessages

                FieldInfo fieldPostponedMessages =
                    boundingState.GetType().GetField("PostponedMessages", ReflectBlockExtensions.DEFAULT_FLAGS);

                Func <IEnumerable <PostponedMessage> > postponedMessagesFactory = () =>
                {
                    var kvc = fieldPostponedMessages.GetValue(boundingState) as IEnumerable <KeyValuePair <ISourceBlock <T>, DataflowMessageHeader> >;

                    var result = from pair in kvc
                                 select new PostponedMessage(pair.Key, pair.Value);

                    return(result);
                };

                propertySetter.SetPostponedMessagesFactory(postponedMessagesFactory);

                #endregion // PostponedMessages
            }
        }