public System.Xml.Linq.XElement ToPhysical(System.Xml.Linq.XElement udsService) { string name = udsService.Attribute("Name").Value; XElement x = new XElement("Service", new XAttribute("Name", name)); XElement prop = new XElement("Property", new XAttribute("Name", "Definition")); x.Add(prop); XElement serv = new XElement("Service"); prop.Add(serv); XElement sd = new XElement("ServiceDescription"); serv.Add(sd); XElement handler = new XElement("Handler", new XAttribute("ExecType", "RemoteComponent")); sd.Add(handler); XElement udsDefinition = udsService.Element("Definition"); foreach (XElement e in udsDefinition.Elements()) sd.Add(e); XElement usage = new XElement("Usage"); sd.Add(usage); XElement sh = new XElement("ServiceHelp"); sh.Add(new XElement("Description")); sh.Add(new XElement("RequestSDDL")); sh.Add(new XElement("ResponseSDDL")); sh.Add(new XElement("Errors")); sh.Add(new XElement("RelatedDocumentServices")); sh.Add(new XElement("Samples")); serv.Add(sh); return x; }
public void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, Stream outputStream) { StreamWriter Output = new StreamWriter(outputStream); int StartAt = CommandNode.Attribute("StartAt") != null ? int.Parse(CommandNode.Attribute("StartAt").Value) : 0; var positions = from c in CommandNode.Descendants("Position") orderby int.Parse(c.Attribute("Start").Value) ascending select new { Name = c.Attribute("Name").Value, Start = int.Parse(c.Attribute("Start").Value) - StartAt, Length = int.Parse(c.Attribute("Length").Value), Justification = c.Attribute("Justification") != null ? c.Attribute("Justification").Value.ToLower() : "left" }; int lineLength = positions.Last().Start + positions.Last().Length; foreach (DataRow row in Table.Rows) { StringBuilder line = new StringBuilder(lineLength); foreach (var p in positions) line.Insert(p.Start, p.Justification == "left" ? (row.Field<string>(p.Name) ?? "").PadRight(p.Length, ' ') : (row.Field<string>(p.Name) ?? "").PadLeft(p.Length, ' ') ); Output.WriteLine(line.ToString()); } Output.Flush(); }
public static ColorInfo FromXml(System.Xml.Linq.XElement el) { var c = new ColorInfo(); c.Category = el.Attribute("Category").Value; c.Name= el.Attribute("Name").Value; c.rgb = int.Parse(el.Attribute("RGB").Value.Substring(1),System.Globalization.NumberStyles.HexNumber); return c; }
public override async Task<DriveFile> GetFileAsync(System.Xml.Linq.XElement xml, CancellationToken token) { var file = new MockDriveFile(this, xml.Attribute("name").Value, bool.Parse(xml.Attribute("isFolder").Value), bool.Parse(xml.Attribute("isImage").Value), bool.Parse(xml.Attribute("isRoot").Value)); return file; }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { XAttribute colorRedAtt = elemtype.Attribute("red"); if (colorRedAtt == null) { //Add error message here color = default(Color); return false; } XAttribute colorGreenAtt = elemtype.Attribute("green"); if (colorGreenAtt == null) { //Add error message here color = default(Color); return false; } XAttribute colorBlueAtt = elemtype.Attribute("blue"); if (colorBlueAtt == null) { //Add error message here color = default(Color); return false; } int alpha = 255; XAttribute colorAlphaAtt = elemtype.Attribute("metal"); if (colorAlphaAtt != null) { switch (colorAlphaAtt.Value) { case "yes": alpha = 0; break; case "no": alpha = 255; break; default: if (!int.TryParse(colorAlphaAtt.Value, out alpha)) alpha = 255; break; } } int red, green, blue; int.TryParse(colorRedAtt.Value, out red); int.TryParse(colorGreenAtt.Value, out green); int.TryParse(colorBlueAtt.Value, out blue); color = new Color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f); // LINEAR //if (PlayerSettings.colorSpace == ColorSpace.Linear) { color = color.linear; } UniqueIndex = num_created; num_created++; return true; }
public Location(System.Xml.Linq.XElement data) { this.RealName = data.Attribute("RealName").Value; this.Latitude = data.Attribute("Latitude").Value; this.Longtitude = data.Attribute("Longtitude").Value; this.LocationType = (TransportType)Enum.Parse(typeof(TransportType), data.Attribute("LocationType").Value); foreach (var x in data.Elements("Alias")) { this.aliases.Add(x.Value); } }
public static PidProfile FromXmlElement(System.Xml.Linq.XElement pidProfileElement) { var profile = new PidProfile() { DirectionProfile = (DirectionProfile)Enum.Parse(typeof(DirectionProfile), pidProfileElement.Attribute("Direction").Value), ProportionalGain = pidProfileElement.Attribute("ProportionalGain").ParseDouble(), IntegralGain = pidProfileElement.Attribute("IntegralGain").ParseDouble(), DerivativeGain = pidProfileElement.Attribute("DerivativeGain").ParseDouble(), }; return profile; }
public override void draw(System.Xml.Linq.XElement e, System.Windows.Controls.Canvas c) { if (e.Attribute("color") != null) { String col = e.Attribute("color").Value; Console.WriteLine("BGCOL : " + col); Rectangle rect = new Rectangle(); rect.Height = cHeight;//HARD CODED BUG rect.Width = cWidth; rect.Fill = new SolidColorBrush(ColorParser.parse(col)); addToCanvas(e, rect, c); } }
public override bool ParseDefinition(System.Xml.Linq.XElement element) { bool result = this.parse(element); Tag = element.Attribute("Tag").Value; return result; }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { if (store == null) //nowhere to put the image. { Debug.LogError("Texture Storage is Null: " + elemtype); return false; } XAttribute fileAtt = elemtype.Attribute("file"); if (fileAtt == null) { Debug.LogError("No file attribute in " + elemtype); //Add error message here return false; } string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value); filePath = Path.GetFullPath(filePath); if (!File.Exists(filePath)) { Debug.LogError("File not found: " + filePath); return false; } byte[] fileData = File.ReadAllBytes(filePath); Texture2D tex = new Texture2D(2,2); tex.LoadImage(fileData); tex.name = filePath; storageIndex = store.AddTexture(tex); return true; }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { XAttribute fileAtt = elemtype.Attribute("file"); if (fileAtt == null) { //Add error message here return false; } string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value); filePath = Path.GetFullPath(filePath); // Load the OBJ in var lStream = new FileStream(filePath, FileMode.Open); var lOBJData = OBJLoader.LoadOBJ(lStream); lStream.Close(); meshData = new MeshData[(int)MeshLayer.Count]; Mesh tempMesh = new Mesh(); for (int i = 0; i < meshData.Length; i++) { tempMesh.LoadOBJ(lOBJData, ((MeshLayer)i).ToString()); meshData[i] = new MeshData(tempMesh); tempMesh.Clear(); } lStream = null; lOBJData = null; return true; }
public static TiltControllerSettings FromXmlElement(System.Xml.Linq.XElement angleControllerElement) { var cwProfileElement = angleControllerElement.Elements("PidProfile").Single(x => x.Attribute("Direction").Value == DirectionProfile.CW.ToString()); var settings = new TiltControllerSettings() { IsEnabled = angleControllerElement.Attribute("IsEnabled").ParseOptionalBoolean(), MotorDriver = (MotorDriver)Enum.Parse(typeof(MotorDriver), angleControllerElement.Attribute("MotorDriver").Value), IntegralWindupThreshold = angleControllerElement.Attribute("IntegralWindupThreshold").ParseDouble(), OutputRateLimit = angleControllerElement.Attribute("OutputRateLimit").ParseInt(), PidProfiles = new Dictionary<DirectionProfile, PidProfile> { {DirectionProfile.CW, PidProfile.FromXmlElement(cwProfileElement) } }, }; return settings; }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { XAttribute indexAtt = elemtype.Attribute("index"); if (indexAtt == null) { //Add error message here value = default(int); return false; } return int.TryParse(indexAtt.Value, out value); }
//<tcm:Item ID="tcm:17-384-64" Title="Some Page Title" Type="64" OrgItemID="tcm:17-107-4" Path="\040 Web Publication\Root\030 - Work" Icon="T64L1P0" Publication="040 Web Publication"></tcm:Item> public ListItem(System.Xml.Linq.XElement node) { TcmId = node.Attribute("ID").SafeStringVal(); Title = node.Attribute("Title").SafeStringVal(); ItemTypeId = node.Attribute("Type").SafeStringVal(); WebDavPath = node.Attribute("Path").SafeStringVal(); Icon = node.Attribute("Icon").SafeStringVal(); ParentTcmId = node.Attribute("OrgItemID").SafeStringVal(); PublicationTitle = node.Attribute("Publication").SafeStringVal(); ItemTypeName = EnumHelper<Tridion.ContentManager.CoreService.Client.ItemType>.Parse(ItemTypeId, true); }
public virtual void From_XML(System.Xml.Linq.XElement xml) { Source_Startup_Policy = Libvirt.Models.Concrete.Disk.Source_Startup_Policies.mandatory; if (xml != null) { var attr = xml.Attribute("startupPolicy"); if (attr != null) { var b = Libvirt.Models.Concrete.Disk.Source_Startup_Policies.mandatory; Enum.TryParse(attr.Value, true, out b); Source_Startup_Policy = b; } } }
public XElement ToUDS(System.Xml.Linq.XElement physicalService) { string name = physicalService.Attribute("Name").Value; XElement x = new XElement("Service", new XAttribute("Name", name), new XAttribute("Enabled", "true")); XElement def = new XElement("Definition", new XAttribute("Type", "DBHelper")); x.Add(def); XElement handler = physicalService.XPathSelectElement("Property[@Name='Definition']/Service/ServiceDescription/Handler"); foreach (XElement e in handler.Elements()) def.Add(e); return x; }
public override void draw(System.Xml.Linq.XElement e, System.Windows.Controls.Canvas c) { String id = e.Attribute("id").Value; try{ LinkedList<XElement> list = templates[id]; foreach(XElement l in list){ Console.WriteLine(l); e.AddAfterSelf(l); } } catch (KeyNotFoundException err) { throw new XMLNotRecognizedElement("template "+id+" not found"); } }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { XAttribute layerAtt = elemtype.Attribute("type"); if (layerAtt == null) { //Add error message here layer = Layer.SOLID; return false; } try { layer = (Layer)Enum.Parse(typeof(Layer), layerAtt.Value); } catch (Exception) { return false; } return true; }
public static DocType readAsXelement(System.Xml.Linq.XElement xroot) { DocType res = new DocType(); XElement el; XAttribute at = xroot.Attribute("id"); if (at == null) return null; else res.id = at.Value; el = xroot.Element(_getKeepName("label")); if (el==null) res.label = ""; else res.label = el.Value; el = xroot.Element(_getKeepName("description")); if (el==null) res.description = ""; else res.description = el.Value; //TODO - what if fld.id is null ? XElement list = xroot.Element(_getKeepName("fieldList")); if (list != null) foreach (XElement field in list.Elements()){ //for each in field Field fld = new Field(); fld.id = (at = field.Attribute("id")) == null ? "" : at.Value; if (fld.id == null) continue; fld.type = (at = field.Attribute("type")) == null ? "" : at.Value; fld.typeArgs = (at = field.Attribute("typeArgs")) == null ? "" : at.Value; //TODO - atribuiçºao fld.label = (el = field.Element(_getKeepName("label"))) == null ? "" : el.Value; fld.description = (el = field.Element(_getKeepName("description"))) == null ? "" : el.Value; res.fields.Add(fld); //create faster tag helper list if (fld.type =="vocabulary" && fld.id != "" && fld.typeArgs != ""){ //we have a field wich indicates tags. res.tagFields.Add(fld); } } return res; }
public City(Country country, System.Xml.Linq.XElement xCity, System.Xml.Linq.XDocument xDoc) { this.ID = xCity.Attribute("id").Value; this.Name = xCity.Element("name").Value; var xPop = xCity.Element("population"); if (xPop != null) this.Population = int.Parse(xPop.Value); var xLat = xCity.Element("latitude"); if (xLat == null) { //Debug.WriteLine(this.Name + " ohne Positionsangabe"); } else { Location = new Location() { Latitude = double.Parse(xCity.Element("latitude").Value, CultureInfo.InvariantCulture), Longitude = double.Parse(xCity.Element("longitude").Value, CultureInfo.InvariantCulture) }; } this.Country = country; }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { if (store == null) //nowhere to put the image. { Debug.LogError("Texture Storage is Null: " + elemtype); return false; } XAttribute patternAtt = elemtype.Attribute("pattern"); if (patternAtt == null) { Debug.LogError("No pattern attribute in " + elemtype); //Add error message here return false; } string patternPath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), patternAtt.Value); patternPath = Path.GetFullPath(patternPath); if (!File.Exists(patternPath)) { Debug.LogError("File not found: " + patternPath); return false; } byte[] patternData = File.ReadAllBytes(patternPath); Texture2D patternTex = new Texture2D(2, 2); patternTex.LoadImage(patternData); XAttribute specularAtt = elemtype.Attribute("specular"); if (specularAtt == null) { Debug.LogError("No specular attribute in " + elemtype); //Add error message here return false; } string specularPath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), specularAtt.Value); specularPath = Path.GetFullPath(specularPath); if (!File.Exists(specularPath)) { Debug.LogError("File not found: " + specularPath); return false; } byte[] specularData = File.ReadAllBytes(specularPath); Texture2D specularTex = new Texture2D(2, 2); specularTex.LoadImage(specularData); if (specularTex.width != patternTex.width || specularTex.height != patternTex.height) { TextureScale.Bilinear(specularTex, patternTex.width, patternTex.height); } Texture2D combinedMap = new Texture2D(patternTex.width, patternTex.height, TextureFormat.ARGB32, false, false); combinedMap.name = patternPath + specularAtt.Value; Color[] patternColors = patternTex.GetPixels(); Color[] specularColors = specularTex.GetPixels(); for (int i = 0; i < patternColors.Length; i++) { patternColors[i] = new Color(patternColors[i].r, patternColors[i].g, patternColors[i].b, specularColors[i].linear.r); } combinedMap.SetPixels(patternColors); combinedMap.Apply(); storageIndex = store.AddTexture(combinedMap); return true; }
public void Load(System.Xml.Linq.XElement _Data) { Sequence.Load(_Data.Element("Sequence")); Name = _Data.Attribute("Name").Value; try { IPAddress = IPAddress.Parse(_Data.Attribute("IPAddress").Value); Port = ushort.Parse(_Data.Attribute("Port").Value); Reconnect(); } catch { } foreach (XElement element in _Data.Elements("MainStation")) { FrontEndMainStation ms = new FrontEndMainStation(); ms.Load(element); mainstations.Add(ms); } foreach (XElement element in _Data.Elements("WebInterface")) { FrontEndWebInterface wi = new FrontEndWebInterface(element); webinterfaces.Add(wi); } }
public override void ConfigureFromNode(System.Xml.Linq.XElement element) { Key = element.Attribute("key").Value; Value = element.Value; }
public static Channel Load(System.Xml.Linq.XElement node) { return new Channel { Code = node.Attribute("id").Value, Name = node.Element("display-name").Value }; }
public static Program Load(System.Xml.Linq.XElement node) { return new Program { ChannelCode = node.Attribute("channel").Value, Title = GetNodeValue(node, "title"), Subtitle = GetNodeValue(node, "sub-title"), Description = GetNodeValue(node, "desc"), StartTime = ToDate(node.Attribute("start").Value), EndTime = ToDate(node.Attribute("stop") .Value), Timestamp = DateTime.Now }; }
public void FromXml(System.Security.SecurityElement e) { // FIXME: falta ter em conta mClassName if (e.Attribute(ClassAttr) != this.GetType().AssemblyQualifiedName) { throw new ArgumentException("SecurityElement class is incorrect."); } if (e.Attribute(VersionAttr) != Version) { throw new ArgumentException("SecurityElement version is incorrect."); } ArrayList fo = new ArrayList(); foreach (SecurityElement c in e.Children) { if (c.Tag != InternalTag) { throw new ArgumentException("SecurityElement child is incorrect."); } if (c.Attribute(ClassAttr) != typeof(string).AssemblyQualifiedName) { throw new ArgumentException("SecurityElement child class is incorrect."); } if (c.Attribute(VersionAttr) != Version) { throw new ArgumentException("SecurityElement child version is incorrect."); } fo.Add(c.Attribute(ValueAttr)); } this.mOperations = new string[fo.Count]; fo.CopyTo(this.mOperations); }
/// <summary> /// <inheritdoc/> /// </summary> public void ParseFromXElement(System.Xml.Linq.XElement source) { if (source.Name != "Unit") throw new Exception("The given source element is not named Unit (but " + source.Name + ") and will not be parsed!"); if (source.Attribute("Name") != null) { Name = source.Attribute("Name").Value; } else { Name = source.Element("Name").Value; } ShortName = source.Element("ShortName").Value; int temp; var parse = (int.TryParse(source.Element("DecimalDigits").Value, out temp)) ? DecimalDigits = temp : DecimalDigits = 3; ThousandSeperator = source.Element("ThousandSeperator").Value; DecimalSeperator = source.Element("DecimalSeperator").Value; }
/// /// <summary> /// Here we override ReadEvent and read additional Video property</summary> /// public override TimelineEvent ReadEvent( System.Xml.Linq.XElement row ) { TimelineEventEx e; e = base.ReadEvent(row) as TimelineEventEx; e.Video = GetAttribute(row.Attribute("video")); return e; }
public bool AddTypeElement(System.Xml.Linq.XElement elemtype) { if (store == null) //nowhere to put the image. { Debug.LogError("Texture Storage is Null: " + elemtype); return false; } XAttribute normalAtt = elemtype.Attribute("normal"); if (normalAtt == null) { Debug.LogError("No normal map in " + elemtype); //Add error message here return false; } string normalPath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), normalAtt.Value); normalPath = Path.GetFullPath(normalPath); if (!File.Exists(normalPath)) { Debug.LogError("File not found: " + normalPath); return false; } byte[] normalData = File.ReadAllBytes(normalPath); Texture2D normalMap = new Texture2D(2, 2, TextureFormat.ARGB32, false, true); normalMap.LoadImage(normalData); XAttribute specularAtt = elemtype.Attribute("specular"); if (specularAtt == null) { Debug.LogError("No specular map in " + elemtype); //Add error message here return false; } string specularPath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), specularAtt.Value); specularPath = Path.GetFullPath(specularPath); if (!File.Exists(specularPath)) { Debug.LogError("File not found: " + specularPath); return false; } byte[] specularData = File.ReadAllBytes(specularPath); Texture2D specularMap = new Texture2D(2, 2, TextureFormat.ARGB32, false, false); specularMap.LoadImage(specularData); if ((specularMap.width != normalMap.width) || (specularMap.height != normalMap.height)) { TextureScale.Bilinear(specularMap, normalMap.width, normalMap.height); } XAttribute occlusionAtt = elemtype.Attribute("occlusion"); if (occlusionAtt == null) { Debug.LogError("No occlusion map in " + elemtype); //Add error message here return false; } string occlusionPath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), occlusionAtt.Value); occlusionPath = Path.GetFullPath(occlusionPath); if (!File.Exists(occlusionPath)) { Debug.LogError("File not found: " + occlusionPath); return false; } byte[] occlusionData = File.ReadAllBytes(occlusionPath); Texture2D occlusionMap = new Texture2D(2, 2, TextureFormat.ARGB32, false, true); occlusionMap.LoadImage(occlusionData); if (occlusionMap.width != normalMap.width || occlusionMap.height != normalMap.height) { TextureScale.Bilinear(occlusionMap, normalMap.width, normalMap.height); } Texture2D combinedMap = new Texture2D(normalMap.width, normalMap.height, TextureFormat.ARGB32, false, true); combinedMap.name = normalPath + occlusionAtt.Value + specularAtt.Value; Color[] normalColors = normalMap.GetPixels(); Color[] occlusionColors = occlusionMap.GetPixels(); Color[] specularColors = specularMap.GetPixels(); if (normalColors.Length != specularColors.Length) Debug.LogError("Maps aren't same size!"); for (int i = 0; i < normalColors.Length; i++) { normalColors[i] = new Color(occlusionColors[i].r, normalColors[i].g, specularColors[i].r, normalColors[i].r); } combinedMap.SetPixels(normalColors); combinedMap.Apply(); storageIndex = store.AddTexture(combinedMap); return true; }
//public Uri MediaUrl { get; set; } //public string PictureUrl { get; set; } //public bool IsPlayable { get { return (Duration.Ticks > 0); } } /// <summary> /// Fill MediaItem with Values /// </summary> /// <param name="element">Element from XML</param> protected internal void FillMediaItem(System.Xml.Linq.XElement element) { Content = GetContentType((string)element.Attribute("content")); IsSkippable = GetIsSkippable((string)element.Element("skippable")); if (IsSkippable) SkipAfter = GetDuration(element.Element("skippable"), "after"); if (element.Element("duration") != null) Duration = GetDuration((string)element.Element("duration")); //MediaUrl = GetUri(mItem.Element("media"), "href"); ThumbUrl = GetString(element.Element("thumb"), "href"); //PictureUrl = GetString(mItem.Element("picture"), "href"),; if (element.Element("meta") != null) { XElement meta = element.Element("meta"); Metadata = new Meta { Title = GetString(meta.Element("title")), Description = GetString(meta.Element("description")), PublishDate = GetPuplishDate(GetString(meta.Element("publishdate"))), }; } if (element.Element("markers") != null) { XElement markers = element.Element("markers"); var m = from marker in markers.Descendants("marker") select new Marker() { Name = GetString(marker.Attribute("name")), Text = GetString(marker), Start = GetDuration(GetString(marker.Attribute("start"))), End = GetDuration(GetString(marker.Attribute("end"))), }; Markers = m.ToList<Marker>(); } if (element.Element("tracking") != null) { XElement tracking = element.Element("tracking"); TrackingData = GetTracking(tracking); } }