Skip to content

Commit 385dcfb

Browse files
committed
ApiBase: Code style and whitespace
1 parent 515430f commit 385dcfb

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/ElectronNET.API/API/ApiBase.cs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected set
5858
protected ApiBase()
5959
{
6060
this.objectName = this.GetType().Name.LowerFirst();
61-
this.invocators = AllInvocators.GetOrAdd(objectName, _ => new ConcurrentDictionary<string, Invocator>());
61+
this.invocators = AllInvocators.GetOrAdd(this.objectName, _ => new ConcurrentDictionary<string, Invocator>());
6262
}
6363

6464
protected void CallMethod0([CallerMemberName] string callerName = null)
@@ -135,15 +135,15 @@ protected Task<T> InvokeAsync<T>(object arg = null, [CallerMemberName] string ca
135135
}).Task<T>();
136136
}
137137
}
138-
138+
139139
protected void AddEvent(Action value, int? id = null, [CallerMemberName] string callerName = null)
140140
{
141141
Debug.Assert(callerName != null, nameof(callerName) + " != null");
142-
var eventName = EventName(callerName);
143-
144-
var eventKey = EventKey(eventName, id);
142+
var eventName = this.EventName(callerName);
143+
144+
var eventKey = this.EventKey(eventName, id);
145145

146-
lock (objLock)
146+
lock (this.objLock)
147147
{
148148
var container = eventContainers.GetOrAdd(eventKey, _ =>
149149
{
@@ -156,14 +156,14 @@ protected void AddEvent(Action value, int? id = null, [CallerMemberName] string
156156
container.Register(value);
157157
}
158158
}
159-
159+
160160
protected void RemoveEvent(Action value, int? id = null, [CallerMemberName] string callerName = null)
161161
{
162162
Debug.Assert(callerName != null, nameof(callerName) + " != null");
163-
var eventName = EventName(callerName);
164-
var eventKey = EventKey(eventName, id);
163+
var eventName = this.EventName(callerName);
164+
var eventKey = this.EventKey(eventName, id);
165165

166-
lock (objLock)
166+
lock (this.objLock)
167167
{
168168
if (eventContainers.TryGetValue(eventKey, out var container) && !container.Unregister(value))
169169
{
@@ -172,15 +172,15 @@ protected void RemoveEvent(Action value, int? id = null, [CallerMemberName] stri
172172
}
173173
}
174174
}
175-
175+
176176
protected void AddEvent<T>(Action<T> value, int? id = null, [CallerMemberName] string callerName = null)
177177
{
178178
Debug.Assert(callerName != null, nameof(callerName) + " != null");
179-
180-
var eventName = EventName(callerName);
181-
var eventKey = EventKey(eventName, id);
182179

183-
lock (objLock)
180+
var eventName = this.EventName(callerName);
181+
var eventKey = this.EventKey(eventName, id);
182+
183+
lock (this.objLock)
184184
{
185185
var container = eventContainers.GetOrAdd(eventKey, _ =>
186186
{
@@ -197,10 +197,10 @@ protected void AddEvent<T>(Action<T> value, int? id = null, [CallerMemberName] s
197197
protected void RemoveEvent<T>(Action<T> value, int? id = null, [CallerMemberName] string callerName = null)
198198
{
199199
Debug.Assert(callerName != null, nameof(callerName) + " != null");
200-
var eventName = EventName(callerName);
201-
var eventKey = EventKey(eventName, id);
200+
var eventName = this.EventName(callerName);
201+
var eventKey = this.EventKey(eventName, id);
202202

203-
lock (objLock)
203+
lock (this.objLock)
204204
{
205205
if (eventContainers.TryGetValue(eventKey, out var container) && !container.Unregister(value))
206206
{
@@ -212,17 +212,17 @@ protected void RemoveEvent<T>(Action<T> value, int? id = null, [CallerMemberName
212212

213213
private string EventName(string callerName)
214214
{
215-
switch (SocketEventNameType)
215+
switch (this.SocketEventNameType)
216216
{
217217
case SocketEventNameTypes.DashedLower:
218-
return $"{objectName}-{callerName.ToDashedEventName()}";
218+
return $"{this.objectName}-{callerName.ToDashedEventName()}";
219219
case SocketEventNameTypes.CamelCase:
220-
return $"{objectName}-{callerName.ToCamelCaseEventName()}";
220+
return $"{this.objectName}-{callerName.ToCamelCaseEventName()}";
221221
default:
222222
throw new ArgumentOutOfRangeException();
223223
}
224224
}
225-
225+
226226
private string EventKey(string eventName, int? id)
227227
{
228228
return string.Format(CultureInfo.InvariantCulture, "{0}{1:D}", eventName, id);
@@ -257,7 +257,7 @@ public Invocator(ApiBase apiBase, string callerName, int timeoutMs, object arg =
257257
default:
258258
throw new ArgumentOutOfRangeException();
259259
}
260-
260+
261261
switch (apiBase.SocketTaskMessageNameType)
262262
{
263263
case SocketTaskMessageNameTypes.DashesLowerFirst:
@@ -289,14 +289,14 @@ public Invocator(ApiBase apiBase, string callerName, int timeoutMs, object arg =
289289
}
290290
}
291291
});
292-
292+
293293
if (arg != null)
294294
{
295-
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id, arg) : BridgeConnector.Socket.Emit(messageName, arg);
295+
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id, arg) : BridgeConnector.Socket.Emit(messageName, arg);
296296
}
297297
else
298298
{
299-
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id) : BridgeConnector.Socket.Emit(messageName);
299+
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id) : BridgeConnector.Socket.Emit(messageName);
300300
}
301301

302302
System.Threading.Tasks.Task.Delay(InvocationTimeout).ContinueWith(_ =>
@@ -321,7 +321,7 @@ public override Task<T1> Task<T1>()
321321
return this.tcsTask as Task<T1>;
322322
}
323323
}
324-
324+
325325
[SuppressMessage("ReSharper", "InconsistentlySynchronizedField")]
326326
private class EventContainer
327327
{
@@ -330,41 +330,41 @@ private class EventContainer
330330

331331
private Action<T> GetEventActionT<T>()
332332
{
333-
return (Action<T>)eventActionT;
333+
return (Action<T>)this.eventActionT;
334334
}
335335

336336
private void SetEventActionT<T>(Action<T> actionT)
337337
{
338-
eventActionT = actionT;
338+
this.eventActionT = actionT;
339339
}
340340

341-
public void OnEventAction() => eventAction?.Invoke();
341+
public void OnEventAction() => this.eventAction?.Invoke();
342342

343-
public void OnEventActionT<T>(T p) => GetEventActionT<T>()?.Invoke(p);
343+
public void OnEventActionT<T>(T p) => this.GetEventActionT<T>()?.Invoke(p);
344344

345345
public void Register(Action receiver)
346346
{
347-
eventAction += receiver;
347+
this.eventAction += receiver;
348348
}
349349

350350
public void Register<T>(Action<T> receiver)
351351
{
352-
var actionT = GetEventActionT<T>();
352+
var actionT = this.GetEventActionT<T>();
353353
actionT += receiver;
354-
SetEventActionT(actionT);
354+
this.SetEventActionT(actionT);
355355
}
356356

357357
public bool Unregister(Action receiver)
358358
{
359-
eventAction -= receiver;
359+
this.eventAction -= receiver;
360360
return this.eventAction != null;
361361
}
362362

363363
public bool Unregister<T>(Action<T> receiver)
364364
{
365-
var actionT = GetEventActionT<T>();
365+
var actionT = this.GetEventActionT<T>();
366366
actionT -= receiver;
367-
SetEventActionT(actionT);
367+
this.SetEventActionT(actionT);
368368

369369
return actionT != null;
370370
}

0 commit comments

Comments
 (0)