public void XmlValidTest() { var xmlLoader = new XmlLoader(); var xml = xmlLoader.Load("http://www.ad.nl/home/rss.xml"); Assert.IsNotNull(xml); }
public void XmlInvalidTypeTest() { var xmlLoader = new XmlLoader(); var xml = xmlLoader.Load("http://jsonplaceholder.typicode.com/posts"); Assert.IsNull(xml); }
public void ExportXml() { string xml = File.ReadAllText("Negate.xml"); IEnumerable<Section> sections = new XmlLoader().ReadXml(xml); string exportedXml = new XmlLoader().ToXml(sections); Assert.AreEqual(xml.Replace(" ", string.Empty), exportedXml.Replace(" ", string.Empty)); }
public HighlightsCollection GetHighlights() { HighlightsCollection highlightsCollection = null; var xmlLoader = new XmlLoader(); highlightsCollection = xmlLoader.GetXml<HighlightsCollection>(HighlightsXmlUrl); return highlightsCollection; }
public GameSummary GetGameSummary() { GameSummary gameSummary = null; var xmlLoader = new XmlLoader(); gameSummary = xmlLoader.GetXml<GameSummary>(GameSummaryXmlUrl); return gameSummary; }
public GameCenter GetGameCenter() { GameCenter gameCenter = null; var xmlLoader = new XmlLoader(); gameCenter = xmlLoader.GetXml<GameCenter>(GameCenterXmlUrl); return gameCenter; }
protected void SetupFromXmlStream(Stream stream) { SuspendLayout(); xmlLoader = new XmlLoader(); SetupXmlLoader(); if (stream != null) { xmlLoader.LoadObjectFromStream(this, stream); } ResumeLayout(false); }
protected void SetupFromXml(string fileName) { SuspendLayout(); xmlLoader = new XmlLoader(); SetupXmlLoader(); if (fileName != null && fileName.Length > 0) { xmlLoader.LoadObjectFromFileDefinition(this, fileName); } ResumeLayout(false); }
public GameSummaryCollection GetSummaryCollection(DateTime date) { var url = BuildUrl(date); GameSummaryCollection gameSummaryCollection = null; var xmlLoader = new XmlLoader(); gameSummaryCollection = xmlLoader.GetXml<GameSummaryCollection>(url); return gameSummaryCollection; }
public void LoadWithRootInstance() { var dummy = new DummyClass { AnotherProperty = "Other value", SampleProperty = "Will be overwritten" }; var loader = new XmlLoader(new DummyParserFactory(RuntimeTypeSource)); var actual = loader.FromString("<DummyClass xmlns=\"root\" SampleProperty=\"Value\" />", dummy); Assert.IsType(dummy.GetType(), actual); Assert.Equal("Value", ((DummyClass)actual).SampleProperty); Assert.Equal("Other value", ((DummyClass)actual).AnotherProperty); }
private XmlEntityReference LoadEntityReferenceInAttribute() { Debug.Assert(_reader.NodeType == XmlNodeType.EntityReference); XmlEntityReference eref = _dummyDocument.CreateEntityReference(_reader.LocalName); if (!_reader.CanResolveEntity) { return(eref); } _reader.ResolveEntity(); while (_reader.ReadAttributeValue()) { switch (_reader.NodeType) { case XmlNodeType.Text: eref.AppendChild(_dummyDocument.CreateTextNode(_reader.Value)); continue; case XmlNodeType.EndEntity: if (eref.ChildNodes.Count == 0) { eref.AppendChild(_dummyDocument.CreateTextNode(string.Empty)); } return(eref); case XmlNodeType.EntityReference: eref.AppendChild(LoadEntityReferenceInAttribute()); break; default: throw XmlLoader.UnexpectedNodeType(_reader.NodeType); } } return(eref); }
public static GameMap LoadMap(int id) { GameMap map = (GameMap)XmlLoader <GameMap> .Load(CreateFileName(id), true); FileInfo info = new FileInfo(XmlLoader <GameMap> .SaveFileName(CreateFogFileName(id), true)); if (info.Exists) { using (FileStream stream = info.OpenRead()) { using (var memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); map.fog = new BitArray(memoryStream.ToArray()); } stream.Close(); } } return(map); }
private static async Task StartApp(string englishPath, string translatedPath, string outputPath) { Console.WriteLine("Initializing update..."); var loader = new XmlLoader(); var englishDoc = loader.Load(englishPath); var translatedDoc = loader.Load(translatedPath); var needingTranslationDoc = CreateNeedingTranslationOnlyDoc(englishDoc, translatedDoc); var translator = new Translator(); var localizationManager = new DivinityLocalizationTranslator(translator, needingTranslationDoc); var fixer = new UpdateMistakesFixer(needingTranslationDoc); Console.WriteLine("Translating new lines..."); await localizationManager.TranslateAll(() => {}); Console.WriteLine("Fixing general translation mistakes"); fixer.FixAll(); Console.WriteLine("Building final artifact..."); var finalArtifact = CreateDocumentWithUnionOfTwo(needingTranslationDoc, translatedDoc); loader.Save(outputPath, finalArtifact); Console.WriteLine("Finished..."); }
public void TestSaveData() { DataBase.Drop(); var tm = new TownManager(); var bdm = new BuildingDataManager(tm); var loader = new XmlLoader(bdm, tm, tm, tm); loader.LoadModel(); var max = loader.Items.OrderByDescending(x => x.Key.Length).First(); var md = new MarketDataManager(); md.Save(max.Key, 1, false, new ItemFromMarketData()); var ord = md.GetOrders(); Assert.AreEqual(1, ord.Count()); //DataBase.Instance.GetCollection<> }
void Start() { selectedNode = false; highlightNode = false; boardMask = LayerMask.GetMask("Board"); moveMask = LayerMask.GetMask("Move"); xmlLoader = GetComponent <XmlLoader>(); if (xmlLoader) { nodos = xmlLoader.nodos; aristas = xmlLoader.aristas;//quitar print("cargado"); } else { print("no"); } //print(nodos.Count);//esto deberi cargarse despues de que cmloadr cumpla su funcion Vertexs(); transform.position = new Vector3(-1 * maxX / 2, maxY / 2, 0f); nodosAfectados = new List <Transform>(); Edges(); }
private void TestComponent(string resource) { var assembly = Assembly.GetExecutingAssembly(); var resources = assembly.GetManifestResourceNames(); var resourceName = resources.First(r => r.EndsWith(resource)); using (var xml = assembly.GetManifestResourceStream(resourceName)) { var loader = new XmlLoader(); loader.Load(xml); // Make sure there were no errors Assert.AreEqual(0, loader.LoadErrors.Count()); var testDescription = loader.GetDescriptions()[0]; // Check component data AssertMetadata(testDescription); AssertProperties(testDescription); AssertFlags(testDescription); AssertConnections(testDescription); AssertRender(testDescription); } }
void Export() { ieDialog = new ImportExportDialog(ExportData.DataFromDBs(), true); ieDialog.ImportExportComplete += (sss, e) => { OpenDialog ofd = new OpenDialog(false, new List <string>() { "*.cmx" }); ofd.FilesOpened += (sn, ee) => { try { XmlLoader <ExportData> .Save(e.Data, ee.Files[0]); } catch (Exception ex) { DebugLogger.WriteLine(ex.ToString()); } }; MainUI.MainView.AddSubview(ofd.View); }; MainUI.MainView.AddSubview(ieDialog.View); }
private static void Render(ILogger logger, string inputPath, string outputPath, PreviewGenerationOptions renderOptions) { var loader = new XmlLoader(); loader.UseDefinitions(); using (var fs = File.Open(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { if (!loader.Load(fs, logger, out var description)) { logger.LogError("Unable to render due to errors."); return; } var drawingContext = PreviewRenderer.RenderPreview((size) => new SkiaDrawingContext((int)size.Width, (int)size.Height, SKColors.White), description, renderOptions); using (var outputFs = File.OpenWrite(outputPath)) { drawingContext.WriteAsPng(outputFs); } } logger.LogInformation($"{inputPath} -> {outputPath}"); }
private void LoadXmlComponents(string[] directories) { var xmlLoader = new XmlLoader(); foreach (string location in directories) { foreach (string file in Directory.GetFiles(location, "*.xml", SearchOption.TopDirectoryOnly)) { using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { xmlLoader.Load(fs); if (!xmlLoader.LoadErrors.Any()) { ComponentDescription description = xmlLoader.GetDescriptions()[0]; description.Metadata.Location = ComponentDescriptionMetadata.LocationType.Installed; description.Source = new ComponentDescriptionSource(file, new ReadOnlyCollection <ComponentDescription>(new[] { description })); var type = GetTypeFromDescription(description); internalLookup.AddDescription(type, description); } } } } }
private void LoadXmlComponents(string[] directories, SearchOption searchOption) { var xmlLoader = new XmlLoader(); foreach (string location in directories) { foreach (string file in Directory.GetFiles(location, "*.xml", searchOption)) { using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { if (xmlLoader.Load(fs, out var description)) { description.Metadata.Location = ComponentDescriptionMetadata.LocationType.Installed; description.Source = new ComponentDescriptionSource(file); foreach (var type in description.GetComponentTypes()) { internalLookup.AddDescription(type, description); } } } } } }
public void TestReadXml() { var db = XmlLoader.LoadItemsXml(); Assert.IsNotNull(db); Assert.AreEqual(405, db.Items.Cast <IItem>().Count(x => x.shopcategory == shopCategory.artefacts)); Assert.AreEqual(72, db.Items.Cast <IItem>().Count(x => x.shopcategory == shopCategory.offhand)); Assert.AreEqual(15, db.Items.Cast <IItem>().Count(x => x.shopsubcategory1 == shopSubCategory.seed)); Assert.AreEqual(72, db.Items.Cast <IItem>().Count(x => x.shopsubcategory1 == shopSubCategory.animals)); //Assert.AreEqual(6, db.Items.Cast<IItem>().Count(x => x.shopsubcategory1 == shopSubCategory.@event)); var items = db.Items.Where(x => !(x is IItem)).ToArray(); Assert.IsNotNull(items); Assert.AreEqual(0, items.Length); Assert.AreEqual(3106, db.Items.Length); // Assert.IsTrue(db.Items.Cast<IItem>().Where(x=>x.craftingcategory!= "farmabal??").All(x=>x.craftingrequirements.Length > 0)); var enums = db.Items.OfType <IItemCraftingcategory>() //.Where(x => x.shopcategory==ShopCategory.melee) .Where(x => x.shopcategory == shopCategory.resources) .OfType <SimpleItem>(); // .Select(x => Tuple.Create(x.shopcategory, x.shopsubcategory1, x.craftingcategory, x.uniquename)) // .Distinct() // .OrderBy(x => x.Item1) // .ThenBy(x=>x.Item2) // .ThenBy(x=>x.Item3); // foreach (var value in enums) { Debug.WriteLine($"{value.uniquename},"); } }
/// <summary> /// 解析Panel /// </summary> /// <param name="node"></param> /// <param name="layoutBody"></param> private void ParseNodeBodyPanel(XmlNode node, FanLayoutBody layoutBody) { XmlNodeList panelNodeList = XmlLoader.GetChildNodesByName(node, "panel"); if (panelNodeList == null || panelNodeList.Count == 0) { return; } foreach (XmlNode panelNode in panelNodeList) { if (layoutBody is FanLayoutDock) { FanLayoutDock bodyDock = (FanLayoutDock)layoutBody; FanLayoutPanel panel = new FanLayoutPanel(); panel.Guid = XmlLoader.ReadAttrValue(panelNode, "guid"); panel.Title = XmlLoader.ReadAttrValue(panelNode, "title"); panel.Name = XmlLoader.ReadAttrValue(panelNode, "name"); panel.Width = XmlLoader.ReadAttrIntValue(panelNode, "width", 200); panel.Height = XmlLoader.ReadAttrIntValue(panelNode, "height", 300); panel.DockPosistion = FanLayoutDockPositionEnumHelper.Parse(XmlLoader.ReadAttrValue(panelNode, "position")); panel.TabView = ("true" == XmlLoader.ReadAttrValue(panelNode, "tabView")); panel.Type = FanLayoutPanelTypeEnumHelper.Parse(XmlLoader.ReadAttrValue(panelNode, "type")); panel.Assembly = XmlLoader.ReadAttrValue(panelNode, "assembly"); panel.AssemblyType = XmlLoader.ReadAttrValue(panelNode, "assembly-type"); //子Panel ParseNodeBodyChildPanel(panelNode, panel.ChildPanelItems); bodyDock.Panels.Add(panel); //读取uiView //ParseNodeUiView(panelNode, ref panel.UiViewControl); } } }
protected GivenAXmlLoader() { Loader = new XmlLoader(new DummyParserFactory(TypeRuntimeTypeSource)); }
internal override void InitParser() { CheckDisposed(); m_patr = new PatrParser(); m_patr.CommentChar = '|'; m_patr.CodePage = Encoding.UTF8.CodePage; m_loader = new XmlLoader(); m_loader.XmlResolver = new XmlFwResolver(); m_loader.QuitOnError = false; }
public void TestValidPluginConfigNoPlugins() { IList <AssemblyConfig> configs = XmlLoader.ParsePluginConfig(Path.Combine(testXmlFiles, "ValidPluginConfigEmpty.xml")); Assert.AreEqual(0, configs.Count); }
public void TestInvalidXmlWithNoChannel() { Assert.Throws <ValidationException>(() => XmlLoader.ParseIrcConfig(Path.Combine(testXmlFiles, "InvalidIrcConfigNoChannel.xml")) ); }
public void TestInvalidXmlWithUserName() { Assert.Throws <ValidationException>(() => XmlLoader.ParseIrcConfig(Path.Combine(testXmlFiles, "InvalidIrcConfigEmptyUserName.xml")) ); }
public ActiveSkillManager() { list = XmlLoader.LoadFromXmlResource <ActiveSkillList>("Xml/ActiveSkills"); list.GenerateDictionary(); Debug.Log("Successfully loaded: " + list.list.Count); }
public static HelpDocument Load(string fileName) { var xmlLoader = new XmlLoader(); xmlLoader.SetXmlSchemaFromResource("EPuzzleHelpDocument.xsd"); return Create(xmlLoader.Load(fileName)); }
public TestXml2Yaml(ITestOutputHelper output) { this.output = output; // retrieve metadata as xml from target server string sqlStatementForTablesToImport = @" select ( select mappingName = N'm_sync_' + tables.[name], mappingDescription = N'HSTG', [enabled] = 'true', [schemaExt] = ( select objectSchema = schema_name(tables.[schema_id]), objectName = tables.[name] for xml path('underlyingSource'), root('AzP_EDW'), type ), [source] = ( select dataStore = ( select connectionKey = 'HSTG_PRD' for xml path(''), type ), [language] = 'T-SQL', code = 'select * from ' + schema_name(tables.[schema_id]) + N'.' + tables.[name] + N' where OMD_INSERT_DATETIME > ? AND OMD_INSERT_DATETIME <= ?;' for xml path(''), type ), [target] = ( select dataStore = ( select connectionKey = 'HSTG' for xml path(''), type ), objectSchema = schema_name(tables.[schema_id]), objectName = tables.[name] for xml path(''), type ), mappedDataItems = ( select sourceDataItem = (select columnName = columns.[name] for xml path(''), type), targetColumn = (select columnName = columns.[name] for xml path(''), type) from sys.columns where columns.[object_id] = tables.[object_id] and columns.[name] not like 'OMD\_%' escape '\' order by columns.column_id for xml path('MappedDataItem'), type ) from EDW_150_History_Area.sys.tables inner join openquery(AUBIWSQLPRD, ' select schema_name(tables.[schema_id]) as [schema_name] , tables.[name] from EDW_150_History_Area.sys.tables; ') src on src.[schema_name] = schema_name(tables.[schema_id]) and src.[name] = tables.[name] where schema_name(tables.[schema_id]) = N'dbo' order by schema_name(tables.[schema_id]), tables.[name] for xml path('MappedDataSet'), root('ArrayOfMappedDataSet') ) as xmlColumn; "; using (OleDbConnection conn = new OleDbConnection(@"Provider=SQLNCLI11;Server=(local);Integrated Security=SSPI;Initial Catalog=EDW_150_History_Area;")) { OleDbCommand cmd = new OleDbCommand(sqlStatementForTablesToImport, conn); conn.Open(); OleDbDataReader reader = cmd.ExecuteReader(); string xmlString = ""; while (reader.Read()) { // read xml to string (assuming single row) xmlString = reader.GetString(0); } reader.Close(); // load to object model List <MappedDataSet> loaded = XmlLoader.LoadFromString(xmlString); loadedMappings.MappedDataSets.AddRange(loaded); } }
private void LoadXmlComponents(ILoggerFactory loggerFactory, string[] directories, SearchOption searchOption, XmlLoader xmlLoader) { var logger = loggerFactory.CreateLogger <DirectoryComponentDescriptionLookup>(); foreach (string location in directories) { foreach (string file in Directory.GetFiles(location, "*.xml", searchOption)) { using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { if (xmlLoader.Load(fs, loggerFactory.CreateLogger <XmlLoader>(), out var description)) { description.Metadata.Location = ComponentDescriptionMetadata.LocationType.Installed; description.Source = new ComponentDescriptionSource(file); foreach (var type in description.GetComponentTypes()) { internalLookup.AddDescription(type, description); } } else { logger.LogError($"Failed to load {file}"); } } } } }
public void TestInvalidPluginConfigNoPath() { Assert.Throws <ArgumentNullException>(() => XmlLoader.ParsePluginConfig(Path.Combine(testXmlFiles, "InvalidPluginConfigEmptyPath.xml")) ); }
static void Main(string[] args) { // try { CmdLineParser cmdLineParser = new CmdLineParser("FSMCompiler v1.0"); cmdLineParser.Add(new ArgumentDefinition("source", 1, "Archivo de entrada.", true)); cmdLineParser.Add(new OptionDefinition("G", "Generador.")); cmdLineParser.Add(new OptionDefinition("H", "Ayuda.")); cmdLineParser.Add(new OptionDefinition("P", "Parametro especifico del generador.")); if (args.Length == 0) { Console.WriteLine(cmdLineParser.HelpText); Console.ReadKey(true); } else { string generatorName = "C"; string sourceFileName = ""; GeneratorParameters generatorParameters = new GeneratorParameters(); cmdLineParser.Parse(args); foreach (OptionInfo optionInfo in cmdLineParser.Options) { switch (optionInfo.Name) { case "G": generatorName = optionInfo.Value; break; case "P": generatorParameters.Add(optionInfo.Value); break; } } foreach (ArgumentInfo argumentInfo in cmdLineParser.Arguments) { switch (argumentInfo.Name) { case "source": sourceFileName = argumentInfo.Value; break; } } Console.WriteLine(); Console.WriteLine("FsmCompiler v1.1"); Console.WriteLine("-------------------------------------------------------------"); Console.WriteLine(" Finite state machine compiler tool."); Console.WriteLine(" Copyright 2015-2020 Rafael Serrano ([email protected])"); Console.WriteLine(); XmlLoader loader = new XmlLoader(); Machine machine = loader.Load(sourceFileName); IGenerator generator = null; switch (generatorName) { case "DOT": generator = new DOTGenerator(generatorParameters); break; case "C": default: generator = new CGenerator(generatorParameters); break; case "CPP": generator = new v1.Generator.CPP.CPPGenerator(generatorParameters); break; } generator.Generate(machine); } /* } * * catch (Exception e) { * while (e != null) { * Console.WriteLine(e.Message); * e = e.InnerException; * } * }*/ }
protected GivenAXmlLoader() { Loader = new XmlLoader(new DummyParserFactory(RuntimeTypeSource)); }
public WpfLoader() { innerLoader = new XmlLoader(new WpfParserFactory()); }
public void TestInvalidXmlWithEmptyPort() { Assert.Throws <FormatException>(() => XmlLoader.ParseIrcConfig(Path.Combine(testXmlFiles, "InvalidIrcConfigEmptyPort.xml")) ); }
public void FileNotFoundTest() { Assert.Throws <FileNotFoundException>(() => XmlLoader.LoadCowSayBotConfig("derp.xml")); }
public void TestInvalidXmlEmptyAdmin() { Assert.Throws <ValidationException>(() => XmlLoader.ParseIrcConfig(Path.Combine(testXmlFiles, "InvalidIrcConfigWithEmptyAdmins.xml")) ); }
public void FileNotFoundTest() { Assert.Throws <FileNotFoundException>(() => XmlLoader.ParseConfig("DNE.xml")); }
public void TestInvalidPluginConfigBadRootName() { Assert.Throws <XmlException>(() => XmlLoader.ParsePluginConfig(Path.Combine(testXmlFiles, "InvalidPluginConfigBadRootNode.xml")) ); }
protected override void CleanupParser() { if (m_loader != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(m_patr); m_loader.Reset(); m_loader = null; } }
public DirectoryComponentDescriptionLookup(ILoggerFactory loggerFactory, string directory, bool recursive, XmlLoader xmlLoader) { LoadXmlComponents(loggerFactory, new[] { directory }, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly, xmlLoader); LoadBinaryComponents(loggerFactory, new[] { directory }, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); }
public void XDocumentLoadTest() { var xDocument = XDocument.Parse(ListXml); XmlLoader.Parse(xDocument); }
public static DungeonInfo DungeonLoad(string Id) { return(XmlLoader.LoadFromXmlResource <DungeonInfo>("Xml/Dungeon/" + Id)); }
public void XmlParseTest() { XmlLoader.Parse(ListXml); }