예제 #1
0
        public MainConfiguration Load()
        {
            var config = new MainConfiguration();

            foreach (var path in _paths)
            {
                if (File.Exists(path))
                {
                    var json       = File.ReadAllText(path);
                    var pathConfig = JsonSerializer.Deserialize <SerializedConfiguration>(
                        json, new JsonSerializerOptions()
                    {
                        PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                    });
                    config.MixWith(pathConfig);
                }
            }

            foreach (var additionalConfig in _configs)
            {
                config.MixWith(additionalConfig);
            }

            return(config);
        }
예제 #2
0
        public void WebHookAuthMgr(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
        {
            MainConfiguration cfg = MainConfiguration.Instance;

            MHE(source, client, "Checking..");


            if (cfg.Authed(additionalArgs[0]))
            {
                if (additionalArgs[1] == "y")
                {
                    MHE(source, client, "Not modified. Already authorized");
                }
                else
                {
                    MHE(source, client, "Authorization revoked - git alerts from this user will not be whitelisted");
                    cfg.AuthedGithubUsers.Remove(additionalArgs[0]);
                }
            }
            else
            {
                if (additionalArgs[1] == "y")
                {
                    cfg.AuthedGithubUsers.Add(additionalArgs[0]);
                    MHE(source, client, "Authorized.");
                }
                else
                {
                    MHE(source, client, "Not modified. Already  not whitelisted");
                }
            }


            cfg.Save();
        }
예제 #3
0
 public Shell(MainConfiguration config)
 {
     _cfg         = config;
     _innerShells = new Dictionary <string, IInnerShell>();
     _context     = new ShellContext(config.StartupPath);
     _current     = null;
 }
 public PersonService(LocalizationService locService)
 {
     this.locService           = locService;
     screenService             = new ScreenService(locService);
     personValidationService   = new PersonValidationService(locService);
     personWithCovidRepository = new PersonWithCovidRepository();
     fileRepository            = new FileRepository();
     mainConfiguration         = new MainConfiguration();
 }
예제 #5
0
        static void Main(string[] args)
        {
            var config = new MainConfiguration();

            //var config = new MainConfiguration()
            //{
            //    LocalDatabases = new Dictionary<string, string>()
            //    {
            //        {"Bombardier","C:\\Databases\\BombardierDatabase.json"},
            //        {"Kaneko","C:\\Databases\\KanekoDatabase.json"}
            //    }
            //};

            ConfigureService.Configure(config);
        }
        public static IServiceCollection RegisterNotificationHandler <TNotification, THandler>(this IServiceCollection services)
            where THandler : INotificationHandler <TNotification>
            where TNotification : INotification
        {
            Type messageType = typeof(Message <TNotification>);

            MessageMapping mapping = new MessageMapping(messageType,
                                                        typeof(TNotification),
                                                        typeof(THandler),
                                                        typeof(INotificationHandler <TNotification>),
                                                        typeof(NotificationHandlerWrapper <TNotification>));

            MainConfiguration.AddMapping(mapping);
            services.TryAddTransient(mapping.HandlerInterfaceType, mapping.HandlerType);

            return(services);
        }
예제 #7
0
 internal static void Configure(MainConfiguration config)
 {
     HostFactory.Run(configure =>
     {
         configure.Service <MainEntry>(service =>
         {
             service.ConstructUsing(s => new MainEntry(config));
             service.WhenStarted(s => s.Start());
             service.WhenStopped(s => s.Stop());
         });
         //Setup Account that window service use to run.
         configure.RunAsLocalSystem();
         configure.SetDescription("Client-Viewer-SelfHost");
         configure.SetDisplayName("Client-Viewer-SelfHost");
         configure.SetServiceName("Client-Viewer");
     });
 }
예제 #8
0
        public Service()
        {
            ServiceName = SERVICE_NAME;

            POGOLib.Logging.Logger.RegisterLogOutput((level, msg) =>
            {
                log.Info($"POGOLib, {level} - {msg}");
            });

            instances = new List <PogoInstance>();
            var mainConfiguration = MainConfiguration.Load();

            foreach (var configuration in mainConfiguration.Instances)
            {
                configuration.MainConfiguration = mainConfiguration;
                instances.Add(new PogoInstance(configuration));
            }
        }
        public static IServiceCollection RegisterCommandHandler <TCommand, THandler, TResult>(this IServiceCollection services)
            where THandler : ICommandHandler <TCommand, TResult>
            where TCommand : ICommand <TResult>
        {
            Type messageType = typeof(Message <TCommand>);

            MessageMapping mapping = new MessageMapping(messageType,
                                                        typeof(TCommand),
                                                        typeof(TResult),
                                                        typeof(THandler),
                                                        typeof(ICommandHandler <TCommand, TResult>),
                                                        typeof(CommandHandlerWrapper <TCommand, TResult>));

            MainConfiguration.AddMapping(mapping);
            services.TryAddTransient(mapping.HandlerInterfaceType, mapping.HandlerType);

            return(services);
        }
예제 #10
0
        public PokemonGoService()
        {
            var config = MainConfiguration.Load();

            pogoInstances = new List <PogoInstance>(config.Instances.Count);

            foreach (var instance in config.Instances)
            {
                instance.MainConfiguration = config;

                var walker        = new Walker(instance.WalkingPoints);
                var startPosition = walker.GetNextPosition();

                var session = Login.GetSession(instance.Username, instance.Password, instance.LoginProvider, startPosition.Latitude, startPosition.Longitude);

                var pogoInstance = new PogoInstance(instance, session, walker);
                pogoInstances.Add(pogoInstance);
            }
        }
예제 #11
0
 public static void LoadMessages()
 {
     if (Messages.Count == 0)
     {
         string messagesPath = MainConfiguration.GetSetting("LanguagesFile");
         try
         {
             using (StreamReader reader = new StreamReader(messagesPath))
             {
                 string contents = reader.ReadToEnd();
                 Messages = SimpleJson
                            .DeserializeObject <
                     Dictionary <string, Dictionary <string, Dictionary <string, string> > > >(
                     contents);
             }
         }
         catch (FileNotFoundException fileNotFoundException)
         {
             Debug.Log("LoadMessages" + fileNotFoundException);
         }
     }
 }
예제 #12
0
 public PersonWithCovidRepository()
 {
     mainConfiguration = new MainConfiguration();
     fileRepository    = new FileRepository();
     persons           = AddPeopleWithCovidAlready();
 }
 public FileRepository()
 {
     mainConfiguration = new MainConfiguration();
 }