Пример #1
0
        private static SyntaxNode LinkSettings(SettingsRoot root, Func <SettingsModel, Scope, SyntaxNode> parse, Scope scope)
        {
            var calls = new List <StatementSyntax>();

            foreach (var header in root.Headers)
            {
                foreach (var value in header.Values)
                {
                    if (value.Left.GetType() != typeof(IdentifierNameSyntax))
                    {
                        //td: error
                        continue;
                    }

                    var valueId = value.Left.ToString();
                    calls.Add(AddSetting.Get <StatementSyntax>(
                                  RoslynCompiler.Quoted(valueId),
                                  value.Right));
                }
            }

            var result = SettingClass.Get <ClassDeclarationSyntax>("__settings");

            return(result
                   .ReplaceNodes(result
                                 .DescendantNodes()
                                 .OfType <MethodDeclarationSyntax>(),
                                 (on, nn) => nn
                                 .AddBodyStatements(calls.ToArray())));
        }
Пример #2
0
        public SettingsRoot ProvideDefaultSettingsRoot()
        {
            var settings = new SettingsRoot(this);

            settings.PopulateWithDefaults();
            return(settings);
        }
Пример #3
0
        public void Write(SettingsRoot model)
        {
            var storageModel = Convert(model);

            storageModel.Version = CurrentStorageModelVersion;
            _blobStorage.Write(BlobContainer, Key, storageModel);
        }
Пример #4
0
        public void Save_Wraps_SerializationException_As_IOException()
        {
            // Arrange
            var         testBundle      = new SettingsRepositoryTestBundle();
            var         mockLog         = new Mock <ILog>();
            var         settings        = new SettingsRoot();
            var         testException   = new SerializationException("test exception");
            IOException thrownException = null;

            testBundle.MockLogProvider.Setup(x => x.GetLogger(It.IsAny <Type>())).Returns(mockLog.Object);
            testBundle.MockXmlSerializer.Setup(x => x.Serialize(It.IsAny <TextWriter>(), It.IsAny <object>())).Throws(testException);

            // Act
            try
            {
                testBundle.SettingsManager.Save(settings);
            }
            catch (IOException ex)
            {
                thrownException = ex;
            }

            // Assert
            testBundle.MockXmlSerializer.Verify(x => x.Serialize(It.IsAny <TextWriter>(), It.IsAny <object>()), Times.Once);
            Assert.IsNotNull(thrownException);
        }
Пример #5
0
        public SettingsRoot Load()
        {
            SettingsRoot settingsRoot = null;
            var          path         = GetSettingsFilePath();

            if (!_file.Exists(path))
            {
                _log.Warn(string.Format("Settings file \"{0}\" does not exist.", path));
            }
            else
            {
                _log.Info(string.Format("Settings file \"{0}\" used.", path));

                try
                {
                    using (var fileStream = _file.Open(path, FileMode.Open))
                    {
                        settingsRoot = (SettingsRoot)_serializer.Deserialize(fileStream);
                    }
                }
                catch (SerializationException e)
                {
                    _log.Error("Error opening settings file.", e);
                }
            }

            return(settingsRoot);
        }
Пример #6
0
    public static SettingsRoot getInstance()
    {
        if( Instance == null )
            Instance = new SettingsRoot();

        return Instance;
    }
Пример #7
0
 public void Validate(SettingsRoot root)
 {
     root.AssetPairs.RequiredNotNull("root.AssetPairs");
     foreach (var(assetPairId, pairSettings) in root.AssetPairs)
     {
         new AssetPairValidator(assetPairId, pairSettings, root).Validate();
     }
 }
 public void Set([NotNull] SettingsRoot settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException(nameof(settings));
     }
     lock (_updateLock) WriteUnsafe(Get(), settings);
 }
 public void DidChangeConfiguration(SettingsRoot settings)
 {
     Session.Settings = settings.WikitextLanguageServer;
     foreach (var doc in Session.DocumentStates.Values)
     {
         doc.RequestAnalysis();
     }
 }
Пример #10
0
 public async Task DidChangeConfiguration(SettingsRoot settings)
 {
     Session.Settings = settings.DemoLanguageServer;
     foreach (var doc in Session.Documents.Values)
     {
         var diag = Session.DiagnosticProvider.LintDocument(doc.Document, Session.Settings.MaxNumberOfProblems);
         await Client.Document.PublishDiagnostics(doc.Document.Uri, diag);
     }
 }
Пример #11
0
 public MmTestEnvironment(MmIntegrationalTestSuit suit) : base(suit)
 {
     Setup <ISettingsStorageService>(
         m => m.Setup(s => s.Read()).Returns(() => SettingsRoot),
         m => m.Setup(s => s.Write(It.IsNotNull <SettingsRoot>()))
         .Callback <SettingsRoot>(r => SettingsRoot = r))
     .Setup <IRabbitMqService>(StubRabbitMqService)
     .Setup <ISystem>(m => m.Setup(s => s.UtcNow).Returns(() => UtcNow))
     .Setup <IAssetsService>(m => m.Setup(s => s.GetAssetPairsWithHttpMessagesAsync(default, default))
Пример #12
0
 public IActionResult Set([FromBody] SettingsRoot settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException(nameof(settings));
     }
     _settingsRootService.Set(settings);
     return(Ok(new { success = true }));
 }
Пример #13
0
        public static void Main(string[] args)
        {
            Offsets offs;
            int     pid = FindPoeProcess(out offs);

            if (pid == 0)
            {
                MessageBox.Show("Path of Exile is not running!");
                return;
            }

            Sounds.PreLoadCommonSounds();

            OverlayRenderer overlay = null;

            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs exceptionArgs)
            {
                if (overlay != null)
                {
                    overlay.Detach();
                }
                MessageBox.Show("Program exited with message:\n " + exceptionArgs.ExceptionObject.ToString());
                Environment.Exit(1);
            };

            SettingsRoot settings = new SettingsRoot("config\\new_settings.txt");

            settings.ReadFromFile();             // 1st read for globals and menu

            using (Memory memory = new Memory(offs, pid))
            {
                offs.DoPatternScans(memory);
                GameController gameController = new GameController(memory);
                gameController.RefreshState();
                try
                {
                    Console.WriteLine("Starting overlay");
                    EventScheduler es = new EventScheduler(gameController);
                    settings.SetObserver((o, s) => es.RequestSave(settings));

                    TransparentDxOverlay transparentDXOverlay = new TransparentDxOverlay(gameController.Window, settings, es);
                    transparentDXOverlay.InitD3D();

                    overlay = new OverlayRenderer(gameController, settings, transparentDXOverlay.RC);
                    transparentDXOverlay.KeyPress += overlay.KeyPressOnForm;
                    Application.Run(transparentDXOverlay);
                }
                finally
                {
                    if (overlay != null)
                    {
                        overlay.Detach();
                    }
                }
            }
        }
Пример #14
0
 private void Change(Func <SettingsRoot, SettingsRoot> changeFunc)
 {
     lock (_updateLock)
     {
         var oldSettings = Get();
         var settings    = changeFunc(oldSettings);
         _settingsStorageService.Write(settings);
         _cache = settings;
     }
 }
        public async Task DidChangeConfiguration(SettingsRoot settings)
        {
            Session.Settings = settings.ReStructuredText;
            foreach (var doc in Session.DocumentStates.Values)
            {
                //Session.Project.RefreshDocument(doc.Document);
//                var diag = Session.DiagnosticProvider.LintDocument(doc.Document, Session.Settings.LanguageServer.MaxNumberOfProblems);
//                await Client.Document.PublishDiagnostics(doc.Document.Uri, diag);
            }
        }
Пример #16
0
 public void Dispose()
 {
     _root.SectionCollectionChanged -= OnRootSectionCollectionChanged;
     _root.CollectionChanged        -= OnRootCollectionChanged;
     _model   = null;
     _root    = null;
     _adapter = null;
     this?.Clear();
     ViewTypes?.Clear();
     ViewTypes = null;
 }
        public void Validate(SettingsRoot root)
        {
            root.OutdationCheckPeriod.RequiredBetween(TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(10),
                                                      "root.OutdationCheckPeriod");
            root.Exchanges.RequiredNotNull("root.AssetPairs");

            foreach (var(exchangeName, exchangeSettings) in root.Exchanges)
            {
                new ExchangesValidator(exchangeName, exchangeSettings).Validate();
            }
        }
Пример #18
0
        public ModelProxy(SettingsView settingsView, SettingsViewRecyclerAdapter adapter)
        {
            _model   = settingsView.Model;
            _root    = settingsView.Root;
            _adapter = adapter;

            _root.SectionCollectionChanged += OnRootSectionCollectionChanged;
            _root.CollectionChanged        += OnRootCollectionChanged;

            FillProxy();
        }
Пример #19
0
 public void Set([NotNull] SettingsRoot settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException(nameof(settings));
     }
     lock (_updateLock)
     {
         _settingsStorageService.Write(settings);
         _cache = settings;
     }
 }
Пример #20
0
        public void SaveSettings(SettingsRoot settings, string leagueJson, string settingsJson, string transactionsJson)
        {
            var context = new FantasyContext();

            foreach (var league in settings.FantasyContent.Leagues)
            {
                decimal pointsPerReception = 0.0M;
                decimal pointsPerPassingTd = 4.0M;

                string ppr, ppptd;

                try
                {
                    ppr = league.Settings.First()
                          .StatModifiers.ModifiedStats
                          .FirstOrDefault(s => s.ModifiedStat.StatId == 11)
                          .ModifiedStat.Value;
                }
                catch
                {
                    ppr = null;
                }

                try
                {
                    ppptd = league.Settings.First()
                            .StatModifiers.ModifiedStats
                            .FirstOrDefault(s => s.ModifiedStat.StatId == 5)
                            .ModifiedStat.Value;
                }
                catch
                {
                    ppptd = null;
                }

                Decimal.TryParse(ppr, out pointsPerReception);
                Decimal.TryParse(ppptd, out pointsPerPassingTd);

                var dbLeague = new YahooFantasy.Models.Simple.Trades.League
                {
                    LeagueKey                 = league.LeagueKey,
                    NumberOfOwners            = league.NumTeams,
                    LeagueJson                = leagueJson,
                    SettingsJson              = settingsJson,
                    TransactionsJson          = transactionsJson,
                    PointsPerPassingTouchdown = pointsPerPassingTd,
                    PointsPerReception        = pointsPerReception
                };

                context.Leagues.Add(dbLeague);
                context.SaveChanges();
            }
        }
        private void WriteUnsafe(SettingsRoot oldSettings, SettingsRoot settings)
        {
            _settingsValidationService.Validate(settings);
            var audit = _settingsChangesAuditService.GetAudit(oldSettings, settings);

            if (audit == null)
            {
                return;                // nothing changed
            }
            _settingsChangesAuditRepository.Insert(audit);
            _settingsStorageService.Write(settings);
            _cache = settings;
        }
Пример #22
0
        public async Task DidChangeConfiguration(SettingsRoot settings)
        {
            Program.logWriter.WriteLine("DidChangeConfiguration {0}", settings);
            Program.logWriter.WriteLine("DidChangeConfiguration MNOP {0}", settings.Setting.MaxNumberOfProblems);
            Session.Settings = settings.Setting;
            Program.logWriter.WriteLine("DidChangeConfiguration {0}", Session.Settings != null);

            foreach (var doc in Session.Documents.Values)
            {
                var diag = Session.DiagnosticProvider.LintDocument(doc.Document, Session.Settings.MaxNumberOfProblems);
                await Client.Document.PublishDiagnostics(doc.Document.Uri, diag);
            }
        }
 public void Initialize()
 {
     _cache = _settingsStorageService.Read()
              ?? new SettingsRoot(ImmutableSortedDictionary <string, AssetPairSettings> .Empty);
     try
     {
         _settingsValidationService.Validate(_cache);
     }
     catch (Exception e)
     {
         _alertService.AlertRiskOfficer(string.Empty, "Found invalid settings on service start: " + e.Message, EventTypeEnum.InvalidSettingsFound);
     }
 }
Пример #24
0
        public OverlayRenderer(GameController gameController, SettingsRoot settings, RenderingContext rc)
        {
            this.Settings       = settings;
            this.gameController = gameController;

            this.plugins = new List <HUDPlugin> {
                new HealthBarRenderer(),
                new ItemAlerter(),
                new MapIconsRenderer(gatherMapIcons),
                new AdvTooltopRenderer(),
                new MonsterTracker(),
                new PoiTracker(),
                new XPHRenderer(),
                new ClientHacks(),
        #if DEBUG
                //new ShowUiHierarchy(),
                //new MainAddresses(),
        #endif
                new PreloadAlert(),
                new DpsMeter(),
                // new FpsMeter(),
            };

            gameController.Area.OnAreaChange += (area) => {
                _modelUpdatePeriod = 6;
                foreach (var hudPlugin in plugins)
                {
                    hudPlugin.OnAreaChange(area);
                }
            };

            foreach (var plugin in plugins)
            {
                if (null != plugin.SettingsNode)
                {
                    Settings.AddModule(plugin.SettingsNode);
                }
            }
            if (Settings.Global.ShowIngameMenu)
            {
        #if !DEBUG
                this.plugins.Add(new Menu.Menu(settings));
        #endif
            }
            UpdateObserverLists();

            rc.RenderModules = this.rc_OnRender;

            this.plugins.ForEach(x => x.Init(gameController));
        }
Пример #25
0
        public static bool IsProjectUnitsFeet()
        {
            //IL_001b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0022: Invalid comparison between Unknown and I4
            SettingsRoot     settings        = CivilApplication.ActiveDocument.Settings;
            SettingsDrawing  drawingSettings = settings.DrawingSettings;
            SettingsUnitZone unitZone        = drawingSettings.UnitZoneSettings;

            if ((int)unitZone.DrawingUnits == 30)
            {
                return(true);
            }
            return(false);
        }
Пример #26
0
        public void CreateNewSettings_Returns_New_Object()
        {
            // Arrange
            var testBundle   = new SettingsRepositoryTestBundle();
            var settingsRoot = new SettingsRoot();

            testBundle.MockEntityProvider.Setup(x => x.ProvideDefaultSettingsRoot()).Returns(settingsRoot);

            // Act
            var settings = testBundle.SettingsManager.CreateNewSettings();

            // Assert
            Assert.AreSame(settingsRoot, settings);
            testBundle.MockEntityProvider.Verify(x => x.ProvideDefaultSettingsRoot(), Times.Once);
        }
Пример #27
0
        public void Save_Writes_To_Serializer()
        {
            // Arrange
            var testBundle = new SettingsRepositoryTestBundle();
            var mockLog    = new Mock <ILog>();
            var settings   = new SettingsRoot();

            testBundle.MockLogProvider.Setup(x => x.GetLogger(It.IsAny <Type>())).Returns(mockLog.Object);

            // Act
            testBundle.SettingsManager.Save(settings);

            // Assert
            testBundle.MockXmlSerializer.Verify(x => x.Serialize(It.IsAny <TextWriter>(), It.IsAny <object>()), Times.Once);
        }
Пример #28
0
        public TransparentDxOverlay(GameWindow window, SettingsRoot settings, EventScheduler es)
        {
            Settings = settings;
            InitializeComponent();
            BackColor         = Color.Black;
            this.window       = window;
            base.ShowIcon     = false;
            base.FormClosing += new FormClosingEventHandler(TransparentDXOverlay_FormClosing);
            string textForTitle = Settings.Global.WindowName;

            Text = String.IsNullOrWhiteSpace(textForTitle) ? "ExileHUD" : textForTitle;
            base.FormBorderStyle = FormBorderStyle.None;
            base.Load           += TransparentDXOverlay_Load;
            overseer             = es;
        }
        public void Initialize()
        {
            _cache = _settingsStorageService.Read()
                     ?? new SettingsRoot(ImmutableSortedDictionary <string, ExchangeSettings> .Empty,
                                         TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(10), false);

            try
            {
                _settingsValidationService.Validate(_cache);
            }
            catch (Exception e)
            {
                _alertService.AlertRiskOfficer(string.Empty, "Found invalid settings on service start: " + e.Message,
                                               EventTypeEnum.InvalidSettingsFound);
            }
        }
Пример #30
0
        private static HeaderModel ParseHeader(string value, SettingsRoot root, Scope scope)
        {
            var trimmed = value.Trim();

            if (trimmed.StartsWith("[") && trimmed.EndsWith("]"))
            {
                var sectionName = trimmed.Substring(1, trimmed.Length - 2);
                var result      = new HeaderModel {
                    Name = sectionName
                };
                root.Headers.Add(result);
                return(result);
            }

            //td: error
            return(null);
        }
Пример #31
0
        /// <summary>
        /// ImportBiztalkGroupSettings
        /// </summary>
        /// <param name="settingsWorker"></param>
        /// <param name="filePath"></param>
        private void ImportBizTalkGroupSettings(SettingsWorker settingsWorker, string filePath)
        {
            SettingsRoot groupSettings = BizTalkSettings.LoadBiztalkGroupSettings(filePath);


            try
            {
                ExportedSettings exportedSettings = new ExportedSettings();
                exportedSettings.ExportedGroup = String.Format("{0}:{1}", databaseName, databaseName);
                exportedSettings.GroupSettings = groupSettings;
                settingsWorker.ImportGroupSettings(exportedSettings);
            }

            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #32
0
    void Start()
    {
        // Checking for any aditional GameData Classes and destroying as needed:
        if ( FindObjectsOfType( typeof( SettingsRoot )).Length > 1 )
        {
            Debug.Log( "Only one instance of GameData is allowed, Distroying thsi instance." );
            DestroyImmediate(gameObject);
        }
        else if( Instance == null )
        {
            Instance = this;
            DontDestroyOnLoad( transform.gameObject );
            DontDestroyOnLoad( Instance );

        }
        //else
        //{
            //Debug.Log( "Error only one instance of this script can exsist at any one time" );
            //throw new ArgumentNullException();
        //}

        settingsData = SettingsData.getInstance();
    }
Пример #33
0
 public override void AttachToParent(SettingsRoot settingsRoot)
 {
     base.AttachToParent(settingsRoot);
     Global = settingsRoot.Global;
 }