Esempio n. 1
0
 public object ReadFrom(ReaderContext context)
 {
     using (MemoryStream input = new MemoryStream())
       {
     context.HttpStream.CopyTo(input);
     return input.ToArray();
       }
 }
Esempio n. 2
0
 public object ReadFrom(ReaderContext context)
 {
   string text = null;
   using (StreamReader r = new StreamReader(context.HttpStream, Encoding.UTF8))
   {
     text = r.ReadToEnd();
   }
   return new Cat { Name = text };
 }
        public object ReadFrom(ReaderContext context)
        {
            Encoding enc = MediaTypeParser.GetEncodingFromCharset(context.Response.ContentType, context.Session.DefaultEncoding);

              using (var textReader = new StreamReader(context.HttpStream, enc))
              using (var reader = XmlReader.Create(textReader))
              {
            return ReadFrom(reader, context);
              }
        }
Esempio n. 4
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				if (token == SecondaryId)
					return _binaryFormatter.Deserialize (r.BaseStream);
				Type t = (Type) ReadObject (r, ctx);
				int len = Read7BitEncodedInt (r);
				Array val = Array.CreateInstance (t, len);
				
				for (int i = 0; i < len; i++)
					val.SetValue (ReadObject (r, ctx), i);
				
				return val;
			}
Esempio n. 5
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				Type t = (Type) ReadObject (r, ctx);
				object value = ReadObject (r, ctx);
				
				return Enum.ToObject (t, value);
			}
Esempio n. 6
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				int len = Read7BitEncodedInt (r);
				object [] ret = new object [len];
				
				for (int i = 0; i < len; i++)
					ret [i] = ReadObject (r, ctx);
				
				return ret;
			}
Esempio n. 7
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				int len = Read7BitEncodedInt (r);
				ArrayList l = new ArrayList (len);
				
				for (int i = 0; i < len; i++)
					l.Add (ReadObject (r, ctx));
				
				return l;
			}
Esempio n. 8
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				Pair p = new Pair ();
				p.First = ReadObject (r, ctx);
				p.Second = ReadObject (r, ctx);
				return p;
			}
Esempio n. 9
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				return r.ReadChar ();
			}
Esempio n. 10
0
			public ReaderContext(ReaderContext previous)
			{
				this.Previous = previous;
			}
Esempio n. 11
0
			public ReaderContext()
			{
				this.Previous = this;
			}
Esempio n. 12
0
 protected override object ReadFrom(XmlReader reader, ReaderContext context)
 {
   return SyndicationItem.Load(reader);
 }
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				Type t = (Type) ReadObject (r, ctx);
				int len = Read7BitEncodedInt (r);
				Array val = Array.CreateInstance (t, len);
				
				for (int i = 0; i < len; i++)
					val.SetValue (ReadObject (r, ctx), i);
				
				return val;
			}
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				if (token == PrimaryId)
					return Color.FromArgb (r.ReadInt32 ());
				else
					return Color.FromKnownColor ((KnownColor) r.ReadInt32 ());
			}
 protected abstract object ReadFrom(XmlReader reader, ReaderContext context);
Esempio n. 16
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				if (token == PrimaryId)
					return r.ReadInt32 ();
				else
					return (int) r.ReadByte ();
			}
Esempio n. 17
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				return token == PrimaryId;
			}
Esempio n. 18
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				Type t = (Type) ObjectFormatter.ReadObject (r, ctx);
				converter = TypeDescriptor.GetConverter (t);
				token = r.ReadByte ();
				string v = (string) base.Read (token, r, ctx);
				return converter.ConvertFrom (null, Helpers.InvariantCulture, v);
			}
Esempio n. 19
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				return new DateTime (r.ReadInt64 ());
			}
Esempio n. 20
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				int len = Read7BitEncodedInt (r);
				byte [] buf = r.ReadBytes (len);
				if (buf.Length != len)
					throw new Exception ();
				
				return new BinaryFormatter ().Deserialize (new MemoryStream (buf));
			}
Esempio n. 21
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				Triplet t = new Triplet ();
				t.First = ReadObject (r, ctx);
				t.Second = ReadObject (r, ctx);
				t.Third = ReadObject (r, ctx);
				return t;
			}
Esempio n. 22
0
			protected abstract object Read (byte token, BinaryReader r, ReaderContext ctx);
Esempio n. 23
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				int len = Read7BitEncodedInt (r);
				Hashtable ht = new Hashtable (len);
				
				for (int i = 0; i < len; i++) {
					object key = ReadObject (r, ctx);
					object val = ReadObject (r, ctx);
					
					ht.Add (key, val);
				}
				
				return ht;
			}
Esempio n. 24
0
			public static object ReadObject (BinaryReader r, ReaderContext ctx)
			{
				byte sig = r.ReadByte ();
				
				if (sig == 0)
					return null;
				
				return readMap [sig].Read (sig, r, ctx);
			}
Esempio n. 25
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				int value = r.ReadInt32 ();
				if (token == PrimaryId)
					return Color.FromArgb (value);
				else {
					if (value == -1) //isempty marker
						return Color.Empty;
					return Color.FromKnownColor ((KnownColor)value);
				}
			}
Esempio n. 26
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				if (token == PrimaryId) {
					string s = r.ReadString ();
					ctx.CacheItem (s);
					return s;
				} else {
					return ctx.GetCache (r.ReadInt16 ());
				}
			}
Esempio n. 27
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				if (token == PrimaryId) {
					string type = r.ReadString ();
					string assembly = r.ReadString ();
					Type t = Assembly.Load (assembly).GetType (type);
					ctx.CacheItem (t);
					return t;
				} else {
					return ctx.GetCache (r.ReadInt16 ());
				}
			}
Esempio n. 28
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				string s = base.Read (token, r, ctx) as string;
				if (String.IsNullOrEmpty (s))
					throw new InvalidOperationException ("string must not be null or empty.");
				
				return new IndexedString (s);
			}
Esempio n. 29
0
			protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
			{
				return Unit.Parse ((string) base.Read (token, r, ctx));
			}
Esempio n. 30
0
 public object ReadFrom(ReaderContext context)
 {
   return context.HttpStream;
 }