Esempio n. 1
0
 private void ReadHeader()
 {
     _headersRead++;
     PropertyName = _stream.ReadString();
     ValueType    = ContentType.String;
     StringValue  = _stream.ReadString();
 }
Esempio n. 2
0
File: Utils.cs Progetto: flwn/HmLib
        private static string tokenize(HmBinaryStreamReader r, StringBuilder outB, int state, int expected, bool returnAfterLoop)
        {
            do
            {
                var ct = state == 0 ? r.ReadContentType()
                    : state-- == 2 ? ContentType.String : ContentType.Array;

                switch (ct)
                {
                    case ContentType.Int:
                        outB.AppendFormat("i'{0}' ", r.ReadInt32());
                        break;
                    case ContentType.Boolean:
                        outB.AppendFormat("b'{0}' ", r.ReadBoolean());
                        break;
                    case ContentType.String:
                        outB.AppendFormat("s'{0}' ", r.ReadString());
                        break;
                    case ContentType.Float:
                        outB.AppendFormat("f'{0}' ", r.ReadDouble());
                        break;
                    case ContentType.Base64:
                        outB.AppendFormat("b64'{0}' ", r.ReadString());
                        break;
                    case ContentType.Array:
                        var arrItems = r.ReadInt32();
                        outB.AppendFormat("array({0})[ ", arrItems);
                        while (arrItems-- > 0)
                        {
                            tokenize(r, outB, state, expected, true);
                        }
                        outB.Append("] ");
                        break;
                    case ContentType.Struct:
                        var itemCount = r.ReadInt32();
                        outB.AppendFormat("struct({0})[ ", itemCount);
                        while (itemCount-- > 0)
                        {
                            outB.AppendFormat("{0}=", r.ReadString());
                            tokenize(r, outB, state, expected, true);
                        }
                        outB.Append("] ");
                        break;
                    default:
                        outB.Append("?? ");
                        break;
                }

                if (returnAfterLoop) break;

            } while (r.BytesRead < expected && state >= 0);

            return outB.ToString();
        }
Esempio n. 3
0
File: Utils.cs Progetto: flwn/HmLib
        private static string tokenize(HmBinaryStreamReader r, StringBuilder outB, int state, int expected, bool returnAfterLoop)
        {
            do
            {
                var ct = state == 0 ? r.ReadContentType()
                    : state-- == 2 ? ContentType.String : ContentType.Array;

                switch (ct)
                {
                case ContentType.Int:
                    outB.AppendFormat("i'{0}' ", r.ReadInt32());
                    break;

                case ContentType.Boolean:
                    outB.AppendFormat("b'{0}' ", r.ReadBoolean());
                    break;

                case ContentType.String:
                    outB.AppendFormat("s'{0}' ", r.ReadString());
                    break;

                case ContentType.Float:
                    outB.AppendFormat("f'{0}' ", r.ReadDouble());
                    break;

                case ContentType.Base64:
                    outB.AppendFormat("b64'{0}' ", r.ReadString());
                    break;

                case ContentType.Array:
                    var arrItems = r.ReadInt32();
                    outB.AppendFormat("array({0})[ ", arrItems);
                    while (arrItems-- > 0)
                    {
                        tokenize(r, outB, state, expected, true);
                    }
                    outB.Append("] ");
                    break;

                case ContentType.Struct:
                    var itemCount = r.ReadInt32();
                    outB.AppendFormat("struct({0})[ ", itemCount);
                    while (itemCount-- > 0)
                    {
                        outB.AppendFormat("{0}=", r.ReadString());
                        tokenize(r, outB, state, expected, true);
                    }
                    outB.Append("] ");
                    break;

                default:
                    outB.Append("?? ");
                    break;
                }

                if (returnAfterLoop)
                {
                    break;
                }
            } while (r.BytesRead < expected && state >= 0);

            return(outB.ToString());
        }