예제 #1
0
        private async Task WatchComponent(ComponentSettings settings)
        {
            var bundler = new AutoComponentBundler(settings);

            bundler.BundlingStart += () =>
            {
                _logger.Print("</package/> Bundling...");
            };
            bundler.BundlingEnd += (bInfo) =>
            {
                _logger.Print("CSS </checkmark/> bundled");
                _logger.Print("</filefolder/> Assembly path: " + bInfo.PathToBundledAssembly);
                _logger.Print("</page_facing_up/> Combined files count: " + bInfo.CombinedFilesCount);
                _logger.Print("</clock/> Bundling time: " + bInfo.BundlingTime);
                Console.WriteLine();
            };
            bundler.BundlingError += (bInfo) =>
            {
                _logger.Print("CSS </crossmark/> builded");
                _logger.Print("</page_facing_up/> Combined files count: " + bInfo.CombinedFilesCount);
                _logger.Print("</clock/> Bundling time: " + bInfo.BundlingTime);
                foreach (Error err in bInfo.Errors)
                {
                    _logger.PrintError(err.Name + ": " + err.Message);
                }
                Console.WriteLine();
            };

            _logger.Print("Watching...");
            await bundler.StartWatchingAsync();

            await Task.Delay(Timeout.Infinite); // Infinity because we need infinity watching
        }
        public void HandleSplitZonesTest()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.SplitZones.Add(LIONEYES1);
            settings.SplitLevels.Add(2);
            MockTimerModel timer = new MockTimerModel();

            LoadRemoverSplitter splitter = new LoadRemoverSplitter(timer, settings);

            splitter.HandleLoadStart(1);
            splitter.HandleLoadEnd(2, "Lioneye's Watch");
            Assert.AreEqual(1, timer.NumSplits);
            // Wrong zone.
            splitter.HandleLoadStart(3);
            splitter.HandleLoadEnd(4, "The Coast");
            Assert.AreEqual(1, timer.NumSplits);
            // Not splitting on levels.
            splitter.HandleLevelUp(5, 2);
            Assert.AreEqual(1, timer.NumSplits);
            // Already entered this zone.
            splitter.HandleLoadStart(6);
            splitter.HandleLoadEnd(7, "Lioneye's Watch");
            Assert.AreEqual(1, timer.NumSplits);
        }
예제 #3
0
        public void CancelTest()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.AutoSplitEnabled   = false;
            settings.LoadRemovalEnabled = true;
            settings.LabSplitType       = ComponentSettings.LabSplitMode.Trials;
            settings.GenerateWithIcons  = false;
            settings.CriteriaToSplit    = ComponentSettings.SplitCriteria.Levels;
            settings.SplitZones.Add(Zone.ZONES[0]);
            settings.SplitZoneLevels.Add(70);
            settings.SplitLevels.Add(100);

            // Emulate a cancel.
            XmlDocument xml = new XmlDocument();

            settings.SetSettings(new ComponentSettings().GetSettings(xml));
            Assert.IsTrue(settings.AutoSplitEnabled);
            Assert.IsFalse(settings.LoadRemovalEnabled);
            Assert.AreEqual(ComponentSettings.LabSplitMode.AllZones, settings.LabSplitType);
            Assert.IsTrue(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Zones, settings.CriteriaToSplit);
            Assert.AreEqual(0, settings.SplitZones.Count);
            Assert.AreEqual(0, settings.SplitZoneLevels.Count);
            Assert.AreEqual(0, settings.SplitLevels.Count);
        }
        public void Part1Part2Test()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.SplitZones.Add(LIONEYES1);
            settings.SplitZones.Add(LIONEYES2);
            MockTimerModel timer = new MockTimerModel();

            LoadRemoverSplitter splitter = new LoadRemoverSplitter(timer, settings);

            splitter.HandleLoadStart(1);
            splitter.HandleLoadEnd(2, "Lioneye's Watch");
            Assert.AreEqual(1, timer.NumSplits);
            // Already entered and still considered part 1.
            splitter.HandleLoadStart(3);
            splitter.HandleLoadEnd(4, "Lioneye's Watch");
            Assert.AreEqual(1, timer.NumSplits);
            // Enter the prerequisite zone.
            splitter.HandleLoadStart(5);
            splitter.HandleLoadEnd(6, "The Cathedral Rooftop");
            Assert.AreEqual(1, timer.NumSplits);
            // Now considered to be entering part 2.
            splitter.HandleLoadStart(7);
            splitter.HandleLoadEnd(8, "Lioneye's Watch");
            Assert.AreEqual(2, timer.NumSplits);
        }
        public void LabOnlyTrialsTest()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.CriteriaToSplit = ComponentSettings.SplitCriteria.Labyrinth;
            settings.LabSplitType    = ComponentSettings.LabSplitMode.Trials;
            MockTimerModel timer = new MockTimerModel();

            LoadRemoverSplitter splitter = new LoadRemoverSplitter(timer, settings);

            // Enter Aspirants' Plaza.
            splitter.HandleLoadStart(3);
            splitter.HandleLoadEnd(4, "Aspirants' Plaza");
            // Activated lab device.
            splitter.HandleIzaroDialogue(6, "Justice will prevail.");
            Assert.AreEqual(1, timer.NumStarts);
            Assert.AreEqual(0, timer.NumSplits);
            // Run through an intermediate lab zone.
            splitter.HandleLoadStart(7);
            splitter.HandleLoadEnd(8, "...");
            Assert.AreEqual(0, timer.NumSplits);
            // Arrive at Aspirant's Trial.
            splitter.HandleLoadStart(8);
            splitter.HandleLoadEnd(9, "Aspirant's Trial");
            Assert.AreEqual(1, timer.NumSplits);
            splitter.HandleLoadStart(10);
            splitter.HandleLoadEnd(11, "Aspirant's Trial");
            Assert.AreEqual(2, timer.NumSplits);
            // Izaro death
            splitter.HandleIzaroDialogue(12, "You are free!");
            Assert.AreEqual(3, timer.NumSplits);
        }
        static async Task Main(string[] args)
        {
            var settings = new ComponentSettings
            {
                Id         = -1,
                Name       = "selfHosted",
                Properties = new Dictionary <string, string>
                {
                    { "masterConfigurationFile", "NodeManagerComponentWebConfig.json" }
                }
            };

            var serverConfigFile = settings.Properties["masterConfigurationFile"];

            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Environment.CurrentDirectory)
                                .AddJsonFile(serverConfigFile, optional: false, reloadOnChange: true)
                                .AddEnvironmentVariables()
                                .Build();

            await new NodeManagerComponent(settings, null)
            .StartAsync(CancellationToken.None);

            Console.ReadLine();
        }
예제 #7
0
        internal Task <Type[]> InitializeAndGetSupportedContractsAsync(ComponentSettings settings)
        {
            return(ThreadHelper.RunInNewThreadAsync(async() =>
            {
                // operation context emulation, since InitializeAsync often uses context-dependent methods
                using (var context = new ComponentOperationContext(this, InitializeOperationName))
                {
                    try
                    {
                        Status.SetSelfStatus(ComponentStatusCodeEnum.Disabled, "Initializing...");
                        await InitializeAsync(new ComponentInitializeRequest(settings), context);
                    }
                    catch (Exception ex)
                    {
                        Status.SetSelfStatus(ComponentStatusCodeEnum.Error, $"Initialization failed: {ex.Message}");
                        context.Log.Error(LogContextEnum.Configuration, "Unhandled exception.", ex, callerName: null);
                    }

                    try
                    {
                        return GetSupportedContracts();
                    }
                    catch (Exception ex)
                    {
                        context.Log.Error(LogContextEnum.Configuration, "Unhandled exception.", ex, callerName: nameof(GetSupportedContracts));
                        return null;
                    }
                }
            }));
        }
        public static TSetting Get <TSetting>(this ComponentSettings componentSettings, string settingName, bool mandatory = true)
        {
            Assure.ArgumentNotNull(settingName, nameof(settingName));

            var value = componentSettings.GetValueOrDefault(settingName);

            if (value == null)
            {
                if (mandatory)
                {
                    throw new KeyNotFoundException($"Setting '{settingName}' was not found.");
                }

                return(default(TSetting));
            }

            var valueType = typeof(TSetting);

            if (valueType == typeof(string))
            {
                return((TSetting)(object)value);
            }

            var nullableUnderlyingType = Nullable.GetUnderlyingType(valueType);

            if (nullableUnderlyingType != null)
            {
                valueType = nullableUnderlyingType;
            }

            return((TSetting)Convert.ChangeType(value, valueType));
        }
예제 #9
0
        object fetchObject(Type t, Func <object, int, bool> test, string src)
        {
            IList objects = null;

            if (src != null)
            {
                var containerType = PluginManager.LocateType(src);
                if (containerType != null)
                {
                    objects = (IList)ComponentSettings.GetCurrent(containerType);
                }
            }

            if (objects == null)
            {
                objects = ComponentSettingsList.GetContainer(t);
            }

            var exact = objects.Cast <object>().Where(test).Where(o => o.GetType().DescendsTo(t)).FirstOrDefault();

            if (exact != null)
            {
                return(exact);
            }

            return(objects.Cast <object>().FirstOrDefault(x => x.GetType().DescendsTo(t)));
        }
예제 #10
0
        public void CancelMissingPropsTest()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.AutoSplitEnabled   = false;
            settings.LoadRemovalEnabled = true;
            settings.LabSplitType       = ComponentSettings.LabSplitMode.Trials;
            settings.GenerateWithIcons  = false;
            settings.CriteriaToSplit    = ComponentSettings.SplitCriteria.Labyrinth;
            settings.SplitZones.Add(Zone.ZONES[0]);
            settings.SplitZoneLevels.Add(70);
            settings.SplitLevels.Add(100);

            // Emulate a cancel where the properties were fetched from file.
            // Never has been observed but we'll handle it anyways.
            XmlDocument xml = new XmlDocument();

            xml.LoadXml("<AutoSplitterSettings><load.removal>True</load.removal></AutoSplitterSettings>");
            XmlNode nodeSettings = xml.FirstChild;

            settings.SetSettings(nodeSettings);
            Assert.IsTrue(settings.AutoSplitEnabled);
            Assert.IsTrue(settings.LoadRemovalEnabled);
            Assert.AreEqual(ComponentSettings.LabSplitMode.AllZones, settings.LabSplitType);
            Assert.IsTrue(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Zones, settings.CriteriaToSplit);
            Assert.AreEqual(0, settings.SplitZones.Count);
            Assert.AreEqual(0, settings.SplitZoneLevels.Count);
            Assert.AreEqual(0, settings.SplitLevels.Count);
        }
예제 #11
0
        public void SetSettingsWithLegacyLabTest()
        {
            XmlDocument xml = new XmlDocument();

            xml.LoadXml(
                @"<AutoSplitterSettings>
   <log.location>C:\Program Files (x86)\Grinding Gear Games\Path of Exile\logs\Client.txt</log.location>
   <load.removal>False</load.removal>
   <auto.split>True</auto.split>
   <split.labyrinth>True</split.labyrinth>
   <split.criteria>Levels</split.criteria>
   <split.zones.on>
      <split.zone>Lioneye's Watch (Part 1)</split.zone>
      <split.zone>The Mud Flats (Part 1)</split.zone>
      <split.zone>The Ledge (Part 1)</split.zone>
   </split.zones.on>
   <split.levels.on>
      <split.level>3</split.level>
   </split.levels.on>
</AutoSplitterSettings>");
            XmlNode           nodeSettings = xml.FirstChild;
            ComponentSettings settings     = new ComponentSettings();

            settings.SetSettings(nodeSettings);
            Assert.IsTrue(settings.AutoSplitEnabled);
            Assert.IsFalse(settings.LoadRemovalEnabled);
            Assert.IsTrue(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Labyrinth, settings.CriteriaToSplit);
            Assert.AreEqual(3, settings.SplitZones.Count);
            Assert.AreEqual(0, settings.SplitZoneLevels.Count);
            Assert.AreEqual(1, settings.SplitLevels.Count);
            Assert.AreEqual(@"C:\Program Files (x86)\Grinding Gear Games\Path of Exile\logs\Client.txt", settings.LogLocation);
        }
예제 #12
0
        public void SetSettingsBeforeLevelChangesTest()
        {
            XmlDocument xml = new XmlDocument();

            xml.LoadXml(
                @"<AutoSplitterSettings>
   <log.location>C:/Program Files (x86)/Grinding Gear Games/Path of Exile/logs/client.txt</log.location>
   <load.removal>True</load.removal>
   <auto.split>True</auto.split>
   <split.labyrinth>False</split.labyrinth>
   <split.zones.on>
      <split.zone>Lioneye's Watch (Part 1)</split.zone>
      <split.zone>Oriath Docks (Part 2)</split.zone>
   </split.zones.on>
</AutoSplitterSettings>");
            XmlNode           nodeSettings = xml.FirstChild;
            ComponentSettings settings     = new ComponentSettings();

            settings.SetSettings(nodeSettings);
            Assert.IsTrue(settings.AutoSplitEnabled);
            Assert.IsTrue(settings.LoadRemovalEnabled);
            Assert.AreEqual(ComponentSettings.LabSplitMode.AllZones, settings.LabSplitType);
            Assert.IsTrue(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Zones, settings.CriteriaToSplit);
            Assert.AreEqual(2, settings.SplitZones.Count);
            Assert.AreEqual(0, settings.SplitZoneLevels.Count);
            Assert.AreEqual(0, settings.SplitLevels.Count);
            Assert.AreEqual("C:/Program Files (x86)/Grinding Gear Games/Path of Exile/logs/client.txt", settings.LogLocation);
        }
예제 #13
0
        public void GetAndSetCustomSettingsTest()
        {
            XmlDocument       xml      = new XmlDocument();
            ComponentSettings settings = new ComponentSettings();

            settings.AutoSplitEnabled   = false;
            settings.LoadRemovalEnabled = true;
            settings.LabSplitType       = ComponentSettings.LabSplitMode.Trials;
            settings.GenerateWithIcons  = false;
            settings.CriteriaToSplit    = ComponentSettings.SplitCriteria.Levels;
            settings.SplitZones.Add(Zone.ZONES[0]);
            settings.SplitZoneLevels.Add(70);
            settings.SplitLevels.Add(100);
            XmlNode node = settings.GetSettings(xml);

            settings = new ComponentSettings();
            settings.SetSettings(node);
            Assert.IsFalse(settings.AutoSplitEnabled);
            Assert.IsTrue(settings.LoadRemovalEnabled);
            Assert.AreEqual(ComponentSettings.LabSplitMode.Trials, settings.LabSplitType);
            Assert.IsFalse(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Levels, settings.CriteriaToSplit);
            Assert.IsTrue(new HashSet <IZone> {
                Zone.ZONES[0]
            }.SetEquals(settings.SplitZones));
            Assert.IsTrue(new HashSet <int> {
                70
            }.SetEquals(settings.SplitZoneLevels));
            Assert.IsTrue(new HashSet <int> {
                100
            }.SetEquals(settings.SplitLevels));
        }
        public void LabOnlyPlazaResetAllZones()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.CriteriaToSplit = ComponentSettings.SplitCriteria.Labyrinth;
            settings.LabSplitType    = ComponentSettings.LabSplitMode.AllZones;
            MockTimerModel timer = new MockTimerModel();

            LoadRemoverSplitter splitter = new LoadRemoverSplitter(timer, settings);

            // Enter Aspirants' Plaza.
            splitter.HandleLoadStart(3);
            splitter.HandleLoadEnd(4, "Aspirants' Plaza");
            // Activated lab device.
            splitter.HandleIzaroDialogue(6, "Justice will prevail.");
            Assert.AreEqual(1, timer.NumStarts);
            Assert.AreEqual(0, timer.NumSplits);
            // Run through an intermediate lab zone.
            splitter.HandleLoadStart(7);
            splitter.HandleLoadEnd(8, "...");
            Assert.AreEqual(1, timer.NumSplits);
            // Enter Aspirants' Plaza resets timer
            splitter.HandleLoadStart(9);
            splitter.HandleLoadEnd(10, "Aspirants' Plaza");
            Assert.AreEqual(0, timer.NumStarts);
            Assert.AreEqual(0, timer.NumSplits);
        }
        public void LabAllZonesTest()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.CriteriaToSplit = ComponentSettings.SplitCriteria.Labyrinth;
            MockTimerModel timer = new MockTimerModel();

            LoadRemoverSplitter splitter = new LoadRemoverSplitter(timer, settings);

            splitter.HandleIzaroDialogue(1, "...");
            Assert.AreEqual(0, timer.NumStarts);
            // Enter Aspirants' Plaza.
            splitter.HandleLoadStart(3);
            splitter.HandleLoadEnd(4, "Aspirants' Plaza");
            Assert.AreEqual(0, timer.NumSplits);
            // Intro Izaro dialogue.
            splitter.HandleIzaroDialogue(5, "You stand before the gates of the lord's labyrinth. Within these walls the Lady of Justice doth preside. She shall weigh your mind in one hand, your heart another. Should she find you wanting, death will be your sentence. Should she find you worthy, you will be given the loyalty and love of an empire. Choose wisely. Strike quickly. Trust completely. And may you find the ending that you deserve.");
            Assert.AreEqual(0, timer.NumStarts);
            // Activated lab device.
            splitter.HandleIzaroDialogue(6, "Justice will prevail.");
            Assert.AreEqual(1, timer.NumStarts);
            Assert.AreEqual(0, timer.NumSplits);
            // Run through some zones.
            splitter.HandleLoadStart(7);
            splitter.HandleLoadEnd(8, "...");
            Assert.AreEqual(1, timer.NumSplits);
            splitter.HandleLoadStart(8);
            splitter.HandleLoadEnd(9, "...");
            Assert.AreEqual(2, timer.NumSplits);
            // Izaro death
            splitter.HandleIzaroDialogue(10, "I die for the Empire!");
            Assert.AreEqual(3, timer.NumSplits);
        }
예제 #16
0
        public void TestPortSerialization()
        {
            var currentSettingsDir = ComponentSettings.GetSettingsDirectory("Bench");

            // Try to invoke the ComponentSettings serializer/deserializer for connections
            // Important thing is that a TestPort is still a TestPort after serialization.
            ComponentSettings.SetSettingsProfile("Bench", "test1");
            InstrumentSettings.Current.ToList();
            TestPortInstrument Instr = new TestPortInstrument();

            InstrumentSettings.Current.Add(Instr);
            RfConnection conn = new RfConnection()
            {
                Port1 = Instr.Port1, Port2 = Instr.Port2
            };

            ConnectionSettings.Current.Clear();
            ConnectionSettings.Current.Add(conn);
            ComponentSettings.SaveAllCurrentSettings();
            ComponentSettings.SetSettingsProfile("Bench", "test2");
            InstrumentSettings.Current.ToList(); // make componentsettings reload.
            ComponentSettings.SetSettingsProfile("Bench", "test1");

            var instr2 = InstrumentSettings.Current.OfType <TestPortInstrument>().First();

            Assert.IsFalse(object.ReferenceEquals(instr2, Instr));
            Instr = instr2;
            conn  = ConnectionSettings.Current.OfType <RfConnection>().First(con => (con.Port1 is TestPort));

            // Now try to serialize a test plan with a Port inside it.
            try
            {
                TestPlan plan = new TestPlan {
                };
                plan.ChildTestSteps.Add(new TestPortStep()
                {
                    SelectedPort = Instr.Port1
                });
                TestPlan newplan;

                using (var str = new MemoryStream(1000))
                {
                    plan.Save(str);
                    str.Position = 0;
                    newplan      = TestPlan.Load(str, plan.Path);
                }
                TestPortStep step = (TestPortStep)newplan.ChildTestSteps.First();
                Assert.IsTrue(step.SelectedPort is TestPort);
            }
            finally
            {
                // Cleanup
                ConnectionSettings.Current.Remove(conn);
                InstrumentSettings.Current.Remove(Instr);
                ComponentSettings.SaveAllCurrentSettings();

                ComponentSettings.SetSettingsProfile("Bench", currentSettingsDir);
            }
        }
예제 #17
0
        public void TestComponentSettingsCtorIfStringIsEmpty()
        {
            var settings           = string.Empty;
            var componentSettings2 = new ComponentSettings(settings);

            Assert.False(componentSettings2.IsCity);
            Assert.False(componentSettings2.IsEmail);
            Assert.False(componentSettings2.IsGender);
            Assert.False(componentSettings2.IsPhone);
            Assert.False(componentSettings2.IsStreet);
        }
예제 #18
0
        public void TestComponentSettingsCtorIfStringHasFullParameters()
        {
            var settings           = "City,Street,Email,Gender,Phone";
            var componentSettings3 = new ComponentSettings(settings);

            Assert.True(componentSettings3.IsCity);
            Assert.True(componentSettings3.IsEmail);
            Assert.True(componentSettings3.IsGender);
            Assert.True(componentSettings3.IsPhone);
            Assert.True(componentSettings3.IsStreet);
        }
예제 #19
0
        public void TestComponentSettingsCtorIfStringIsNull()
        {
            string settings          = null;
            var    componentSettings = new ComponentSettings(settings);

            Assert.False(componentSettings.IsCity);
            Assert.False(componentSettings.IsEmail);
            Assert.False(componentSettings.IsGender);
            Assert.False(componentSettings.IsPhone);
            Assert.False(componentSettings.IsStreet);
        }
예제 #20
0
파일: Config.cs 프로젝트: jijicanyu/Eir
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine("PHP Settings: ");
            sb.AppendLine(PHPSettings.ToString());
            sb.AppendLine("Graph Settings: ");
            sb.AppendLine(GraphSettings.ToString());
            sb.AppendLine("Component Settings:");
            sb.AppendLine(ComponentSettings.ToString());
            return(sb.ToString());
        }
        private static string GetValueOrDefault(this ComponentSettings componentSettings, string key)
        {
            Assure.ArgumentNotNull(key, nameof(key));

            if (componentSettings == null)
            {
                return(null);
            }

            return(componentSettings.ContainsKey(key)
                ? componentSettings[key]
                : null);
        }
예제 #22
0
        public static void SetSettingsDir(string dir)
        {
            ComponentSettings.PersistSettingGroups = false;
            string settingsSetDir = Path.Combine(ComponentSettings.SettingsDirectoryRoot, "Bench", dir);

            if (dir != "Default" && !Directory.Exists(settingsSetDir))
            {
                Console.WriteLine("Could not find settings directory \"{0}\"", settingsSetDir);
                RunCliAction.Exit(ExitStatus.ArgumentError);
            }
            ComponentSettings.SetSettingsProfile("Bench", dir);
            log.TraceInformation("Settings: " + ComponentSettings.GetSettingsDirectory("Bench"));
        }
        public void NoSplitWhenInLabModeTest()
        {
            ComponentSettings settings = new ComponentSettings();

            settings.CriteriaToSplit = ComponentSettings.SplitCriteria.Labyrinth;
            settings.SplitLevels.Add(10);
            MockTimerModel timer = new MockTimerModel();

            LoadRemoverSplitter splitter = new LoadRemoverSplitter(timer, settings);

            // Lab mode disables other autosplitting behaviour.
            splitter.HandleLevelUp(1, 10);
            Assert.AreEqual(0, timer.NumSplits);
        }
예제 #24
0
        public static IComponentSettings ToComponentSettings(this IServiceConfiguration configuration)
        {
            var settings = new ComponentSettings
            {
                Name       = configuration.Name,
                Properties = configuration.Properties.ToDictionary(kv => kv.Key, kv => kv.Value)
            };

            if (settings.Properties.TryGetValue("id", out string id) && long.TryParse(id, out long numericId))
            {
                settings.Id = numericId;
            }

            return(settings);
        }
        public void GetAndSetDefaultSettingsTest()
        {
            XmlDocument       xml      = new XmlDocument();
            ComponentSettings settings = new ComponentSettings();
            XmlNode           node     = settings.GetSettings(xml);

            settings = new ComponentSettings();
            settings.SetSettings(node);
            Assert.IsTrue(settings.AutoSplitEnabled);
            Assert.IsFalse(settings.LoadRemovalEnabled);
            Assert.AreEqual(ComponentSettings.LabSplitMode.AllZones, settings.LabSplitType);
            Assert.IsTrue(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Zones, settings.CriteriaToSplit);
            Assert.AreEqual(0, settings.SplitZones.Count);
            Assert.AreEqual(0, settings.SplitLevels.Count);
        }
예제 #26
0
 protected void AddComponents(IComponent tabComponent = null)
 {
     foreach (var component in Layout.Components)
     {
         var settingsControl = component.GetSettingsControl(Layout.Mode);
         if (settingsControl != null)
         {
             AddNewTab(component.ComponentName, settingsControl);
             ComponentSettings.Add(component.GetSettings(new XmlDocument()));
             Components.Add(component);
             if (component == tabComponent)
             {
                 tabControl.SelectTab(tabControl.TabPages.Count - 1);
             }
         }
     }
 }
예제 #27
0
        /// <summary> Deserialization implementation. </summary>
        public override bool Deserialize(XElement element, ITypeData t, Action <object> setter)
        {
            if (t.DescendsTo(TypeData.FromType(typeof(IConstResourceProperty))))
            {
                if (element.IsEmpty)
                {
                    return(true);                 // Dont do anything with a <port/>
                }
                var name = element.Attribute("Name");
                if (name == null)
                {
                    return(true);
                }
                Serializer.Deserialize(element.Element("Device"), obj =>
                {
                    var resource = obj as IResource;

                    if (obj is ComponentSettings)
                    {  // for legacy support. type argument was a component settings, not a device. In this case used index to get the resource.
                        obj     = ComponentSettings.GetCurrent(obj.GetType());
                        var lst = (IList)obj;
                        var dev = element.Element("Device");
                        if (dev != null && int.TryParse(dev.Value, out int index) && index >= 0 && lst.Count > index)
                        {
                            resource = ((IList)obj)[index] as IResource;
                        }
                    }
                    if (resource == null)
                    {
                        return;
                    }


                    foreach (var resProp in resource.GetConstProperties())
                    {
                        if (TypeData.GetTypeData(resProp).DescendsTo(t) && resProp.Name == name.Value)
                        {
                            setter(resProp);
                            return;
                        }
                    }
                }, typeof(IResource));
                return(true);
            }
            return(false);
        }
        public PixelSplitterComponent(LiveSplitState state)
        {
            this.state = state;

            var repoProvider  = new JsonBasedActionRepositoryProvider();
            var imageProvider = new CaptureDeviceGameImageProvider();


            settings = new ComponentSettings(state, repoProvider, imageProvider);
            var settingsProvider = new PixelSplitterSettingsProvider(settings);

            CaptureDeviceGameImageProvider.SettingsProvider = settingsProvider;

            controller = new LiveSplitController(this.state);

            actionMatcher = new ActionMatchComparer(new GameImageMatchComparer(), settingsProvider);
            runHandler    = new PixelSplitterRunHandler(controller, repoProvider, actionMatcher, imageProvider, settingsProvider);
        }
예제 #29
0
        public void SetDefaultSettingsTest()
        {
            XmlDocument xml = new XmlDocument();

            xml.LoadXml("<AutoSplitterSettings></AutoSplitterSettings>");
            XmlNode           nodeSettings = xml.FirstChild;
            ComponentSettings settings     = new ComponentSettings();

            settings.SetSettings(nodeSettings);
            Assert.IsTrue(settings.AutoSplitEnabled);
            Assert.IsFalse(settings.LoadRemovalEnabled);
            Assert.AreEqual(ComponentSettings.LabSplitMode.AllZones, settings.LabSplitType);
            Assert.IsTrue(settings.GenerateWithIcons);
            Assert.AreEqual(ComponentSettings.SplitCriteria.Zones, settings.CriteriaToSplit);
            Assert.AreEqual(0, settings.SplitZones.Count);
            Assert.AreEqual(0, settings.SplitZoneLevels.Count);
            Assert.AreEqual(0, settings.SplitLevels.Count);
        }
예제 #30
0
        public static IServiceCollection AddMaComponents(this IServiceCollection services, Action <IComponentSettings> config)
        {
            ComponentSettings cps = new ComponentSettings();

            cps.ServicesNamespace ??= new List <string>();
            config.Invoke(cps);
            services.AddSingleton <IComponentSettings>(cps);

            try
            {
                services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
                services.AddSingleton <Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor, Microsoft.AspNetCore.Mvc.Infrastructure.ActionContextAccessor>();
            }
            catch
            {
            }
            services.AddSingleton <IIMaComponent, IMaComponent>();
            return(services.AddScoped <RazorLightService>());
        }