コード例 #1
0
        /// <summary>
        /// Element (representing component) created.
        /// </summary>
        /// <remarks>Called upon element construction (first moment component becomes a pipeline element).</remarks>
        /// <param name="pipeline">Pipeline to which the element belongs.</param>
        /// <param name="element">Element being created.</param>
        /// <param name="component">Component associated with this pipeline element.</param>
        public void PipelineElementCreate(Pipeline pipeline, PipelineElement element, object component)
        {
            var node = new PipelineDiagnosticsInternal.PipelineElementDiagnostics(element, pipeline.Id);

            if (node.Kind == PipelineElementKind.Subpipeline)
            {
                node.RepresentsSubpipeline = this.graphs[((Pipeline)component).Id];
                this.graphs[pipeline.Id].Subpipelines.TryAdd(node.RepresentsSubpipeline.Id, node.RepresentsSubpipeline);
            }
            else if (node.Kind == PipelineElementKind.Connector)
            {
                if (this.connectors.TryGetValue(component, out PipelineDiagnosticsInternal.PipelineElementDiagnostics bridge))
                {
                    node.ConnectorBridgeToPipelineElement   = bridge;
                    bridge.ConnectorBridgeToPipelineElement = node;
                }
                else
                {
                    if (!this.connectors.TryAdd(component, node))
                    {
                        throw new InvalidOperationException("Failed to add connector");
                    }
                }
            }

            this.graphs[pipeline.Id].PipelineElements.TryAdd(element.Id, node);
        }
コード例 #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="PipelineElementDiagnostics"/> class.
            /// </summary>
            /// <param name="pipelineElementDiagnosticsInternal">Internal pipeline element diagnostics.</param>
            /// <param name="builder">Builder of pipeline parts used during construction.</param>
            internal PipelineElementDiagnostics(PipelineDiagnosticsInternal.PipelineElementDiagnostics pipelineElementDiagnosticsInternal, Builder builder)
            {
                this.Id         = pipelineElementDiagnosticsInternal.Id;
                this.Name       = pipelineElementDiagnosticsInternal.Name;
                this.TypeName   = pipelineElementDiagnosticsInternal.TypeName;
                this.Kind       = pipelineElementDiagnosticsInternal.Kind;
                this.IsRunning  = pipelineElementDiagnosticsInternal.IsRunning;
                this.Finalized  = pipelineElementDiagnosticsInternal.Finalized;
                this.Emitters   = pipelineElementDiagnosticsInternal.Emitters.Values.Select(e => builder.GetOrCreateEmitterDiagnostics(e)).ToArray();
                this.Receivers  = pipelineElementDiagnosticsInternal.Receivers.Values.Select(r => builder.GetOrCreateReceiverDiagnostics(r)).ToArray();
                this.PipelineId = pipelineElementDiagnosticsInternal.PipelineId;
                if (pipelineElementDiagnosticsInternal.RepresentsSubpipeline != null)
                {
                    builder.EnqueueThunk(() =>
                    {
                        if (builder.Pipelines.TryGetValue(pipelineElementDiagnosticsInternal.RepresentsSubpipeline.Id, out var pipeline))
                        {
                            this.RepresentsSubpipeline = pipeline;
                        }
                    });
                }

                if (pipelineElementDiagnosticsInternal.ConnectorBridgeToPipelineElement != null)
                {
                    builder.EnqueueThunk(() =>
                    {
                        if (builder.PipelineElements.TryGetValue(pipelineElementDiagnosticsInternal.ConnectorBridgeToPipelineElement.Id, out var bridge))
                        {
                            this.ConnectorBridgeToPipelineElement = bridge;
                        }
                    });
                }
            }
コード例 #3
0
ファイル: DiagnosticsCollector.cs プロジェクト: yusharth/psi
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiverCollector"/> class.
 /// </summary>
 /// <param name="pipelineElementDiagnostics">Pipeline element diagnostics instance associated with this receiver.</param>
 /// <param name="receiverId">The id for the receiver to collect diagnostics about.</param>
 /// <param name="diagnosticsConfig">Diagnostics configuration.</param>
 internal ReceiverCollector(
     PipelineDiagnosticsInternal.PipelineElementDiagnostics pipelineElementDiagnostics,
     int receiverId,
     DiagnosticsConfiguration diagnosticsConfig)
 {
     this.pipelineElementDiagnostics = pipelineElementDiagnostics;
     this.receiverDiagnostics        = this.pipelineElementDiagnostics.Receivers[receiverId];
     this.diagnosticsConfig          = diagnosticsConfig;
 }
コード例 #4
0
 /// <summary>
 /// Get or create external pipeline element diagnostics representation.
 /// </summary>
 /// <param name="pipelineElementDiagnosticsInternal">Internal pipeline element diagnostics representation.</param>
 /// <returns>External pipeline element diagnostics representation.</returns>
 public PipelineElementDiagnostics GetOrCreatePipelineElementDiagnostics(PipelineDiagnosticsInternal.PipelineElementDiagnostics pipelineElementDiagnosticsInternal)
 {
     return(this.GetOrCreate(this.PipelineElements, pipelineElementDiagnosticsInternal, e => e.Id, (e, c) => new PipelineElementDiagnostics(e, c)));
 }