Пример #1
0
        internal Sitemap(REST aRest, System.IO.BinaryReader aReader)
        {
            Name = aReader.ReadString();
            Link = new Uri(aReader.ReadString());
            Homepage = new Uri(aReader.ReadString());

            var count = aReader.ReadInt32();
            for (var idx = 0; idx < count; ++idx)
            {
                Item item;
                if (aRest.Items.TryGetValue(aReader.ReadString(), out item))
                    Items[item.Name] = item;
            }

            Page page;
            count = aReader.ReadInt32();
            for (var idx = 0; idx < count; ++idx)
            {
                if (aRest.Pages.TryGetValue(aReader.ReadString(), out page))
                    Pages[page.Id] = page;
            }

            if (aRest.Pages.TryGetValue(aReader.ReadString(), out page))
                Page = page;
        }
Пример #2
0
 internal Item(REST aRest,string aType, string aName, string aState, string aLink)
 {
     mRest = aRest;
     Type = (ItemType)Enum.Parse(typeof(ItemType), aType, true);
     Name = aName;
     mState = aState;
     Link = new Uri(aLink);
 }
Пример #3
0
        internal Widget(REST aRest, System.IO.BinaryReader aReader)
        {
            Type = (WidgetType)aReader.ReadInt32();
            Label = aReader.ReadString();
            Icon = aReader.ReadString();

            Item item;
            if(aRest.Items.TryGetValue(aReader.ReadString(), out item))
                Item = item;

            Page page;
            if (aRest.Pages.TryGetValue(aReader.ReadString(), out page))
                LinkedPage = page;

            var uri = aReader.ReadString();
            if (!string.IsNullOrWhiteSpace(uri))
                Url = new Uri(uri);

            Refresh = aReader.ReadInt32();
            Period = aReader.ReadString();

            MinValue = aReader.ReadDouble();
            MaxValue = aReader.ReadDouble();
            Step = aReader.ReadDouble();

            var count = aReader.ReadInt32();
            for (var idx = 0; idx < count; ++idx)
                mWidgets.Add(new Widget(aRest, aReader));
        }
Пример #4
0
 internal Page(REST aRest)
 {
     mRest = aRest;
 }
Пример #5
0
        internal Item(REST aRest, System.IO.BinaryReader aReader)
        {
            mRest = aRest;

            mState = aReader.ReadString();
            Type = (ItemType)aReader.ReadInt32();
            Name = aReader.ReadString();
            Link = new Uri(aReader.ReadString());
        }
Пример #6
0
 internal Page(REST aRest)
 {
     mRest = aRest;
 }
Пример #7
0
        public static REST FromDataStore(byte[] aData)
        {
            using (var ms = new MemoryStream(aData))
            {
                using (var reader = new BinaryReader(ms))
                {
                    var result = new REST();

                    result.mQueryId = reader.ReadInt32();

                    var count = reader.ReadInt32();
                    for (var idx = 0; idx < count; ++idx)
                    {
                        var k = reader.ReadString();
                        var v = reader.ReadString();

                        result.Links[k] = new Uri(v);
                    }

                    count = reader.ReadInt32();
                    for (var idx = 0; idx < count; ++idx)
                    {
                        var k = reader.ReadString();

                        result.Items[k] = new Item(result, reader);
                    }

                    count = reader.ReadInt32();
                    for (var idx = 0; idx < count; ++idx)
                    {
                        var k = reader.ReadString();
                        result.Pages[k] = new Page(result);
                    }

                    count = reader.ReadInt32();
                    for (var idx = 0; idx < count; ++idx)
                    {
                        var k = reader.ReadString();

                        result.Pages[k].FromStream(reader);
                    }

                    count = reader.ReadInt32();
                    for (var idx = 0; idx < count; ++idx)
                    {
                        var k = reader.ReadString();
                        result.Sitemaps[k] = new Sitemap(result, reader);
                    }


                    return result;
                }
            }
        }