public override async Task LoadAsync(Account account, string id, System.Xml.Linq.XElement xml, CancellationToken token) { await base.LoadAsync(account, id, xml, token); DestFolder = xml.Element("destFolder").Value; File = await account.GetFileAsync(xml.Element("file"), token); }
protected override void InternalFromXml(System.Xml.Linq.XElement xml, TmxMap tmxMap) { Debug.Assert(xml.Name == "object"); Debug.Assert(xml.Element("polyline") != null); var points = from pt in xml.Element("polyline").Attribute("points").Value.Split(' ') let x = float.Parse(pt.Split(',')[0]) let y = float.Parse(pt.Split(',')[1]) select new PointF(x, y); // If there are only 2 points in the polyline then we force a midpoint between them // This is because the clipper library is rejecting polylines unless there is 3 or more points if (points.Count() == 2) { var A = points.First(); var B = points.Last(); var M = TmxMath.MidPoint(A, B); this.Points = new List <PointF>() { A, M, B }; } else { this.Points = points.ToList(); } }
public void From_XML(System.Xml.Linq.XElement xml) { var element = xml.Element("name"); if (element == null) { if (xml.Name == "name") { element = xml; } else { element = null; } } if (element != null) { name = element.Value; } element = xml.Element("title"); if (element != null) { title = element.Value; } element = xml.Element("description"); if (element != null) { description = element.Value; } element = xml.Element("uuid"); if (element != null) { uuid = element.Value; } }
/// <summary> /// Создать информацию о файле на основе xml элемента. /// </summary> /// <param name="xmlElement">Xml элемент.</param> /// <param name="packageFolderPath">Путь к папке хранения файлов, переданных в пакете.</param> /// <param name="sentByEmail">Признак, что пакет захвачен с почты.</param> /// <returns>Информация о файле.</returns> public virtual IBlob CreateBlobFromXelement(System.Xml.Linq.XElement xmlElement, string packageFolderPath, bool sentByEmail) { var blob = Functions.Blob.Remote.CreateBlob(); var relativeFilePath = Path.GetFileName(xmlElement.Element(Constants.Module.DcsInputFilesTagNames.FileName).Value); var absoluteFilePath = Path.Combine(packageFolderPath, relativeFilePath); if (File.Exists(absoluteFilePath)) { blob.FilePath = absoluteFilePath; blob.OriginalFileName = xmlElement.Element(Constants.Module.DcsInputFilesTagNames.FileDescription).Value; if (sentByEmail) { blob.Body.Write(System.IO.File.OpenRead(absoluteFilePath)); } } else { Logger.Error(Resources.FileNotFoundFormat(absoluteFilePath)); } blob.Save(); return(blob); }
private void LeerIdioma() { System.Xml.Linq.XElement xml = Tools.Helper.GetTranslation("Espera"); this.Text = xml.Element("S01").Value; label1.Text = xml.Element("S01").Value; }
private static string GetEditionName() { string editionName = string.Empty; string localApplicationDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string settingsPath = Path.Combine(localApplicationDataPath, "MapSuiteGisEditor"); if (!Directory.Exists(settingsPath)) { editionName = new InfrastructureManager().EditionName; } else { string activeProfiler = Path.Combine(settingsPath, "ActiveProfiler.xml"); if (File.Exists(activeProfiler)) { System.Xml.Linq.XElement startUpSetting = System.Xml.Linq.XElement.Load(activeProfiler); if (startUpSetting.Element("EditionName") != null) { editionName = startUpSetting.Element("EditionName").Value; } } } return(editionName); }
public Activity Parse(System.Xml.Linq.XElement inputElement) { var activity = new RdvEventSourceActivity(); activity.Name = inputElement.Attribute("name").Value; activity.Type = (ActivityType)inputElement.Element(XmlnsConstant.tibcoProcessNameSpace + "type").Value; var configElement = inputElement.Element("config"); activity.Subject = XElementParserUtils.GetStringValue(configElement.Element("subject")); activity.SharedChannel = XElementParserUtils.GetStringValue(configElement.Element("sharedChannel")); //TODO manage REF or XSD : is it really used ? Let's do something dirty and assume it's always a string name message /*if (configElement.Element ("XsdString").Attribute ("ref") != null) { * activity.XsdStringReference = configElement.Element("XsdString").Attribute("ref").ToString(); * } * else * { * activity.ObjectXNodes = configElement.Element("XsdString").Nodes(); * var activityParameters = new XsdParser().Parse (configElement.Element("XsdString").Nodes(), string.Empty); * activity.Parameters = activityParameters; * }*/ activity.Parameters = new List <ClassParameter> { new ClassParameter { Name = "message", Type = "System.String" } }; return(activity); }
// <MeshSection material="character_anim:headM" ctype="fff fff ff ff ff ffff hhhh" semantic="position normal texcoord1 texcoord2 texcoord3 blendweights blendindices"> /// <summary> /// /// </summary> /// <param name="xMeshSection"></param> /// <returns></returns> public static EZMMeshSection Parse(System.Xml.Linq.XElement xElement) { EZMMeshSection result = null; if (xElement.Name == "MeshSection") { result = new EZMMeshSection(); { var attr = xElement.Attribute("material"); if (attr != null) { result.MaterialName = attr.Value; } } { var attr = xElement.Attribute("ctype"); if (attr != null) { result.Ctype = attr.Value; } } { var attr = xElement.Attribute("semantic"); if (attr != null) { result.Semantic = attr.Value; } } { var aabb = xElement.Element("MeshAABB"); if (aabb != null) { var xMin = aabb.Attribute("min"); if (xMin != null) { string[] parts = xMin.Value.Split(Separator.separators, StringSplitOptions.RemoveEmptyEntries); var x = float.Parse(parts[0]); var y = float.Parse(parts[1]); var z = float.Parse(parts[2]); result.Min = new vec3(x, y, z); } var xMax = aabb.Attribute("max"); if (xMax != null) { string[] parts = xMax.Value.Split(Separator.separators, StringSplitOptions.RemoveEmptyEntries); var x = float.Parse(parts[0]); var y = float.Parse(parts[1]); var z = float.Parse(parts[2]); result.Max = new vec3(x, y, z); } } } { result.Indexbuffer = ParseIndexbuffer(xElement.Element("indexbuffer")); } } return(result); }
/// <summary> /// 必须重写这个方法,这个方法里应当包含怎么解析文件的数据 /// </summary> /// <param name="content"></param> public override void LoadByString(string content) { // 上面的存储是使用xml的方式的,所以此处解析也要对照 System.Xml.Linq.XElement element = System.Xml.Linq.XElement.Parse(content); IpAddress = element.Element(nameof(IpAddress)).Value; Port = int.Parse(element.Element(nameof(Port)).Value); }
public Data.Person Adapt(System.Xml.Linq.XElement xElement) { return(new Data.Person( ) { Id = xElement.Attribute("Id").GetValue(Guid.NewGuid( ), s => new Guid(s)), Name = xElement.Element("Name").GetValue( ), Phone = xElement.Element("Phone").GetValue( ) }); }
public Reservation PostXml([FromBody] System.Xml.Linq.XElement res) { return(repository.AddReservation(new Reservation { Name = res.Element("Name").Value, StartLocation = res.Element("StartLocation").Value, EndLocation = res.Element("EndLocation").Value })); }
public Reservation PostXml([FromBody] System.Xml.Linq.XElement res) { return(repository.AddReservation(new Reservation { Prix = res.Element("Prix").Value, Depart = res.Element("Depart").Value, Arriver = res.Element("Arriver").Value })); }
private void LeerIdioma() { try { System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "Plugins" + System.IO.Path.DirectorySeparatorChar + "LaytonLang.xml"); xml = xml.Element(pluginHost.Get_Language()).Element("InfoAni"); btnSave.Text = xml.Element("S03").Value; } catch { throw new Exception("There was an error reading the XML file of language."); } }
public Espera(string label, int step) { InitializeComponent(); System.Xml.Linq.XElement xml = Tools.Helper.GetTranslation("Espera"); this.Text = xml.Element("S01").Value; label1.Text = xml.Element(label).Value; progressBar1.Style = ProgressBarStyle.Continuous; progressBar1.Step = step; }
object IParser.Parse(XElement e) { if (e == null) { throw new ArgumentNullException("e", Message.Get("Common.NullArgument", "e")); } var templateElement = e.Element("template"); if (templateElement == null) { throw new ArgumentException(Message.Get("Xml.NoElement", "template", e), "e"); } var template = templateParser.Parse(templateElement); #if f // Проверка элемента инстанса. var instancesElement = e.Element("instances"); if (instancesElement == null) { throw new ArgumentException(Message.Get("Xml.NoElement", "instances", e), "e"); } // Получение элемента инстанса. var instanceElements = instancesElement.Elements("instance"); #endif var instanceElements = e.Elements("instance"); if (instanceElements.Count() == 0) { throw new ArgumentException(Message.Get("Xml.NoElements", "instance", e), "e"); } if (typeof(T) == typeof(GroupReport)) { var instances = new List <Instance>(); foreach (var instanceElement in instanceElements) { instanceParser = new InstanceParser(template); instances.Add(instanceParser.Parse(instanceElement)); } return(new GroupReport(template, instances)); } else #warning Неясное сообщение исключения. { throw new InvalidOperationException("В ReportParser был передан неверный тип объекта."); } }
private void ReadLanguage() { try { System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load(Application.StartupPath + Path.DirectorySeparatorChar + "Plugins" + Path.DirectorySeparatorChar + "CommonLang.xml"); xml = xml.Element(pluginHost.Get_Language()).Element("BasicControl"); btnSave.Text = xml.Element("S00").Value; } catch { throw new NotSupportedException("There was an error reading the language file"); } }
protected override void InternalFromXml(System.Xml.Linq.XElement xml, TmxMap tmxMap) { Debug.Assert(xml.Name == "object"); Debug.Assert(xml.Element("polyline") != null); var points = from pt in xml.Element("polyline").Attribute("points").Value.Split(' ') let x = float.Parse(pt.Split(',')[0]) let y = float.Parse(pt.Split(',')[1]) select new PointF(x, y); this.Points = points.ToList(); }
public void ReadLanguage() { try { System.Xml.Linq.XElement xml = Tools.Helper.GetTranslation("Sistema"); this.Text = xml.Element("S03").Value; xml = Tools.Helper.GetTranslation("Messages"); contextMenuStrip1.Items[0].Text = xml.Element("S0E").Value; //clearLogToolStripMenuItem.Text = xml.Element("S26").Value; } catch { throw new NotSupportedException("There was an error reading the language file"); } }
public static VirtualRSSXmlFile Load(string FilePath) { VirtualRSSXmlFile LoadedVirtualRSSXmlFile; try { System.Xml.Linq.XDocument RSSXmlFile = System.Xml.Linq.XDocument.Load(FilePath); System.Xml.Linq.XElement RSS_Channel = RSSXmlFile.Element("rss").Element("channel"); LoadedVirtualRSSXmlFile = new VirtualRSSXmlFile( RSS_Channel.Element("title").Value, RSS_Channel.Element("link").Value, RSS_Channel.Element("description").Value, RSS_Channel.Element("generator").Value, RSS_Channel.Element("docs").Value, RSS_Channel.Element("language").Value, RSS_Channel.Element("pubDate").Value, RSS_Channel.Element("lastBuildDate").Value ); System.Xml.Linq.XElement[] ItemArray = RSS_Channel.Elements("item").ToArray(); foreach (System.Xml.Linq.XElement Item in ItemArray) { item CurrentItem = new item(Item.Element("title").Value, Item.Element("link").Value, Item.Element("description").Value, Item.Element("pubDate").Value); LoadedVirtualRSSXmlFile.ItemList.Add(CurrentItem); } } catch { LoadedVirtualRSSXmlFile = null; throw; } return(LoadedVirtualRSSXmlFile); }
private void ReadLanguage() { try { System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "Plugins" + System.IO.Path.DirectorySeparatorChar + "TXTLang.xml"); xml = xml.Element(pluginHost.Get_Language()); xml = xml.Element("TXT"); btnSave.Text = xml.Element("S00").Value; label1.Text = xml.Element("S01").Value; checkWordWrap.Text = xml.Element("S02").Value; } catch { throw new Exception("There was an error reading the XML file of language."); } }
private void ReadLanguage(string lang) { try { System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "Plugins" + System.IO.Path.DirectorySeparatorChar + "FontLang.xml"); xml = xml.Element(lang).Element("CharControl"); label1.Text = xml.Element("S00").Value; label3.Text = xml.Element("S01").Value; label2.Text = xml.Element("S02").Value; label4.Text = xml.Element("S03").Value; } catch { throw new NotSupportedException("There was an error reading the language file"); } }
public override void From_XML(System.Xml.Linq.XElement xml) { var os = xml.Element("source"); if (os == null) { if (xml.Name == "source") { os = xml; } else { os = null; } } if (os != null) { var attr = os.Attribute("dir"); if (attr != null) { dir_path = attr.Value; } base.From_XML(os); } }
/// <summary> /// Get Conductor object from XmlNode /// </summary> /// <param name="conductorItemNode"></param> /// <remarks> /// Takes an eventConductor child element from an eventItem and gets all its /// child elements to create a Conductor object, then returns that object. /// </remarks> /// <returns></returns> public static Conductor GetConductorFromNode(System.Xml.Linq.XElement conductorItemNode) { System.Xml.Linq.XElement conductorElement = conductorItemNode.Element(Constants.Conductor.conductorElement); if (conductorElement == null || string.IsNullOrEmpty((string)conductorElement.GetXElement(Constants.Conductor.conductorIDElement))) { return(null); } int conductorID; int.TryParse((string)conductorElement.GetXElement(Constants.Conductor.conductorIDElement), out conductorID); var conductor = Conductor.GetConductorByID(conductorID); if (!conductor.IsNew) { return(conductor); } var conductorFirstName = conductorElement.GetXElement(Constants.Conductor.conductorFirstNameElement); var conductorLastName = conductorElement.GetXElement(Constants.Conductor.conductorLastNameElement); var conductorNote = conductorElement.GetXElement(Constants.Conductor.conductorNoteElement); var conductorName4 = conductorElement.GetXElement(Constants.Conductor.conductorName4Element); var conductorName5 = conductorElement.GetXElement(Constants.Conductor.conductorName5Element); conductor = SetConductorData(conductorID, conductor, conductorFirstName, conductorLastName, conductorName4, conductorName5, conductorNote); return(conductor); }
/// <summary> /// Returns a Project object based on the eventProject data passed by the /// XElement eventItem element. /// </summary> /// <param name="node"></param> /// <returns></returns> public static Project GetProjectFromNode(System.Xml.Linq.XElement node) { System.Xml.Linq.XElement projectElement = node.Element(Constants.Project.projectElement); if (projectElement == null || string.IsNullOrEmpty(projectElement.GetXElement(Constants.Project.projectIDElement))) { return(null); } int projectID; int.TryParse(projectElement.GetXElement(Constants.Project.projectIDElement), out projectID); Project project = GetProjectByID(projectID); if (!project.IsNew) { return(project); } string projectName = projectElement.GetXElement(Constants.Project.projectNameElement); string projectName2 = projectElement.GetXElement(Constants.Project.projectName2Element); string projectTypeName = projectElement.GetXElement(Constants.Project.projectTypeNameElement); project = SetWorkData(projectID, project, projectName, projectName2, projectTypeName); return(project); }
/// <summary> /// Returns a Season object based on the eventSeason data passed by the /// XElement eventItem element. /// </summary> /// <param name="node"></param> /// <returns></returns> public static Season GetSeasonFromNode(System.Xml.Linq.XElement node) { System.Xml.Linq.XElement seasonElement = node.Element(Constants.Season.seasonElement); if (seasonElement == null || string.IsNullOrEmpty((string)seasonElement.GetXElement(Constants.Season.seasonIDElement))) { return(null); } int seasonID; int.TryParse(seasonElement.GetXElement(Constants.Season.seasonIDElement), out seasonID); Season season = GetSeasonByID(seasonID); if (!season.IsNew) { return(season); } string seasonName = seasonElement.GetXElement(Constants.Season.seasonNameElement); string seasonCode = seasonElement.GetXElement(Constants.Season.seasonCodeElement); season = SetSeasonData(seasonID, season, seasonCode, seasonName); return(season); }
/// <summary> /// Get TypeGroup object based on an XElement node /// </summary> /// <param name="node"></param> /// <remarks> /// Takes a eventItem node and extracts the TypeGroup information /// for that event. It then returns either an existing TypeGroup if one /// exists with the same id, or creates a new one to return. /// </remarks> /// <returns></returns> public static EventTypeGroup GetEventTypeGroupFromNode(System.Xml.Linq.XElement node) { System.Xml.Linq.XElement typeGroupElement = node.Element(Constants.EventTypeGroup.typeGroupElement); if (typeGroupElement == null || string.IsNullOrEmpty((string)typeGroupElement.GetXElement(Constants.EventTypeGroup.typeGroupIDElement))) { return(null); } int typeGroupID; int.TryParse(typeGroupElement.GetXElement(Constants.EventTypeGroup.typeGroupIDElement), out typeGroupID); if (typeGroupID == 0) { typeGroupID = 1000; } EventTypeGroup typeGroup = GetTypeGroupByID(typeGroupID); if (!typeGroup.IsNew) { return(typeGroup); } string typeGroupName = typeGroupElement.GetXElement(Constants.EventTypeGroup.typeGroupNameElement); string typeGroupName2 = typeGroupElement.GetXElement(Constants.EventTypeGroup.typeGroupName2Element); typeGroup = SetTypeGroupData(typeGroupID, typeGroup, typeGroupName, typeGroupName2); return(typeGroup); }
protected override void InternalFromXml(System.Xml.Linq.XElement xml, TmxMap tmxMap) { var points = from pt in xml.Element("polygon").Attribute("points").Value.Split(' ') let x = float.Parse(pt.Split(',')[0]) let y = float.Parse(pt.Split(',')[1]) select new PointF(x, y); this.Points = points.ToList(); // Test if polygons are counter clocksise // From: http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order float sum = 0.0f; for (int i = 1; i < this.Points.Count(); i++) { var p1 = this.Points[i - 1]; var p2 = this.Points[i]; float v = (p2.X - p1.X) * -(p2.Y + p1.Y); sum += v; } if (sum < 0) { // Winding of polygons is counter-clockwise. Reverse the list. this.Points.Reverse(); } }
public new void From_XML(System.Xml.Linq.XElement xml) { Reset(); base.From_XML(xml); var element = xml.Element("capability"); if (element == null) { if (xml.Name == "capability") { element = xml; } else { element = null; } } if (element == null) { return; } var ele = element.Element("product"); if (ele != null) { product = ele.Value; } }
/// <summary> /// This method reads the specified element. /// </summary> /// <param name="pObjectToInitialize">The object to initialize</param> /// <param name="pElement">The element.</param> /// <param name="pSerializationContext">The serialization context.</param> /// <returns>The initialized object if the input object is valid.</returns> public override object Read(object pObjectToInitialize, System.Xml.Linq.XElement pElement, IXSerializationContext pSerializationContext) { IXTemplate lTemplate = pObjectToInitialize as IXTemplate; if (lTemplate != null) { Type lTemplatedObjectType = pSerializationContext.ResolveType(pElement.Element(XConstants.TYPE_TAG)); if (lTemplatedObjectType != null) { IXSerializationContract lContract = pSerializationContext.SelectContract(null, lTemplatedObjectType); object lTemplatedObject = null; if (lContract != null) { lTemplatedObject = lContract.Read(lTemplatedObject, pElement, pSerializationContext); } if (lTemplatedObject != null) { lTemplate.InitializeFrom(lTemplatedObject); } } } return(pObjectToInitialize); }
/// <summary> /// Given an XElement node extracts the composer information and creates a Composer object and returns it. /// </summary> /// <param name="node"></param> /// <returns></returns> public static Composer GetComposerFromNode(System.Xml.Linq.XElement node) { if (node == null || node.Element(Constants.Composer.composerIDElement) == null) { return(null); } int composerID; int.TryParse(node.GetXElement(Constants.Composer.composerIDElement), out composerID); Composer composer = Composer.GetComposerByID(composerID); if (!composer.IsNew) { return(composer); } composer.ComposerID = composerID; GetComposerData(node, composer); return(composer); }