An implementation of a storage context connected to Azure Storage.
Inheritance: IStorageContext
 public StorageListModelCollection(StorageContext context, IEnumerable<Guid> ids)
 {
     this.InternalStorage = context;
     this.InternalDictionary = new Dictionary<Guid, StorageListModel>();
     foreach (var id in ids)
     {
         this.InternalDictionary.Add(id, context.InternalLists.InternalFind(id));
     }
 }
 public StoragePostModel(StorageContext storageContext, IMessage message)
 {
     this.PostDate = message.Date;
     this.Content = message.Content;
     this.Id = message.Id;
     this.Poster =
         storageContext.InternalAccounts.InternalFind(message.PosterId).PopulateWith(
             name: message.PosterName, avatar: message.PosterAvatar);
 }
        public void RepositoriesAreNotNull()
        {
            var storageContext = new StorageContext(new Storage(azureAccountName, azureAccountKey));

            Assert.That(storageContext.Accounts, Is.Not.Null);
            Assert.That(storageContext.Lists, Is.Not.Null);
            Assert.That(storageContext.Posts, Is.Not.Null);
            Assert.That(storageContext.Users, Is.Not.Null);
        }
 public StorageUserModel(IStorage storage, StorageContext storageContext, Guid id)
     : base(storage, storageContext, id)
 {
     this.accounts = new StorageEntityCollection<StorageAccountModel, IAccountModel>(storageContext)
         {
             FetchIdCollection = () => storage.User.GetAccounts(id),
             GetId = account => account.Id,
             GetModel = storageContext.InternalAccounts.InternalFind,
             ReverseAdd = account => account.InternalUsers.CacheAdd(this),
             ReverseRemove = account => account.InternalUsers.CacheRemove(this),
             SaveAdd = account => storage.Account.Add(account.Id, id),
             SaveRemove = account => storage.Account.Remove(account.Id, id),
         };
 }
        public StorageListModel(IStorage storage, StorageContext storageContext, Guid listId)
            : base(storage, storageContext, listId)
        {
            this.followers = new StorageEntityCollection<StorageAccountModel, IAccountModel>(storageContext)
                {
                    FetchIdCollection = () => storage.List.GetFollowingAccounts(listId),
                    GetId = account => account.Id,
                    GetModel = storageContext.InternalAccounts.InternalFind,
                    ReverseAdd = account =>
                        {
                            // TODO: this shouldn't involve storage calls
                            account.InternalAllFollowedLists.CacheAdd(this);
                            if (!this.IsPrivate)
                            {
                                account.InternalPublicFollowedLists.CacheAdd(this);
                            }
                        },
                    ReverseRemove = account =>
                        {
                            // TODO: this shouldn't involve storage calls
                            account.InternalAllFollowedLists.CacheRemove(this);
                            if (!this.IsPrivate)
                            {
                                account.InternalPublicFollowedLists.CacheRemove(this);
                            }
                        },
                    SaveAdd = account => storage.List.Follow(listId, account.Id),
                    SaveRemove = account => storage.List.Unfollow(listId, account.Id)
                };

            this.members = new StorageEntityCollection<StorageAccountModel, IAccountModel>(storageContext)
                {
                    FetchIdCollection = () => storage.List.GetAccounts(listId),
                    GetId = account => account.Id,
                    GetModel = storageContext.InternalAccounts.InternalFind,
                    ReverseAdd = account => account.InternalMemberOfLists.CacheAdd(this),
                    ReverseRemove = account => account.InternalMemberOfLists.CacheRemove(this),
                    SaveAdd = account => storage.List.Add(listId, account.Id),
                    SaveRemove = account => storage.List.Remove(listId, account.Id)
                };
        }
        public void Init()
        {
            var builder = new TestControllerBuilder();
            builder.HttpContext.Request.Expect(r => r.Cookies).Return(new HttpCookieCollection());
            builder.HttpContext.Response.Expect(r => r.Cookies).Return(new HttpCookieCollection());
            var storage = new StorageContext(new Storage(azureAccountName, azureAccountKey));
            var controller = builder.CreateController<UserController>(storage);

            this.Builder = builder;
            this.Storage = storage;
            this.Controller = controller;
        }
Beispiel #7
0
 protected StorageEntityRepository(StorageContext storageContext)
 {
     this.StorageContext = storageContext;
     this.EntitiesMap    = new Dictionary <Guid, T>();
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ListRepository"/> class.
 /// </summary>
 /// <param name="storageContext">
 /// The storage context.
 /// </param>
 public ListRepository(StorageContext storageContext)
     : base(storageContext)
 {
 }
 protected StorageEntityModel(IStorage storage, StorageContext storageContext, Guid id)
 {
     this.Storage = storage;
     this.StorageContext = storageContext;
     this.Id = id;
 }