private SoundInfo LoadSound(XElement soundNode, string basePath) { SoundInfo sound = new SoundInfo { Name = soundNode.RequireAttribute("name").Value }; sound.Loop = soundNode.TryAttribute<bool>("loop"); sound.Volume = soundNode.TryAttribute<float>("volume", 1); XAttribute pathattr = soundNode.Attribute("path"); XAttribute trackAttr = soundNode.Attribute("track"); if (pathattr != null) { sound.Type = AudioType.Wav; sound.Path = FilePath.FromRelative(pathattr.Value, basePath); } else if (trackAttr != null) { sound.Type = AudioType.NSF; int track; if (!trackAttr.Value.TryParse(out track) || track <= 0) throw new GameXmlException(trackAttr, "Sound track attribute must be an integer greater than zero."); sound.NsfTrack = track; sound.Priority = soundNode.TryAttribute<byte>("priority", 100); } else { sound.Type = AudioType.Unknown; } return sound; }
public MiningCrystals(XElement MiningCrystals) { TypeId = (int)MiningCrystals.Attribute("typeId"); OreType = (OreType)Enum.Parse(typeof(OreType), (string)MiningCrystals.Attribute("oreType")); Quantity = (int)MiningCrystals.Attribute("quantity"); Description = (string)MiningCrystals.Attribute("description") ?? (string)MiningCrystals.Attribute("typeId"); }
internal CharacterAttachmentBrand(CharacterAttachmentSlot slot, XElement element) { Slot = slot; // Set up strings var brandNameAttribute = element.Attribute("Name"); if (brandNameAttribute != null) Name = brandNameAttribute.Value; var brandThumbnailAttribute = element.Attribute("Thumbnail"); if (brandThumbnailAttribute != null) ThumbnailPath = brandThumbnailAttribute.Value; // Get attachments var slotAttachmentElements = element.Elements("Attachment"); int count = slotAttachmentElements.Count(); if (Slot.CanBeEmpty) count++; var slotAttachments = new CharacterAttachment[count]; for (int i = 0; i < slotAttachmentElements.Count(); i++) { var slotAttachmentElement = slotAttachmentElements.ElementAt(i); slotAttachments[i] = new CharacterAttachment(Slot, slotAttachmentElement); } if (Slot.CanBeEmpty) slotAttachments[slotAttachmentElements.Count()] = new CharacterAttachment(Slot, null); Attachments = slotAttachments; }
public static GameObject buildObjectFromXML(XElement xmlObject) { string objectName = (xmlObject.Attribute("name") != null) ? ((string)xmlObject.Attribute("name")) : ("Unit Map Object"); string sprite = "testTile_White_Black"; return generateObject(objectName, sprite); }
static void ProvisionModuleInternal(this Web web, string baseFolder, XElement moduleXml) { if (moduleXml == null) { throw new ArgumentNullException(nameof(moduleXml)); } if (moduleXml.Name != XName.Get("Module", SharePointNamespaceName)) { throw new ArgumentException(CoreResources.ProvisioningExtensions_ProvisionModuleInternal_Expected_element__Module__, nameof(moduleXml)); } var name = moduleXml.Attribute("Name").Value; var moduleBaseUrl = moduleXml.Attribute("Url").Value; var modulePath = moduleXml.Attribute("Path").Value; var moduleBaseFolder = Path.Combine(baseFolder, modulePath); Log.Debug(Constants.LOGGING_SOURCE, "Provisioning module '{0}'", name); foreach (var child in moduleXml.Elements()) { if (child.Name == XName.Get("File", SharePointNamespaceName)) { var filePath = child.Attribute("Path").Value; try { ProvisionFileInternal(web, moduleBaseUrl, moduleBaseFolder, child); } catch (Exception ex) { Log.Error(Constants.LOGGING_SOURCE, CoreResources.ProvisioningExtensions_ErrorProvisioningModule0File1, name, filePath, ex.Message); } } else { throw new NotSupportedException(string.Format("Module child '{0}' not supported.", child.Name)); } } }
/// <summary> /// Parses a Cruise Control export 'Project' node into a CruiseControlProject object /// </summary> /// <param name="element">XElement object</param> /// <returns>Cruise Control Project</returns> public static CruiseControlProject ParseCruiseControlExportToCruiseControlProject(XElement element) { if (element == null) return null; var project = new CruiseControlProject(); var name = element.Attribute("name"); if (name != null) project.Name = name.Value; var lastBuildStatus = element.Attribute("lastBuildStatus"); if (lastBuildStatus != null) project.LastBuildStatus = lastBuildStatus.Value; var lastBuildTime = element.Attribute("lastBuildTime"); DateTime date; if (lastBuildTime != null && DateTime.TryParse(lastBuildTime.Value, out date)) project.LastBuildTime = date; var url = element.Attribute("webUrl"); if (url != null) project.WebUrl = url.Value; return project; }
/// <summary> /// Initializes the <see cref="ValueAction"/>. /// </summary> /// <param name="xml">The XML the defines the action.</param> /// <returns>The value action.</returns> public override bool Deserialize(XElement xml) { this.Path = xml.Attribute("path").Value; this.Timeout = Int32.Parse(xml.Attribute("timeout").Value); return true; }
//========================================================================== public SvgPatternElement(SvgDocument document, SvgBaseElement parent, XElement patternElement) : base(document, parent, patternElement) { XAttribute pattern_transform_attribute = patternElement.Attribute("patternTransform"); if(pattern_transform_attribute != null) PatternTransform = SvgTransform.Parse(pattern_transform_attribute.Value); XAttribute pattern_units_attribute = patternElement.Attribute("patternUnits"); if(pattern_units_attribute != null) switch(pattern_units_attribute.Value) { case "objectBoundingBox": PatternUnits = SvgPatternUnits.ObjectBoundingBox; break; case "userSpaceOnUse": PatternUnits = SvgPatternUnits.UserSpaceOnUse; break; default: throw new NotImplementedException(String.Format("patternUnits value '{0}' is no supported", pattern_units_attribute.Value)); } XAttribute width_attribute = patternElement.Attribute("width"); if(width_attribute != null) Width = SvgLength.Parse(width_attribute.Value); XAttribute height_attribute = patternElement.Attribute("height"); if(height_attribute != null) Height = SvgLength.Parse(height_attribute.Value); }
public static Vector2 loadFromXElement(this Vector2 vector2, XElement objectXML) { vector2.X = Convert.ToSingle(objectXML.Attribute("X").Value); vector2.Y = Convert.ToSingle(objectXML.Attribute("Y").Value); return vector2; }
public Effect(XElement element) { if (element.Attribute("id") != null) Id = element.Attribute("id").Value; if (element.Attribute("name") != null) Name = element.Attribute("name").Value; var commonElement = element.Element(XName.Get("profile_COMMON", COLLADAConverter.Namespace)); if (commonElement != null) { var techniqueElement = commonElement.Element(XName.Get("technique", COLLADAConverter.Namespace)); if (techniqueElement != null) { var phongElement = techniqueElement.Element(XName.Get("phong", COLLADAConverter.Namespace)); if (phongElement != null) { Emission = XmlReaderHelper.ReadColor(phongElement.Element(XName.Get("emission", COLLADAConverter.Namespace)).Element(XName.Get("color", COLLADAConverter.Namespace))); Ambient = XmlReaderHelper.ReadColor(phongElement.Element(XName.Get("ambient", COLLADAConverter.Namespace)).Element(XName.Get("color", COLLADAConverter.Namespace))); Specular = XmlReaderHelper.ReadColor(phongElement.Element(XName.Get("specular", COLLADAConverter.Namespace)).Element(XName.Get("color", COLLADAConverter.Namespace))); Shininess = XmlReaderHelper.ReadFloat(phongElement.Element(XName.Get("shininess", COLLADAConverter.Namespace)).Element(XName.Get("float", COLLADAConverter.Namespace))); Reflectivity = XmlReaderHelper.ReadFloat(phongElement.Element(XName.Get("reflectivity", COLLADAConverter.Namespace)).Element(XName.Get("float", COLLADAConverter.Namespace))); Transparent = XmlReaderHelper.ReadColor(phongElement.Element(XName.Get("transparent", COLLADAConverter.Namespace)).Element(XName.Get("color", COLLADAConverter.Namespace))); Transparency = XmlReaderHelper.ReadFloat(phongElement.Element(XName.Get("transparency", COLLADAConverter.Namespace)).Element(XName.Get("float", COLLADAConverter.Namespace))); var diffuseElement = phongElement.Element(XName.Get("diffuse", COLLADAConverter.Namespace)); var diffuseColorElement = diffuseElement.Element(XName.Get("color", COLLADAConverter.Namespace)); if (diffuseColorElement != null) Diffuse = XmlReaderHelper.ReadColor(diffuseColorElement); } } } }
public static ShapeInfo FromXml(Client client, SXL.XElement shape_el) { var info = new ShapeInfo(); info.ID = shape_el.Attribute("id").Value; client.WriteVerbose("Reading shape id={0}", info.ID); info.Label = shape_el.Attribute("label").Value; info.Stencil = shape_el.Attribute("stencil").Value; info.Master = shape_el.Attribute("master").Value; info.Element = shape_el; info.URL = VA.Scripting.XmlUtil.GetAttributeValue(shape_el, "url", null); info.custprops = new Dictionary <string, VACUSTPROP.CustomPropertyCells>(); foreach (var customprop_el in shape_el.Elements("customprop")) { string cp_name = customprop_el.Attribute("name").Value; string cp_value = customprop_el.Attribute("value").Value; var cp = new VACUSTPROP.CustomPropertyCells(); cp.Value = cp_value; info.custprops.Add(cp_name, cp); } return(info); }
public AccessRequest(string cls, XElement xElement) { var nameAttr = xElement.Attribute("name"); string name = nameAttr == null ? "" : nameAttr.Value; Identifier = new IdentifierImpl(cls, name); checkType = xElement.Attribute("type").Value; requiredClaims = xElement.Descendants("claim").Select(c => new Claim(c.Attribute("type").Value, c.Attribute("value").Value)).ToList(); }
public Font(string name, XElement fontXmlNode, GraphicsDevice device) { XAttribute xwidth = fontXmlNode.Attribute("width"); XAttribute xheight = fontXmlNode.Attribute("height"); string filename = fontXmlNode.Value; if (xwidth == null || xheight == null) throw new Exception("Width or Height attribute for font is missing"); int width; int height; if (!int.TryParse(xwidth.Value, out width)) throw new Exception("Width value is invalid: " + xwidth.Value); if (!int.TryParse(xheight.Value, out height)) throw new Exception("Height value is invalid: " + xheight.Value); System.IO.Stream fontStream = System.IO.File.OpenRead(filename); this.Image = Texture2D.FromStream(device, fontStream); fontStream.Dispose(); FilePath = filename; Name = name; CellWidth = width; CellHeight = height; Generate(); }
public MissionFitting(XElement missionfitting) { Mission = (string)missionfitting.Attribute("mission") ?? ""; Faction = (string)missionfitting.Attribute("faction") ?? "Default"; Fitting = (string)missionfitting.Attribute("fitting") ?? ""; Ship = (string)missionfitting.Attribute("ship") ?? ""; }
/// <summary> /// Private constructor. /// </summary> /// <param name="element">The XML element.</param> private AtomYtAccessControl(XElement element) : base(xmlPrefix, xmlName, element) { // Set the mandatory attributes. this.Action = element.Attribute("action").Value; this.Permission = element.Attribute("permission").Value; }
internal override void OverrideXmlData(XElement sourceObject, XElement targetObject) { XNamespace ns = SchemaVersion; // the engine is not extracting title and description, only allows to set them DropAttribute(sourceObject, "Title"); DropAttribute(sourceObject, "Description"); // master pages are extracted relative to the root site without token...e.g. /_catalogs/MasterPage/oslo.master. // given we can use tokens in the template we do a manual comparison and drop the MasterPageUrl and CustomMasterPageUrl attributes when ok if (ValidateMasterPage(sourceObject.Attribute("MasterPageUrl").Value, targetObject.Attribute("MasterPageUrl").Value) && ValidateMasterPage(sourceObject.Attribute("CustomMasterPageUrl").Value, targetObject.Attribute("CustomMasterPageUrl").Value)) { DropAttribute(sourceObject, "MasterPageUrl"); DropAttribute(sourceObject, "CustomMasterPageUrl"); DropAttribute(targetObject, "MasterPageUrl"); DropAttribute(targetObject, "CustomMasterPageUrl"); } #if ONPREMISES // we don't support NoCrawl and RequestAccessEmail in on-premises so drop them from source and target DropAttribute(sourceObject, "NoCrawl"); DropAttribute(targetObject, "NoCrawl"); DropAttribute(sourceObject, "RequestAccessEmail"); DropAttribute(targetObject, "RequestAccessEmail"); #endif }
public Email(XElement configElement) : this((configElement.Attribute("Server") ?? configElement.Attribute("Host")).Value, int.Parse(configElement.Attribute("Port").Value, CultureInfo.InvariantCulture), bool.Parse(configElement.Attribute("SSL").Value), configElement.Attribute("Password").Value) { }
public static DgShapeInfo FromXml(Client client, SXL.XElement shape_el) { var info = new DgShapeInfo(); info.ID = shape_el.Attribute("id").Value; client.Output.WriteVerbose("Reading shape id={0}", info.ID); info.Label = shape_el.Attribute("label").Value; info.Stencil = shape_el.Attribute("stencil").Value; info.Master = shape_el.Attribute("master").Value; info.Element = shape_el; info.Url = shape_el.GetAttributeValue("url", null); info.CustProps = new CustomPropertyDictionary(); foreach (var customprop_el in shape_el.Elements("customprop")) { string cp_name = customprop_el.Attribute("name").Value; string cp_value = customprop_el.Attribute("value").Value; var cp = new CustomPropertyCells(); cp.Value = cp_value; info.CustProps.Add(cp_name, cp); } return(info); }
public CallAction(Chain parentChain, XElement actionElement) : base(parentChain, actionElement) { if (actionElement.HasAttributes == true && actionElement.Attribute("Chain") != null) { chainName = actionElement.Attribute("Chain").Value; } }
// Level public Level(XElement data) { _gravity = Loader.loadVector2(data.Attribute("gravity"), new Vector2(0, 32)); _wind = Loader.loadVector2(data.Attribute("wind"), Vector2.Zero); _name = Loader.loadString(data.Attribute("name"), "new_level"); _backgroundUID = Loader.loadString(data.Attribute("background_uid"), "default_background"); }
/// <summary> /// v3 serialization /// </summary> /// <param name="e"></param> public TranscriptionPhrase(XElement e) { Elements = e.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value); Elements.Remove("b"); Elements.Remove("e"); Elements.Remove("f"); this._phonetics = (e.Attribute("f") ?? EmptyAttribute).Value; this._text = e.Value.Trim('\r', '\n'); if (e.Attribute("b") != null) { string val = e.Attribute("b").Value; int ms; if (int.TryParse(val, out ms)) { Begin = TimeSpan.FromMilliseconds(ms); } else Begin = XmlConvert.ToTimeSpan(val); } if (e.Attribute("e") != null) { string val = e.Attribute("e").Value; int ms; if (int.TryParse(val, out ms)) { End = TimeSpan.FromMilliseconds(ms); } else End = XmlConvert.ToTimeSpan(val); } }
/// <summary> /// Constructor for the xml file, that is stored in the .xls file /// </summary> /// <param name="element">The root XElement of the xml</param> /// <param name="workbook">The current workbook</param> public SingleViolation(XElement element, Workbook workbook) : base(element, workbook) { this.severity = Decimal.Parse(element.Attribute(XName.Get("severity")).Value); this.controlName = element.Attribute(XName.Get("controlname")).Value; this.groupedViolation = Convert.ToBoolean(element.Attribute(XName.Get("groupedviolation")).Value); }
/// <summary> /// Initializes the <see cref="ValueAction"/>. /// </summary> /// <param name="xml"> /// The XML the defines the action. /// </param> /// <returns> /// The value action. /// </returns> public override bool Deserialize(XElement xml) { this.Start = xml.Attribute("start").ValueOrDefault(); this.End = xml.Attribute("end").ValueOrDefault(); return this.Start.HasValue() && this.End.HasValue(); }
public override bool Deserialize(XElement xml) { this.Name = xml.Attribute("name").ValueOrDefault(); this.Value = xml.Attribute("value").ValueOrDefault(); return true; }
internal override void Parse(XElement element) { // Search results have different pagination fields for some reason... if (element.Name == "search") { Start = element.ElementAsInt("results-start"); End = element.ElementAsInt("results-end"); TotalItems = element.ElementAsInt("total-results"); return; } var startAttribute = element.Attribute("start"); var endAttribute = element.Attribute("end"); var totalAttribute = element.Attribute("total"); if (startAttribute != null && endAttribute != null && totalAttribute != null) { int start = 0, end = 0, total = 0; int.TryParse(startAttribute.Value, out start); int.TryParse(endAttribute.Value, out end); int.TryParse(totalAttribute.Value, out total); Start = start; End = end; TotalItems = total; } }
private static MapRoot ReadMapRoot(XElement element) { var width = Convert.ToInt32(element.Attribute("Width").Value); var height = Convert.ToInt32(element.Attribute("Height").Value); var tileWidth = Convert.ToInt32(element.Attribute("TileWidth").Value); var tileHeight = Convert.ToInt32(element.Attribute("TileHeight").Value); var textureNames = element.Attribute("Textures").Value.Split(','); var mapRoot = new MapRoot( width , height , tileWidth , tileHeight , textureNames , null); var layerElements = element.Element("Layers").Elements("Layer"); foreach (var layer in layerElements) { ReadMapLayer(layer, ref mapRoot.Layers[Convert.ToInt32(layer.Attribute("Index").Value)]); } //mapRoot.PointLights = ReadMapLights(element.Element("Lights")); //mapRoot.MonsterSpawners = ReadMapSpawners(element.Element("Spawns")); return mapRoot; }
//========================================================================== public SvgRectElement(SvgDocument document, SvgBaseElement parent, XElement rectElement) : base(document, parent, rectElement) { XAttribute x_attribute = rectElement.Attribute("x"); if(x_attribute != null) X = SvgCoordinate.Parse(x_attribute.Value); XAttribute y_attribute = rectElement.Attribute("y"); if(y_attribute != null) Y = SvgCoordinate.Parse(y_attribute.Value); XAttribute width_attribute = rectElement.Attribute("width"); if(width_attribute != null) Width = SvgLength.Parse(width_attribute.Value); XAttribute height_attribute = rectElement.Attribute("height"); if(height_attribute != null) Height = SvgLength.Parse(height_attribute.Value); XAttribute rx_attribute = rectElement.Attribute("rx"); if(rx_attribute != null) CornerRadiusX = SvgCoordinate.Parse(rx_attribute.Value); XAttribute ry_attribute = rectElement.Attribute("ry"); if(ry_attribute != null) CornerRadiusY = SvgCoordinate.Parse(ry_attribute.Value); }
internal override bool FixElement(XElement rt, FwDataFixer.ErrorLogger errorLogger) { var xaClass = rt.Attribute("class").Value; switch (xaClass) { case "StStyle": var guid = rt.Attribute("guid").Value; if (!m_deletedGuids.Contains(guid)) return true; // keep it as far as we're concerned. var name = rt.Element("Name").Element("Uni").Value; // none can be null or we wouldn't have listed it for deletion errorLogger(String.Format(Strings.ksRemovingDuplicateStyle, name), true); return false; // This element must go away! case "LangProject": case "Scripture": var styles = rt.Element("Styles"); if (styles == null) return true; // Removing these here prevents additional error messages about missing objects, since the // targets of these objsurs are no longer present. foreach (var objsur in styles.Elements().ToArray()) // ToArray so as not to modify collection we're iterating over { var surGuid = objsur.Attribute("guid").Value; if (m_deletedGuids.Contains(surGuid)) objsur.Remove(); } break; } return true; // we're not deleting it. }
private void ProcessAssemblyDirective(IRootingServiceProvider rootProvider, XElement assemblyElement) { var assemblyNameAttribute = assemblyElement.Attribute("Name"); if (assemblyNameAttribute == null) throw new Exception(); ModuleDesc assembly = _context.ResolveAssembly(new AssemblyName(assemblyNameAttribute.Value)); var dynamicDegreeAttribute = assemblyElement.Attribute("Dynamic"); if (dynamicDegreeAttribute != null) { if (dynamicDegreeAttribute.Value != "Required All") throw new NotSupportedException(); // Reuse LibraryRootProvider to root everything new LibraryRootProvider((EcmaModule)assembly).AddCompilationRoots(rootProvider); } foreach (var element in assemblyElement.Elements()) { switch (element.Name.LocalName) { case "Type": ProcessTypeDirective(rootProvider, assembly, element); break; default: throw new NotSupportedException(); } } }
private static IExerciseDefinition GetExercise(XElement exerciseXml, IDictionary<string, IConstraint> allConstraints) { var exercise = new ExerciseDefinition(exerciseXml.Attribute("name").Value, new ExerciseTemplate(exerciseXml.Attribute("template").Value)); var numbersXml = from n in exerciseXml.Descendants("numbers").First().Descendants("number") select n; foreach (var number in numbersXml) { var minValue = int.Parse(number.Attribute("minvalue").Value); var maxValue = int.Parse(number.Attribute("maxvalue").Value); var decimals = int.Parse(number.Attribute("decimals").Value); exercise.AddNumberDefinition(new NumberDefinition("", minValue, maxValue, decimals)); } var constraintsRoot = exerciseXml.Descendants("constraints").FirstOrDefault(); if (constraintsRoot != null) { var constraintsXml = from c in constraintsRoot.Descendants("constraint") select c; foreach (var constraint in constraintsXml) { var constraintName = constraint.Attribute("type").Value; exercise.AddConstraint(allConstraints[constraintName]); } } return exercise; }
public ProjectDefinition(XElement element, Dictionary<string, string> replacementsDictionary) { Name = Helpers.ReplaceProperties((string)element.Attribute("name"), replacementsDictionary); Startup = string.Equals((string)element.Attribute("startup"), "true", StringComparison.InvariantCultureIgnoreCase); Condition = (string)element.Attribute("condition"); Path = Helpers.ReplaceProperties(element.Value, replacementsDictionary); }
public static SectionString Parse(XElement element) { try { if(element.Name != "string") throw new ArgumentException("Неопознанное имя строки секции"); var text = element.Value; var section = new SectionString(); if (element.Attribute(XName.Get("groups")) != null) { var groups = element.Attribute("groups").Value; var groupsArray = groups.Split(' '); section.Groups = new List<string>(groupsArray); } else { section.Groups = new List<string>(); } section.Text = text; return section; } catch (Exception e) { throw new DictionaryParseException("Ошибка создания элемента секции из xml узла. Подробности в InnerException.", e); } }
public override void FromXml(System.Xml.Linq.XElement xml) { this.Name = xml.Attribute("name") != null?xml.Attribute("name").Value : string.Empty; if (xml.HasElements) { // targets // classes ReadFromXMLChildItemsByName <ClassStyleModel>(xml, "classes", this.Classes, this); } }
public static T GetAttributeValue <T>(SXL.XElement el, SXL.XName name, T defval, System.Func <string, T> converter) { var a = el.Attribute(name); if (a == null) { return(defval); } string v = el.Attribute(name).Value; return(converter(v)); }
public void Deserialize(System.Xml.Linq.XElement node, XmlDeserializeContext context) { this.Name = node.Attribute("_N", this.Name); this.MessageTemplate = node.Attribute("_MT", this.MessageTemplate); this.Tag = node.Attribute("_tag", this.Tag); this.TypeDescription = node.Attribute("_TD", this.TypeDescription); if (node.HasElements) { this._Parameters = new PropertyValidatorParameterDescriptorCollection(); this._Parameters.Deserialize(node, context); } }
public static T GetAttributeValue <T>(SXL.XElement el, SXL.XName name, System.Func <string, T> converter) { var a = el.Attribute(name); if (a == null) { string msg = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Missing value for attribute \"{0}\"", name); throw new System.ArgumentException(msg); } string v = el.Attribute(name).Value; return(converter(v)); }
/// <summary> /// Froms the XML. /// </summary> /// <param name="xml">The XML.</param> public override void FromXml(System.Xml.Linq.XElement xml) { if (xml.HasAttributes) { this.Name = xml.Attribute("name") != null?xml.Attribute("name").Value : string.Empty; this.ControlType = xml.Attribute("controlType") != null?xml.Attribute("controlType").Value : string.Empty; this.Target = xml.Attribute("target") != null?xml.Attribute("target").Value : string.Empty; this.IsDefault = xml.Attribute("isDefault") != null?bool.Parse(xml.Attribute("isDefault").Value) : false; } if (!string.IsNullOrEmpty(xml.Value)) { string[] attributes = xml.Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < attributes.Length; i++) { string[] components = attributes[i].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (components.Length == 2) { this[components[0].Trim()] = components[1].Trim(); } } } }
public static DGConnectorInfo FromXml(Client client, SXL.XElement shape_el) { var info = new DGConnectorInfo(); info.ID = shape_el.Attribute("id").Value; client.WriteVerbose("Reading connector id={0}", info.ID); info.Label = shape_el.Attribute("label").Value; info.From = shape_el.Attribute("from").Value; info.To = shape_el.Attribute("to").Value; info.Element = shape_el; return(info); }
public void Deserialize(System.Xml.Linq.XElement element) { if (element == null || string.IsNullOrWhiteSpace(element.Attribute("class").Value)) { return; } if (element.Attribute("class").Value != "ObjectRef") { throw new Exception("Wrong class."); } index = Utility.Get <int>("index", element); Path = Utility.GetElement(element, "Path").Value.ToString(); }
private static double GetDoubleAtt(System.Xml.Linq.XElement dfEle, string attName) { if (dfEle == null || string.IsNullOrEmpty(attName)) { return(0); } if (dfEle.Attribute(attName) != null) { double d = 0; if (double.TryParse(dfEle.Attribute(attName).Value, out d)) { return(d); } } return(0); }
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(); mesh = new Mesh[(int)MeshLayer.Count]; for (int i = 0; i < mesh.Length; i++) { mesh[i] = new Mesh(); mesh[i].LoadOBJ(lOBJData, ((MeshLayer)i).ToString()); } lStream = null; lOBJData = null; return(true); }
public override void ReadXml(System.Xml.Linq.XElement element) { base.ReadXml(element); XAttribute attri = element.Attribute("Text"); if (attri != null) { Text = attri.Value; } attri = element.Attribute("Angle"); if (attri != null) { Angle = attri.Value.ToDouble(0); } }
protected override void LoadAttributes(System.Xml.Linq.XElement element) { if (!element.Name.LocalName.Equals("shape", StringComparison.InvariantCulture)) { throw new InvalidOperationException("'shape' element expected."); } if (element.Attribute("path") != null) { this.Path = element.Attribute("path").Value; } if (element.Attribute("color") != null) { this.Color = (Color)ColorConverter.ConvertFromString(element.Attribute("color").Value); } }
/// <summary> /// Froms the XML. /// </summary> /// <param name="xml">The XML.</param> public override void FromXml(System.Xml.Linq.XElement xml) { this.Name = xml.Attribute("name") != null?xml.Attribute("name").Value : string.Empty; this.Description = xml.Attribute("description") != null?xml.Attribute("description").Value : string.Empty; this.PropertyType = xml.Attribute("type") != null?xml.Attribute("type").Value : string.Empty; this.Getter = xml.Attribute("getter") != null?xml.Attribute("getter").Value : string.Empty; }
public static string GetAttributeValue(this SXL.XElement el, SXL.XName name, string defval) { var attr = el.Attribute(name); if (attr == null) { return defval; } return attr.Value; }
/// <summary> /// Gets attribute /// </summary> /// <param name="element">Element</param> /// <param name="name">Name</param> /// <returns>Attribute</returns> internal static string GetAttribute(this System.Xml.Linq.XElement element, string name) { XAttribute attr = element.Attribute(System.Xml.Linq.XName.Get(name)); if (attr == null) { return(""); } return(attr.Value); }
void IXElementSerializable.Deserialize(System.Xml.Linq.XElement node, XmlDeserializeContext context) { this.Name = node.Attribute(ns + "name", string.Empty); this.Description = node.Attribute(ns + "desc", string.Empty); this.InitFromConfiguration(UserRecentDataConfigurationSection.GetConfig().Categories[this.Name]); if (node.HasElements) { var items = node.Element(ns + "items"); if (items != null) { foreach (var item in items.Elements(ns + "item")) { PropertyValueCollection value = new PropertyValueCollection(); value.Deserialize(item, context); this.Items.Add(value); } } } }
// public static ConnectionString GetPoco(System.Xml.Linq.XElement e) { if (e == null || e.Attribute("nm") == null) { return(null); } string nm = (string)e.Attribute("nm"); string pn = (string)e.Attribute("pn") ?? null; string str = e.Element("str") != null?e.Element("str").Value : null; // ConnectionString cs = new ConnectionString() { Name = nm, ProviderName = pn, String = str }; return(cs); }
public void Deserialize(System.Xml.Linq.XElement element) { if (element.Attribute("class").Value != "Color") { throw new Exception("Wrong class."); } a = Convert.ToByte(Utility.GetElement(element, "a").Value.ToString()); r = Convert.ToByte(Utility.GetElement(element, "r").Value.ToString()); g = Convert.ToByte(Utility.GetElement(element, "g").Value.ToString()); b = Convert.ToByte(Utility.GetElement(element, "b").Value.ToString()); }
public static string GetAttributeValue(SXL.XElement el, SXL.XName name, string defval) { var attr = el.Attribute(name); if (attr == null) { return(defval); } return(attr.Value ?? defval); }
protected override void LoadAttributes(System.Xml.Linq.XElement element) { if (!element.Name.LocalName.Equals("text", StringComparison.InvariantCulture)) { throw new InvalidOperationException("'text' element expected."); } //this.Text = element.Attribute("text").Value; var textElement = element.Descendants("text").FirstOrDefault(); if (textElement != null) { this.Text = textElement.Value; } if (element.Attribute("color") != null) { this.Color = (Color)ColorConverter.ConvertFromString(element.Attribute("color").Value); } }
/// <summary> /// 获取指定名称的xml属性值 /// </summary> /// <param name="e"></param> /// <param name="name"></param> /// <returns>失败返回null</returns> public static string AttributeValue(this System.Xml.Linq.XElement e, System.Xml.Linq.XName name) { if (e != null) { var a = e.Attribute(name); if (a != null) { return(a.Value); } } return(null); }
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)); }
protected virtual bool PassesXsiTypeFilter(System.Xml.Linq.XElement element) { if (false == this.FilterByXsiType) { return(true); } var attribute = element.Attribute(XName.Get("type", "http://www.w3.org/2001/XMLSchema-instance")); if (null == attribute) { return(false); // Not the cleanest, could we avoid getting here? } string value = attribute.Value ?? String.Empty; string valueNamespace = String.Empty; string valueType = value; if (value.Contains(":")) { valueNamespace = value.Substring(0, value.IndexOf(":")); valueType = value.Substring(value.IndexOf(":") + 1); } if ( false == String.IsNullOrWhiteSpace(this.XsiTypeFilterExpectedNamespace) && false == String.IsNullOrWhiteSpace(valueNamespace) ) { try { var expectedPrefix = element.GetPrefixOfNamespace(XNamespace.Get(this.XsiTypeFilterExpectedNamespace)) ?? String.Empty; if (false == expectedPrefix.Equals(valueNamespace)) { return(false); } } catch { return(false); // This namespace couldn't be found } } if ( false == String.IsNullOrWhiteSpace(this.XsiTypeFilterExpectedType) && false == String.IsNullOrWhiteSpace(valueType) ) { if (false == XsiTypeFilterExpectedType.Equals(valueType)) { return(false); } } return(true); }
static void MoveAttributeIfAny(System.Xml.Linq.XName attributeName, System.Xml.Linq.XElement from, System.Xml.Linq.XElement to) { System.Xml.Linq.XAttribute attr = from.Attribute(attributeName); if (attr != null) { // Remove the attribute from its current parent: attr.Remove(); // Add the attribute to its new parent to.Add(attr); } }
// public static DataStore GetPoco(System.Xml.Linq.XElement e) { if (e == null || e.Attribute("nm") == null) { return(null); } string nm = (string)e.Attribute("nm"); string csNm = (string)e.Attribute("csNm") ?? null; bool lddo = false; if (e.Attribute("lddo") != null) { bool.TryParse(e.Attribute("lddo").Value, out lddo); } bool lso = false; if (e.Attribute("lso") != null) { bool.TryParse(e.Attribute("lso").Value, out lso); } bool wf = false; if (e.Attribute("wf") != null) { bool.TryParse(e.Attribute("wf").Value, out wf); } string stgDir = e.Element("stgDir") != null?e.Element("stgDir").Value : null; // DataStore ds = new DataStore() { Name = nm, ConnectionStringName = csNm, LoadDefaultDatabaseOnly = lddo, LoadSystemObjects = lso, WithFields = wf, StagePathDir = stgDir }; return(ds); }
//<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 override void ReadXml(System.Xml.Linq.XElement element) { base.ReadXml(element); XAttribute attriX = element.Attribute("X"); XAttribute attriY = element.Attribute("Y"); if (attriX != null && attriY != null) { Coordinates = new System.Windows.Point(attriX.Value.ToDouble(0), attriY.Value.ToDouble(0)); } // 11-12-2010 Scott if (element.Attribute("FontFamily") != null) { FontFamily = element.ReadString("FontFamily"); } if (element.Attribute("FontSize") != null) { FontSize = element.ReadDouble("FontSize"); } if (element.Attribute("BorderWidth") != null) { BorderWidth = element.ReadDouble("BorderWidth"); } if (element.Elements("Color") != null && element.Elements("Color").Any(e => e.Attribute("Name").Value == "TextColor")) { TextColor = element.ReadElementColor("TextColor"); } if (element.Elements("Color") != null && element.Elements("Color").Any(e => e.Attribute("Name").Value == "FillColor")) { FillColor = element.ReadElementColor("FillColor"); } if (element.Elements("Color") != null && element.Elements("Color").Any(e => e.Attribute("Name").Value == "BorderColor")) { BorderColor = element.ReadElementColor("BorderColor"); } }
/// <summary> /// Froms the XML. /// </summary> /// <param name="xml">The XML.</param> public override void FromXml(System.Xml.Linq.XElement xml) { if (xml.HasAttributes) { this.Name = xml.Attribute("name") != null?xml.Attribute("name").Value : string.Empty; this.ClassStyle = xml.Attribute("class") != null?xml.Attribute("class").Value : string.Empty; this.IsDefault = xml.Attribute("default") != null?bool.Parse(xml.Attribute("default").Value) : false; } }
/// <summary> /// Создание задачи из XML-определения /// </summary> /// <param name="declaration">XML-определение</param> /// <returns></returns> public ITask Parse(System.Xml.Linq.XElement declaration) { if (declaration == null) { throw new ArgumentNullException("Отсутствует определение задачи"); } _expression = declaration.Attribute("expression").Value; _tasks = new List <ITask>(); var taskNodes = declaration.XPathSelectElements(@"Task"); foreach (var taskNode in taskNodes) { _tasks.Add(Tasks.TaskFactory.Create(taskNode)); } return(this); }