Exemplo n.º 1
0
		public  void Initialize(IFactory factory)
		{
			this.Structures = new Collection.Dictionary<int, Structure>(Kean.KeyValue.Create(0, factory.Create<Structure>()), Kean.KeyValue.Create(1, factory.Create<Structure>()));
			this.Classes = new Collection.Dictionary<int, Class>(Kean.KeyValue.Create(0, (Class)factory.Create<ComplexClass>()), Kean.KeyValue.Create(1, factory.Create<Class>()));
			this.Objects = new Collection.Dictionary<string, object>(Kean.KeyValue.Create("complex", (object)factory.Create<ComplexClass>()), Kean.KeyValue.Create("class", (object)factory.Create<Class>()), Kean.KeyValue.Create("boolean", (object)factory.Create<bool>()), Kean.KeyValue.Create("time", (object)factory.Create<DateTime>()));
			this.Numbers = new Collection.Dictionary<string, int>();
			for (int i = 0; i < 10; i++)
				this.Numbers[this.keys[i]] = i;
			this.Empty = new Collection.Dictionary<string, int>();
		}
Exemplo n.º 2
0
		bool Process(string contentType, IO.IByteInDevice device, Func<string, IO.IByteInDevice, bool> process)
		{
			bool result = false;
			if (contentType.NotNull() && contentType.StartsWith("multipart/x-mixed-replace"))
			{
				byte[] boundary = this.GetBoundary(contentType);
				device.Skip(boundary);
				while (this.response.NotNull() && device.Opened)
				{
					Collection.IDictionary<string, string> headers = new Collection.Dictionary<string, string>(
						                                                 device.Read(13, 10, 13, 10).Decode().Join()
						.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
						.Map(header =>
						{
							string[] splitted = header.Split(new string[] { ": " }, 2, StringSplitOptions.None);
							return splitted.Length == 2 ? KeyValue.Create(splitted[0], splitted[1]) : KeyValue.Create((string)null, (string)null);
						}));
					this.Process(headers["Content-Type"], Wrap.PartialByteInDevice.Open(device, boundary), process);
				}
			}
			else
				result = process(contentType, device);
			return result;
		}