LFollowedListsData() public method

public LFollowedListsData ( System.Guid accountId ) : HashSetBlob
accountId System.Guid
return HashSetBlob
コード例 #1
0
ファイル: ListStorage.cs プロジェクト: xuedong/Tigwi
        public void Follow(Guid listId, Guid accountId)
        {
            using (blobFactory.LFollowedListsLock(accountId))
            {
                if (!blobFactory.LFollowingAccounts(listId).AddWithRetry(accountId))
                {
                    throw new ListNotFound();
                }

                blobFactory.LFollowedListsData(accountId).Add(listId);
            }
        }
コード例 #2
0
ファイル: AccountStorage.cs プロジェクト: xuedong/Tigwi
        public Guid Create(Guid adminId, string name, string description, bool bypassNameReservation = false)
        {
            Blob <Guid> bIdByName = blobFactory.AIdByName(name);

            // lock the name
            if (!bypassNameReservation)
            {
                if (!bIdByName.SetIfNotExists(Guid.Empty))
                {
                    throw new AccountAlreadyExists();
                }
            }

            Guid accountId = Guid.NewGuid();

            // TODO : we could do it without a lock - or at least store the data before
            using (blobFactory.UAccountsLock(adminId))
            {
                Guid personnalListId = Guid.NewGuid();

                // store the data
                HashSet <Guid> users = new HashSet <Guid>();
                users.Add(adminId);
                blobFactory.AUsers(accountId).Set(users);

                HashSet <Guid> followedByAll = new HashSet <Guid>();
                followedByAll.Add(personnalListId);
                blobFactory.LFollowedByAll(accountId).Set(followedByAll);

                blobFactory.AInfo(accountId).Set(new AccountInfo(name, description));
                blobFactory.AAdminId(accountId).Set(adminId);
                blobFactory.LOwnedListsPublic(accountId).Set(new HashSet <Guid>());
                blobFactory.LOwnedListsPrivate(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedListsData(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedByPublic(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedListsLockInit(accountId);
                blobFactory.MTaggedMessages(accountId).Init();
                blobFactory.AAutocompletion().Add(new KeyValuePair <string, string>(name.GenerateDoubleMetaphone(), name));

                // Setup the personnal list
                blobFactory.LPersonnalList(accountId).Set(personnalListId);
                blobFactory.LInfo(personnalListId).Set(new ListInfo("", "", true, true));
                blobFactory.LOwner(personnalListId).Set(accountId);
                blobFactory.MListMessages(personnalListId).Init();
                blobFactory.LFollowedAccounts(personnalListId).Set(new Dictionary <Guid, bool>());

                // we finish by unlocking the name
                bIdByName.Set(accountId);

                // we make this account accessible
                blobFactory.UAccountsData(adminId).Add(accountId);
            }

            return(accountId);
        }