Exemple #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="EntityWriter" /> class.
        /// </summary>
        /// <param name="entityContext">
        ///     The entity context.
        /// </param>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="entity">
        ///     The entity.
        /// </param>
        /// <param name="ignoreKeys">
        ///     The keys to ignore.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        /// <param name="entitiesWritten">
        ///     The entities written.
        /// </param>
        /// <exception cref="ArgumentException">
        ///     If <see cref="Behaviors.DoNotCache" /> has been combined with <see cref="Behaviors.CreateLazy" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If <see cref="Behaviors.BypassWriteCache" /> has been combined with <see cref="Behaviors.CreateLazy" />.
        /// </exception>
        private EntityWriter(EntityContext entityContext, ISet <Key> ignoreKeys, Behaviors behaviors,
                             ISet <object> entitiesWritten)
        {
            if (behaviors.IsCreateLazy())
            {
                if (behaviors.DoNotCache())
                {
                    throw new ArgumentException(@"DontCache cannot be combined with CreateLazy", nameof(behaviors));
                }

                if (behaviors.BypassWriteCache())
                {
                    throw new ArgumentException(@"BypassWriteCache cannot be combined with CreateLazy", nameof(behaviors));
                }
            }

            this.entityContext   = entityContext;
            this.ignoreKeys      = ignoreKeys;
            this.behaviors       = behaviors;
            this.entitiesWritten = entitiesWritten;
            this.reviewKey       = entityContext.Configuration.ReviewKey;
        }
Exemple #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="EntityWriter" /> class.
        /// </summary>
        /// <param name="entityContext">
        ///     The entity context.
        /// </param>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="entity">
        ///     The entity.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        /// <param name="entitiesWritten">
        ///     The entities written.
        /// </param>
        /// <exception cref="ArgumentException">
        ///     If <see cref="Behaviors.DoNotCache" /> has been combined with <see cref="Behaviors.CreateLazy" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If <see cref="Behaviors.BypassWriteCache" /> has been combined with <see cref="Behaviors.CreateLazy" />.
        /// </exception>
        private EntityWriter(EntityContext entityContext, Type entityType, object entity, Behaviors behaviors,
                             IdentitySet entitiesWritten)
        {
            if (behaviors.IsCreateLazy())
            {
                if (behaviors.DoNotCache())
                {
                    throw new ArgumentException(@"DontCache cannot be combined with CreateLazy", nameof(behaviors));
                }

                if (behaviors.BypassWriteCache())
                {
                    throw new ArgumentException(@"BypassWriteCache cannot be combined with CreateLazy", nameof(behaviors));
                }
            }

            this.entityContext      = entityContext;
            this.behaviors          = behaviors;
            this.entityType         = entityType;
            this.entity             = entity;
            this.entitiesWritten    = entitiesWritten;
            this.entitySpecsWritten = entityContext.EntitySpecsWritten;
            this.entitySpecsFetched = entityContext.EntitySpecsFetched;
        }