コード例 #1
0
        /// <summary>
        /// Initialize the privateKey and perform a version compatibility check using the User-Agent header.
        /// </summary>
        public async Task <bool> Hello(IConfigAdapter config)
        {
            privateKey = config.Read("privateKey");
            if (String.IsNullOrEmpty(privateKey))
            {
                privateKey = Guid.NewGuid().ToString();
                config.Write("privateKey", privateKey);
            }

            logger("Checking if your version is still compatible with " + uploadUrl);
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", privateKey);
            try
            {
                var result = await httpClient.GetAsync(uploadUrl + "/logs/hello");

                logger(await result.Content.ReadAsStringAsync());
                IsReady = result.IsSuccessStatusCode;
                return(IsReady);
            }
            catch (Exception ex)
            {
                logger("Login failed: " + ex.Message);
                return(false);
            }
        }
コード例 #2
0
        public ApplicationManager(ApplicationManagerSettings settings)
        {
            _settings = settings;

            _config = new RegistryConfigAdapter(settings.CompanyName, settings.ApplicationName);
            _server = new NamedPipeServer();
            _server.ClientDisconnected      += OnClientConnectionDisconnected;
            _server.ReceivedCommand         += OnClientConnectionCommand;
            _server.ClientConnectionFailure += OnClientConnectionFailure;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: rumstil/eqlogparser
 public MainForm()
 {
     InitializeComponent();
     SetDoubleBuffered(lvFights, true);
     config = new RegConfigAdapter();
     //config = new XmlConfigAdapter();
     spells = new SpellParser();
     //parser.MinDate = DateTime.Parse("2020-09-27");
     fightsQueue = new ConcurrentQueue <FightInfo>();
     lootQueue   = new ConcurrentQueue <LootInfo>();
     fightList   = new List <FightInfo>(2000);
     fightStatus = new Dictionary <string, string>();
     lootList    = new List <LootInfo>();
     uploader    = new Uploader(LogInfo);
     _           = ProcessEventsAsync();
 }
コード例 #4
0
        /// <summary>
        /// Führen Sie die Vorgänge aus, um den Dienst zu starten.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            Config = (IConfigAdapter)ObjectFactory.CreateInstance("Suchwerk.Interface.IConfigAdapter");
            string DataPath = (string)Config.Load("DataPath", "NO");

            if (System.IO.Directory.Exists(DataPath))
            {
                System.IO.File.Delete(DataPath + "log.txt");
                LogFileListner = new MyTextWriterTraceListener(DataPath + "log.txt");
                Trace.Listeners.Add(LogFileListner);
            }
            Trace.AutoFlush = true;
            Debug.AutoFlush = true;

            Thread InitThread = new Thread(new ThreadStart(StartServer));

            InitThread.Start();
        }
コード例 #5
0
        private void SetToCache <TConfig>(IConfigAdapter adapter, TConfig config)
        {
            if (_ignoreCaching || _cacheProvider == null)
            {
                return;
            }

            var cacheKey = typeof(TConfig).FullName;

            var t = adapter.Expiration ?? _defaultExpiration;

            if (t <= TimeSpan.MinValue)
            {
                t = _defaultExpiration;
            }

            _cacheProvider.Set(cacheKey, config, t);
        }
コード例 #6
0
 public AdapterRegisterdException(IConfigAdapter adapter)
     : this(adapter.GetType())
 {
 }
コード例 #7
0
 internal static bool TryGetAdapter(ConfigFileFormat format, out IConfigAdapter adapter) =>
 Dic.TryGetValue(format, out adapter);
コード例 #8
0
 public static void AddAdapter(ConfigFileFormat format, IConfigAdapter adapter) =>
 Dic[format] = adapter ?? throw new ArgumentNullException(nameof(adapter));