@@ -31,17 +31,18 @@ public TypeScriptBlock CreateServiceBlock()
3131 serviceBlock
3232 . Parent
3333 . AddAndUseBlock ( "static callCached<TView>(endpoint: IEndpoint, data)" )
34- . AddAndUseBlock ( "if (this.endpointCache[endpoint.toString()] == null)" )
35- . AddAndUseBlock ( "return this.call(endpoint, data).then(result =>" , isFunctionBlock : true ,
34+ . AddStatement ( "var cacheKey = endpoint.toString();" )
35+ . AddAndUseBlock ( "if (this.endpointCache[cacheKey] == null)" )
36+ . AddAndUseBlock ( "return this.call<TView>(endpoint, data).then(result =>" , isFunctionBlock : true ,
3637 terminationString : ";" )
37- . AddStatement ( "this.endpointCache[endpoint.toString() ] = result;" )
38- . AddStatement ( "return this.endpointCache[endpoint.toString() ];" )
38+ . AddStatement ( "this.endpointCache[cacheKey ] = result;" )
39+ . AddStatement ( "return this.endpointCache[cacheKey ];" )
3940 . Parent
4041 . Parent
4142 . AddStatement ( "const deferred = this.$q.defer();" )
42- . AddStatement ( "deferred.resolve(this.endpointCache[endpoint.toString() ]);" )
43+ . AddStatement ( "deferred.resolve(this.endpointCache[cacheKey ]);" )
4344 . AddStatement ( "return deferred.promise;" ) ;
44-
45+
4546 return serviceBlock
4647 . Parent
4748 . Parent ;
@@ -94,11 +95,11 @@ public void WriteServiceObjectToBlock(TypeScriptBlock serviceBlock, WebApiContro
9495 var endpointFullName = $ "{ Config . EndpointsNamespace } .{ webApiController . Name } .{ actionName } ";
9596
9697 var cachedBlock = Config . EndpointsSupportCaching &&
97- string . Equals ( verb . Verb , "GET" , StringComparison . InvariantCultureIgnoreCase )
98+ string . Equals ( verb . Verb , WebApiHttpVerb . Get . Verb , StringComparison . InvariantCultureIgnoreCase )
9899 ? new TypeScriptBlock ( )
99100 . AddAndUseBlock ( $ "callCached<TView>({ callArgumentDefinition } )")
100101 . AddStatement ( $ "return { Config . ServiceName } .callCached<TView>(this, { callArgumentValue } );")
101- : null ;
102+ : null ;
102103
103104 controllerBlock
104105 . AddAndUseBlock
0 commit comments