示例#1
0
 private string GetOperationReturnType(OperationModel o)
 {
     if (o.TypeReference.Element == null)
     {
         return(o.IsAsync() ? "async Task" : "void");
     }
     return(o.IsAsync() ? $"async Task<{GetTypeName(o.TypeReference)}>" : GetTypeName(o.TypeReference));
 }
 public string EmitOperationReturnType(OperationModel o)
 {
     if (o.TypeReference.Element == null)
     {
         return(o.IsAsync() ? "Task" : "void");
     }
     return(o.IsAsync() ? $"Task<{NormalizeNamespace(Types.InContext(InterfaceContext).Get(o.TypeReference).Name)}>" : NormalizeNamespace(Types.InContext(InterfaceContext).Get(o.TypeReference).Name));
 }
示例#3
0
 public string EmitOperationReturnType(OperationModel o)
 {
     if (o.ReturnType == null)
     {
         return(o.IsAsync() ? "async Task" : "void");
     }
     return(o.IsAsync() ? $"async Task<{GetTypeName(o.ReturnType)}>" : GetTypeName(o.ReturnType));
 }
 public override string AfterCallToAppLayer(ServiceModel service, OperationModel operation)
 {
     if (operation.Stereotypes.Any(x => x.Name == "ReadOnly"))
     {
         return("");
     }
     return(operation.IsAsync()
         ? $@"
             await _dbContext.SaveChangesAsync();"
         : $@"
             _dbContext.SaveChanges();");
 }
        public override string BeforeCallToAppLayer(ServiceModel service, OperationModel operation)
        {
            if (!operation.GetStereotypeProperty <bool>("Transactional Settings", "Explicit Scope", true))
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            sb.AppendIndentation(3)
            .AppendLine("var tso = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted };");

            sb.AppendIndentation(3)
            .AppendLine($"using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, tso{(operation.IsAsync() ? ", TransactionScopeAsyncFlowOption.Enabled" : string.Empty)}))")
            .AppendIndentation(3)
            .AppendLine("{");

            return(sb.ToString());
        }