Root() public static method

public static Root ( AccountDomainObject account ) : AccountDomainObjectVersion
account AccountDomainObject
return AccountDomainObjectVersion
Esempio n. 1
0
        private void OnAccountChanged(AccountName accountName)
        {
            AccountDomainObject account = _accountRepository.GetBy(accountName);

            lock (_gate)
            {
                Accounts[accountName] = AccountDomainObjectVersion.Root(account);
            }
        }
Esempio n. 2
0
 public IAccount GetOrCreate(AccountName accountName)
 {
     lock (_gate)
     {
         AccountDomainObjectVersion accountLatestVersion;
         if (Accounts.TryGetValue(accountName, out accountLatestVersion))
         {
             if (_accountCurrentVersion != null && _accountCurrentVersion.IsChildOf(accountLatestVersion))
             {
                 return(_accountCurrentVersion.Account);
             }
             _accountCurrentVersion = accountLatestVersion.CreateChildVersion();
         }
         else
         {
             var account           = _accountRepository.GetBy(accountName) ?? _accountRepository.Add(accountName);
             var newAccountVersion = AccountDomainObjectVersion.Root(account);
             Accounts[accountName]  = newAccountVersion;
             _accountCurrentVersion = newAccountVersion.CreateChildVersion();
         }
     }
     return(_accountCurrentVersion.Account);
 }