public void TryCreate_ShouldReturnTrue_ForKnownAppenders(string xml, Type expectedModelType) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); Assert.IsTrue(AppenderModel.TryCreate(xmlDoc.FirstChild.FirstChild, xmlDoc.FirstChild, out AppenderModel _)); }
public void TryCreate_ShouldReturnCorrectType(string xml, Type expectedModelType) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); AppenderModel.TryCreate(xmlDoc.FirstChild.FirstChild, xmlDoc.FirstChild, out AppenderModel model); Assert.IsInstanceOf(expectedModelType, model); }
public void TryCreate_ShouldReturnFalse_ForUnknownAppenders() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<log4net>" + "<appender>" + "</appender>" + "</log4net>"); Assert.IsFalse(AppenderModel.TryCreate(xmlDoc.FirstChild.FirstChild, xmlDoc.FirstChild, out AppenderModel _)); }
private void LoadPossibleReferences() { XmlNodeList availableRefs = mConfiguration.Log4NetNode.SelectNodes("appender"); foreach (XmlNode appender in availableRefs) { string name = appender.Attributes["name"].Value; if (Equals(appender, mConfiguration.OriginalNode) || RefsCollection.Any(@ref => Equals(@ref.Name, name))) { continue; } if (AppenderModel.TryCreate(appender, mConfiguration.Log4NetNode, out AppenderModel appenderModel)) { RefsCollection.Add(appenderModel); } } }
private bool LoadAppenders() { //Only selects appenders under this log4net element XmlNodeList appenderList = Log4NetNode.SelectNodes("appender"); bool unrecognized = false; foreach (XmlNode node in appenderList) { if (AppenderModel.TryCreate(node, Log4NetNode, out AppenderModel model)) { mMutableChildren.Add(model); } else { unrecognized = true; } } return(unrecognized); }