protected override void BeginProcessing()
        {
            InitializeEventHandlers();
            AzureSession.Instance.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
            IAzureContext context;

            if (RequireDefaultContext() &&
                TryGetDefaultContext(out context) &&
                context.Account != null &&
                context.Subscription != null)
            {
                AzureSession.Instance.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
                                                                   () =>
                {
                    var client = new ResourceManagementClient(
                        context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager),
                        AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(context, AzureEnvironment.Endpoint.ResourceManager));
                    client.SubscriptionId = context.Subscription.Id;
                    return(client);
                },
                                                                   s => DebugMessages.Enqueue(s)));
            }

            base.BeginProcessing();
        }
예제 #2
0
 /// <summary>
 /// Creates new instance from AzureRMCmdlet and add the RPRegistration handler.
 /// </summary>
 public AzureRMCmdlet()
 {
     AzureSession.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
     AzureSession.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
                                               () => new ResourceManagementClient(
                                                   AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(DefaultContext, AzureEnvironment.Endpoint.ResourceManager),
                                                   DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)),
                                               s => DebugMessages.Enqueue(s)));
 }
예제 #3
0
        protected override void BeginProcessing()
        {
            AzureSession.Instance.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
            AzureSession.Instance.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
                                                               () => new ResourceManagementClient(
                                                                   DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager),
                                                                   AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(DefaultContext, AzureEnvironment.Endpoint.ResourceManager)),
                                                               s => DebugMessages.Enqueue(s)));

            base.BeginProcessing();
        }
예제 #4
0
        protected virtual void SetupDebuggingTraces()
        {
            _httpTracingInterceptor = _httpTracingInterceptor ?? new
                                      RecordingTracingInterceptor(DebugMessages, _matchers);
            _adalListener = _adalListener ?? new DebugStreamTraceListener(DebugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            if (AzureSession.Instance.TryGetComponent(nameof(IAzureEventListenerFactory), out IAzureEventListenerFactory factory))
            {
                _azureEventListener = factory.GetAzureEventListener(
                    (message) =>
                {
                    DebugMessages.Enqueue(message);
                });
            }
        }
예제 #5
0
 public void Debug(string message, params object[] items)
 {
     DebugMessages.Enqueue(message);
     _logger.Debug(message, items);
 }
예제 #6
0
 public void LogDebug(string data)
 {
     Messages.Enqueue(data);
     DebugMessages.Enqueue(data);
     DumpMessage("DEBUG", data);
 }
 private void EnqueueDebugSender(object sender, StreamEventArgs args)
 {
     DebugMessages.Enqueue(args.Message);
 }
예제 #8
0
 public static void LogDebug(string _message)
 {
     // TODO: look into using string builder to optomise string concatenation
     DebugMessages.Enqueue(GeneratePostMessageText() + _message);
 }