コード例 #1
0
        public void Parse_InvalidAttributeValue_Throws()
        {
            var    xDocument = LoadXml("InvalidAttributeValue.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*Error parsing 'IsEnabled' value*");
        }
コード例 #2
0
ファイル: StroopMainForm.cs プロジェクト: blha303/STROOP
        public void LoadConfig(LoadingForm loadingForm)
        {
            int statusNum = 0;

            // Read configuration
            loadingForm.UpdateStatus("Loading main configuration", statusNum++);
            XmlConfigParser.OpenConfig(@"Config/Config.xml");
            loadingForm.UpdateStatus("Loading Miscellaneous Data", statusNum++);
            _miscData = XmlConfigParser.OpenWatchVarData(@"Config/MiscData.xml", "MiscDataSchema.xsd");
            loadingForm.UpdateStatus("Loading Object Data", statusNum++);
            _objectData = XmlConfigParser.OpenWatchVarData(@"Config/ObjectData.xml", "ObjectDataSchema.xsd", "objectOffset");
            loadingForm.UpdateStatus("Loading Object Associations", statusNum++);
            _objectAssoc = XmlConfigParser.OpenObjectAssoc(@"Config/ObjectAssociations.xml", _slotManagerGui);
            loadingForm.UpdateStatus("Loading Mario Data", statusNum++);
            _marioData = XmlConfigParser.OpenWatchVarData(@"Config/MarioData.xml", "MarioDataSchema.xsd", "marioOffset");
            loadingForm.UpdateStatus("Loading Camera Data", statusNum++);
            _cameraData = XmlConfigParser.OpenWatchVarData(@"Config/CameraData.xml", "CameraDataSchema.xsd");
            loadingForm.UpdateStatus("Loading HUD Data", statusNum++);
            _triangleData = XmlConfigParser.OpenWatchVarData(@"Config/TrianglesData.xml", "TrianglesDataSchema.xsd", "triangleOffset");
            loadingForm.UpdateStatus("Loading Triangles Data", statusNum++);
            _hudData = XmlConfigParser.OpenWatchVarData(@"Config/HudData.xml", "HudDataSchema.xsd");
            loadingForm.UpdateStatus("Loading Map Associations", statusNum++);
            _mapAssoc = XmlConfigParser.OpenMapAssoc(@"Config/MapAssociations.xml");
            loadingForm.UpdateStatus("Loading Scripts", statusNum++);
            _scriptParser = XmlConfigParser.OpenScripts(@"Config/Scripts.xml");
            loadingForm.UpdateStatus("Loading Hacks", statusNum++);
            _romHacks = XmlConfigParser.OpenHacks(@"Config/Hacks.xml");

            loadingForm.UpdateStatus("Finishing", statusNum);
        }
コード例 #3
0
        public override void ParseConfig(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                Logger.ErrorFormat("dynamic prediction error correction config is Empty");
                return;
            }

            var cfg = XmlConfigParser <DynamicPredictionErrorCorrectionConfig> .Load(xml);

            if (null == cfg)
            {
                Logger.ErrorFormat("dynamic prediction error correction config is illegal content:{0}", xml);
                return;
            }

            LinearDeltaThresholdSq  = cfg.LinearDeltaThresholdSq;
            LinearInterpAlpha       = cfg.LinearInterpAlpha;
            LinearRecipFixTime      = cfg.LinearRecipFixTime;
            AngularDeltaThreshold   = cfg.AngularDeltaThreshold;
            AngularInterpAlpha      = cfg.AngularInterpAlpha;
            AngularRecipFixTime     = cfg.AngularRecipFixTime;
            BodySpeedThresholdSq    = cfg.BodySpeedThresholdSq;
            BodyPositionThresholdSq = cfg.BodyPositionThresholdSq;
        }
コード例 #4
0
        public void Parse_VisibleMembersTypeNameAttributeMissing_Throws()
        {
            var    xDocument = LoadXml("VisibleMembersTypeNameAttributeMissing.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*'Name' attribute missing*");
        }
コード例 #5
0
        public void Parse_NsDepCopConfigElementNotFound_Throws()
        {
            var    xDocument = LoadXml("NsDepCopConfigElementNotFound.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*root element not found*");
        }
コード例 #6
0
        public void Parse_AllowedRuleForNamespaceWithVisibleMembersWithOfNamespaceAttribute_Throws()
        {
            var    xDocument = LoadXml("AllowedRuleForNamespaceWithVisibleMembersWithOfNamespaceAttribute.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*'OfNamespace' attribute must not be defined*");
        }
コード例 #7
0
        public void Parse_AllowedRuleToAttributeMissing_Throws()
        {
            var    xDocument = LoadXml("AllowedRuleToAttributeMissing.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*'To' attribute missing*");
        }
コード例 #8
0
        public void Parse_AllowedRuleForNamespaceTreeWithVisibleMembers_Throws()
        {
            var    xDocument = LoadXml("AllowedRuleForNamespaceTreeWithVisibleMembers.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*must be a single namespace*");
        }
コード例 #9
0
        public override void ParseConfig(string xml)
        {
            _configs.Clear();
            _transitions.Clear();
            StateTransitionConfig cfg = null;

            try
            {
                cfg = XmlConfigParser <StateTransitionConfig> .Load(xml);
            }
            catch (Exception e)
            {
                Logger.Error("error : " + e.ToString());
            }
            foreach (var item in cfg.Items)
            {
                item.vsTransition = new bool[(int)Transition.Length];

                foreach (var transition in item.Transitions)
                {
                    item.vsTransition[(int)transition] = true;
                }

                _configs[item.State] = item;
            }
            InitTransitions();
        }
コード例 #10
0
        public override void ParseConfig(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                Logger.Error("InputBlockConfig config xml is empty !");
                return;
            }
            _configs.Clear();
            var cfg = XmlConfigParser <InputBlockConfig> .Load(xml);

            if (null == cfg)
            {
                Logger.ErrorFormat("InputBlockConfig config is illegal content : {0}", xml);
                return;
            }

            foreach (InputBlockItem inputBlockItem in cfg.Items)
            {
                if (!_configs.ContainsKey(inputBlockItem.PostureType))
                {
                    _configs.Add(inputBlockItem.PostureType, inputBlockItem);
                }
                else
                {
                    Logger.ErrorFormat("{0} is already in config!!!", inputBlockItem.PostureType);
                }
            }
        }
コード例 #11
0
        public void Initialize(
            string varFilePath = null,
            List <VariableGroup> allVariableGroupsNullable     = null,
            List <VariableGroup> visibleVariableGroupsNullable = null)
        {
            if (IsInitialized)
            {
                throw new ArgumentOutOfRangeException("WatchVariableFlowLayoutPanel already initialized");
            }

            List <VariableGroup> allVariableGroups = allVariableGroupsNullable ?? new List <VariableGroup>();

            if (allVariableGroups.Contains(VariableGroup.Custom))
            {
                throw new ArgumentOutOfRangeException();
            }
            allVariableGroups.Add(VariableGroup.Custom);

            List <VariableGroup> visibleVariableGroups = visibleVariableGroupsNullable ?? new List <VariableGroup>();

            if (visibleVariableGroups.Contains(VariableGroup.Custom))
            {
                throw new ArgumentOutOfRangeException();
            }
            visibleVariableGroups.Add(VariableGroup.Custom);

            _varFilePath = varFilePath;
            _allGroups.AddRange(allVariableGroups);
            _initialVisibleGroups.AddRange(visibleVariableGroups);
            _visibleGroups.AddRange(visibleVariableGroups);

            _selectionToolStripItems =
                WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                    () => new List <WatchVariableControl>(_selectedWatchVarControls), this);

            List <WatchVariableControlPrecursor> precursors = new List <WatchVariableControlPrecursor>();

            if (_varFilePath != null)
            {
                precursors = XmlConfigParser.OpenWatchVariableControlPrecursors(_varFilePath);
                //precursors = WatchVariableData.GetPrecursors(_varFilePath);
            }

            AddVariables(precursors.ConvertAll(precursor => precursor.CreateWatchVariableControl()));
            AddItemsToContextMenuStrip();

            IsInitialized = true;

            ///////////////////////////////FOR DEBUGGING///////////////////////////////////////
            //Config.Print();
            //Config.Print("[@\"" + varFilePath + "\"] = new List<WatchVariableControlPrecursor>()");
            //Config.Print("{");
            //foreach (WatchVariableControlPrecursor precursor in precursors)
            //{
            //    Config.Print("    " + precursor.ToStringForCode() + ",");
            //}
            //Config.Print("},");
            //Config.Print();
            ///////////////////////////////////////////////////////////////////////////////////
        }
コード例 #12
0
        public void Parse_InvalidNamespaceString_Throws()
        {
            var    xDocument = LoadXml("InvalidNamespaceString.nsdepcop");
            Action a         = () => XmlConfigParser.Parse(xDocument);

            a.ShouldThrow <Exception>().WithMessage("*not a valid Namespace*");
        }
コード例 #13
0
        public override void ParseConfig(string xml)
        {
            var cfg = XmlConfigParser <ClientEffectCommonConfig> .Load(xml);

            foreach (var item in cfg.Items)
            {
                if (_configs.ContainsKey(item.Type))
                {
                    Logger.ErrorFormat("Duplicate define for type {0}", item.Type);
                }
                _configs[item.Type] = item;

                switch (item.Type)
                {
                case EClientEffectType.BulletDrop:
                    BulletDropServerMaxCount = item.ServerLimit;
                    BulletDropClientMaxCount = item.ClientLimit;
                    BulletDropLifeTime       = item.LifeTime;
                    break;

                case EClientEffectType.DefaultHit:
                    DecayLifeTime = item.LifeTime;
                    break;
                }
            }
        }
コード例 #14
0
ファイル: StroopMainForm.cs プロジェクト: Fuyukai/STROOP
        private void buttonOtherDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Delete selected variables?", "Delete Variables", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
                == DialogResult.Yes)
            {
                // Find indexes to delete
                var deleteVars = new List <int>();
                foreach (DataGridViewRow selectedRow in dataGridViewExpressions.SelectedRows)
                {
                    var row   = _tableOtherData.Rows[selectedRow.Index];
                    int assoc = _otherDataRowAssoc.FirstOrDefault(v => v.Value == row).Key;
                    deleteVars.Add(assoc);
                }

                // Delete rows
                foreach (int i in deleteVars)
                {
                    DataRow row = _otherDataRowAssoc[i];
                    _miscData.RemoveAt(i);
                    _otherDataRowAssoc.Remove(i);
                    row.Delete();
                }

                // Delete from xml file
                XmlConfigParser.DeleteWatchVariablesOtherData(deleteVars);
            }
        }
コード例 #15
0
        public override void ParseConfig(string xml)
        {
            var cfg = XmlConfigParser <NewWeaponConfig> .Load(xml);

            foreach (var item in cfg.Items)
            {
                _weaponDic[item.Id] = item;
                switch ((EWeaponSubType)item.SubType)
                {
                case EWeaponSubType.C4:
                    C4Id = item.Id;
                    break;

                case EWeaponSubType.Hand:
                    EmptyHandId = item.Id;
                    break;

                case EWeaponSubType.Melee:
                    switch (item.Id)
                    {
                    case (int)EWeaponIdType.MeleeVariant:
                        MeleeVariant = item.Id;
                        break;
                    }
                    break;
                }
            }
            if (!C4Id.HasValue)
            {
                Logger.Error("config for c4 doesn't exist");
            }
        }
コード例 #16
0
        public override void ParseConfig(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                Logger.ErrorFormat("vehicle asset config is Empty");
                return;
            }

            var cfg = XmlConfigParser <VehicleAssetConfig> .Load(xml);

            if (null == cfg)
            {
                Logger.ErrorFormat("vehicle asset config is illegal content:{0}", xml);
                return;
            }

            foreach (var item in cfg.Items)
            {
                if (_items.ContainsKey(item.Id))
                {
                    Logger.ErrorFormat("the vehicle asset id has been assigned {0}", item.Id);
                    continue;
                }

                _items[item.Id] = item;
            }
        }
コード例 #17
0
        public override void ParseConfig(string xml)
        {
            Data = XmlConfigParser <ScenesLightmapData.MeshRecords> .Load(xml);

            Data.ListToDict();
            Data.recordsList.Clear();
        }
コード例 #18
0
        private Configuration ReadIncludeConfiguration(bool replace)
        {
            try
            {
                Properties properties = new Properties();
                properties.Load(CONFIG_INCLUDE_PROPS_FILE);

                string cname = properties.GetProperty(CONFIG_PROP_NAME);
                Assert.False(String.IsNullOrWhiteSpace(cname));
                string cfile = properties.GetProperty(CONFIG_PROP_FILENAME);
                Assert.False(String.IsNullOrWhiteSpace(cfile));
                string version = properties.GetProperty(CONFIG_PROP_VERSION);
                Assert.False(String.IsNullOrWhiteSpace(version));

                LogUtils.Info(String.Format("Reading Configuration: [file={0}][version={1}]", cfile, version));

                using (FileReader reader = new FileReader(cfile))
                {
                    reader.Open();
                    XmlConfigParser       parser   = new XmlConfigParser();
                    ConfigurationSettings settings = new ConfigurationSettings();
                    settings.ReplaceProperties = replace;

                    parser.Parse(cname, reader, Version.Parse(version), settings);

                    return(parser.GetConfiguration());
                }
            }
            catch (Exception ex)
            {
                LogUtils.Error(ex);
                throw ex;
            }
        }
コード例 #19
0
        public override void ParseConfig(string xml)
        {
            Data = XmlConfigParser <ScenesIndoorCullData.IndoorCullRecords> .Load(xml);

            Data.ListToDict();
            Data.recordsList.Clear();
        }
コード例 #20
0
 static void InitConfigParser()
 {
     XmlConfigParser.AddConfigParser(CONFIG_NODE_NAME, _ =>
     {
         configNode          = _;
         lastTrackerFileName = _.Attribute(XName.Get("path")).Value;
     });
 }
コード例 #21
0
ファイル: InputTab.cs プロジェクト: chaosBrick/STROOP
        public override void InitializeTab()
        {
            base.InitializeTab();

            _guiList = XmlConfigParser.CreateInputImageAssocList(@"Config/InputImageAssociations.xml");;

            inputDisplayPanel.SetInputDisplayGui(_guiList);
        }
コード例 #22
0
        public void UpdateMaxIssueCount_NoMaxIssueCountAttribute_Works()
        {
            const int newMaxIssueCount = 101;
            var       xDocument        = LoadXml("NoRootAttributes.nsdepcop");

            XmlConfigParser.UpdateMaxIssueCount(xDocument, newMaxIssueCount);
            xDocument.Element("NsDepCopConfig")?.Attribute("MaxIssueCount")?.Value.Should().Be(newMaxIssueCount.ToString());
        }
コード例 #23
0
        public override void ParseConfig(string xml)
        {
            var cfg = XmlConfigParser <WeaponPartsConfig> .Load(xml);

            foreach (var item in cfg.Items)
            {
                partItems[item.Id] = item;
            }
        }
コード例 #24
0
        public override void ParseConfig(string xml)
        {
            var cfg = XmlConfigParser <ClientEffectCommonConfig> .Load(xml);

            foreach (var item in cfg.Items)
            {
                _configs[item.Type] = item;
            }
        }
コード例 #25
0
        public override void ParseConfig(string xml)
        {
            var data = XmlConfigParser <AudioWeaponConfig> .Load(xml);

            foreach (var item in data.Items)
            {
                itemsMap[item.Id] = item;
            }
        }
コード例 #26
0
        public override void ParseConfig(string xml)
        {
            _configs = XmlConfigParser <WeaponConfigs> .Load(xml);

            foreach (var item in _configs.Weapons)
            {
                _configCache[item.Id] = new WeaponAllConfigs(item);
            }
        }
コード例 #27
0
        public override void ParseConfig(string xml)
        {
            var cfg = XmlConfigParser <BulletDropConfig> .Load(xml);

            foreach (var bulletDropConfigItem in cfg.Items)
            {
                _itemDic[bulletDropConfigItem.Type] = bulletDropConfigItem;
            }
        }
コード例 #28
0
        public override void ParseConfig(string xml)
        {
            _config = XmlConfigParser <RaycastActionConfig> .Load(xml);

            if (null == _config)
            {
                Logger.Error("parse raycastAction config failed !!");
            }
        }
コード例 #29
0
        public override void ParseConfig(string xml)
        {
            var cfg = XmlConfigParser <ClipDropConfig> .Load(xml);

            _config = cfg;
            foreach (var item in cfg.Items)
            {
                _configDic[item.Id] = item;
            }
        }
コード例 #30
0
 public override void ParseConfig(string xml)
 {
     try
     {
         MapConfigPoints.current = XmlConfigParser <MapConfigPoints> .Load(xml);
     }catch (Exception e)
     {
         Debug.LogErrorFormat("load map position failed.{0}", e.Message);
     }
 }
コード例 #31
0
ファイル: XmlConfigDescriptor.cs プロジェクト: LazyTarget/Lux
 public XmlConfigDescriptor()
 {
     Properties = new Dictionary<string, object>();
     DataStore = new ConfigXmlDataStore();
     Parser = new XmlConfigParser();
 }