예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddRouting(options => options.LowercaseUrls = true);
            services.AddAutoMapper(AssemblyReflection.GetCurrentAssemblies());
            services.AddResolverDependencies();
            services.AddMediatR(typeof(PersonCreateCommandHandler));
            services.AddMediatR(typeof(PersonDeleteCommandHandler));


            services.AddRabbitMq(Configuration);

            services.AddDatabaseNeo4J(Configuration);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("sender", new Info
                {
                    Version        = "v1",
                    Title          = "Censo Regional - Commands",
                    Description    = "",
                    TermsOfService = "None",
                    Contact        = new Contact
                    {
                        Name  = "Samuel de Oliveira",
                        Email = "*****@*****.**",
                        Url   = ""
                    }
                });
            });
        }
예제 #2
0
        private static void RegisterDomainServices(IServiceCollection services)
        {
            var domainServices = AssemblyReflection.GetDomainServices();

            foreach (var serv in domainServices)
            {
                services.AddTransient(serv);
            }
        }
예제 #3
0
        int Common.IAppDomainMethod.ExecuteInDomain()
        {
            bool regFilePathCheckResult = PathUtils.TryCheckForValidLocalAndAbsoluteFileSystemPath(Settings.RegFilePath);

            if (!regFilePathCheckResult)
            {
                return((int)ResultCodes.InvalidRegfilePath);
            }

            AppDomain            domain             = AppDomain.CurrentDomain;
            Assembly             addinAssembly      = Assembly.LoadFile(Settings.AssemblyPath);
            IEnumerable <object> assemblyAttributes = AssemblyReflection.GetCustomAssemblyAttributes(addinAssembly);

            if (!AssemblyReflection.AssemblyIsComVisible(addinAssembly, assemblyAttributes))
            {
                return((int)ResultCodes.AssemblyNotComVisible);
            }

            List <string> results = new List <string>();

            Type[] types = addinAssembly.GetExportedTypes();
            foreach (Type item in types)
            {
                if (!item.IsClass)
                {
                    continue;
                }

                IEnumerable <object> addinClassAttributes = Common.AttributeReflection.GetCustomClassAttributes(item);
                if (!AddinClassReflection.IsValidAddinClass(addinClassAttributes, item.Attributes))
                {
                    continue;
                }

                string regContent = CreateRegistryFileContent(addinAssembly, assemblyAttributes, Settings.Mode, item, addinClassAttributes);

                object exportResult = DoExportCall(item);
                string exportValues = ProceedExportResult(exportResult);
                if (null != exportValues)
                {
                    regContent += exportValues;
                }

                results.Add(regContent);
            }

            if (results.Count == 0)
            {
                return((int)ResultCodes.NothingFound);
            }

            WriteRegistryContentToLocalFileSystem(results);

            return((int)ResultCodes.Okay);
        }
예제 #4
0
        int Common.IAppDomainMethod.ExecuteInDomain()
        {
            AppDomain domain          = AppDomain.CurrentDomain;
            Assembly  addinAssembly   = Assembly.LoadFile(Settings.AssemblyPath);
            int       signCheckResult = DoTokenCheck(addinAssembly);

            if (0 != signCheckResult)
            {
                return(signCheckResult);
            }

            DoMetrics(addinAssembly);

            IEnumerable <object> assemblyAttributes = AssemblyReflection.GetCustomAssemblyAttributes(addinAssembly);

            if (!AssemblyReflection.AssemblyIsComVisible(addinAssembly, assemblyAttributes))
            {
                return((int)ResultCodes.AssemblyNotComVisible);
            }

            Type[] types = addinAssembly.GetExportedTypes();
            foreach (Type item in types)
            {
                if (!item.IsClass)
                {
                    continue;
                }

                IEnumerable <object> addinClassAttributes = Common.AttributeReflection.GetCustomClassAttributes(item);
                if (!AddinClassReflection.IsValidAddinClass(addinClassAttributes, item.Attributes))
                {
                    continue;
                }

                CreateRegistryEntries(addinAssembly, assemblyAttributes, Settings.Mode, item, addinClassAttributes);
                CreateOfficeKeys(item, addinClassAttributes, Settings.Mode == SingletonSettings.RegisterMode.System);
                if (Settings.DoRegisterCall)
                {
                    if (!new Dispatcher.RegisterMethod().Call(item,
                                                              Settings.Mode == SingletonSettings.RegisterMode.System ? 0 : 1,
                                                              Settings.AddinRegMode == SingletonSettings.AddinRegMode.Off ? 0 : 1))
                    {
                        return((int)ResultCodes.RegisterCallFailed);
                    }
                }
            }

            return((int)ResultCodes.Okay);
        }
        private static void RegisterApplications(IServiceCollection services)
        {
            var applicationInterfaces = AssemblyReflection.GetApplicationInterfaces();
            var applicationClasses    = AssemblyReflection.GetApplicationClasses();

            foreach (var @interface in applicationInterfaces)
            {
                var type = AssemblyReflection.FindType(@interface, applicationClasses);

                if (type != null)
                {
                    services.AddScoped(@interface, type);
                }
            }
        }
예제 #6
0
        private static void RegisterRepositories(IServiceCollection services)
        {
            var domainInterfaces = AssemblyReflection.GetRepositoryInterfaces();
            var repositories     = AssemblyReflection.GetRepositories();

            foreach (var repo in repositories)
            {
                var @interface = AssemblyReflection.FindInterface(repo, domainInterfaces);

                if (@interface != null)
                {
                    services.AddSingleton(@interface, repo);
                }
            }
        }
        public static void AddResolverDependencies(this IServiceCollection services)
        {
            var domainInterfaces = AssemblyReflection.GetInterfaces();
            var repositories     = AssemblyReflection.GetInfra();

            foreach (var repo in repositories)
            {
                var @interface = AssemblyReflection.FindInterface(repo, domainInterfaces);

                if (@interface != null)
                {
                    services.AddScoped(@interface, repo);
                }
            }
        }
예제 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.AddControllers();

            var key = Encoding.ASCII.GetBytes(Environment.GetEnvironmentVariable("AUTHENTICATION_SECRET"));

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            services.AddAutoMapper(AssemblyReflection.GetCurrentAssemblies());
            services.AddResolverDependencies();
            services.AddRouting(options => options.LowercaseUrls = true);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new OpenApiInfo
                {
                    Title       = "Teste.EL.NucleoAluguel",
                    Description = "API - Nucleo Alguel [Teste EL]",
                    Version     = "v1"
                });
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }
예제 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddRouting(options => options.LowercaseUrls = true);
            services.AddResolverDependencies();

            services.AddMediatR(typeof(PersonCreateOrDeleteEventHandler));
            services.AddMediatR(typeof(FamilyTreeByPersonQueryHandler));
            services.AddMediatR(typeof(PercentagePeopleSameNameByRegionQueryHandler));
            services.AddMediatR(typeof(QuantityPeopleByManyFiltersQueryHandler));
            services.AddAutoMapper(AssemblyReflection.GetCurrentAssemblies());
            services.AddRabbitMq(Configuration);
            services.AddDatabaseNeo4J(Configuration);
            services.AddCors(o => o.AddPolicy("CorsPolicy", builder => {
                builder
                .WithOrigins("http://*****:*****@gmail.com",
                        Url   = ""
                    }
                });
            });
        }
예제 #10
0
        int Common.IAppDomainMethod.ExecuteInDomain()
        {
            AppDomain domain          = AppDomain.CurrentDomain;
            Assembly  addinAssembly   = Assembly.LoadFile(Settings.AssemblyPath);
            int       signCheckResult = DoTokenCheck(addinAssembly);

            if (0 != signCheckResult)
            {
                return(signCheckResult);
            }

            IEnumerable <object> assemblyAttributes = AssemblyReflection.GetCustomAssemblyAttributes(addinAssembly);

            Type[] types = addinAssembly.GetExportedTypes();
            foreach (Type item in types)
            {
                if (!item.IsClass)
                {
                    continue;
                }

                IEnumerable <object> addinClassAttributes = Common.AttributeReflection.GetCustomClassAttributes(item);
                if (!AddinClassReflection.IsValidAddinClass(addinClassAttributes, item.Attributes))
                {
                    continue;
                }

                AddinRegAnalyzer.KeyTarget target = AddinRegAnalyzer.KeyTarget.Both;
                switch (Settings.Mode)
                {
                case SingletonSettings.UnRegisterMode.Auto:
                    target = AddinRegAnalyzer.KeyTarget.Both;
                    break;

                case SingletonSettings.UnRegisterMode.System:
                    target = AddinRegAnalyzer.KeyTarget.System;
                    break;

                case SingletonSettings.UnRegisterMode.User:
                    target = AddinRegAnalyzer.KeyTarget.User;
                    break;

                default:
                    throw new IndexOutOfRangeException("Mode");
                }

                DeleteRegistryEntries(addinAssembly, assemblyAttributes, Settings.Mode, item, addinClassAttributes);
                DeleteOfficeKeys(item, addinClassAttributes, target);
                if (Settings.DoRegisterCall)
                {
                    int installScope = Settings.Mode == SingletonSettings.UnRegisterMode.System ? 0 : 1;
                    int keyState     = Settings.AddinRegMode == SingletonSettings.AddinRegMode.Off ? 0 : 1;

                    if (!new Dispatcher.UnRegisterMethod().Call(item,
                                                                installScope,
                                                                keyState))
                    {
                        return((int)ResultCodes.UnRegisterCallFailed);
                    }
                }
            }

            return((int)ResultCodes.Okay);
        }