Example #1
0
            /// <summary>
            /// Create runner
            /// </summary>
            /// <param name="outer"></param>
            /// <param name="config"></param>
            /// <param name="endpointId"></param>
            /// <param name="secret"></param>
            /// <param name="logger"></param>
            public TwinHost(SupervisorServices outer, IModuleConfig config,
                            string endpointId, string secret, ILogger logger)
            {
                _outer   = outer;
                _product = "OpcTwin_" + GetType().Assembly.GetReleaseVersion().ToString();
                _logger  = (logger ?? Log.Logger).ForContext("SourceContext", new {
                    endpointId,
                    product = _product
                }, true);

                BypassCertVerification = config.BypassCertVerification;
                Transport = config.Transport;
                EdgeHubConnectionString = GetEdgeHubConnectionString(config,
                                                                     endpointId, secret);
                EnableMetrics = config.EnableMetrics;

                // Create twin scoped component context for the host
                _container = outer._factory.Create(builder => {
                    builder.RegisterInstance(this)
                    .AsImplementedInterfaces().SingleInstance();
                });

                _cts     = new CancellationTokenSource();
                _reset   = new TaskCompletionSource <bool>();
                _started = new TaskCompletionSource <bool>();
                Status   = EndpointActivationState.Activated;
                _runner  = Task.Run(RunAsync);
            }
            /// <summary>
            /// Create runner
            /// </summary>
            /// <param name="outer"></param>
            /// <param name="config"></param>
            /// <param name="endpointId"></param>
            /// <param name="secret"></param>
            public TwinHost(SupervisorServices outer,
                            IModuleConfig config, string endpointId, string secret)
            {
                _outer = outer;

                BypassCertVerification = config.BypassCertVerification;
                Transport = config.Transport;
                EdgeHubConnectionString = GetEdgeHubConnectionString(config,
                                                                     endpointId, secret);

                // Create twin scoped component context for the host
                _container = outer._factory.Create(builder => {
                    builder.RegisterInstance(this)
                    .AsImplementedInterfaces().SingleInstance();
                });

                _cts     = new CancellationTokenSource();
                _reset   = new TaskCompletionSource <bool>();
                _started = new TaskCompletionSource <bool>();
                Status   = EndpointActivationState.Activated;
                _runner  = Task.Run(RunAsync);
            }