Skip to content

Commit fdcd12e

Browse files
committed
Comment related changes.
1 parent 349c35b commit fdcd12e

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

src/WebApiToTypeScript/Block/TypeScriptBlock.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ public TypeScriptBlock(string outer = "")
4545
Outer = outer;
4646
}
4747

48-
public TypeScriptBlock AddBlock(TypeScriptBlock block)
49-
{
50-
if (block != null)
51-
CreateChild(block);
52-
53-
return this;
54-
}
55-
5648
public TypeScriptBlock AddBlock(string outer = null, bool isFunctionBlock = false, string terminationString = "")
5749
{
5850
var child = CreateChild(outer, isFunctionBlock, terminationString);
@@ -67,13 +59,6 @@ public TypeScriptBlock AddAndUseBlock(string outer = null, bool isFunctionBlock
6759
return child;
6860
}
6961

70-
private TypeScriptBlock CreateChild(TypeScriptBlock block)
71-
{
72-
Children.Add(block);
73-
74-
return this;
75-
}
76-
7762
private TypeScriptBlock CreateChild(string outer, bool isFunctionBlock, string terminationString = "")
7863
{
7964
var child = new TypeScriptBlock

src/WebApiToTypeScript/Endpoints/AngularEndpointsService.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/WebApiToTypeScript/Endpoints/EndpointsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private void WriteInterfaceWithCallToBlock(TypeScriptBlock interfaceWithCallBloc
121121
interfaceWithCallBlock
122122
.AddStatement($"call<TView>({callArgumentsList}): ng.IPromise<TView>;");
123123

124-
if (Config.EndpointsSupportCaching && string.Equals(verb.Verb, WebApiHttpVerb.Get.Verb, StringComparison.InvariantCultureIgnoreCase))
124+
if (Config.EndpointsSupportCaching && verb == WebApiHttpVerb.Get)
125125
interfaceWithCallBlock
126126
.AddStatement($"callCached<TView>({callArgumentsList}): ng.IPromise<TView>;");
127127
}

0 commit comments

Comments
 (0)