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; }
Parser(IO.ICharacterReader reader) { this.tokenizer = new Tokenizer(reader); }
public static Parser Open(IO.ICharacterReader reader) { return reader.NotNull() ? new Parser(reader) : null; }
public static Parser Open(IO.ICharacterInDevice device) { return Parser.Open(IO.CharacterReader.Open(device)); }
public static Parser Open(IO.IByteDevice device) { return Parser.Open(IO.CharacterDevice.Open(device)); }
public static Parser Open(IO.IByteInDevice device) { return Parser.Open(IO.ByteDeviceCombiner.Open(device)); }
Parser(IO.ICharacterReader reader) { this.reader = reader; }
public Formatting(IO.ICharacterWriter backend) { this.writer = new IO.Text.Indenter(backend); this.Format = true; }