public override string BeginOperation(ServiceModel service, ServiceOperationModel operation) => operation.IsReadOnly ? string.Empty : $@" AuditContext.Current.StartAuditing( userId: ServiceCallContext.Instance.Get<IUserContextData>().UserId, application: ""{_applicationManager.ApplicationName}"", service: ""{service.Name}"", serviceOperation: ""{operation.Name}"", ipAddress: Request.GetClientIpAddress()); _auditingStrategy.BeforeServiceCallHandler(AuditContext.Current.ServiceCallAudit);";
private string GetMethodCallParameters(ServiceOperationModel o) { if (!o.Parameters.Any()) { return(""); } return(o.Parameters.Select(x => $"payload.{x.Name.ToCamelCase()}").Aggregate((x, y) => x + ", " + y)); }
private static string GetMethodCallParameters(ServiceOperationModel operation) { if (operation.Parameters == null || !operation.Parameters.Any()) { return(string.Empty); } return(operation.Parameters .Select(x => x.Name) .Aggregate((x, y) => $"{x}, {y}")); }
public string OnExceptionCaught(ServiceOperationModel operation) { var onExceptionCaught = GetDecorators().Aggregate(x => x.OnExceptionCaught(Model, operation)); if (GetDecorators().Any(x => x.HandlesCaughtException())) { return(onExceptionCaught); } return(onExceptionCaught + @" throw;"); }
public override string BeforeTransaction(ServiceModel service, ServiceOperationModel operation) { if (operation.UsesRawSignature || operation.Parameters == null || !operation.Parameters.Any()) { return(string.Empty); } return(@" if (payload == null) { throw new BadHttpRequestException(""Invalid or empty JSON message received.""); } "); }
private static string GetReadAs(ServiceOperationModel operation) { if (!operation.UsesRawSignature) { return($"ReadAsAsync<{operation.ReturnType.FullName}>()"); } if (operation.ReturnType.FullName.Equals(typeof(byte[]).Name, StringComparison.InvariantCultureIgnoreCase) || operation.ReturnType.FullName.Equals(typeof(byte[]).FullName, StringComparison.InvariantCultureIgnoreCase)) { return("ReadAsByteArrayAsync()"); } return($"ReadAsAsync<{operation.ReturnType.FullName}>()"); }
void GetMethodCallParameters(ServiceOperationModel o) { for (int i = 0; i < o.Parameters.Count; i++) { ParameterModel p = o.Parameters[i]; if (i != 0) { #line default #line hidden #line 89 "C:\Dev\Intent.Modules\Modules\Intent.Modules.AngularJs.ServiceAgent\Templates\Proxy\TypescriptWebApiClientServiceProxyTemplate.tt" this.Write(", "); #line default #line hidden #line 89 "C:\Dev\Intent.Modules\Modules\Intent.Modules.AngularJs.ServiceAgent\Templates\Proxy\TypescriptWebApiClientServiceProxyTemplate.tt" } #line default #line hidden #line 91 "C:\Dev\Intent.Modules\Modules\Intent.Modules.AngularJs.ServiceAgent\Templates\Proxy\TypescriptWebApiClientServiceProxyTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(LowerFirst(p.Name))); #line default #line hidden #line 91 "C:\Dev\Intent.Modules\Modules\Intent.Modules.AngularJs.ServiceAgent\Templates\Proxy\TypescriptWebApiClientServiceProxyTemplate.tt" this.Write(": "); #line default #line hidden #line 91 "C:\Dev\Intent.Modules\Modules\Intent.Modules.AngularJs.ServiceAgent\Templates\Proxy\TypescriptWebApiClientServiceProxyTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(LowerFirst(p.Name))); #line default #line hidden #line 91 "C:\Dev\Intent.Modules\Modules\Intent.Modules.AngularJs.ServiceAgent\Templates\Proxy\TypescriptWebApiClientServiceProxyTemplate.tt" } }
void GetMethodCallParameters(ServiceOperationModel o) { for (int i = 0; i < o.Parameters.Count; i++) { ParameterModel p = o.Parameters[i]; if (i != 0) { #line default #line hidden #line 154 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Electron.NodeEdgeProxy\Legacy\AngularNodeEdgeTypeScriptServiceProxy\AngularNodeEdgeTypeScriptServiceProxyTemplate.tt" this.Write(", "); #line default #line hidden #line 154 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Electron.NodeEdgeProxy\Legacy\AngularNodeEdgeTypeScriptServiceProxy\AngularNodeEdgeTypeScriptServiceProxyTemplate.tt" } #line default #line hidden #line 156 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Electron.NodeEdgeProxy\Legacy\AngularNodeEdgeTypeScriptServiceProxy\AngularNodeEdgeTypeScriptServiceProxyTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(LowerFirst(p.Name))); #line default #line hidden #line 156 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Electron.NodeEdgeProxy\Legacy\AngularNodeEdgeTypeScriptServiceProxy\AngularNodeEdgeTypeScriptServiceProxyTemplate.tt" this.Write(": "); #line default #line hidden #line 156 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Electron.NodeEdgeProxy\Legacy\AngularNodeEdgeTypeScriptServiceProxy\AngularNodeEdgeTypeScriptServiceProxyTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(LowerFirst(p.Name))); #line default #line hidden #line 156 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Electron.NodeEdgeProxy\Legacy\AngularNodeEdgeTypeScriptServiceProxy\AngularNodeEdgeTypeScriptServiceProxyTemplate.tt" } }
private static string GetHttpResponseMessageContent(ServiceOperationModel operation) { if (operation.ReturnType.FullName.Equals(typeof(byte[]).Name, StringComparison.InvariantCultureIgnoreCase) || operation.ReturnType.FullName.Equals(typeof(byte[]).FullName, StringComparison.InvariantCultureIgnoreCase)) { return("new StreamContent(new MemoryStream(appServiceResult))"); } if (operation.ReturnType.FullName.Equals(typeof(string).Name, StringComparison.InvariantCultureIgnoreCase) || operation.ReturnType.FullName.Equals(typeof(string).FullName, StringComparison.InvariantCultureIgnoreCase)) { return("new StringContent(appServiceResult)"); } throw new InvalidOperationException($"Unknown: {operation.ReturnType.FullName}"); }
public string AfterTransaction(ServiceModel service, ServiceOperationModel operation) { var returnString = @" "; if (operation.HasReturnType()) { returnString += $@" Logger.Trace(""{FormatOperationName(operation.Name)}Returning: {{0}}"", SanitizingJsonSerializer.Serialize(result));"; } returnString += $@" Logger.Info(""{FormatOperationName(operation.Name)}Duration (ms): {{0:#,0}}"", stopWatch.ElapsedMilliseconds);"; return(returnString); }
public string OnExceptionCaught(ServiceModel service, ServiceOperationModel operation) { switch (service.DistributionMode) { case ServiceDistributionMode.WebApi: return(!operation.UsesRawSignature ? OnExceptionCaught(new[] { "payload" }, operation.Name) : OnExceptionCaught(operation.Parameters.Select(x => x.Name), operation.Name)); case ServiceDistributionMode.Wcf: case ServiceDistributionMode.WcfRestful: return(OnExceptionCaught(operation.Parameters.Select(x => x.Name), operation.Name)); default: throw new ArgumentOutOfRangeException(); } }
string GetReturnType(ServiceOperationModel o) { if (o.ReturnType.TypeName.StartsWith("PagedResult")) { return("Contracts.PagedResultDTO<" + ConvertType(o.ReturnType.GenericArguments[0]) + ">"); } else if (o.ReturnType.TypeName.StartsWith("IList") || o.ReturnType.TypeName.StartsWith("List")) { return(ConvertType(o.ReturnType.GenericArguments[0]) + "[]"); } if (o.ReturnType.IsGenericType && o.ReturnType.TypeName.Contains("Nullable")) { return(ConvertType(o.ReturnType.GenericArguments[0])); } else if (o.ReturnType.IsGenericType && o.ReturnType.TypeName.Contains("Dictionary")) { return("any[]"); } else { return(ConvertType(o.ReturnType)); } }
void GetMethodCallParameters(ServiceOperationModel o, bool withLeadingComma, string prefix) { List <ParameterModel> parameters = o.Parameters; for (int i = 0; i < parameters.Count; i++) { ParameterModel p = parameters[i]; if (withLeadingComma || (!withLeadingComma && i != 0)) { #line default #line hidden #line 63 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Application.Contracts\Legacy\ServiceContract\./../Services.ttinclude" this.Write(", "); #line default #line hidden #line 63 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Application.Contracts\Legacy\ServiceContract\./../Services.ttinclude" } #line default #line hidden #line 65 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Application.Contracts\Legacy\ServiceContract\./../Services.ttinclude" this.Write(this.ToStringHelper.ToStringWithCulture(prefix + p.Name)); #line default #line hidden #line 65 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.Application.Contracts\Legacy\ServiceContract\./../Services.ttinclude" } }
public virtual string BeginOperation(ServiceModel service, ServiceOperationModel operation) => @"";
public string BeginOperation(ServiceOperationModel operation) { return(GetDecorators().Aggregate(x => x.BeginOperation(Model, operation))); }
private static string GetMethodReturnType(ServiceOperationModel operation) { return(ReturnsHttpResponseMessage(operation) ? "HttpResponseMessage" : operation.ReturnType.FullName); }
private static bool ReturnsHttpResponseMessage(ServiceOperationModel operation) { return(operation.HasReturnType() && operation.UsesRawSignature); }
public string AfterTransaction(ServiceOperationModel operation) { return(GetDecorators().Aggregate(x => x.AfterTransaction(Model, operation))); }
public string BeforeTransaction(ServiceModel service, ServiceOperationModel operation) => @"";
public override string AfterTransaction(ServiceModel service, ServiceOperationModel operation) => @" _clientNotificationService.Flush();";
public string AfterCallToAppLayer(ServiceOperationModel operation) { return(GetDecorators().Aggregate(x => x.AfterCallToAppLayer(Model, operation))); }
public override string AfterCallToAppLayer(ServiceModel service, ServiceOperationModel operation) => operation.IsReadOnly ? string.Empty : @" _auditingStrategy.AfterServiceCallHandler(AuditContext.Current.ServiceCallAudit);";
public override string BeginOperation(ServiceModel service, ServiceOperationModel operation) => @" var userContext = _userContextProvider.GetUserContext(); ServiceCallContext.Instance.Set<IUserContextData>(userContext);";
void GetMethodCallParameters(ServiceOperationModel o, bool withLeadingComma) { GetMethodCallParameters(o.Parameters, withLeadingComma); }
void GetMethodCallParameters(ServiceOperationModel o) { GetMethodCallParameters(o, false); }
public virtual string AfterCallToAppLayer(ServiceModel service, ServiceOperationModel operation) => @"";
public virtual string OnExceptionCaught(ServiceModel service, ServiceOperationModel operation) => @"";
public virtual string AfterTransaction(ServiceModel service, ServiceOperationModel operation) => @"";
void GetMethodDefinitionParameters(ServiceOperationModel o) { GetMethodDefinitionParameters(o, false); }
public string BeforeCallToAppLayer(ServiceModel service, ServiceOperationModel operation) => @"";