public override bool Equals(object obj) { //Check for null and compare run-time types. if (obj == null || this.GetType() != obj.GetType()) { return(false); } PropertyAndType pt = (PropertyAndType)obj; return((this.propName == pt.PropertyName) && (this.propType == pt.Type)); }
private void Configure() { XmlNode xmlType = null; XmlNode xmlSchema = null; XmlNode xmlProp = null; XmlNode xmlUrn = null; XmlNodeList nodeList = null; XmlDocument xmlDoc = new XmlDocument(); PropertyAndType pt; PropertyAndObject po; ReturnValue = true; string testBin = Environment.GetEnvironmentVariable("TESTBIN"); if (testBin == null) testBin = string.Empty; XmlTextReader xmlr = new XmlTextReader(testBin + @"\" + configFile); xmlr.ProhibitDtd = true; try { xmlDoc.Load(xmlr); } catch (Exception) { xmlr = new XmlTextReader(configFile); xmlr.ProhibitDtd = true; try { xmlDoc.Load(xmlr); } catch (ApplicationException ex) { WriteLine(string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.ErrorLoadingConfiguration, ex)); throw new ApplicationException( Properties.Resources.ErrorLoadingConfigurationException, ex); } } XmlElement docElem = xmlDoc.DocumentElement; nodeList = docElem.GetElementsByTagName("Ignore"); int k = 0; foreach (XmlNode node in nodeList) { k++; xmlType = node.Attributes.GetNamedItem("Type"); xmlProp = node.Attributes.GetNamedItem("Prop"); xmlUrn = node.Attributes.GetNamedItem("Urn"); xmlSchema = node.Attributes.GetNamedItem("Schema"); if (xmlType == null && xmlProp == null && xmlUrn == null && xmlSchema == null) { throw new ApplicationException(string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.BadConfigurationFile, k)); } if (xmlSchema != null) { ignoreSchema.Add(xmlSchema.Value); } else if (xmlProp == null && xmlUrn == null) { // Ignore the Type ignoreType.Add(xmlType.Value); } else if (xmlType == null && xmlProp == null) { // Ignore the object ignoreObject.Add(xmlUrn.Value); } else if (xmlType == null && xmlUrn == null) { // Ignore the property ignoreProperty.Add(xmlProp.Value); } else if (xmlUrn == null) { // Ignore a property for a specific Type pt = new PropertyAndType(); pt.PropertyName = xmlProp.Value; pt.Type = xmlType.Value; ignorePropertyForType.Add(pt); } else if (xmlType == null) { // Ignore a property for the object po = new PropertyAndObject(); po.PropertyName = xmlProp.Value; po.Urn = new Uri(xmlUrn.Value); ignorePropertyForObject.Add(po); } } nodeList = docElem.GetElementsByTagName("CanBeNullReference"); k = 0; foreach (XmlNode node in nodeList) { k++; xmlType = node.Attributes.GetNamedItem("Type"); xmlProp = node.Attributes.GetNamedItem("Prop"); if (xmlType == null || xmlProp == null) { throw new ApplicationException(string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.BadConfigurationFileNullReference, k)); } pt = new PropertyAndType(); pt.PropertyName = xmlProp.Value; pt.Type = xmlType.Value; collectionCanBeNull.Add(pt); } }