public void Scenario7() { var result = CSharpTemplateBase.NormalizeNamespace( localNamespace: "Intent.Modules.Application.DependencyInjection.Templates.DependencyInjection", foreignType: "Intent.Modules.Application.DependencyInjection.Templates.DependencyInjection.DependencyInjectionDecorator", knownOtherPaths: new string[] { "System", "System.Collections.Generic", "Intent.Engine", "Intent.Modules.Common", "Intent.Modules.Common.CSharp.Templates", "Intent.Modules.Common.Templates", "Intent.RoslynWeaver.Attributes", "Intent.Templates", }, usingPaths: new string[] { "System", "System.Collections.Generic", "Intent.Engine", "Intent.Modules.Common", "Intent.Modules.Common.CSharp.Templates", "Intent.Modules.Common.Templates", "Intent.RoslynWeaver.Attributes", "Intent.Templates", }); Assert.Equal("DependencyInjectionDecorator", result); }
public void Scenario6() { var result = CSharpTemplateBase.NormalizeNamespace( localNamespace: "Intent.Modules.Application.MediatR.Templates.QueryModel", foreignType: "Intent.Modelers.Services.CQRS.Api.QueryModel", knownOtherPaths: new string[] { "System.Collections.Generic", "Intent.Engine", "Intent.Modelers.Services.CQRS.Api", "Intent.Modules.Common.CSharp.Templates", "Intent.Modules.Common.Templates", "Intent.RoslynWeaver.Attributes", "Intent.Templates" }, usingPaths: new string[] { "System.Collections.Generic", "Intent.Engine", "Intent.Modelers.Services.CQRS.Api", "Intent.Modules.Common.CSharp.Templates", "Intent.Modules.Common.Templates", "Intent.RoslynWeaver.Attributes", "Intent.Templates" }); Assert.Equal("Modelers.Services.CQRS.Api.QueryModel", result); }
public void Scenario4() { var result = CSharpTemplateBase.NormalizeNamespace( localNamespace: "Solution.Application.Contracts.Internal.CompanyDetailsManagement", foreignType: "Solution.Application.Common.Enums.CompanyDetails.SocialMediaType", knownOtherPaths: ProjectNames, usingPaths: new string[] { }); Assert.Equal("Common.Enums.CompanyDetails.SocialMediaType", result); }
public static IEnumerable <string> GetValidationRules <TModel>(this CSharpTemplateBase <TModel> template, IEnumerable <DTOFieldModel> properties) { foreach (var property in properties) { var validations = new List <string>(); if (!template.Types.Get(property.TypeReference).IsPrimitive&& !property.TypeReference.IsNullable) { validations.Add(".NotNull()"); } if (property.HasStringValidation()) { if (property.GetStringValidation().NotEmpty()) { validations.Add(".NotEmpty()"); } if (property.GetStringValidation().MaxLength() != null) { validations.Add($".MaximumLength({property.GetStringValidation().MaxLength()})"); } if (property.GetStringValidation().HasCustomValidation()) { validations.Add($".Must(Validate{property.Name})"); } } else if (property.InternalElement.IsMapped) { try { var attribute = property.InternalElement.MappedElement.Element.AsAttributeModel(); if (attribute.HasStereotype("Text Constraints") && attribute.GetStereotypeProperty <int?>("Text Constraints", "MaxLength") > 0) { validations.Add( $".MaximumLength({attribute.GetStereotypeProperty<int>("Text Constraints", "MaxLength")})"); } } catch (Exception e) { Logging.Log.Debug("Could not resolve [Text Constraints] stereotype for Domain attribute: " + e.Message); } } if (!validations.Any()) { continue; } yield return($@"RuleFor(v => v.{property.Name.ToPascalCase()}) {string.Join($"{Environment.NewLine} ", validations)};"); } }
public void Scenario3() { var result = CSharpTemplateBase.NormalizeNamespace( localNamespace: "Solution.Application.ApplicationLayer", foreignType: "Solution.Application.Contracts.Internal.CompanyDetailsManagement.StatutoryInfoDTO", knownOtherPaths: ProjectNames, usingPaths: new string[] { "System.Runtime.Serialization", "AutoMapper", "Intent.RoslynWeaver.Attributes", }); Assert.Equal("Contracts.Internal.CompanyDetailsManagement.StatutoryInfoDTO", result); }
public void Scenario1() { var result = CSharpTemplateBase.NormalizeNamespace( localNamespace: "Solution.Application.Contracts.Internal.CompanyDetailsManagement", foreignType: "Solution.Common.Types.Country", knownOtherPaths: ProjectNames, usingPaths: new string[] { "System", "System.Collections.Generic", "System.Runtime.Serialization", "Intent.RoslynWeaver.Attributes", }); Assert.Equal("Solution.Common.Types.Country", result); }
public void Scenario5() { var result = CSharpTemplateBase.NormalizeNamespace( localNamespace: "MyCompany.Movies.Api", foreignType: "MyCompany.Movies.Application.Movies", knownOtherPaths: new string[] { "MyCompany.Movies.Infrastructure.Data", "MyCompany.Movies.Application", "MyCompany.Movies.Application.ServiceCallHandlers.Movies", "MyCompany.Movies.Domain" }, usingPaths: new string[] { "MyCompany.Movies.Infrastructure.Data", "MyCompany.Movies.Application", "MyCompany.Movies.Application.ServiceCallHandlers.Movies", "MyCompany.Movies.Domain" }); Assert.Equal("Application.Movies", result); }
public static string GetCurrentUserServiceInterface <TModel>(this CSharpTemplateBase <TModel> template) { return(template.GetTypeName(CurrentUserServiceInterfaceTemplate.TemplateId)); }
public static string GetForbiddenAccessException <TModel>(this CSharpTemplateBase <TModel> template) { return(template.GetTypeName(ForbiddenAccessExceptionTemplate.TemplateId)); }
public static string GetAuthorizationAttribute <TModel>(this CSharpTemplateBase <TModel> template) { return(template.GetTypeName(AuthorizeAttributeTemplate.TemplateId)); }