private SwitchRelations ObtainAttributes(XmlNode node, SwitchRelations switchGroup) { SwitchRelations relations; if (switchGroup != null) { relations = switchGroup.Clone(); } else { relations = new SwitchRelations(); } foreach (XmlAttribute attribute in node.Attributes) { string str = attribute.Name.ToUpperInvariant(); if (str != null) { if (!(str == "NAME")) { if (str == "STATUS") { goto Label_0065; } } else { relations.SwitchValue = attribute.InnerText; } } continue; Label_0065: relations.Status = attribute.InnerText; } return(relations); }
private bool ContainsCurrentPlatform(string SwitchValue) { if ((this.Platform != null) && this.relationsParser.SwitchRelationsList.ContainsKey(SwitchValue)) { SwitchRelations relations = this.relationsParser.SwitchRelationsList[SwitchValue]; if (relations.ExcludedPlatforms.Count > 0) { foreach (string str in relations.ExcludedPlatforms) { if (this.Platform == str) { return(false); } } } if (relations.IncludedPlatforms.Count > 0) { bool flag = false; foreach (string str2 in relations.IncludedPlatforms) { if (this.Platform == str2) { flag = true; } } return(flag); } } return(true); }
private bool ParseSwitchGroupOrSwitch(XmlNode node, Dictionary <string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { while (node != null) { if (node.NodeType == XmlNodeType.Element) { if (string.Equals(node.Name, "SWITCHGROUP", StringComparison.OrdinalIgnoreCase)) { SwitchRelations relations = this.ObtainAttributes(node, switchRelations); if (!this.ParseSwitchGroupOrSwitch(node.FirstChild, switchRelationsList, relations)) { return(false); } } else if (string.Equals(node.Name, "SWITCH", StringComparison.OrdinalIgnoreCase)) { if (!this.ParseSwitch(node, switchRelationsList, switchRelations)) { return(false); } } else if (string.Equals(node.Name, "IMPORT", StringComparison.OrdinalIgnoreCase) && !this.ParseImportOption(node)) { return(false); } } node = node.NextSibling; } return(true); }
private void GenerateOverrides(Property property, CodeMemberProperty propertyName) { if (this.relationsParser.SwitchRelationsList.ContainsKey(property.SwitchName)) { SwitchRelations relations = this.relationsParser.SwitchRelationsList[property.SwitchName]; if (relations.Overrides.Count > 0) { foreach (string str in relations.Overrides) { propertyName.SetStatements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("switchToAdd"), "Overrides"), "AddLast", new CodeExpression[] { new CodeObjectCreateExpression(new CodeTypeReference("KeyValuePair<string,string>"), new CodeExpression[] { new CodeSnippetExpression(this.SurroundWithQuotes(relations.SwitchValue)), new CodeSnippetExpression(this.SurroundWithQuotes(str)) }) })); } } if (property.ReverseSwitchName != "") { relations = this.relationsParser.SwitchRelationsList[property.ReverseSwitchName]; if (relations.Overrides.Count > 0) { foreach (string str2 in relations.Overrides) { propertyName.SetStatements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("switchToAdd"), "Overrides"), "AddLast", new CodeExpression[] { new CodeObjectCreateExpression(new CodeTypeReference("KeyValuePair<string,string>"), new CodeExpression[] { new CodeSnippetExpression(this.SurroundWithQuotes(relations.SwitchValue)), new CodeSnippetExpression(this.SurroundWithQuotes(str2)) }) })); } } } } }
/// <summary> /// Gets all the attributes assigned in the xml file for this parameter or all of the nested switches for /// this parameter group /// </summary> private static SwitchRelations ObtainAttributes(XmlNode node, SwitchRelations switchGroup) { SwitchRelations switchRelations; if (switchGroup != null) { switchRelations = switchGroup.Clone(); } else { switchRelations = new SwitchRelations(); } foreach (XmlAttribute attribute in node.Attributes) { // do case-insensitive comparison switch (attribute.Name.ToUpperInvariant()) { case nameProperty: switchRelations.SwitchValue = attribute.InnerText; break; case status: switchRelations.Status = attribute.InnerText; break; default: //LogError("InvalidAttribute", attribute.Name); break; } } return(switchRelations); }
public SwitchRelations Clone() { SwitchRelations cloned = new SwitchRelations(); cloned._switchValue = _switchValue; cloned._status = _status; cloned._conflicts = new List<string>(_conflicts); cloned._overrides = new List<string>(_overrides); cloned._requires = new List<string>(_requires); cloned._excludedPlatforms = new List<string>(_excludedPlatforms); cloned._includedPlatforms = new List<string>(_includedPlatforms); cloned._externalConflicts = new Dictionary<string, List<string>>(_externalConflicts, StringComparer.OrdinalIgnoreCase); cloned._externalOverrides = new Dictionary<string, List<string>>(_externalOverrides, StringComparer.OrdinalIgnoreCase); cloned._externalRequires = new Dictionary<string, List<string>>(_externalRequires, StringComparer.OrdinalIgnoreCase); return cloned; }
public SwitchRelations Clone() { SwitchRelations cloned = new SwitchRelations(); cloned._switchValue = _switchValue; cloned._status = _status; cloned._conflicts = new List <string>(_conflicts); cloned._overrides = new List <string>(_overrides); cloned._requires = new List <string>(_requires); cloned._excludedPlatforms = new List <string>(_excludedPlatforms); cloned._includedPlatforms = new List <string>(_includedPlatforms); cloned._externalConflicts = new Dictionary <string, List <string> >(_externalConflicts, StringComparer.OrdinalIgnoreCase); cloned._externalOverrides = new Dictionary <string, List <string> >(_externalOverrides, StringComparer.OrdinalIgnoreCase); cloned._externalRequires = new Dictionary <string, List <string> >(_externalRequires, StringComparer.OrdinalIgnoreCase); return(cloned); }
private bool ParseSwitchGroupOrSwitch(XmlNode node, Dictionary <string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { while (node != null) { if (node.NodeType == XmlNodeType.Element) { // if the node's name is <ParameterGroup> get all the attributes if (String.Equals(node.Name, switchGroupType, StringComparison.OrdinalIgnoreCase)) { SwitchRelations newSwitchRelations = ObtainAttributes(node, switchRelations); if (!ParseSwitchGroupOrSwitch(node.FirstChild, switchRelationsList, newSwitchRelations)) { return(false); } } else if (String.Equals(node.Name, switchType, StringComparison.OrdinalIgnoreCase)) { // node is a switchRelations if (!ParseSwitch(node, switchRelationsList, switchRelations)) { return(false); } } else if (String.Equals(node.Name, importType, StringComparison.OrdinalIgnoreCase)) { // node is an import option if (!ParseImportOption(node)) { return(false); } } } node = node.NextSibling; } return(true); }
public SwitchRelations Clone() { var cloned = new SwitchRelations { SwitchValue = SwitchValue, Status = Status, Conflicts = new List <string>(Conflicts), Overrides = new List <string>(Overrides), Requires = new List <string>(Requires), ExcludedPlatforms = new List <string>(ExcludedPlatforms), IncludedPlatforms = new List <string>(IncludedPlatforms), ExternalConflicts = new Dictionary <string, List <string> >( ExternalConflicts, StringComparer.OrdinalIgnoreCase), ExternalOverrides = new Dictionary <string, List <string> >( ExternalOverrides, StringComparer.OrdinalIgnoreCase), ExternalRequires = new Dictionary <string, List <string> >( ExternalRequires, StringComparer.OrdinalIgnoreCase) }; return(cloned); }
private SwitchRelations ObtainAttributes(XmlNode node, SwitchRelations switchGroup) { SwitchRelations relations; if (switchGroup != null) { relations = switchGroup.Clone(); } else { relations = new SwitchRelations(); } foreach (XmlAttribute attribute in node.Attributes) { string str = attribute.Name.ToUpperInvariant(); if (str != null) { if (!(str == "NAME")) { if (str == "STATUS") { goto Label_0065; } } else { relations.SwitchValue = attribute.InnerText; } } continue; Label_0065: relations.Status = attribute.InnerText; } return relations; }
private static bool ParseSwitch(XmlNode node, Dictionary <string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { SwitchRelations switchRelationsToAdd = ObtainAttributes(node, switchRelations); // make sure that the switchRelationsList has a name, unless it is type always if (string.IsNullOrEmpty(switchRelationsToAdd.SwitchValue)) { return(false); } // generate the list of parameters in order if (!switchRelationsList.ContainsKey(switchRelationsToAdd.SwitchValue)) { switchRelationsList.Remove(switchRelationsToAdd.SwitchValue); } // build the dependencies and the values for a parameter XmlNode child = node.FirstChild; while (child != null) { if (child.NodeType == XmlNodeType.Element) { if (String.Equals(child.Name, requiresType, StringComparison.OrdinalIgnoreCase)) { string tool = String.Empty; string Switch = String.Empty; bool isExternal = false; foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case nameProperty: break; case toolAttribute: isExternal = true; tool = attrib.InnerText; break; case switchAttribute: Switch = attrib.InnerText; break; default: return(false); } } if (!isExternal) { if (Switch != String.Empty) { switchRelationsToAdd.Requires.Add(Switch); } else { return(false); } } else { if (!switchRelationsToAdd.ExternalRequires.ContainsKey(tool)) { var switches = new List <string> { Switch }; switchRelationsToAdd.ExternalRequires.Add(tool, switches); } else { switchRelationsToAdd.ExternalRequires[tool].Add(Switch); } } } else if (String.Equals(child.Name, includedPlatformType, StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case nameProperty: switchRelationsToAdd.IncludedPlatforms.Add(attrib.InnerText); break; default: return(false); } } } else if (String.Equals(child.Name, excludedPlatformType, StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case nameProperty: switchRelationsToAdd.ExcludedPlatforms.Add(attrib.InnerText); break; default: return(false); } } } else if (String.Equals(child.Name, overridesType, StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case switchName: switchRelationsToAdd.Overrides.Add(attrib.InnerText); break; case argumentValueName: break; default: return(false); } } } } child = child.NextSibling; } // We've read any enumerated values and any dependencies, so we just // have to add the switchRelations switchRelationsList.Add(switchRelationsToAdd.SwitchValue, switchRelationsToAdd); return(true); }
private bool ParseSwitch(XmlNode node, Dictionary<string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { SwitchRelations switchRelationsToAdd = ObtainAttributes(node, switchRelations); // make sure that the switchRelationsList has a name, unless it is type always if (switchRelationsToAdd.SwitchValue == null || switchRelationsToAdd.SwitchValue == String.Empty) { return false; } // generate the list of parameters in order if (!switchRelationsList.ContainsKey(switchRelationsToAdd.SwitchValue)) { switchRelationsList.Remove(switchRelationsToAdd.SwitchValue); } // build the dependencies and the values for a parameter XmlNode child = node.FirstChild; while (child != null) { if (child.NodeType == XmlNodeType.Element) { if (String.Equals(child.Name, requiresType, StringComparison.OrdinalIgnoreCase)) { string Name = String.Empty; string Tool = String.Empty; string Switch = String.Empty; bool isExternal = false; foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case nameProperty: Name = attrib.InnerText; break; case toolAttribute: isExternal = true; Tool = attrib.InnerText; break; case switchAttribute: Switch = attrib.InnerText; break; default: return false; } } if (!isExternal) if (Switch != String.Empty) switchRelationsToAdd.Requires.Add(Switch); else return false; else { if (!switchRelationsToAdd.ExternalRequires.ContainsKey(Tool)) { List<string> switches = new List<string>(); switches.Add(Switch); switchRelationsToAdd.ExternalRequires.Add(Tool, switches); } else { switchRelationsToAdd.ExternalRequires[Tool].Add(Switch); } } } else if (String.Equals(child.Name, includedPlatformType, StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case nameProperty: switchRelationsToAdd.IncludedPlatforms.Add(attrib.InnerText); break; default: return false; } } } else if (String.Equals(child.Name, excludedPlatformType, StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case nameProperty: switchRelationsToAdd.ExcludedPlatforms.Add(attrib.InnerText); break; default: return false; } } } else if (String.Equals(child.Name, overridesType, StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attrib in child.Attributes) { switch (attrib.Name.ToUpperInvariant()) { case switchName: switchRelationsToAdd.Overrides.Add(attrib.InnerText); break; case argumentValueName: break; default: return false; } } } } child = child.NextSibling; } // We've read any enumerated values and any dependencies, so we just // have to add the switchRelations switchRelationsList.Add(switchRelationsToAdd.SwitchValue, switchRelationsToAdd); return true; }
/// <summary> /// Gets all the attributes assigned in the xml file for this parameter or all of the nested switches for /// this parameter group /// </summary> /// <param name="node"></param> /// <param name="switchGroup"></param> /// <returns></returns> private SwitchRelations ObtainAttributes(XmlNode node, SwitchRelations switchGroup) { SwitchRelations switchRelations; if (switchGroup != null) { switchRelations = switchGroup.Clone(); } else { switchRelations = new SwitchRelations(); } foreach (XmlAttribute attribute in node.Attributes) { // do case-insensitive comparison switch (attribute.Name.ToUpperInvariant()) { case nameProperty: switchRelations.SwitchValue = attribute.InnerText; break; case status: switchRelations.Status = attribute.InnerText; break; default: //LogError("InvalidAttribute", attribute.Name); break; } } return switchRelations; }
private bool ParseSwitchGroupOrSwitch(XmlNode node, Dictionary<string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { while (node != null) { if (node.NodeType == XmlNodeType.Element) { if (string.Equals(node.Name, "SWITCHGROUP", StringComparison.OrdinalIgnoreCase)) { SwitchRelations relations = this.ObtainAttributes(node, switchRelations); if (!this.ParseSwitchGroupOrSwitch(node.FirstChild, switchRelationsList, relations)) { return false; } } else if (string.Equals(node.Name, "SWITCH", StringComparison.OrdinalIgnoreCase)) { if (!this.ParseSwitch(node, switchRelationsList, switchRelations)) { return false; } } else if (string.Equals(node.Name, "IMPORT", StringComparison.OrdinalIgnoreCase) && !this.ParseImportOption(node)) { return false; } } node = node.NextSibling; } return true; }
private bool ParseSwitch(XmlNode node, Dictionary<string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { SwitchRelations relations = this.ObtainAttributes(node, switchRelations); if ((relations.SwitchValue == null) || (relations.SwitchValue == string.Empty)) { return false; } if (!switchRelationsList.ContainsKey(relations.SwitchValue)) { switchRelationsList.Remove(relations.SwitchValue); } for (XmlNode node2 = node.FirstChild; node2 != null; node2 = node2.NextSibling) { if (node2.NodeType == XmlNodeType.Element) { if (string.Equals(node2.Name, "REQUIRES", StringComparison.OrdinalIgnoreCase)) { string key = string.Empty; string item = string.Empty; bool flag = false; foreach (XmlAttribute attribute in node2.Attributes) { string str3 = attribute.Name.ToUpperInvariant(); if (str3 == null) { goto Label_00FE; } if (!(str3 == "NAME")) { if (str3 == "TOOL") { goto Label_00E7; } if (str3 == "SWITCH") { goto Label_00F4; } goto Label_00FE; } string innerText = attribute.InnerText; continue; Label_00E7: flag = true; key = attribute.InnerText; continue; Label_00F4: item = attribute.InnerText; continue; Label_00FE: return false; } if (!flag) { if (item == string.Empty) { return false; } relations.Requires.Add(item); } else if (!relations.ExternalRequires.ContainsKey(key)) { List<string> list = new List<string> { item }; relations.ExternalRequires.Add(key, list); } else { relations.ExternalRequires[key].Add(item); } } else if (string.Equals(node2.Name, "INCLUDEDPLATFORM", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute2 in node2.Attributes) { string str4; if (((str4 = attribute2.Name.ToUpperInvariant()) != null) && (str4 == "NAME")) { relations.IncludedPlatforms.Add(attribute2.InnerText); } else { return false; } } } else if (string.Equals(node2.Name, "EXCLUDEDPLATFORM", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute3 in node2.Attributes) { string str5; if (((str5 = attribute3.Name.ToUpperInvariant()) != null) && (str5 == "NAME")) { relations.ExcludedPlatforms.Add(attribute3.InnerText); } else { return false; } } } else if (string.Equals(node2.Name, "OVERRIDES", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute4 in node2.Attributes) { string str6 = attribute4.Name.ToUpperInvariant(); if (str6 != null) { if (!(str6 == "SWITCH")) { if (str6 == "ARGUMENTVALUE") { continue; } } else { relations.Overrides.Add(attribute4.InnerText); continue; } } return false; } } } } switchRelationsList.Add(relations.SwitchValue, relations); return true; }
private bool ParseSwitchGroupOrSwitch(XmlNode node, Dictionary<string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { while (node != null) { if (node.NodeType == XmlNodeType.Element) { // if the node's name is <ParameterGroup> get all the attributes if (String.Equals(node.Name, switchGroupType, StringComparison.OrdinalIgnoreCase)) { SwitchRelations newSwitchRelations = ObtainAttributes(node, switchRelations); if (!ParseSwitchGroupOrSwitch(node.FirstChild, switchRelationsList, newSwitchRelations)) { return false; } } else if (String.Equals(node.Name, switchType, StringComparison.OrdinalIgnoreCase)) { // node is a switchRelations if (!ParseSwitch(node, switchRelationsList, switchRelations)) { return false; } } else if (String.Equals(node.Name, importType, StringComparison.OrdinalIgnoreCase)) { // node is an import option if (!ParseImportOption(node)) { return false; } } } node = node.NextSibling; } return true; }
private bool ParseSwitch(XmlNode node, Dictionary <string, SwitchRelations> switchRelationsList, SwitchRelations switchRelations) { SwitchRelations relations = this.ObtainAttributes(node, switchRelations); if ((relations.SwitchValue == null) || (relations.SwitchValue == string.Empty)) { return(false); } if (!switchRelationsList.ContainsKey(relations.SwitchValue)) { switchRelationsList.Remove(relations.SwitchValue); } for (XmlNode node2 = node.FirstChild; node2 != null; node2 = node2.NextSibling) { if (node2.NodeType == XmlNodeType.Element) { if (string.Equals(node2.Name, "REQUIRES", StringComparison.OrdinalIgnoreCase)) { string key = string.Empty; string item = string.Empty; bool flag = false; foreach (XmlAttribute attribute in node2.Attributes) { string str3 = attribute.Name.ToUpperInvariant(); if (str3 == null) { goto Label_00FE; } if (!(str3 == "NAME")) { if (str3 == "TOOL") { goto Label_00E7; } if (str3 == "SWITCH") { goto Label_00F4; } goto Label_00FE; } string innerText = attribute.InnerText; continue; Label_00E7: flag = true; key = attribute.InnerText; continue; Label_00F4: item = attribute.InnerText; continue; Label_00FE: return(false); } if (!flag) { if (item == string.Empty) { return(false); } relations.Requires.Add(item); } else if (!relations.ExternalRequires.ContainsKey(key)) { List <string> list = new List <string> { item }; relations.ExternalRequires.Add(key, list); } else { relations.ExternalRequires[key].Add(item); } } else if (string.Equals(node2.Name, "INCLUDEDPLATFORM", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute2 in node2.Attributes) { string str4; if (((str4 = attribute2.Name.ToUpperInvariant()) != null) && (str4 == "NAME")) { relations.IncludedPlatforms.Add(attribute2.InnerText); } else { return(false); } } } else if (string.Equals(node2.Name, "EXCLUDEDPLATFORM", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute3 in node2.Attributes) { string str5; if (((str5 = attribute3.Name.ToUpperInvariant()) != null) && (str5 == "NAME")) { relations.ExcludedPlatforms.Add(attribute3.InnerText); } else { return(false); } } } else if (string.Equals(node2.Name, "OVERRIDES", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute4 in node2.Attributes) { string str6 = attribute4.Name.ToUpperInvariant(); if (str6 != null) { if (!(str6 == "SWITCH")) { if (str6 == "ARGUMENTVALUE") { continue; } } else { relations.Overrides.Add(attribute4.InnerText); continue; } } return(false); } } } } switchRelationsList.Add(relations.SwitchValue, relations); return(true); }