@@ -105,6 +105,7 @@ export class ModuleClass extends Class {
105105
106106 yield $this . fPipeline . assignPrivate ( ClientRuntime . HttpPipeline . new ( ClientRuntime . HttpClientFactory . new ( System . Net . Http . HttpClient . new ( ) ) ) ) ;
107107 yield $this . fPipelineWithProxy . assignPrivate ( ClientRuntime . HttpPipeline . new ( ClientRuntime . HttpClientFactory . new ( System . Net . Http . HttpClient . new ( $this . fHandler ) ) ) ) ;
108+ yield "Init();" ;
108109 }
109110 } ) ) ;
110111
@@ -113,6 +114,7 @@ export class ModuleClass extends Class {
113114 this . add ( new PartialMethod ( 'AfterCreatePipeline' , dotnet . Void , { parameters : [ this . pInvocationInfo , this . pPipeline ] } ) ) ;
114115 this . add ( new PartialMethod ( 'CustomInit' , dotnet . Void ) ) ;
115116
117+
116118 /* Setting the Proxy */
117119 this . add ( new Method ( 'SetProxyConfiguration' , dotnet . Void , {
118120 parameters : [ this . pProxy , this . pProxyCredential , this . pUseDefaultCredentials ] ,
@@ -128,8 +130,23 @@ export class ModuleClass extends Class {
128130 }
129131
130132 createInitAndPipeline ( namespace : Namespace ) {
133+
131134 const $this = this ;
132- // non-azure init method
135+ // Custom Event Listener without Azure Spefic concepts. (ProcessId and CorelationId)
136+ const customEventListenerFunc = System . Func (
137+ dotnet . String ,
138+ System . Threading . CancellationToken ,
139+ System . Func ( System . EventArgs ) ,
140+ this . incomingSignalFunc ,
141+ InvocationInfo ,
142+ dotnet . String ,
143+ System . Exception ,
144+ /* returns */ System . Threading . Tasks . Task ( ) ) ;
145+
146+ const incomingSignalDelegate = namespace . add ( new Alias ( 'SignalDelegate' , this . incomingSignalFunc ) ) ;
147+ const eventListenerDelegate = namespace . add ( new Alias ( 'EventListenerDelegate' , customEventListenerFunc ) ) ;
148+ const EventListener = this . add ( new Property ( 'EventListener' , eventListenerDelegate , { description : 'A delegate that gets called for each signalled event' } ) ) ;
149+
133150 this . initMethod . add ( function * ( ) {
134151 yield '// called at module init time...' ;
135152 yield 'CustomInit();' ;
@@ -152,6 +169,20 @@ export class ModuleClass extends Class {
152169 } ) ;
153170
154171 this . add ( new LambdaProperty ( 'Name' , dotnet . String , new StringExpression ( this . state . project . moduleName ) , { description : 'The Name of this module ' } ) ) ;
172+
173+ // Add Signal extensibility point
174+ const pSignal = new Parameter ( 'signal' , incomingSignalDelegate , { description : 'The callback for the event dispatcher ' } ) ;
175+ // Emit signal extensibility points that called EventListenerDelegate, allowing us to handle Signals emitted by the Pipeline in the Auth Module
176+ const signalImpl = this . add ( new Method ( 'Signal' , System . Threading . Tasks . Task ( ) , {
177+ parameters : [ this . pId , this . pToken , this . pGetEventData , pSignal , this . pInvocationInfo , this . pParameterSetName , this . pException ] , async : Modifier . Async ,
178+ description : 'Called to dispatch events to the common module listener' ,
179+ returnsDescription : `A <see cref="${ System . Threading . Tasks . Task ( ) } " /> that will be complete when handling of the event is completed.`
180+ } ) ) ;
181+
182+ signalImpl . push ( Using ( 'NoSynchronizationContext' , '' ) ) ;
183+ signalImpl . add ( function * ( ) {
184+ yield `await ${ EventListener . value } ?.Invoke(${ $this . pId . value } ,${ $this . pToken . value } ,${ $this . pGetEventData . value } , ${ pSignal . value } , ${ $this . pInvocationInfo } , ${ $this . pParameterSetName } ,${ $this . pException } );` ;
185+ } ) ;
155186 }
156187
157188 createAzureInitAndPipeline ( namespace : Namespace ) {
0 commit comments