public static void SetAuthorizationFor(this IDocumentSession session, object entity, DocumentAuthorization documentAuthorization)
		{
			var metadata = session.Advanced.GetMetadataFor(entity);
			var jsonSerializer = JsonExtensions.CreateDefaultJsonSerializer();
			jsonSerializer.ContractResolver = session.Advanced.DocumentStore.Conventions.JsonContractResolver;
			metadata[RavenDocumentAuthorization] = RavenJObject.FromObject(documentAuthorization, jsonSerializer);
		}
 public static void SetAuthorizationFor(this IDocumentSession session, object entity, DocumentAuthorization documentAuthorization)
 {
     var metadata = session.Advanced.GetMetadataFor(entity);
     metadata[RavenDocumentAuthorization] = JObject.FromObject(documentAuthorization, new JsonSerializer
     {
         ContractResolver = session.Advanced.Conventions.JsonContractResolver,
     });
 }
示例#3
0
        public static void Initialize(this Entity entity, IDocumentSession session)
        {
            if (string.IsNullOrWhiteSpace(entity.Id))
                throw new NullReferenceException("project.Id");

            var permission = new DocumentPermission
                {
                    Allow = true,
                    Operation =
                        Global.Constants.Projects,
                };
            var authorization = new DocumentAuthorization
                {
                    Permissions = {permission},
                    Tags = {entity.Id}
                };
            session.SetAuthorizationFor(entity, authorization);
        }