Esempio n. 1
0
        /// <inheritdoc/>
        public TDocument LoadDocument <TDocument>(string link, out Func <bool> isDeletedFunc)
            where TDocument : class, IDynamicDocument
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(link));

            var baseDocument = Base.GetExistingDocument(link);

            if (baseDocument == null)
            {
                isDeletedFunc = null;
                return(null);
            }

            var document = EntityDocument <StubEntity> .Create(typeof(TDocument), baseDocument);

            if (document != null)
            {
                isDeletedFunc = () => document.IsDeleted;

                return((TDocument)document);
            }

            isDeletedFunc = null;
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets or creates an binder document with the specified ID.
        /// </summary>
        /// <typeparam name="TDocument">The binder document type.</typeparam>
        /// <param name="id">The document ID.</param>
        /// <exception cref="KeyNotFoundException">
        /// Thrown if <typeparamref name="TDocument"/> was not previously registered by a call to
        /// <see cref="EntityDatabase.Register(Func{Document, IEntityDocument}, Func{IDictionary{string, object}, EntityDatabase, Revision, IEntityDocument}, string[])"/>.
        /// </exception>
        /// <returns>The existing or newly created document.</returns>
        public TDocument GetBinderDocument <TDocument>(string id)
            where TDocument : class, IEntityDocument
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(id));

            return(EntityDocument <StubEntity> .Create <TDocument>(Base.GetDocument(id)));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets an existing binder document with the specified ID.
        /// </summary>
        /// <typeparam name="TDocument">The binder document type.</typeparam>
        /// <param name="id">The document ID.</param>
        /// <exception cref="KeyNotFoundException">
        /// Thrown if <typeparamref name="TDocument"/> was not previously registered by a call to
        /// <see cref="EntityDatabase.Register{TDocument}(Func{Document, IEntityDocument}, Func{IDictionary{string, object}, EntityDatabase, Revision, IEntityDocument}, string[])"/>.
        /// </exception>
        /// <returns>The existing document if present or <c>null</c>.</returns>
        public TDocument GetExistingBinderDocument <TDocument>(string id)
            where TDocument : class, IEntityDocument
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(id));

            var document = Base.GetExistingDocument(id);

            if (document == null)
            {
                return(null);
            }

            return(EntityDocument <StubEntity> .Create <TDocument>(document));
        }
Esempio n. 4
0
 /// <summary>
 /// Creates a new binder document with a unique ID.
 /// </summary>
 /// <typeparam name="TDocument">The binder document type.</typeparam>
 /// <returns>The new document.</returns>
 /// <exception cref="KeyNotFoundException">
 /// Thrown if <typeparamref name="TDocument"/> was not previously registered by a call to
 /// <see cref="EntityDatabase.Register(Func{Document, IEntityDocument}, Func{IDictionary{string, object}, EntityDatabase, Revision, IEntityDocument}, string[])"/>.
 /// </exception>
 /// <remarks>
 /// <para>
 /// New documents are empty when initially created and are implicitly read/write
 /// and have their <see cref="EntityDocument{TEntity}.IsModified"/> property
 /// set to <c>true</c>.
 /// </para>
 /// </remarks>
 public TDocument CreateBinderDocument <TDocument>()
     where TDocument : class, IEntityDocument
 {
     return(EntityDocument <StubEntity> .Create <TDocument>(Base.CreateDocument()));
 }