コード例 #1
0
        public static CSharpClassDefinition GetRepositoryBaseClassDefinition(this DapperProject project)
        {
            var classDefinition = new CSharpClassDefinition();

            classDefinition.Namespaces.Add("System");
            classDefinition.Namespaces.Add("System.Linq");
            classDefinition.Namespaces.Add("System.Threading.Tasks");
            classDefinition.Namespaces.Add("Microsoft.Extensions.Options");

            classDefinition.Namespaces.Add(project.GetEntityLayerNamespace());

            classDefinition.Namespace = project.GetDataLayerContractsNamespace();

            classDefinition.Name = "Repository";

            classDefinition.Constructors.Add(new ClassConstructorDefinition(new ParameterDefinition("IOptions<AppSettings>", "appSettings"))
            {
                Lines = new List <ILine>
                {
                    new CodeLine("ConnectionString = appSettings.Value.ConnectionString;")
                }
            });

            classDefinition.Properties.Add(new PropertyDefinition("String", "ConnectionString ")
            {
                AccessModifier = AccessModifier.Protected,
                IsReadOnly     = true
            });

            return(classDefinition);
        }
コード例 #2
0
 public static RepositoryBaseClassDefinition GetRepositoryBaseClassDefinition(this DapperProject project)
 => new RepositoryBaseClassDefinition
 {
     Namespaces =
     {
         "System.Data",
         project.GetEntityLayerNamespace()
     },
     Namespace      = project.GetDataLayerContractsNamespace(),
     AccessModifier = AccessModifier.Public,
     Name           = "Repository",
     Constructors   =
     {
         new ClassConstructorDefinition(AccessModifier.Public, new ParameterDefinition("IDbConnection", "connection"))
         {
             Lines =
             {
                 new CodeLine("Connection = connection;")
             }
         }
     },
     Properties =
     {
         new PropertyDefinition(AccessModifier.Protected, "IDbConnection", "Connection")
         {
             IsReadOnly = true
         }
     }
 };
コード例 #3
0
 public static RepositoryInterfaceDefinition GetRepositoryInterfaceDefinition(this DapperProject project)
 => new RepositoryInterfaceDefinition
 {
     Namespace      = project.GetDataLayerContractsNamespace(),
     AccessModifier = AccessModifier.Public,
     Name           = "IRepository"
 };
コード例 #4
0
 public static RepositoryInterfaceDefinition GetRepositoryInterfaceDefinition(this DapperProject project)
 {
     return(new RepositoryInterfaceDefinition
     {
         Namespace = project.GetDataLayerContractsNamespace(),
         Name = "IRepository"
     });
 }