generated/Module.cs
// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.4, generator: @autorest/powershell@3.0.415) // Changes may cause incorrect behavior and will be lost if the code is regenerated. namespace Commvault.Powershell { using static Commvault.Powershell.Runtime.Extensions; using SignalDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>; using EventListenerDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Management.Automation.InvocationInfo, string, global::System.Exception, global::System.Threading.Tasks.Task>; /// <summary>A class that contains the module-common code and data.</summary> public partial class Module { public global::System.Net.Http.HttpClientHandler _handler = new global::System.Net.Http.HttpClientHandler(); /// <summary>the ISendAsync pipeline instance</summary> private Commvault.Powershell.Runtime.HttpPipeline _pipeline; /// <summary>the ISendAsync pipeline instance (when proxy is enabled)</summary> private Commvault.Powershell.Runtime.HttpPipeline _pipelineWithProxy; public global::System.Net.WebProxy _webProxy = new global::System.Net.WebProxy(); /// <summary>The instance of the Client API</summary> public Commvault.Powershell.CommvaultPowerShell ClientAPI { get; set; } /// <summary>A delegate that gets called for each signalled event</summary> public EventListenerDelegate EventListener { get; set; } /// <summary>Backing field for <see cref="Instance" /> property.</summary> private static Commvault.Powershell.Module _instance; /// <summary>the singleton of this module class</summary> public static Commvault.Powershell.Module Instance => Commvault.Powershell.Module._instance?? (Commvault.Powershell.Module._instance = new Commvault.Powershell.Module()); /// <summary>The Name of this module</summary> public string Name => @"CommvaultPowershell"; /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param> /// <param name="pipeline">The HttpPipeline for the request</param> partial void AfterCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Commvault.Powershell.Runtime.HttpPipeline pipeline); /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param> /// <param name="pipeline">The HttpPipeline for the request</param> partial void BeforeCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Commvault.Powershell.Runtime.HttpPipeline pipeline); partial void CustomInit(); /// <summary>Creates an instance of the HttpPipeline for each call.</summary> /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param> /// <param name="parameterSetName">the cmdlet's parameterset name.</param> /// <returns>An instance of Commvault.Powershell.Runtime.HttpPipeline for the remote call.</returns> public Commvault.Powershell.Runtime.HttpPipeline CreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, string parameterSetName = null) { Commvault.Powershell.Runtime.HttpPipeline pipeline = null; BeforeCreatePipeline(invocationInfo, ref pipeline); pipeline = (pipeline ?? (_handler.UseProxy ? _pipelineWithProxy : _pipeline)).Clone(); AfterCreatePipeline(invocationInfo, ref pipeline); return pipeline; } /// <summary>Initialization steps performed after the module is loaded.</summary> public void Init() { // called at module init time... CustomInit(); } /// <summary>Creates the module instance.</summary> private Module() { /// constructor ClientAPI = new Commvault.Powershell.CommvaultPowerShell(); _handler.Proxy = _webProxy; _pipeline = new Commvault.Powershell.Runtime.HttpPipeline(new Commvault.Powershell.Runtime.HttpClientFactory(new global::System.Net.Http.HttpClient())); _pipelineWithProxy = new Commvault.Powershell.Runtime.HttpPipeline(new Commvault.Powershell.Runtime.HttpClientFactory(new global::System.Net.Http.HttpClient(_handler))); } /// <param name="proxy">The HTTP Proxy to use.</param> /// <param name="proxyCredential">The HTTP Proxy Credentials</param> /// <param name="proxyUseDefaultCredentials">True if the proxy should use default credentials</param> public void SetProxyConfiguration(global::System.Uri proxy, global::System.Management.Automation.PSCredential proxyCredential, bool proxyUseDefaultCredentials) { // set the proxy configuration _webProxy.Address = proxy; _webProxy.BypassProxyOnLocal = false; _webProxy.Credentials = proxyCredential ?.GetNetworkCredential(); _webProxy.UseDefaultCredentials = proxyUseDefaultCredentials; _handler.UseProxy = proxy != null; } /// <summary>Called to dispatch events to the common module listener</summary> /// <param name="id">The ID of the event </param> /// <param name="token">The cancellation token for the event </param> /// <param name="getEventData">A delegate to get the detailed event data</param> /// <param name="signal">The callback for the event dispatcher </param> /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param> /// <param name="parameterSetName">the cmdlet's parameterset name.</param> /// <param name="exception">the exception that is being thrown (if available)</param> /// <returns> /// A <see cref="global::System.Threading.Tasks.Task" /> that will be complete when handling of the event is completed. /// </returns> public async global::System.Threading.Tasks.Task Signal(string id, global::System.Threading.CancellationToken token, global::System.Func<global::System.EventArgs> getEventData, SignalDelegate signal, global::System.Management.Automation.InvocationInfo invocationInfo, string parameterSetName, global::System.Exception exception) { using( NoSynchronizationContext ) { if (EventListener != null) { await EventListener.Invoke(id,token,getEventData, signal, invocationInfo, parameterSetName,exception); } } } } } |