private T GetXmlAdapter <T>() where T : class
        {
            var xpath = new XPathAdapter(new XmlDocument());

            return((T)factory.GetAdapter(typeof(T), new Hashtable(), new DictionaryDescriptor()
                                         .AddBehavior(XPathBehavior.Instance).AddBehavior(xpath)
                                         .AddBehavior(new MemberwiseEqualityHashCodeStrategy())));
        }
Exemple #2
0
        public void Can_Remove_Properties()
        {
            var xml = @"<Season xmlns='RISE' xmlns:rise='RISE'>
					 <Name>Soccer Adult Spring II 2010</Name>
				  </Season>"                ;

            XmlDocument document = null;
            var         season   = CreateXmlAdapter <ISeason>(xml, ref document);

            Assert.IsTrue(XPathAdapter.IsPropertyDefined("Name", season));
            season.Name = "";
            Assert.IsFalse(XPathAdapter.IsPropertyDefined("Name", season));
        }
Exemple #3
0
        public void Can_Determine_If_Property_Defined_In_Xml()
        {
            var xml = @"<Season xmlns='RISE'>
					 <Address xmlns='Common'>
						<Line1>2922 South Highway 205</Line1>
					 </Address>
				  </Season>"                ;

            XmlDocument document = null;
            var         season   = CreateXmlAdapter <ISeason>(xml, ref document);

            Assert.IsTrue(XPathAdapter.IsPropertyDefined("Location", season));
            Assert.IsFalse(XPathAdapter.IsPropertyDefined("Name", season));
        }
Exemple #4
0
        public void Can_Determine_If_Collection_Defined_In_Xml()
        {
            var xml = @"<Season xmlns='RISE' xmlns:rise='RISE'>
					 <League>
						<Team name='Hit And Run'>
						   <AmountDue>100.50</AmountDue>
						</Team>
						<Team name='Nemisis'>
						   <AmountDue>250.00</AmountDue>
						</Team>
					 </League>
				  </Season>"                ;

            XmlDocument document = null;
            var         season   = CreateXmlAdapter <ISeason>(xml, ref document);

            Assert.IsTrue(XPathAdapter.IsPropertyDefined("Teams", season));
            Assert.IsFalse(XPathAdapter.IsPropertyDefined("Tags", season));
        }