コード例 #1
0
		public void WriteTo ()
		{
			var doc = new InlineCategoriesDocument ();
			var f = new AtomPub10CategoriesDocumentFormatter (doc);
			doc.Scheme = "http";
			doc.IsFixed = false;
			var sw = new StringWriter ();
			using (var xw = XmlWriter.Create (sw, settings))
				f.WriteTo (xw);
			Assert.AreEqual (app1, sw.ToString ());
		}
コード例 #2
0
ファイル: CategoriesDocument.cs プロジェクト: nickchal/pash
		public static CategoriesDocument Load (XmlReader reader)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			var f = new AtomPub10CategoriesDocumentFormatter ();
			reader.MoveToContent ();

			CategoriesDocument doc;
			if (reader.GetAttribute ("href") == null)
				doc = new InlineCategoriesDocument ();
			else
				doc = new ReferencedCategoriesDocument ();
			doc.GetFormatter ().ReadFrom (reader);

			return doc;
		}
コード例 #3
0
        public override void WriteToStream(Type type, object value, Stream writeStream, HttpContent content) {

            var document = value as IPublicationCategoriesDocument;

            var atomDoc = new InlineCategoriesDocument(
                document.Categories.Select(c => new SyndicationCategory(c.Name) { Label = c.Label }),
                document.IsFixed,
                document.Scheme
            );

            var formatter = new AtomPub10CategoriesDocumentFormatter(atomDoc);

            using (writeStream) {
                using (var writer = XmlWriter.Create(writeStream)) {
                    formatter.WriteTo(writer);
                }
            }
        }
コード例 #4
0
 public static CategoriesDocument Load(XmlReader reader)
 {
     AtomPub10CategoriesDocumentFormatter formatter = new AtomPub10CategoriesDocumentFormatter();
     formatter.ReadFrom(reader);
     return formatter.Document;
 }
コード例 #5
0
		public void ReadFrom ()
		{
			var f = new AtomPub10CategoriesDocumentFormatter ();
			f.ReadFrom (XmlReader.Create (new StringReader (app1)));
			var inline = f.Document as InlineCategoriesDocument;
			Assert.IsNotNull (inline, "#1");
			Assert.AreEqual ("http", inline.Scheme, "#2");
		}
コード例 #6
0
		public void WriteTo2 ()
		{
			var doc = new InlineCategoriesDocument ();
			var f = new AtomPub10CategoriesDocumentFormatter (doc);
			doc.Categories.Add (new SyndicationCategory ("TEST CATEGORY"));
			var sw = new StringWriter ();
			using (var xw = XmlWriter.Create (sw, settings))
				f.WriteTo (xw);
			Assert.AreEqual (app2, sw.ToString ());
		}
コード例 #7
0
		public void GetSchema ()
		{
			IXmlSerializable i = new AtomPub10CategoriesDocumentFormatter ();
			Assert.IsNull (i.GetSchema ());
		}