Esempio n. 1
0
        public CSecurityManager(string aSecurityFile)
        {
            _SecurityFile = aSecurityFile;
            if (!File.Exists(_SecurityFile))
            {
                BuildEmptySecurityFile(_SecurityFile);
            }

            _SecurityDoc = new XmlDocument();
            _SecurityDoc.Load(_SecurityFile);

            _SecRoot = XmlTools.getXmlNodeByName(XML_SECURITY, _SecurityDoc);
        }
Esempio n. 2
0
        /// <summary>
        /// 从一个Xml中解析
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ConfigFileName"></param>
        /// <returns></returns>
        private static T FromConfigFile <T>(string ConfigFileName) where T : class, new()
        {
            if (File.Exists(ConfigFileName))
            {
                using (XmlReader reader = XmlReader.Create(ConfigFileName))
                {
                    XmlSerializer xs = XmlTools.GetXmlSerializer(typeof(T));
                    return(xs.Deserialize(reader) as T);
                }
            }

            return(null);
        }
Esempio n. 3
0
        public void Save(string directory)
        {
            BSP.VendorSampleDirectoryPath = ".";
            XmlTools.SaveObject(VendorSampleDirectory, Path.Combine(directory, "VendorSamples.XML"));
            XmlTools.SaveObject(BSP, Path.Combine(directory, "BSP.XML"));

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("KSDK2xImporter." + MainFileName))
            {
                byte[] data = new byte[stream.Length];
                stream.Read(data, 0, data.Length);
                File.WriteAllBytes(Path.Combine(directory, MainFileName), data);
            }
        }
Esempio n. 4
0
 static void Main(string[] args)
 {
     while (true)
     {
         Console.Write("XML: ");
         string userInput = ReadLine();
         if (String.IsNullOrEmpty(userInput))
         {
             continue;
         }
         Console.WriteLine(XmlTools.Convert(userInput));
     }
 }
Esempio n. 5
0
        private bool isJsonResponse(RestResponse r)
        {
            if (ContentType.parse(r.ContentType) == ContentType.JSON)
            {
                return(true);
            }

            if (r.Body != null && StringTools.regex(r.Body.Trim(), "\\{.+\\}"))
            {
                return(XmlTools.isValidJson(r.Body));
            }
            return(false);
        }
Esempio n. 6
0
        } // End Function HasDataSet

        public static string GetDataSetDefinition(System.Xml.XmlDocument doc, string dataSetName)
        {
            dataSetName = XmlTools.XmlEscape(dataSetName);

            if (HasDataSet(doc, dataSetName))
            {
                System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);
                System.Xml.XmlNode             xnSQL = doc.SelectSingleNode("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"" + dataSetName + "\"]/dft:Query/dft:CommandText", nsmgr);
                return(xnSQL.InnerText);
            }

            return(null);
        } // End Function GetDataSetDefinition
Esempio n. 7
0
        public override void ApplyLocale(CLocalization aLocale)
        {
            base.ApplyLocale(Locale);

            XmlNode lLocNode = Locale.GetPanelData(this.Name);

            _bApply.Text = Locale.GetTagText("apply");

            if (lLocNode != null)
            {
                _chEnabledParam.Text = XmlTools.getXmlNodeByName("embeddedparam", lLocNode).InnerXml;
            }
        }
Esempio n. 8
0
            public STM32BSPBuilder(BSPDirectories dirs, string cubeDir)
                : base(dirs)
            {
                STM32CubeDir = cubeDir;
                ShortName    = "STM32";

                SDKList = XmlTools.LoadObject <STM32SDKCollection>(Path.Combine(dirs.InputDir, SDKFetcher.SDKListFileName));

                foreach (var sdk in SDKList.SDKs)
                {
                    SystemVars[$"STM32:{sdk.Family.ToUpper()}_DIR"] = Directory.GetDirectories(Path.Combine(dirs.InputDir, sdk.FolderName), "STM32Cube_FW_*").First();
                }
            }
Esempio n. 9
0
        /// <summary> 属性生成模板 </summary>
        string PropertyToTemplate(PropertyInfo property, string propertyName, string propertyTypeName)
        {
            var s = System.Convert.ToString(18, 2).PadLeft(6, '0');

            StringBuilder sb = new StringBuilder();

            Func <string, string, string> fun = (l, k) =>
            {
                //  Message:应用模板
                return(this.SelectITemplateCommand.Template(l, k, propertyTypeName));
            };

            string d = "说明";

            if (File.Exists(this.PdbPath))
            {
                if (XmlTools.filePathStr != this.PdbPath)
                {
                    XmlTools.Load(PdbPath);
                }

                var v = XmlTools.GetNodes("member");

                //foreach (var item in v)
                //{
                //    Debug.WriteLine(item);
                //}

                string format = "P:{0}.{1}";

                string pName = string.Format(format, property.DeclaringType.FullName, propertyName);

                var f = XmlTools.FindNode("member", l => l.Attributes.Find(k => k.Name == "name" && k.InnerText == pName) != null);

                if (f != null)
                {
                    d = f.InnerText.Replace("\r\n", "").Trim();
                }
            }

            if (property.ReflectedType.IsEnumerableType())
            {
                return(null);
            }

            Debug.WriteLine(fun.Invoke(propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1), d));

            sb.AppendLine(fun.Invoke(propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1), d));

            return(sb.ToString());
        }
Esempio n. 10
0
        private static List <Component> GetComponentsFromSubParts(XmlElement subParts, string vaultPath)
        {
            List <Component> components = new List <Component>();

            foreach (XmlElement subPart in XmlTools.GetElements(subParts, "subpart"))
            {
                Option <XmlElement> partElement = XmlTools.SafeGetElement(subPart, "part");
                if (partElement.IsSome)
                {
                    components.AddRange(GetComponentsFromPart(vaultPath, partElement.Get()));
                }
            }
            return(components);
        }
Esempio n. 11
0
        private static List <Component> GetComponentsFromPart(string vaultPath, XmlElement rootPartElement)
        {
            List <Component> components = new List <Component>();

            components.Add(Component.Read(rootPartElement, vaultPath));
            Option <XmlElement> subPartsElement = XmlTools.SafeGetElement(rootPartElement, "subparts");

            if (subPartsElement.IsSome)
            {
                components.AddRange(GetComponentsFromSubParts(subPartsElement.Get(), vaultPath));
            }

            return(components);
        }
Esempio n. 12
0
        public void ToXml(XmlWriter xml)
        {
            if (IsEmpty)
            {
                return;
            }

            xml.WriteStartElement("termekdij_szerzes_atvallalas");
            {
                XmlTools.WriteValueElement(xml, "bekezdes_pontja", BekezdesPontja, 100, true);
                XmlTools.WriteValueElement(xml, "bekezdes_alpontja", BekezdesAlpontja, 100, true);
            }
            xml.WriteEndElement();
        }
Esempio n. 13
0
        public async Task <QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken)
        {
            if (!session.TextView.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out ITextDocument textDoc))
            {
                return(null);
            }

            SnapshotPoint?triggerPoint = session.GetTriggerPoint(session.TextView.TextSnapshot);

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

            int pos = triggerPoint.Value.Position;

            if (!PackageCompletionSource.IsInRangeForPackageCompletion(session.TextView.TextSnapshot, pos, out Span s, out string packageId, out string packageVersion, out string type))
            {
                XmlInfo info = XmlTools.GetXmlInfo(session.TextView.TextSnapshot, pos);

                if (info != null)
                {
                    IWorkspace    workspace      = workspace = _workspaceManager.GetWorkspace(textDoc.FilePath);
                    string        evaluatedValue = workspace.GetEvaluatedPropertyValue(info.AttributeValue);
                    ITrackingSpan target         = session.TextView.TextSnapshot.CreateTrackingSpan(new Span(info.AttributeValueStart, info.AttributeValueLength), SpanTrackingMode.EdgeNegative);

                    if (info.AttributeName == "Condition")
                    {
                        try
                        {
                            bool isTrue = workspace.EvaluateCondition(info.AttributeValue);
                            evaluatedValue = $"Expanded value: {evaluatedValue}\nEvaluation result: {isTrue}";
                            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                            return(new QuickInfoItem(target, evaluatedValue));
                        }
                        catch (Exception ex)
                        {
                            Debug.Fail(ex.ToString());
                        }
                    }
                    else
                    {
                        evaluatedValue = $"Value(s):\n    {string.Join("\n    ", evaluatedValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))}";
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                        return(new QuickInfoItem(target, evaluatedValue));
                    }
                }
            }
        /// <summary>
        /// Although there is no such element as &lt;xrefGrp&gt;, this handler is here to handle a "groupified"
        /// xref.
        /// </summary>
        /// <param name="elt">A "groupified" xref, aka &lt;xrefGrp&gt;</param>
        /// <returns>Fully parsed MTF equivalent of xref.</returns>
        public static XElement HandleXrefGrp(XElement elt)
        {
            LoggingManager.OutputInfo($"Converting to <descripGrp>: {XmlTools.GetNodeLocation(elt)}");
            LoggingManager.OutputVerbose($"Element: {elt}");

            XElement newElt = new XElement("descripGrp");

            ParseChildNodes(elt, newElt);

            XElement xrefTarget = HandleXrefTargetAttributeAsAdmin(elt.Element(elt.Name.Namespace + "xref"));

            newElt.Add(xrefTarget);
            return(newElt);
        }
Esempio n. 15
0
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
        {
            var mainClassifier = fam.Definition.Subfamilies.First(f => f.IsPrimary);
            List <Task <MCUDefinitionWithPredicate> > tasks = new List <Task <MCUDefinitionWithPredicate> >();

            Console.Write("Parsing {0} registers in background threads", fam.Definition.Name);
            RegisterParserErrors errors = new RegisterParserErrors();

            foreach (var fn in Directory.GetFiles(dir, "*.h"))
            {
                string subfamily = Path.GetFileNameWithoutExtension(fn);
                if (subfamily.Length != 11 && subfamily.Length != 12)
                {
                    continue;
                }

                /*if (subfamily != "stm32f301x8")
                 * continue;*/

                Func <MCUDefinitionWithPredicate> func = () =>
                {
                    RegisterParserConfiguration cfg = XmlTools.LoadObject <RegisterParserConfiguration>(fam.BSP.Directories.RulesDir + @"\PeripheralRegisters.xml");
                    var r = new MCUDefinitionWithPredicate
                    {
                        MCUName        = subfamily,
                        RegisterSets   = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegisters(fn, cfg, errors, fam.MCUs[0].Core),
                        MatchPredicate = m => StringComparer.InvariantCultureIgnoreCase.Compare(mainClassifier.TryMatchMCUName(m.Name), subfamily) == 0,
                    };
                    Console.Write(".");
                    return(r);
                };

                //  func();
                tasks.Add(Task.Run(func));
            }

            Task.WaitAll(tasks.ToArray());
            var errorCnt = errors.ErrorCount;

            if (errorCnt != 0)
            {
                throw new Exception("Found " + errorCnt + " errors while parsing headers");

                //   for (int i = 0; i < errors.ErrorCount;i++)
                //     Console.WriteLine("\n er  " + i + "  -  " + errors.DetalErrors(i));
            }

            Console.WriteLine("done");
            return(from r in tasks select r.Result);
        }
Esempio n. 16
0
 internal ResourceTypeIconConfiguration(XmlNode node)
 {
     _resType = XmlTools.GetRequiredAttribute(node, "type");
     foreach (XmlNode iconNode in node.SelectNodes("icon"))
     {
         ResourceIconInstance iconInstance = new ResourceIconInstance(iconNode);
         AddIconInstance(iconInstance);
     }
     foreach (XmlNode overlayNode in node.SelectNodes("overlay"))
     {
         ResourceIconInstance iconInstance = new ResourceIconInstance(overlayNode);
         _overlayIconInstances.Add(iconInstance);
     }
 }
Esempio n. 17
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new Exception("Usage: risc-v.exe <freedom-e-sdk directory>");
            }

            var bspBuilder = new RISCVBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules"));

            PathTools.CopyDirectoryRecursive(@"..\..\bsp-template", bspBuilder.Directories.OutputDir);

            var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(bspBuilder.BSPRoot, "bsp.xml"));

            var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml"));

            List <string> projectFiles = new List <string>();
            PropertyList  unused       = null;

            if (commonPseudofamily.Definition.CoreFramework != null)
            {
                foreach (var job in commonPseudofamily.Definition.CoreFramework.CopyJobs)
                {
                    job.CopyAndBuildFlags(bspBuilder, projectFiles, null, ref unused);
                }
            }

            List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(bsp.Frameworks);

            frameworks.AddRange(commonPseudofamily.GenerateFrameworkDefinitions());
            bsp.Frameworks = frameworks.ToArray();

            var samples = commonPseudofamily.CopySamples(frameworks).ToArray();

            bsp.Examples = samples.Select(s => s.RelativePath).ToArray();


            var mainFamily = bsp.MCUFamilies.First();

            if (mainFamily.AdditionalSourceFiles != null || mainFamily.AdditionalHeaderFiles != null || bsp.FileConditions != null)
            {
                throw new Exception("TODO: merge lists");
            }

            mainFamily.AdditionalSourceFiles = projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray();
            mainFamily.AdditionalHeaderFiles = projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray();
            bsp.FileConditions = bspBuilder.MatchedFileConditions.ToArray();

            XmlTools.SaveObject(bsp, Path.Combine(bspBuilder.BSPRoot, "BSP.XML"));
        }
Esempio n. 18
0
        protected internal override bool eval(string expr, string json)
        {
            // for backward compatibility we should keep for now xpath expectations
            if (!forceJsEvaluation && XmlTools.isValidXPath(Context, expr) && !wrapper.looksLikeAJsExpression(expr))
            {
                throw new System.ArgumentException("XPath expectations in JSON content are not supported anymore. Please use JavaScript expressions.");
            }
            object exprResult = wrapper.evaluateExpression(json, expr, imports);

            if (exprResult == null)
            {
                return(false);
            }
            return(bool.Parse(exprResult.ToString()));
        }
Esempio n. 19
0
        protected void applyLocaleToItem(CAuthItem lItem)
        {
            XmlNode lPanelData;

            if (_Locale != null && (lPanelData = _Locale.GetPanelData("authitem")) != null)
            {
                try { lItem.Tags = XmlTools.getXmlNodeByName("typelist", lPanelData); }
                catch (Exception E) { throw new Exception("Typelist not found.", E); };
                lItem.TagRemove   = _Locale.GetTagText("remove");
                lItem.TagApply    = _Locale.GetTagText("apply");
                lItem.TagReset    = _Locale.GetTagText("reset");
                lItem.TagPassword = _Locale.GetTagText("password");
                lItem.TagUser     = _Locale.GetTagText("user");
            }
        }
Esempio n. 20
0
        //[AllowAnonymous]
        public ActionResult Index()
        {
            var items = new List <SocialMedia>();

            foreach (XmlNode node in oConst.GetNodeList("/constants/SocialMediaIcons/icon"))
            {
                SocialMedia sm = new SocialMedia();
                sm.src = Url.Content(XmlTools.NothingToString(node.SelectSingleNode("src")));
                sm.url = XmlTools.NothingToString(node.SelectSingleNode("url"));
                items.Add(sm);
            }
            ViewBag.smlist = items;

            return(View());
        }
Esempio n. 21
0
        public void ToXml(XmlWriter xml)
        {
            if (IsEmpty)
            {
                return;
            }

            xml.WriteStartElement("beszallokartya");
            {
                XmlTools.WriteValueElement(xml, "jaratszam", Jaratszam, 100, true);
                XmlTools.WriteValueElement(xml, "kedv_neve", KedvezmenyezettNeve, 100, true);
                XmlTools.WriteValueElement(xml, "uticel", Uticel, 100, true);
            }
            xml.WriteEndElement();
        }
Esempio n. 22
0
        public virtual string handle(IRunnerVariablesProvider variablesProvider, Config config,
                                     RestResponse response, object expressionContext, string expression)
        {
            IDictionary <string, string> namespaceContext = (IDictionary <string, string>)expressionContext;
            XPathNavigator node =
                XmlTools.extractXPath(namespaceContext, expression, response.Body);
            string val = XmlTools.xPathResultToXmlString(node);
            int    pos = val.IndexOf("?>", StringComparison.Ordinal);

            if (pos >= 0)
            {
                val = val.Substring(pos + 2);
            }
            return(val);
        }
Esempio n. 23
0
        public void Imprimir()
        {
            var path = @"C:\Zion.NFCe\XMls";

            var imp = new NFCe.ImprimirNFCe(new NFCe.ConfigDanfeNFCe("Microsoft Sans Serif", 7), "EPSON TM-T20 ReceiptE4 (1)");

            var files = Directory.GetFiles(path);

            foreach (var file in files.OrderByDescending(x => x.Length))
            {
                var xml = XmlTools.CarregarXmlStringDeArquivo(file);
                imp.Imprimir(xml);
                return;
            }
        }
Esempio n. 24
0
        private static void _EndueAssetBundleName()
        {
            var abf     = XmlTools.Deserialize <AssetBundleFolders> (Constants.AssetBundleFoldersPath);
            var folders = abf.normal_folders;

            EditorUtility.DisplayProgressBar("Endue AssetName", "Enduing AssetName...", 0f);

            for (int i = 0; i < folders.Length; ++i)
            {
                EditorUtility.DisplayProgressBar("Endue AssetName", "Enduing AssetName...", 1f * i / folders.Length);
                var source = os.path.join(Application.dataPath, folders [i]);
                _EndueAssetBundleName(source);
            }

            EditorUtility.ClearProgressBar();
        }
Esempio n. 25
0
        public string GetTagText(string aTagName)
        {
            if (_Tags == null)
            {
                throw new ELocalizationTag("Tags node not found!");
            }

            XmlNode lTag = XmlTools.getXmlNodeByAttrVal(XMLa_NAME, aTagName, _Tags);

            if (lTag == null)
            {
                throw new ELocalizationTag("Tag not found: \"" + aTagName + "\"");
            }

            return(lTag == null ? "-" : lTag.InnerText);
        }
Esempio n. 26
0
        public void Should_Extract_TextNode_From_Xml_As_Node()
        {
            // Arrange.
            string xml           = "<a><b>test</b><c>1</c><c>2</c></a>";
            string expectedValue = "test";

            // Act.
            object rawValue =
                XmlTools.extractXPath("/a/b/text()", xml, XPathEvaluationReturnType.Node);
            XPathNavigator actualValue = rawValue as XPathNavigator;

            // Assert.
            Assert.IsInstanceOfType(rawValue, typeof(XPathNavigator));
            Assert.IsNotNull(actualValue);
            Assert.AreEqual(expectedValue, actualValue.Value);
        }
Esempio n. 27
0
        private static IResourceComparer LoadComparer(XmlNode node)
        {
            string assemblyName = XmlTools.GetRequiredAttribute(node, "assembly");
            string className    = XmlTools.GetRequiredAttribute(node, "class");

            Assembly[] asmList = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly asm in asmList)
            {
                if (asm.GetName().Name == assemblyName)
                {
                    Type comparerType = asm.GetType(className);
                    return((IResourceComparer)Activator.CreateInstance(comparerType));
                }
            }
            throw new ActionException("Could not find action assembly " + assemblyName);
        }
Esempio n. 28
0
        public void ToXml(XmlWriter xml)
        {
            if (IsEmpty)
            {
                return;
            }

            xml.WriteStartElement("legikozl");
            {
                XmlTools.WriteValueElement(xml, "felsztomeg", TeljesFelszallasiTomeg, false);
                XmlTools.WriteValueElement(xml, "legiker", LegiKereskedelem, false);
                XmlTools.WriteValueElement(xml, "forgba_datum", ElsoForgalombaHelyezesIdopontja, false);
                XmlTools.WriteValueElement(xml, "repultora", RepultOrakSzama, false);
            }
            xml.WriteEndElement();
        }
Esempio n. 29
0
        public void ToXml(XmlWriter xml)
        {
            if (IsEmpty)
            {
                return;
            }

            xml.WriteStartElement("vizikozl");
            {
                XmlTools.WriteValueElement(xml, "hajo_hossz", Hosszusag, false);
                XmlTools.WriteValueElement(xml, "vizitev", Tevekenyseg, 100, false);
                XmlTools.WriteValueElement(xml, "forgba_datum", ElsoForgalombaHelyezesIdopontja, false);
                XmlTools.WriteValueElement(xml, "hajozott_ora", HajozottOrakSzama, false);
            }
            xml.WriteEndElement();
        }
Esempio n. 30
0
        public override void ApplyLocale(CLocalization aLocale)
        {
            XmlNode lData = null;

            if (HostDialog != null)
            {
                lData = aLocale.GetWizardData(HostDialog.Name);
                if (lData != null)
                {
                    lData = XmlTools.getXmlNodeByAttrVal("page", "name", this.Name, lData);
                    _lDescription.Text = XmlTools.getXmlNodeByName("description", lData).InnerText;
                }
            }

            LocaleData = lData;
        }
Esempio n. 31
0
                public static void saveSettings(string filename)
                {
                    TricksterTools.Library.Xml.Settings.XmlTricksterRoot XmlRoot = new TricksterTools.Library.Xml.Settings.XmlTricksterRoot();
                    XmlTools Tools = new XmlTools();
                    XmlSettings Settings = new XmlSettings();
                    XmlSettingHungUpTime hungtime = new XmlSettingHungUpTime();
                    XmlSettingUpdate update = new XmlSettingUpdate();
                    XmlSettingGameStartUp gamestartup = new XmlSettingGameStartUp();
                    XmlSettingLogging logging = new XmlSettingLogging();
                    XmlSettingIcons icons = new XmlSettingIcons();

                    hungtime.enable = (HungUp.enable) ? "true" : "false";
                    hungtime.sec = HungUp.sec;
                    update.startup = (Update.startupAutoCehck) ? "true" : "false";
                    update.checkBeta = (Update.checkBetaVersion) ? "true" : "false";
                    gamestartup.mode = GameStartUp.mode;
                    logging.enable = (Logging.enable) ? "true" : "false";
                    logging.Path = Logging.filePath;
                    icons.resourceName = Icons.resourceName;

                    Settings.HungupTime = hungtime;
                    Settings.UpdateCheck = update;
                    Settings.StartUpGame = gamestartup;
                    //Settings.Logging = logging;
                    Settings.Icon = icons;
                    Tools.Settings = Settings;
                    XmlRoot.Tools = Tools;

                    string filepath = "";
                    if (Path.IsPathRooted(filename))
                    {
                        filepath = filename;
                        filename = Path.GetFileName(filename);
                    }
                    else
                    {
                        filepath = Path.GetFullPath(Environment.CurrentDirectory + @"\" + filename);
                    }

                    if (!File.Exists(filepath))
                    {
                        // �t�@�C�����Ȃ���΍쐬
                        FileStream fs = new FileStream(filepath, FileMode.Create);
                        fs.Close();
                    }

                    try
                    {
                        System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(TricksterTools.Library.Xml.Settings.XmlTricksterRoot));
                        FileStream fs = new FileStream(filepath, FileMode.Create);
                        serializer.Serialize(fs, XmlRoot);
                        fs.Close();
                    }
                    catch (System.Security.SecurityException se)
                    {
                        SimpleLogger.WriteLine(se.Message);
                        //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�Z�L�����e�B�G���[�ł��B", "SecurityExceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw se;
                    }
                    catch (System.IO.IOException ioe)
                    {
                        SimpleLogger.WriteLine(ioe.Message);
                        //MessageBox.Show("��O�G���[:" + Environment.NewLine + "���o�͎��ɃG���[���������܂����B", "IOExceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw ioe;
                    }
                    catch (System.Xml.XmlException xe)
                    {
                        SimpleLogger.WriteLine(xe.Message);
                        //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�ݒ�ǂݍ��݃G���[", "XmlExceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw xe;
                    }
                    catch (System.Exception e)
                    {
                        SimpleLogger.WriteLine(e.Message);
                        //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�����̓��肪�ł��܂���ł����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw e;
                    }
                }
Esempio n. 32
0
        public static void saveConfig(XmlPlugin[] Plugin)
        {
            string filename = @".\plugins.config.xml";
            XmlTricksterRoot XmlRoot = new XmlTricksterRoot();
            XmlTools Tools = new XmlTools();

            Tools.Plugin = Plugin;
            XmlRoot.Tools = Tools;

            string filepath = "";
            if (Path.IsPathRooted(filename))
            {
                filepath = filename;
                filename = Path.GetFileName(filename);
            }
            else
            {
                filepath = Path.GetFullPath(Environment.CurrentDirectory + @"\" + filename);
            }

            if (!File.Exists(filepath))
            {
                // �t�@�C�����Ȃ���΍쐬
                FileStream fs = new FileStream(filepath, FileMode.Create);
                fs.Close();
            }

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(XmlTricksterRoot));
                FileStream fs = new FileStream(filepath, FileMode.Create);
                serializer.Serialize(fs, XmlRoot);
                fs.Close();
            }
            catch (System.Security.SecurityException se)
            {
                SimpleLogger.WriteLine(se.Message);
                //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�Z�L�����e�B�G���[�ł��B", "SecurityException error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw se;
            }
            catch (System.IO.IOException ioe)
            {
                SimpleLogger.WriteLine(ioe.Message);
                //MessageBox.Show("��O�G���[:" + Environment.NewLine + "���o�͎��ɃG���[���������܂����B", "IOException error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw ioe;
            }
            catch (System.Xml.XmlException xe)
            {
                SimpleLogger.WriteLine(xe.Message);
                //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�ݒ�ǂݍ��݃G���[", "XmlException error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw xe;
            }
            catch (System.Exception e)
            {
                SimpleLogger.WriteLine(e.Message);
                //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�����̓��肪�ł��܂���ł����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw e;
            }
        }