コード例 #1
0
            private Folder Read(BinaryReader reader)
            {
                var folderId = Guid.Parse(reader.ReadString());
                var created  = new DateTime(reader.ReadInt64());
                var modified = new DateTime(reader.ReadInt64());

                var meta = new StoreItemMetaInfo <FolderId>(new FolderId(folderId), created, modified);

                var folder = new Folder(meta);

                using (folder.SuppressChangeTracking())
                {
                    folder.Title = reader.ReadString();

                    var count = reader.ReadInt32();
                    for (int i = 0; i < count; ++i)
                    {
                        var isFolder = reader.ReadBoolean();
                        if (isFolder)
                        {
                            var child = Read(reader);
                            folder.Entries.Add(child);
                        }
                        else
                        {
                            var docId = Guid.Parse(reader.ReadString());
                            folder.Entries.Add(myStore.GetCore(new DocumentId(docId)));
                        }
                    }

                    return(folder);
                }
            }
コード例 #2
0
        protected override Document GetCore(DocumentId id)
        {
            Contract.Invariant(myIndex != null, "DocumentStore not initialized");

            using (var reader = new BinaryReader(GetMetaFile(id).Stream(FileAccess.Read)))
            {
                var created  = new DateTime(reader.ReadInt64());
                var modified = new DateTime(reader.ReadInt64());
                var meta     = new StoreItemMetaInfo <DocumentId>(id, created, modified);

                var doc = new Document(meta, () => ReadContent(GetBodyFile(id)));
                using (doc.SuppressChangeTracking())
                {
                    doc.Title = reader.ReadString();

                    var count = reader.ReadInt32();
                    for (int i = 0; i < count; ++i)
                    {
                        doc.Tags.Add(reader.ReadString());
                    }

                    return(doc);
                }
            }
        }
コード例 #3
0
        public Document(StoreItemMetaInfo <DocumentId> meta, Func <FlowDocument> reader)
            : base(meta)
        {
            Contract.RequiresNotNull(reader, "reader");

            myBody = new Lazy <FlowDocument>(reader);

            myTags = new ObservableCollection <string>();
            myTags.CollectionChanged += OnTagsChanged;
        }
コード例 #4
0
        protected AbstractStoreItem(StoreItemMetaInfo <TId> meta)
        {
            Id           = meta.Id;
            Created      = meta.Created;
            LastModified = meta.LastModified;

            if (meta.IsNew)
            {
                myIsModified = true;
            }
        }
コード例 #5
0
 /// <summary>
 /// Used to restore a folder from persistance.
 /// </summary>
 public Folder(StoreItemMetaInfo <FolderId> meta)
     : base(meta)
 {
     myEntries = new ObservableCollection <IStoreItem>();
     CollectionChangedEventManager.AddHandler(myEntries, OnCollectionChanged);
 }