Beispiel #1
0
        // Constructors

        private VersionCapturer(Session session, VersionSet versions)
            : base(session)
        {
            ArgumentValidator.EnsureArgumentNotNull(versions, "versions");
            Versions = versions;
            AttachEventHandlers();
        }
 /// <summary>
 /// Merges the current <see cref="VersionSet"/> with provided one.
 /// </summary>
 /// <param name="other">The other <see cref="VersionSet"/>.</param>
 /// <param name="session"></param>
 public void MergeWith(VersionSet other, Session session)
 {
     foreach (var pair in other.versions.Where(p => session.EntityStateCache.ContainsKey(p.Key.Key)))
     {
         versions[pair.Key] = pair.Value;
     }
 }
Beispiel #3
0
 /// <inheritdoc/>
 VersionSet IVersionSetProvider.CreateVersionSet(IEnumerable <Key> keys)
 {
     using (Activate())
         using (var tx = OpenAutoTransaction()) {
             var entities = Query.Many <Entity>(keys);
             var result   = new VersionSet();
             foreach (var entity in entities)
             {
                 if (entity != null)
                 {
                     _ = result.Add(entity, false);
                 }
             }
             tx.Complete();
             return(result);
         }
 }
Beispiel #4
0
 /// <summary>
 /// Attaches the validator to the specified session.
 /// </summary>
 /// <param name="session">The session to attach validator to.</param>
 /// <param name="expectedVersions">The set containing expected versions.</param>
 /// <returns>
 /// A newly created <see cref="VersionValidator"/> attached
 /// to the specified <paramref name="session"/>.
 /// </returns>
 public static VersionValidator Attach(Session session, VersionSet expectedVersions)
 {
     return(new VersionValidator(session, expectedVersions.Get));
 }
Beispiel #5
0
 public static VersionValidator Attach(VersionSet expectedVersions)
 {
     return(Attach(Session.Demand(), expectedVersions));
 }
Beispiel #6
0
        // Factory methods

        /// <summary>
        /// Attaches the version capturer to the current session.
        /// </summary>
        /// <param name="session">The session to attach the capturer to.</param>
        /// <param name="versions">The <see cref="VersionSet"/> to append captured versions to.</param>
        /// <returns>
        /// A newly created <see cref="VersionCapturer"/> attached
        /// to the specified <paramref name="session"/>.
        /// </returns>
        public static VersionCapturer Attach(Session session, VersionSet versions)
        {
            return(new VersionCapturer(session, versions));
        }
 public static VersionCapturer Attach(VersionSet versions)
 {
     return(Attach(Session.Demand(), versions));
 }