Пример #1
0
        /// <summary>
        /// Initializes the manager by pulling the authenticated player
        /// from session and database
        /// (may not perform initialization if the type does not match the id)
        /// </summary>
        /// <typeparam name="T">Type of the requested entity</typeparam>
        private void Initialize <T>() where T : Entity
        {
            string id = Id();

            if (id == null)
            {
                // there's no authenticated player
                authenticatedPlayer = null;
                initialized         = true;
            }
            else
            {
                // if the id belongs to a different type,
                // do not initialize
                var docId = DocumentId.Parse(id);
                if (docId.Collection != EntityUtils.CollectionFromType(typeof(T)))
                {
                    return;
                }

                // here we have the authenticated player
                authenticatedPlayer = entityManager.Find <T>(id);
                initialized         = true;
            }
        }
Пример #2
0
        public static EntityQuery <TEntity> TakeAll(IArango arango)
        {
            var query = new EntityQuery <TEntity>(arango);

            query.Query.For("entity").In(
                EntityUtils.CollectionFromType(typeof(TEntity))
                ).Do();

            return(query);
        }
Пример #3
0
        public void DeletingNonExistingCollectionThrows()
        {
            arango.Collections.Remove(
                EntityUtils.CollectionFromType(typeof(PlayerEntity))
                );

            Assert.Throws <EntityPersistenceException>(() => {
                manager.Delete(new PlayerEntity {
                    EntityKey = "john"
                });
            });
        }
Пример #4
0
        public void UpdatingInNonExistingCollectionThrows()
        {
            arango.Collections.Remove(
                EntityUtils.CollectionFromType(typeof(PlayerEntity))
                );

            Assert.Throws <EntityPersistenceException>(() => {
                manager.Update(new PlayerEntity {
                    Name      = "Johnny",
                    EntityKey = "john",
                });
            });
        }