@@ -94,14 +94,7 @@ public void WriteServiceObjectToBlock(TypeScriptBlock serviceBlock, WebApiContro
9494 var interfaceWithCallFullName = $ "{ Config . EndpointsNamespace } .{ webApiController . Name } .I{ actionName } WithCall";
9595 var endpointFullName = $ "{ Config . EndpointsNamespace } .{ webApiController . Name } .{ actionName } ";
9696
97- var cachedBlock = Config . EndpointsSupportCaching &&
98- string . Equals ( verb . Verb , WebApiHttpVerb . Get . Verb , StringComparison . InvariantCultureIgnoreCase )
99- ? new TypeScriptBlock ( )
100- . AddAndUseBlock ( $ "callCached<TView>({ callArgumentDefinition } )")
101- . AddStatement ( $ "return { Config . ServiceName } .callCached<TView>(this, { callArgumentValue } );")
102- : null ;
103-
104- controllerBlock
97+ var endpointExtendBlock = controllerBlock
10598 . AddAndUseBlock
10699 (
107100 outer : $ "{ actionName } : (args{ optionalString } : { interfaceFullName } ): { interfaceWithCallFullName } =>",
@@ -112,8 +105,11 @@ public void WriteServiceObjectToBlock(TypeScriptBlock serviceBlock, WebApiContro
112105 . AddAndUseBlock ( "return _.extendOwn(endpoint," , isFunctionBlock : true , terminationString : ";" )
113106 . AddAndUseBlock ( $ "call<TView>({ callArgumentDefinition } )", isFunctionBlock : false , terminationString : "," )
114107 . AddStatement ( $ "return { Config . ServiceName } .call<TView>(this, { callArgumentValue } );")
115- . Parent
116- . AddBlock ( cachedBlock ) ;
108+ . Parent ;
109+
110+ if ( Config . EndpointsSupportCaching && verb == WebApiHttpVerb . Get )
111+ endpointExtendBlock . AddAndUseBlock ( $ "callCached<TView>({ callArgumentDefinition } )")
112+ . AddStatement ( $ "return { Config . ServiceName } .callCached<TView>(this, { callArgumentValue } );") ;
117113 }
118114 }
119115 }
0 commit comments