public void ShouldCreateCollectionSerialiserWhenInstanceTypeIsCollection()
		{
			FieldInfo field = typeof (CollectionTestClass).GetField("Stuff");
			attribute = (ReflectorPropertyAttribute) field.GetCustomAttributes(false)[0];
			IXmlSerialiser serialiser = factory.Create(ReflectorMember.Create(field), attribute);
			Assert.AreEqual(typeof(XmlCollectionSerialiser), serialiser.GetType());
		}
Esempio n. 2
0
        public void ShouldUseDefaultSerialiserFactory()
        {
            ReflectorPropertyAttribute attribute  = new ReflectorPropertyAttribute("foo");
            IXmlSerialiser             serialiser = attribute.CreateSerialiser(member);

            Assert.IsNotNull(serialiser);
        }
Esempio n. 3
0
        public void WriteHandlesAList()
        {
            var attribute  = new ReflectorPropertyAttribute("list");
            var serialiser = new NameValuePairSerialiser(null, attribute, true);
            var values     = new NameValuePair[]
            {
                new NameValuePair("name1", "the value of 1"),
                new NameValuePair("name2", "the value of 2")
            };
            var builder = new StringBuilder();

            using (var stringWriter = new StringWriter(builder))
            {
                var settings = new XmlWriterSettings
                {
                    Indent = false,
                    NewLineOnAttributes = false,
                    OmitXmlDeclaration  = true
                };
                using (var writer = XmlWriter.Create(stringWriter, settings))
                {
                    serialiser.Write(writer, values);
                }
            }

            Assert.AreEqual(
                "<list><value name=\"name1\">the value of 1</value><value name=\"name2\">the value of 2</value></list>",
                builder.ToString());
        }
Esempio n. 4
0
        public void ShouldCreateCollectionSerialiserWhenInstanceTypeIsCollection()
        {
            FieldInfo field = typeof(CollectionTestClass).GetField("Stuff");

            attribute = (ReflectorPropertyAttribute)field.GetCustomAttributes(false)[0];
            IXmlSerialiser serialiser = factory.Create(ReflectorMember.Create(field), attribute);

            Assert.AreEqual(typeof(XmlCollectionSerialiser), serialiser.GetType());
        }
Esempio n. 5
0
        public void ShouldCreateCollectionSerialiserWhenCollectionPropertyIsPassed()
        {
            DefaultSerialiserFactory   factory    = new DefaultSerialiserFactory();
            PropertyInfo               property   = typeof(Project).GetProperty("Triggers");
            ReflectorPropertyAttribute attribute  = (ReflectorPropertyAttribute)property.GetCustomAttributes(false)[0];
            IXmlSerialiser             serialiser = factory.Create(ReflectorMember.Create(property), attribute);

            Assert.AreEqual(typeof(XmlCollectionSerialiser), serialiser.GetType());
        }
Esempio n. 6
0
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     if (attribute.InstanceType == null || attribute.InstanceType.Equals(typeof(string)))
     {
         return(new StringJTokenSerializer(memberInfo, attribute));
     }
     else
     {
         throw new System.NotSupportedException(attribute.InstanceType.Name);
     }
 }
Esempio n. 7
0
        public void ReadHandlesNull()
        {
            var member    = TestClass.Fetch();
            var attribute = new ReflectorPropertyAttribute("test");

            attribute.Required = false;
            var serialiser = new PrivateStringSerialiser(member, attribute);
            var result     = serialiser.Read(null, null);

            Assert.IsNull(result);
        }
Esempio n. 8
0
        public void ReadFailsNullOnRequired()
        {
            var member    = TestClass.Fetch();
            var attribute = new ReflectorPropertyAttribute("test");

            attribute.Required = true;
            var serialiser = new PrivateStringSerialiser(member, attribute);

            Assert.Throws <NetReflectorItemRequiredException>(() =>
            {
                serialiser.Read(null, null);
            }, "test is required");
        }
Esempio n. 9
0
        public void ReadLoadsAttribute()
        {
            var member     = TestClass.Fetch();
            var attribute  = new ReflectorPropertyAttribute("test");
            var serialiser = new PrivateStringSerialiser(member, attribute);
            var document   = new XmlDocument();
            var element    = document.CreateAttribute("test");

            element.Value = "value of the attribute";
            var result = serialiser.Read(element, null);

            Assert.IsInstanceOf <PrivateString>(result);
            Assert.AreEqual("value of the attribute", (result as PrivateString).PrivateValue);
        }
Esempio n. 10
0
        public void WriteHandlesDirect()
        {
            var member     = TestClass.Fetch();
            var attribute  = new ReflectorPropertyAttribute("test");
            var serialiser = new PrivateStringSerialiser(member, attribute);
            var builder    = new StringBuilder();
            var settings   = new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            };

            using (var writer = XmlWriter.Create(builder, settings))
            {
                serialiser.Write(writer, new PrivateString
                {
                    PrivateValue = "test"
                });
            }

            Assert.AreEqual("<test>********</test>", builder.ToString());
        }
Esempio n. 11
0
        public void WriteHandlesASingleItem()
        {
            var attribute  = new ReflectorPropertyAttribute("value");
            var serialiser = new NameValuePairSerialiser(null, attribute, false);
            var value      = new NameValuePair("a name", "the value");
            var builder    = new StringBuilder();

            using (var stringWriter = new StringWriter(builder))
            {
                var settings = new XmlWriterSettings
                {
                    Indent = false,
                    NewLineOnAttributes = false,
                    OmitXmlDeclaration  = true
                };
                using (var writer = XmlWriter.Create(stringWriter, settings))
                {
                    serialiser.Write(writer, value);
                }
            }

            Assert.AreEqual("<value name=\"a name\">the value</value>", builder.ToString());
        }
Esempio n. 12
0
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     return(new BuildReportXslFilenameSerialiser(memberInfo, attribute));
 }
 public XmlDateTimeSerialiser(ReflectorMember member, ReflectorPropertyAttribute attribute)
     : base(member, attribute)
 {
 }
 /// <summary>
 /// Creates the specified serialiser.
 /// </summary>
 /// <param name="memberInfo">The member info.</param>
 /// <param name="attribute">The attribute defining the serialiser.</param>
 /// <returns>A new instance of <see cref="UriSerializer"/>.</returns>
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     return(new PrivateStringSerialiser(memberInfo, attribute));
 }
Esempio n. 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NetworkCredentialsSerializer"/> class.
 /// </summary>
 /// <param name="member">The member to use.</param>
 /// <param name="attribute">The attribute defining the serialiser.</param>
 public NetworkCredentialsSerializer(ReflectorMember member, ReflectorPropertyAttribute attribute)
     : base(member, attribute)
 {
 }
 /// <summary>
 /// Create the serialiser.
 /// </summary>
 /// <param name="memberInfo"></param>
 /// <param name="attribute"></param>
 /// <returns></returns>
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     return(new NameValuePairSerialiser(memberInfo, attribute, true));
 }
Esempio n. 17
0
 protected void SetUp()
 {
     attribute = new ReflectorPropertyAttribute("foo");
     factory   = new DefaultSerialiserFactory();
 }
		public IXmlMemberSerialiser Create(ReflectorMember member, ReflectorPropertyAttribute attribute)
		{
			return new CustomSerialiser(member, attribute);
		}
Esempio n. 19
0
 public WsIdCollectionSerializer(ReflectorMember member,
                                 ReflectorPropertyAttribute attribute)
     : base(member, attribute)
 {
 }
Esempio n. 20
0
 public StringJTokenSerializer(ReflectorMember member, ReflectorPropertyAttribute attribute) : base(member, attribute)
 {
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UriSerializer"/> class.
 /// </summary>
 /// <param name="member">The member.</param>
 /// <param name="attribute">The attribute.</param>
 public UriSerializer(ReflectorMember member, ReflectorPropertyAttribute attribute)
     : base(member, attribute)
 {
 }
Esempio n. 22
0
 public CustomSerialiser(ReflectorMember member, ReflectorPropertyAttribute attribute) : base(member, attribute)
 {
 }
Esempio n. 23
0
 public IXmlMemberSerialiser Create(ReflectorMember member, ReflectorPropertyAttribute attribute)
 {
     return(new CustomSerialiser(member, attribute));
 }
		public CustomSerialiser(ReflectorMember member, ReflectorPropertyAttribute attribute) : base(member, attribute)
		{}
 /// <summary>
 /// Creates the specified serialiser.
 /// </summary>
 /// <param name="memberInfo">The member info.</param>
 /// <param name="attribute">The attribute defining the serialiser.</param>
 /// <returns>A new instance of <see cref="NetworkCredentialsSerializer"/>.</returns>
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     return(new NetworkCredentialsSerializer(memberInfo, attribute));
 }
		protected void SetUp()
		{
			attribute = new ReflectorPropertyAttribute("foo");
			factory = new DefaultSerialiserFactory();
		}
Esempio n. 27
0
 public IXmlMemberSerialiser Create(ReflectorMember member,
                                    ReflectorPropertyAttribute attribute)
 {
     return(new WsIdCollectionSerializer(member, attribute));
 }
Esempio n. 28
0
 public ApplicationPoolConfigSerializer(ReflectorMember member, ReflectorPropertyAttribute attribute) : base(member, attribute)
 {
 }
 /// <summary>
 /// Initialise a new <see cref="NameValuePairSerialiser"/>.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="attribute"></param>
 /// <param name="isList"></param>
 public NameValuePairSerialiser(ReflectorMember info, ReflectorPropertyAttribute attribute, bool isList)
     : base(info, attribute)
 {
     this.isList = isList;
 }
Esempio n. 30
0
 public TimeoutSerializer(ReflectorMember info, ReflectorPropertyAttribute attribute) : base(info, attribute)
 {
 }
 /// <summary>
 /// Initialise a new <see cref="MergeFileSerialiser"/>.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="attribute"></param>
 public MergeFileSerialiser(ReflectorMember info, ReflectorPropertyAttribute attribute)
     : base(info, attribute)
 {
 }
Esempio n. 32
0
 public VirtualDirectorySerializer(ReflectorMember member, ReflectorPropertyAttribute attribute) : base(member, attribute)
 {
 }
 public StringDictionarySerializer(ReflectorMember member, ReflectorPropertyAttribute attribute) : base(member, attribute)
 {
 }
Esempio n. 34
0
 /// <summary>
 /// Create the serialiser.
 /// </summary>
 /// <param name="memberInfo"></param>
 /// <param name="attribute"></param>
 /// <returns></returns>
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     return(new MergeFileSerialiser(memberInfo, attribute));
 }
Esempio n. 35
0
 public IXmlMemberSerialiser Create(ReflectorMember memberInfo, ReflectorPropertyAttribute attribute)
 {
     return(new BindingsSerializer(memberInfo, attribute));
 }
		public void ShouldUseDefaultSerialiserFactory()
		{
			ReflectorPropertyAttribute attribute = new ReflectorPropertyAttribute("foo");
			IXmlSerialiser serialiser = attribute.CreateSerialiser(member);
			Assert.IsNotNull(serialiser);
		}