private void PopulateList(String SourceType, String OutputType)
{
//Populate The ListOfSubRules Property using LINQ to XML
var XMLSubRules = from XMLSubRule
in XDocument.Load("DataStore.xml").Descendants("SubRule")
where (XMLSubRule.Attribute("SourceType").Value == SourceType && XMLSubRule.Attribute("OutputType").Value == OutputType)
{
Expression = XMLSubRule.Element("Expression").Value,
IsMatchExpression = XMLSubRule.Element("IsMatchExpression").Value,
OpeningElement = XMLSubRule.Element("OpeningElement").Value,
ClosingElement = XMLSubRule.Element("ClosingElement").Value
};
foreach (var XMLSubRule in XMLSubRules)
{
ListOfSubRules.
Add(new SubRule
(XMLSubRule.
Expression,
XMLSubRule.IsMatchExpression,
XMLSubRule.OpeningElement,
XMLSubRule.ClosingElement));
}
}
private void GetCommentCode(String SourceType, String OutputType)
{
var CommentFromXML = from XMLComment
in XDocument.Load("DataStore.xml").Descendants("Comments")
where (XMLComment.Attribute("SourceType").Value == SourceType && XMLComment.Attribute("OutputType").Value == OutputType)
{
Expression = XMLComment.Element("Expression").Value,
OpeningElement = XMLComment.Element("OpeningElement").Value,
ClosingElement = XMLComment.Element("ClosingElement").Value
};
}
private void CreateMasterExpression()
{
String RawMasterExpressionString = String.Empty;
foreach (SubRule SubRuleItem in ListOfSubRules)
{
const string AndOrSymbol = "|";
RawMasterExpressionString = RawMasterExpressionString + AndOrSymbol + SubRuleItem.Expression;
}
// Removes the first OR from the string otherwise it will error.
MasterExpression = RawMasterExpressionString.Remove(0,1);
}
}
}