/// <summary> /// Generates an Xml element for this rule /// </summary> /// <param name="doc">The parent Xml document</param> /// <returns>XmlNode representing this rule</returns> public override System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc) { string xmlString = "<friendlyRule>" + friendlyRule + "</friendlyRule>" + "<assignmentType>" + ((int)assignmentType).ToString() + "</assignmentType>" + "<destinationColumnName>" + destinationColumnName + "</destinationColumnName>" + "<destinationColumnType>" + destinationColumnType + "</destinationColumnType>"; xmlString = xmlString + "<parameterList>"; foreach (string parameter in this.AssignmentParameters) { xmlString = xmlString + "<parameter>" + parameter + "</parameter>"; } xmlString = xmlString + "</parameterList>"; System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; System.Xml.XmlAttribute order = doc.CreateAttribute("order"); System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "EpiDashboard.Rules.Rule_SimpleAssign"; element.Attributes.Append(type); return(element); }
/// <summary> /// Constructor for the When block. Parses the contents of the When block (property /// groups, item groups, and nested chooses) and stores them. /// </summary> /// <remarks> /// </remarks> /// <owner>DavidLe</owner> /// <param name="parentProject"></param> /// <param name="parentGroupingCollection"></param> /// <param name="whenElement"></param> /// <param name="importedFromAnotherProject"></param> /// <param name="options"></param> /// <param name="nestingDepth">stack overflow guard</param> internal When( Project parentProject, GroupingCollection parentGroupingCollection, XmlElement whenElement, bool importedFromAnotherProject, Options options, int nestingDepth ) { // Make sure the <When> node has been given to us. error.VerifyThrow(whenElement != null, "Need valid (non-null) <When> element."); // Make sure this really is the <When> node. error.VerifyThrow(whenElement.Name == XMakeElements.when || whenElement.Name == XMakeElements.otherwise, "Expected <{0}> or <{1}> element; received <{2}> element.", XMakeElements.when, XMakeElements.otherwise, whenElement.Name); this.propertyAndItemLists = new GroupingCollection(parentGroupingCollection); this.parentProject = parentProject; string elementName = ((options == Options.ProcessWhen) ? XMakeElements.when : XMakeElements.otherwise); if (options == Options.ProcessWhen) { conditionAttribute = ProjectXmlUtilities.GetConditionAttribute(whenElement, /*verify sole attribute*/ true); ProjectErrorUtilities.VerifyThrowInvalidProject(conditionAttribute != null, whenElement, "MissingCondition", XMakeElements.when); } else { ProjectXmlUtilities.VerifyThrowProjectNoAttributes(whenElement); } ProcessWhenChildren(whenElement, parentProject, importedFromAnotherProject, nestingDepth); }
private static void serializer_UnknownAttribute(object sender, XmlAttributeEventArgs e) { #if DEBUG System.Xml.XmlAttribute attr = e.Attr; Program.debugStream.WriteLine("Unknown attribute " + attr.Name + "='" + attr.Value + "'"); #endif }
private static PhoneNumberElementType GetTypeByNode(XmlAttribute node) { var str = node.InnerText; switch (str) { case "international-prefix": return PhoneNumberElementType.InternationalPrefix; case "country-prefix": return PhoneNumberElementType.CountryPrefix; case "national-prefix": return PhoneNumberElementType.NationalPrefix; case "unknown-national-prefix": return PhoneNumberElementType.UnknownNationalPrefix; case "national-code": return PhoneNumberElementType.NationalCode; case "area-code": return PhoneNumberElementType.AreaCode; case "local-number": return PhoneNumberElementType.LocalNumber; default: throw new MalformedXMLException ( "The XML Received from Time and Date did not include an object name which complies with an AstronomyObjectType enum: " + str ); } }
private string GetXmlAttributeAsString(XmlAttribute attribute) { if (attribute == null) return ""; return attribute.Value.Trim(); }
public void core0012A() { string computedValue = ""; string expectedValue = "Yes"; System.Xml.XmlAttribute streetAttr = null; System.Xml.XmlNode testNode = null; testResults results = new testResults("Core0012A"); try { results.description = "Upon retrieval the \"value\" attribute of an Attr" + "object is returned as a string with any Entity " + "References replaced with their values."; // // Retrieve the targeted data. // testNode = util.nodeObject(util.FOURTH, util.SIXTH); streetAttr = (System.Xml.XmlAttribute)testNode.Attributes.GetNamedItem("street"); computedValue = streetAttr.Value; } catch (System.Exception ex) { computedValue = "Exception " + ex.Message; } // // Write out results // results.expected = expectedValue; results.actual = computedValue; Assert.AreEqual(results.expected, results.actual); // return results; }
void IHasAttribute.InitAtrribute(XmlAttribute Attr) { switch(Attr.Name) { case "mips_generate": MipGenerate = bool.Parse(Attr.Value); break; case "array_index": ArrayIndex = uint.Parse(Attr.Value); break; case "mip_index": MipIndex = uint.Parse(Attr.Value); break; case "depth": Depth = uint.Parse(Attr.Value); break; case "face": Face = (CubeFace)Enum.Parse(typeof(CubeFace),Attr.Value); break; default: throw new Exception("Invalid Atrribute"); } }
public void Serialize(XmlElement node) { if (ShouldIgnore(node)) return; Serialize(BEGIN_ELEMENT); Serialize(node.NamespaceURI); Serialize(node.LocalName); var attrs = new XmlAttribute[node.Attributes.Count]; node.Attributes.CopyTo(attrs, 0); Array.Sort(attrs, new AttributeComparer()); foreach (var attr in attrs) { Serialize(attr); } Serialize(END_ATTRIBUTES); foreach (XmlNode child in node.ChildNodes) { if (child is XmlElement) { Serialize(child as XmlElement); } else { Serialize(child as XmlCharacterData); } } Serialize(END_ELEMENT); }
private static object GetNodeObject(System.Xml.XmlNode node) { XmlText text = node as XmlText; if (text != null) { return(text.InnerText); } XmlAttributeCollection attributes = node.Attributes; if ((attributes == null) || (attributes.Count == 0)) { if (!node.HasChildNodes) { return(node.InnerText); } XmlNodeList childNodes = node.ChildNodes; if ((childNodes.Count == 1) && (childNodes[0].NodeType == XmlNodeType.Text)) { return(node.InnerText); } System.Xml.XmlAttribute attribute = node as System.Xml.XmlAttribute; if (attribute != null) { return(attribute.Value); } } return(node); }
public void core0001A() { object computedValue = null; object expectedValue = null; System.Xml.XmlNode testNode = null; System.Xml.XmlAttribute domesticAttr = null; testResults results = new testResults("Core0001A"); try { results.description = "The ParentNode attribute should be null for" + " an Attr object."; // // Retrieve targeted data and examine parentNode attribute. // testNode = util.nodeObject(util.FIRST, util.SIXTH); domesticAttr = (System.Xml.XmlAttribute)testNode.Attributes.GetNamedItem("domestic"); computedValue = domesticAttr.ParentNode; // // Write out results // } catch (System.Exception ex) { computedValue = "Exception " + ex.Message; } results.expected = (expectedValue == null).ToString(); results.actual = (computedValue == null).ToString(); Assert.AreEqual(results.expected, results.actual); // return results; }
private static void AddDebugHooks(this XmlSerializer serializer) { uknowns = new StringBuilder(); uknownTags = new HashSet <string>(); serializer.UnknownAttribute += (sender, args) => { System.Xml.XmlAttribute attr = args.Attr; string msg = $"{args.LineNumber}:{args.LinePosition},{args.ObjectBeingDeserialized.GetType()},Unknown attribute,{attr.Name},{attr.Value}"; uknowns.AppendLine(msg); uknownTags.Add($"{args.ObjectBeingDeserialized.GetType()},{attr.Name}"); }; serializer.UnknownNode += (sender, args) => { string msg = $"{args.LineNumber}:{args.LinePosition},{args.ObjectBeingDeserialized.GetType()},Unknown Node,{args.Name},{args.Text}"; uknowns.AppendLine(msg); uknownTags.Add($"{args.ObjectBeingDeserialized.GetType()},{args.Name}"); }; serializer.UnknownElement += (sender, args) => { string msg = $"{args.LineNumber}:{args.LinePosition},{args.ObjectBeingDeserialized.GetType()},Unknown Element,{args.Element.Name},{args.Element.InnerXml}"; uknowns.AppendLine(msg); uknownTags.Add($"{args.ObjectBeingDeserialized.GetType()},{args.Element.Name}"); }; serializer.UnreferencedObject += (sender, args) => { string msg = $"0:0,{args.UnreferencedObject.GetType()},Unreferenced Object,{args.UnreferencedId},{args.UnreferencedObject}"; uknowns.AppendLine(msg); }; }
public void core0005A() { string computedValue = ""; string expectedValue = "Yes"; System.Xml.XmlAttribute domesticAttr = null; System.Xml.XmlNode testNode = null; testResults results = new testResults("Core0005A"); try { results.description = "If an attribute is explicitly assigned any value, " + "then that value is the attribute's effective value."; // // Retrieve the targeted data and examine its assigned value. // testNode = util.nodeObject(util.FIRST, util.SIXTH); domesticAttr = (System.Xml.XmlAttribute)testNode.Attributes.GetNamedItem("domestic"); computedValue = domesticAttr.Value; } catch (System.Exception ex) { computedValue = "Exception " + ex.Message; } // // Write out results // results.expected = expectedValue; results.actual = computedValue; Assert.AreEqual(results.expected, results.actual); // return results; }
public static string GetValueAsString(XmlAttribute attribute, string defaultValue) { if (attribute == null) return defaultValue; return Mask.EmptyString(attribute.Value, defaultValue); }
private void CreateElement() { _x = _rootSvg.CreateAttribute("x"); _y = _rootSvg.CreateAttribute("y"); _fill = _rootSvg.CreateAttribute("fill"); _style = _rootSvg.CreateAttribute("style"); _textAnchor = _rootSvg.CreateAttribute("text-anchor"); _fontFamily = _rootSvg.CreateAttribute("font-family"); _fontFamily.Value = "'Segoe UI',sans-serif"; _fontSize = _rootSvg.CreateAttribute("font-size"); _onMouseOver = _rootSvg.CreateAttribute("onmouseover"); _onMouseOut = _rootSvg.CreateAttribute("onmouseout"); Attributes.Append(_x); Attributes.Append(_y); Attributes.Append(_fill); Attributes.Append(_style); Attributes.Append(_textAnchor); Attributes.Append(_fontFamily); Attributes.Append(_fontSize); Attributes.Append(_onMouseOver); Attributes.Append(_onMouseOut); }
/// <summary> /// Adds lines containing httpmodules to web.config file. /// </summary> /// <param name="xmlDoc">Document pointing to web.config file.</param> /// <remarks>This module handles the MapInfo session creation.</remarks> internal static bool AddHttpModules(XmlDocument xmlDoc) { bool updated = false; // Now create httphandler node XmlNode httpNode = xmlDoc.SelectSingleNode("//httpModules"); if (httpNode == null) { httpNode = xmlDoc.CreateNode(XmlNodeType.Element, "httpModules", ""); } string searchStr = string.Format("//add[contains(@type, '{0}')]", "MapInfo.Engine.WebSessionActivator"); XmlNode node = xmlDoc.SelectSingleNode(searchStr); AssemblyName coreEngineAssembly = typeof(MapInfo.Engine.WebSessionActivator).Assembly.GetName(); if (RemoveEntry(node, coreEngineAssembly, "type")) { XmlNode addNode = xmlDoc.CreateNode(XmlNodeType.Element, "add", ""); System.Xml.XmlAttribute addAttrib1 = xmlDoc.CreateAttribute("type"); addAttrib1.Value = string.Format("{0}, {1}", "MapInfo.Engine.WebSessionActivator", coreEngineAssembly.FullName); addNode.Attributes.Append(addAttrib1); System.Xml.XmlAttribute addAttrib2 = xmlDoc.CreateAttribute("name"); addAttrib2.Value = "WebSessionActivator"; addNode.Attributes.Append(addAttrib2); httpNode.AppendChild(addNode); updated = true; } // Now insert this information into system.web node in the file if (updated) { System.Xml.XmlNodeList sysNode = xmlDoc.GetElementsByTagName("system.web"); sysNode.Item(0).AppendChild(httpNode); } return updated; }
internal static bool AddSessionState(XmlDocument xmlDoc) { bool updated = false; XmlNode sessStateNode = xmlDoc.SelectSingleNode("//sessionState"); if (sessStateNode == null) { sessStateNode = xmlDoc.CreateNode(XmlNodeType.Element, "sessionState", ""); System.Xml.XmlAttribute addAttrib1 = xmlDoc.CreateAttribute("mode"); addAttrib1.Value = "StateServer"; sessStateNode.Attributes.Append(addAttrib1); System.Xml.XmlAttribute addAttrib2 = xmlDoc.CreateAttribute("stateConnectionString"); addAttrib2.Value = "tcpip=127.0.0.1:42424"; sessStateNode.Attributes.Append(addAttrib2); System.Xml.XmlAttribute addAttrib3 = xmlDoc.CreateAttribute("sqlConnectionString"); addAttrib3.Value = "data source=127.0.0.1;user id=sa;password="******"cookieless"); addAttrib4.Value = "false"; sessStateNode.Attributes.Append(addAttrib4); System.Xml.XmlAttribute addAttrib5 = xmlDoc.CreateAttribute("timeout"); addAttrib5.Value = "20"; sessStateNode.Attributes.Append(addAttrib5); System.Xml.XmlNodeList sysNode = xmlDoc.GetElementsByTagName("system.web"); sysNode.Item(0).AppendChild(sessStateNode); updated = true; } return updated; }
/// <summary> /// Convert the data filter conditions into XML /// </summary> /// <returns>XmlElement</returns> public XmlElement Serialize(XmlDocument doc) { System.Xml.XmlElement root = doc.CreateElement("dataFilters"); System.Xml.XmlAttribute type = doc.CreateAttribute("recordProcessScope"); switch (this.RecordProcessScope) { case RecordProcessingScope.Undeleted: type.Value = "undeleted"; break; case RecordProcessingScope.Deleted: type.Value = "deleted"; break; case RecordProcessingScope.Both: type.Value = "both"; break; } root.Attributes.Append(type); foreach (DataRow row in ConditionTable.Rows) { FilterCondition filterCondition = (FilterCondition)row[COLUMN_FILTER]; XmlNode xmlNode = filterCondition.Serialize(doc, row[COLUMN_FRIENDLY_JOIN].ToString().ToLowerInvariant()); root.AppendChild(xmlNode); } return(root); }
private static bool AddHttpNode(XmlDocument xmlDoc, XmlNode httpHandlersNode, string path, string type) { string searchStr = string.Format("//add[contains(@path, '{0}')]", path); XmlNode node = xmlDoc.SelectSingleNode(searchStr); bool updated = false; AssemblyName _webAssembly = typeof(MapInfo.WebControls.MapControl).Assembly.GetName(); if (RemoveEntry(node, _webAssembly, "type")) { XmlNode addNode = xmlDoc.CreateNode(XmlNodeType.Element, "add", ""); System.Xml.XmlAttribute addAttrib1 = xmlDoc.CreateAttribute("verb"); addAttrib1.Value = "*"; addNode.Attributes.Append(addAttrib1); System.Xml.XmlAttribute addAttrib2 = xmlDoc.CreateAttribute("path"); addAttrib2.Value = path; addNode.Attributes.Append(addAttrib2); System.Xml.XmlAttribute addAttrib3 = xmlDoc.CreateAttribute("type"); addAttrib3.Value =string.Format("{0}, {1}", type, _webAssembly.FullName); addNode.Attributes.Append(addAttrib3); httpHandlersNode.AppendChild(addNode); updated = true; } return updated; }
/// <summary> /// Processes an attribute for the Compiler. /// </summary> /// <param name="sourceLineNumbers">Source line number for the parent element.</param> /// <param name="parentElement">Parent element of element to process.</param> /// <param name="attribute">Attribute to process.</param> /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> public override void ParseAttribute(SourceLineNumberCollection sourceLineNumbers, XmlElement parentElement, XmlAttribute attribute, Dictionary<string, string> contextValues) { switch (parentElement.LocalName) { case "Extension": // at the time the IsRichSavedGame extension attribute is parsed, the compiler // might not yet have parsed the Id attribute, so we need to get it directly // from the parent element and put it into the contextValues dictionary. string extensionId = parentElement.GetAttribute("Id"); if (String.IsNullOrEmpty(extensionId)) { this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Extension", "IsRichSavedGame", "Id")); } else { contextValues["ExtensionId"] = extensionId; switch (attribute.LocalName) { case "IsRichSavedGame": if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { this.ProcessIsRichSavedGameAttribute(sourceLineNumbers, contextValues); } break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attribute); break; } } break; default: this.Core.UnexpectedElement(parentElement, parentElement); break; } }
/// <summary> /// Gets the attribute safely (returns null if not existing). /// The name is case insensitive. /// </summary> /// <param name="xmlNode">The XML node.</param> /// <param name="name">The name (case insensitive).</param> /// <param name="defaultValue">The default value to return if attribute is not found.</param> /// <returns></returns> public static string GetAttributeSafe(this XmlNode xmlNode, string name, string defaultValue = null) { if (null == xmlNode) { return(null); } if (string.IsNullOrWhiteSpace(name)) { return(null); } System.Xml.XmlAttribute xmlAttrib = xmlNode.Attributes.Cast <System.Xml.XmlAttribute>().Where(a => name.Equals(a.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (null == xmlAttrib || xmlAttrib.Value.Equals("[DEFAULTVALUE]", StringComparison.OrdinalIgnoreCase)) { return(defaultValue); } if (xmlAttrib.Value.Equals("[NULL]", StringComparison.OrdinalIgnoreCase)) { return(null); } return(xmlAttrib.Value); }
public void SetCustomAttribute(string key, string value) { try { if ((XmlNode.Attributes.GetNamedItem(key) != null)) { if (value == null) { XmlNode.Attributes.Remove((XmlAttribute)XmlNode.Attributes.GetNamedItem(key)); } else { XmlNode.Attributes.GetNamedItem(key).Value = value; } } else if ((value != null)) { System.Xml.XmlAttribute objAttr = XMLDoc.CreateAttribute(key); objAttr.Value = value; XmlNode.Attributes.Append(objAttr); } } catch (Exception ex) { throw ex; } }
protected override void ExecuteCore(XmlAttribute attribute) { var data = string.Format("{0}=\"{1}\"", attribute.Name, attribute.Value); var section = attribute.OwnerDocument.CreateCDataSection(data); attribute.OwnerElement.PrependChild(section); attribute.OwnerElement.Attributes.Remove(attribute); }
private void serializer_UnknownAttribute (object sender, XmlAttributeEventArgs e) { System.Xml.XmlAttribute attr = e.Attr; Console.WriteLine("Unknown attribute " + attr.Name + "='" + attr.Value + "'"); }
public XmlNode Serialize(XmlDocument doc) { string xmlString = "<friendlyRule>" + friendlyRule + "</friendlyRule>" + "<groupName>" + GroupName + "</groupName>"; xmlString = xmlString + "<variables>"; foreach (string s in this.Variables) { xmlString = xmlString + "<variable>"; xmlString = xmlString + s.Replace("<", "<").Replace(">", ">"); xmlString = xmlString + "</variable>"; } xmlString = xmlString + "</variables>"; System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "EpiDashboard.Rules.Rule_VariableGroup"; element.Attributes.Append(type); return(element); }
protected override void InitAtrrib(XmlAttribute Attr) { if(Attr.Name == "digits") Digits = byte.Parse(Attr.Value); else if(Attr.Name == "magnitude") Magnitude = short.Parse(Attr.Value); }
/// <summary> /// Validates the XML any attributes. /// </summary> /// <param name="anyAttributes">Any attributes.</param> public void ValidateXmlAnyAttributes(XmlAttribute[] anyAttributes) { if (anyAttributes == null) { throw new ArgumentNullException("anyAttributes"); } if (anyAttributes.Length == 0) { return; } foreach (var attr in anyAttributes) { if (!Saml20Utils.ValidateRequiredString(attr.Prefix)) { throw new Saml20FormatException("Attribute extension xml attributes MUST BE namespace qualified"); } foreach (var samlns in Saml20Constants.SamlNamespaces) { if (attr.NamespaceURI == samlns) { throw new Saml20FormatException("Attribute extension xml attributes MUST NOT use a namespace reserved by SAML"); } } } }
private XmlElement GetAssertion(XmlDocument doc, TransactionFlowOption option, string prefix, string name, string ns, string policyNs) { if (doc == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("doc"); } XmlElement element = null; switch (option) { case TransactionFlowOption.NotAllowed: return(element); case TransactionFlowOption.Allowed: { element = doc.CreateElement(prefix, name, ns); System.Xml.XmlAttribute node = doc.CreateAttribute("wsp", "Optional", policyNs); node.Value = "true"; element.Attributes.Append(node); if ((this.transactionProtocol == System.ServiceModel.TransactionProtocol.OleTransactions) || (this.transactionProtocol == System.ServiceModel.TransactionProtocol.WSAtomicTransactionOctober2004)) { System.Xml.XmlAttribute attribute2 = doc.CreateAttribute("wsp1", "Optional", "http://schemas.xmlsoap.org/ws/2002/12/policy"); attribute2.Value = "true"; element.Attributes.Append(attribute2); } return(element); } case TransactionFlowOption.Mandatory: return(doc.CreateElement(prefix, name, ns)); } return(element); }
public static void SetSound(int id, string str) { try { if (m_MsgArray.ContainsKey(id)) { if (m_MsgArray[id].Sound == str) { return; } } System.Xml.XmlDocument xDu = new XmlDocument(); xDu.Load(Constant.MsgConfigFileName); System.Xml.XmlNode aNode = null; for (int i = 0; i < xDu.DocumentElement.ChildNodes.Count; i++) { if (xDu.DocumentElement.ChildNodes[i].Attributes["id"].Value == id.ToString()) { aNode = xDu.DocumentElement.ChildNodes[i]; break; } } if (aNode == null) { aNode = xDu.CreateNode(System.Xml.XmlNodeType.Element, "Msg", ""); xDu.DocumentElement.AppendChild(aNode); System.Xml.XmlAttribute a = xDu.CreateAttribute("id"); a.Value = id.ToString(); aNode.Attributes.Append(a); a = xDu.CreateAttribute("Text"); aNode.Attributes.Append(a); a = xDu.CreateAttribute("Sound"); aNode.Attributes.Append(a); } aNode.Attributes["Sound"].Value = str; xDu.Save(Constant.MsgConfigFileName); //设置当前属性 if (m_MsgArray.ContainsKey(id)) { m_MsgArray[id].Sound = str; } else { msgInfo m = new msgInfo(); m.id = id; m.Sound = str; m.Text = ""; m_MsgArray.Add(id, m); } } catch (Exception ee) { LogInfo.Log.WriteInfo(LogInfo.LogType.Error, "加载提示信息出错:" + ee.ToString() + "\r\n"); } }
private void MoveNextInXml(XmlDataNode dataNode) { if (this.IsXmlDataNode) { this.xmlNodeReader.Read(); if (this.xmlNodeReader.Depth == 0) { this.internalNodeType = ExtensionDataNodeType.EndElement; this.xmlNodeReader = null; } } else { this.internalNodeType = ExtensionDataNodeType.Xml; if (this.element == null) { this.element = this.nextElement; } else { this.PushElement(); } System.Xml.XmlNode node = XmlObjectSerializerReadContext.CreateWrapperXmlElement(dataNode.OwnerDocument, dataNode.XmlAttributes, dataNode.XmlChildNodes, this.element.prefix, this.element.localName, this.element.ns); for (int i = 0; i < this.element.attributeCount; i++) { AttributeData data = this.element.attributes[i]; System.Xml.XmlAttribute attribute = dataNode.OwnerDocument.CreateAttribute(data.prefix, data.localName, data.ns); attribute.Value = data.value; node.Attributes.Append(attribute); } this.xmlNodeReader = new XmlNodeReader(node); this.xmlNodeReader.Read(); } }
private static DateTime GetModifiedDateTime(DateTime dateTime, XmlAttribute attr, int value) { switch (attr.Name.ToLower(CultureInfo.InvariantCulture)) { case "year": case "addyear": dateTime = dateTime.AddYears(value); break; case "month": case "addmonth": dateTime = dateTime.AddMonths(value); break; case "week": case "addweek": dateTime = dateTime.AddDays(value * 7); break; case "day": case "adday": dateTime = dateTime.AddDays(value); break; case "hour": case "addhour": dateTime = dateTime.AddHours(value); break; case "min": case "addmin": dateTime = dateTime.AddMinutes(value); break; case "sec": case "addsec": dateTime = dateTime.AddSeconds(value); break; } return dateTime; }
/// <summary> /// Generates Xml representation of this filter condition /// </summary> /// <param name="doc">The Xml docment</param> /// <returns>XmlNode</returns> public override XmlNode Serialize(XmlDocument doc) { string xmlString = "<description>" + this.Description + "</description>" + "<sql>" + this.Sql + "</sql>" + "<value>" + DateTime.Parse(this.Value.ToString(), System.Globalization.CultureInfo.InvariantCulture).ToString("s") + "</value>" + "<parameterName>" + this.ParameterName + "</parameterName>"; xmlString += "<queryParameter>"; xmlString += "<dbType>" + ((int)this.Parameter.DbType).ToString() + "</dbType>"; xmlString += "<name>" + this.Parameter.ParameterName + "</name>"; xmlString += "<value>" + this.Parameter.Value + "</value>"; xmlString += "</queryParameter>"; System.Xml.XmlElement element = doc.CreateElement("rowFilterCondition"); element.InnerXml = xmlString; System.Xml.XmlAttribute type = doc.CreateAttribute("filterType"); type.Value = this.GetType().ToString(); //"Epi.ImportExport.RowFilterConditionBase"; element.Attributes.Append(type); return(element); }
public void core0009A() { string computedValue = "";//0; string expectedValue = "False"; System.Xml.XmlAttribute streetAttr = null; System.Xml.XmlNode testNode = null; testResults results = new testResults("Core0009A"); try { results.description = "The \"specified\" attribute for an Attr node " + "should be set to false if the attribute was " + "not explictly given a value."; // // Retrieve the targeted data and capture its "specified" attribute. // testNode = util.nodeObject(util.FIRST, util.SIXTH); streetAttr = (System.Xml.XmlAttribute)testNode.Attributes.GetNamedItem("street"); computedValue = streetAttr.Specified.ToString(); } catch (System.Exception ex) { computedValue = "Exception " + ex.Message; } // // Write out results // results.expected = expectedValue; results.actual = computedValue; Assert.AreEqual(results.expected, results.actual); // return results; }
public void core0007A() { string computedValue = ""; string expectedValue = "street"; System.Xml.XmlAttribute streetAttr = null; System.Xml.XmlNode testNode = null; testResults results = new testResults("Core0007A"); try { results.description = "The \"name\" attribute of an Attr object contains " + "the name of that attribute."; // // Retrieve the targeted data and capture its assigned name. // testNode = util.nodeObject(util.SECOND, util.SIXTH); streetAttr = (System.Xml.XmlAttribute)testNode.Attributes.GetNamedItem("street"); computedValue = streetAttr.Name; } catch (System.Exception ex) { computedValue = "Exception " + ex.Message; } // // Write out results // results.expected = expectedValue; results.actual = computedValue; Assert.AreEqual(results.expected, results.actual); // return results; }
private void ReadTraceLogConfig() { System.Xml.XmlNode udp = this.xmlNode.SelectSingleNode("//Trace"); if (udp != null) { System.Xml.XmlNodeList configs = udp.SelectNodes("Config"); foreach (System.Xml.XmlNode config in configs) { //id="capture" category="" level="DEBUG" module="capture" System.Xml.XmlAttribute id = config.Attributes["id"]; System.Xml.XmlAttribute category = config.Attributes["category"]; System.Xml.XmlAttribute level = config.Attributes["level"]; System.Xml.XmlAttribute module = config.Attributes["module"]; if (id == null) { throw new StackException("config error: console config should have id."); } // create a config instance TraceLogConfig traceLogConfig = new TraceLogConfig(); traceLogConfig.Category = category.Value; traceLogConfig.Level = (LogLevel)Enum.Parse(typeof(LogLevel), level.Value); traceLogConfig.Module = module.Value; if (this.logConfigs.ContainsKey(id.Value)) { throw new StackException("the id of config must be unique."); } this.logConfigs.Add(id.Value, traceLogConfig); } } }
/// <summary>Read Element named magic. </summary> private void ReadMagic(System.Xml.XmlElement element, MimeType mimeType) { // element.getValue(); System.String offset = null; System.String content = null; System.String type = null; System.Xml.XmlNamedNodeMap attrs = (System.Xml.XmlAttributeCollection)element.Attributes; for (int i = 0; i < attrs.Count; i++) { System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)attrs.Item(i); if (attr.Name.Equals("offset")) { offset = attr.Value; } else if (attr.Name.Equals("type")) { type = attr.Value; if (String.Compare(type, "byte", true) == 0) { type = "System.Byte"; } } else if (attr.Name.Equals("value")) { content = attr.Value; } } if ((offset != null) && (content != null)) { mimeType.AddMagic(System.Int32.Parse(offset), type, content); } }
private void ReadFileLogConfig() { System.Xml.XmlNode file = this.xmlNode.SelectSingleNode("//File"); if (file != null) { System.Xml.XmlNodeList configs = file.SelectNodes("Config"); foreach (System.Xml.XmlNode config in configs) { //id="stack" category="" level="DEBUG" module="stack" fileName="stack.log" System.Xml.XmlAttribute id = config.Attributes["id"]; System.Xml.XmlAttribute category = config.Attributes["category"]; System.Xml.XmlAttribute level = config.Attributes["level"]; System.Xml.XmlAttribute module = config.Attributes["module"]; System.Xml.XmlAttribute fileName = config.Attributes["fileName"]; if (id == null || fileName == null) { throw new StackException("config error: file config should have id and fileName."); } // create a config instance FileLogConfig fileLogConfig = new FileLogConfig(); fileLogConfig.Category = category.Value; fileLogConfig.Level = (LogLevel)Enum.Parse(typeof(LogLevel), level.Value); fileLogConfig.Module = module.Value; fileLogConfig.FileName = fileName.Value; if (this.logConfigs.ContainsKey(id.Value)) { throw new StackException("the id of config must be unique."); } this.logConfigs.Add(id.Value, fileLogConfig); } } }
// Read XML document from stream public bool LoadFromStream(Stream stream, String docName) { // m_filename = filename; // m_name = System.IO.Path.GetFileName(filename); m_xdoc = new XmlDocument(); m_toplevel = null; //bool fileExist = System.IO.File.Exists(m_filename); try { m_xdoc.Load(stream); m_toplevel = m_xdoc.ChildNodes[1]; //m_version = GetInt(m_xdoc, "FileVersion", 0); if (m_toplevel.Name != docName) { m_toplevel = null; } else { m_verattr = m_toplevel.Attributes["FileVersion"]; m_version = int.Parse(m_verattr.Value); } return true; } catch (Exception ex) { DebugLogger.Instance().LogError(m_name + ": " + ex.Message); m_toplevel = null; } return false; }
public XmlNode Serialize(XmlDocument doc) { string xmlString = "<ConfidenceLevel>" + cbxConfidenceLevel.Text + "</ConfidenceLevel>" + "<Power>" + txtPower.Text + "</Power>" + "<RatioControlsExposed>" + txtRatioControlsExposed.Text + "</RatioControlsExposed>" + "<PctControlsExposed>" + txtPctControlsExposed.Text + "</PctControlsExposed>" + "<OddsRatio>" + txtOddsRatio.Text + "</OddsRatio>" + "<PctCasesWithExposure>" + txtPctCasesWithExposure.Text + "</PctCasesWithExposure>"; System.Xml.XmlElement element = doc.CreateElement("statcalcCohortGadget"); element.InnerXml = xmlString; System.Xml.XmlAttribute locationY = doc.CreateAttribute("top"); System.Xml.XmlAttribute locationX = doc.CreateAttribute("left"); System.Xml.XmlAttribute collapsed = doc.CreateAttribute("collapsed"); System.Xml.XmlAttribute type = doc.CreateAttribute("gadgetType"); locationY.Value = Canvas.GetTop(this).ToString("F2"); locationX.Value = Canvas.GetLeft(this).ToString("F2"); collapsed.Value = "false"; // currently no way to collapse the gadget, so leave this 'false' for now type.Value = "EpiDashboard.StatCalc.Cohort"; element.Attributes.Append(locationY); element.Attributes.Append(locationX); element.Attributes.Append(collapsed); element.Attributes.Append(type); return(element); }
public string ReadLocalSettingString(string sectionName, string settingName, string defaultValue) { string sectionNameValid = RemoveInvalidXmlChars(sectionName); string settingNameValid = RemoveInvalidXmlChars(settingName); string Result = defaultValue; if (System.IO.File.Exists(ConfigFileName)) { //Intento obtener el valor del archivo de configuración Xml if (ConfigDocument == null) { ConfigDocument = new System.Xml.XmlDocument(); try { ConfigDocument.Load(ConfigFileName); } catch { // El archivo de configuración está vacío o dañado return(null); } } System.Xml.XmlNode SettingNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']/Setting[@name='" + settingNameValid + "']"); if (SettingNode != null) { System.Xml.XmlAttribute SettingAttribute = SettingNode.Attributes["value"]; if (SettingAttribute != null) { Result = SettingAttribute.Value; } } } return(Result); }
internal ConditionEvaluationState(XmlAttribute conditionAttribute, Expander expanderToUse, Hashtable conditionedPropertiesInProject, string parsedCondition) { this.conditionAttribute = conditionAttribute; this.expanderToUse = expanderToUse; this.conditionedPropertiesInProject = conditionedPropertiesInProject; this.parsedCondition = parsedCondition; }
internal XmlAttributeEventArgs(XmlAttribute attr, int lineNum, int linePos, object source) { this.attr = attr; this.lineNumber = lineNum; this.linePosition = linePos; this.obj = source; }
private void with_an_attribute_that_has_a_name() { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml("<node datetime='now' />"); _attribute = xmlDocument.FirstChild.Attributes[0]; _expectedName = "datetime"; }
public void AttributeInnerAndOuterXml () { attr = doc.CreateAttribute ("foo", "bar", "http://abc.def"); attr.Value = "baz"; Assert.AreEqual ("baz", attr.InnerXml, "#1"); Assert.AreEqual ("foo:bar=\"baz\"", attr.OuterXml, "#2"); }
/// <summary> /// Processes an attribute for the Compiler. /// </summary> /// <param name="sourceLineNumbers">Source line number for the parent element.</param> /// <param name="parentElement">Parent element of element to process.</param> /// <param name="attribute">Attribute to process.</param> /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> public override void ParseAttribute(SourceLineNumberCollection sourceLineNumbers, XmlElement parentElement, XmlAttribute attribute, Dictionary<string, string> contextValues) { switch (parentElement.LocalName) { case "ExePackage": case "MsiPackage": case "MspPackage": case "MsuPackage": string packageId; if (!contextValues.TryGetValue("PackageId", out packageId) || String.IsNullOrEmpty(packageId)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.LocalName, "Id", attribute.LocalName)); } else { switch (attribute.LocalName) { case "PrereqSupportPackage": if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { Row row = this.Core.CreateRow(sourceLineNumbers, "MbaPrerequisiteSupportPackage"); row[0] = packageId; } break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attribute); break; } } break; case "Variable": // at the time the extension attribute is parsed, the compiler might not yet have // parsed the Name attribute, so we need to get it directly from the parent element. string variableName = parentElement.GetAttribute("Name"); if (String.IsNullOrEmpty(variableName)) { this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name")); } else { switch (attribute.LocalName) { case "Overridable": if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { Row row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOverridableVariable"); row[0] = variableName; } break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attribute); break; } } break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attribute); break; } }
/// <summary> /// Generates Xml representation of this filter condition /// </summary> /// <param name="doc">The Xml docment</param> /// <returns>XmlNode</returns> public virtual XmlNode Serialize(XmlDocument doc) { string xmlString = "<description>" + this.Description + "</description>" + "<sql>" + this.Sql.ToString().Replace("<", "<").Replace(">", ">") + "</sql>" + "<value>" + this.Value + "</value>" + "<columnName>" + this.ColumnName.Replace("<", "<").Replace(">", ">") + "</columnName>" + "<parameterName>" + this.ParameterName + "</parameterName>"; xmlString += "<queryParameter>"; xmlString += "<dbType>" + ((int)this.Parameter.DbType).ToString() + "</dbType>"; xmlString += "<name>" + this.Parameter.ParameterName + "</name>"; xmlString += "<value>" + this.Parameter.Value + "</value>"; xmlString += "</queryParameter>"; System.Xml.XmlElement element = doc.CreateElement("rowFilterCondition"); element.InnerXml = xmlString; System.Xml.XmlAttribute type = doc.CreateAttribute("filterType"); type.Value = this.GetType().ToString(); //"Epi.ImportExport.RowFilterConditionBase"; element.Attributes.Append(type); return(element); }
XmlAttribute attrXmlNS; //Used for "Xml" namespace attribute which should be present on all nodes. internal DocumentXPathNavigator( XmlNode node ) { Debug.Assert( ( (int)(node.XPNodeType) ) != -1 ); _curNode = node; _doc = (_curNode.NodeType == XmlNodeType.Document) ? (XmlDocument)_curNode : _curNode.OwnerDocument; _attrInd = -1; attrXmlNS = _doc.CreateAttribute( "xmlns", "xml", XmlDocument.strReservedXmlns ); attrXmlNS.Value = "http://www.w3.org/XML/1998/namespace"; }
private void CreateElement(SvgRoot svg) { XmlElement = svg.CreateElement("a"); _href = svg.CreateAttribute("href", "xlink"); XmlElement.Attributes.Append(_href); XmlElement.AppendChild(Text.XmlElement); }
/// <summary> /// BuildItemGroup element is provided /// </summary> internal BuildItemGroupXml(XmlElement element) { ErrorUtilities.VerifyThrowNoAssert(element != null, "Need a valid XML node."); ProjectXmlUtilities.VerifyThrowElementName(element, XMakeElements.itemGroup); this.element = element; this.conditionAttribute = ProjectXmlUtilities.GetConditionAttribute(element, true /*no other attributes allowed*/); }
public string ToString(System.Xml.XmlAttribute Attribute) { if ((Attribute == null)) { return(string.Empty); } return(Attribute.Value); }
/// <summary> /// This event is thrown if the attribute is not known. /// </summary> /// <param name="sender">The current object sender.</param> /// <param name="e">Attribute event argument.</param> void serialiser_UnknownAttribute(object sender, XmlAttributeEventArgs e) { System.Xml.XmlAttribute xmlAttribute = e.Attr; // Throw a general exception. throw new System.Exception( "Unknown Attribute " + xmlAttribute.Name + " = " + xmlAttribute.Value); }
internal XmlAttributeEventArgs(XmlAttribute attr, int lineNumber, int linePosition, object o, string qnames) { this.attr = attr; this.o = o; this.qnames = qnames; this.lineNumber = lineNumber; this.linePosition = linePosition; }
// Methods private static string FilterNull(XmlAttribute strValue) { if (strValue != null) { return strValue.Value.ToString(); } return ""; }
/// <summary> /// 从xml文件取得appSettings值 /// </summary> /// <param name="key"></param> /// <returns></returns> public static string GetAppSettingsFromXml(string key) { string result = string.Empty; System.Xml.XmlAttribute att = XMLHelper.GetXmlAttribute(configPath, "/configuration/appSettings/add[@key=\"" + key + "\"]", "value"); result = att.Value; return(result); }
private void with_an_attribute_that_has_a_name() { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml("<node datetime='now' />"); // ReSharper disable once PossibleNullReferenceException _attribute = xmlDocument.FirstChild.Attributes[0]; _expectedName = "datetime"; }
static bool AreEqual(XmlAttribute lhs, XmlAttribute rhs) { if(lhs.Name != rhs.Name) return false; if (lhs.Value != rhs.Value) return false; return true; }
void AddXmlNode(XmlNode node, XmlAttribute attribute) { if (mResourceNodes.ContainsKey(attribute.Value.ToString())) return; mResourceNodes.Add(attribute.Value.ToString(), node); mResourceNameList.Add(attribute.Value.ToString()); }
private static string GetRelativePath(XmlAttribute attribute) { var path = attribute.Value; if (!path.Contains(Constants.BACKSLASH)){ return null; } var lastSlash = path.LastIndexOf(Constants.BACKSLASH, StringComparison.Ordinal); return path.Substring(0, lastSlash + 1); }
public void Init() { XmlDocument document = new XmlDocument(); document.LoadXml("<root first='a' second='b'/>"); firstAttribute = document.DocumentElement.GetAttributeNode("first"); properties = XmlAttributePropertyDescriptor.GetProperties(document.DocumentElement.Attributes); firstAttributePropertyDescriptor = (XmlAttributePropertyDescriptor)properties["first"]; secondAttributePropertyDescriptor = (XmlAttributePropertyDescriptor)properties["second"]; }
protected static void BindIndex(XmlAttribute indexAttribute, Table table, Column column) { if (indexAttribute != null && table != null) { StringTokenizer tokens = new StringTokenizer(indexAttribute.Value, ", "); foreach (string token in tokens) table.GetOrCreateIndex(token).AddColumn(column); } }
void IHasAttribute.InitAtrribute(XmlAttribute Attr) { if(ID == "mesh2-geometry-position-array") { } if(Attr.Name == "count") Count = uint.Parse(Attr.Value); else InitAtrrib(Attr); }