public MethodInvocationContext(MethodInfo method,
                                       ServiceHandlerConfiguration serviceConfiguration,
                                       ServiceHandlerConfigurationInstance instanceConfiguration)
        {
            InstanceConfiguration = instanceConfiguration;
            ServiceConfiguration  = serviceConfiguration;
            MethodInfo            = method;

            var attrib = (AsyncStateMachineAttribute)method.GetCustomAttribute(typeof(AsyncStateMachineAttribute));

            if (attrib != null)
            {
                IsAsync = true;
            }

            RestAttribute = method.GetCustomAttribute(typeof(RestAttribute), true) as RestAttribute;
            if (RestAttribute == null)
            {
                return;
            }

            // set allowable authorization roles
            if (RestAttribute.AuthorizationRoles != null)
            {
                AuthorizationRoles = RestAttribute.AuthorizationRoles
                                     .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                     .ToList();
                if (AuthorizationRoles.Count == 0)
                {
                    AuthorizationRoles.Add(string.Empty);  // Any authorized user
                }
            }
        }
Beispiel #2
0
        public override void LoadFor(DatabaseDocument databaseDocument)
        {
            var session = ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession(databaseDocument.Id);

            session.Advanced.LoadStartingWithAsync <AuthorizationUser>("Authorization/Users").
            ContinueOnSuccessInTheUIThread(data =>
            {
                AuthorizationUsers.Clear();
                foreach (var authorizationUser in data)
                {
                    AuthorizationUsers.Add(authorizationUser);
                }
                foreach (var authorizationUser in data)
                {
                    OriginalAuthorizationUsers.Add(authorizationUser);
                }
            });

            session.Advanced.LoadStartingWithAsync <AuthorizationRole>("Authorization/Roles").
            ContinueOnSuccessInTheUIThread(data =>
            {
                AuthorizationRoles.Clear();
                foreach (var authorizationRole in data)
                {
                    AuthorizationRoles.Add(authorizationRole);
                }
                foreach (var authorizationRole in data)
                {
                    OriginalAuthorizationRoles.Add(authorizationRole);
                }
            });
        }
        public override void LoadFor(DatabaseDocument _)
        {
            var session = ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession(ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Name);

            session.Advanced.LoadStartingWithAsync <AuthorizationUser>("Authorization/Users").
            ContinueOnSuccessInTheUIThread(data =>
            {
                AuthorizationUsers.Clear();
                foreach (var authorizationUser in data)
                {
                    AuthorizationUsers.Add(authorizationUser);
                }
                foreach (var authorizationUser in data)
                {
                    OriginalAuthorizationUsers.Add(authorizationUser);
                }

                AuthorizationUsers.CollectionChanged += (sender, args) => HasUnsavedChanges = true;
            });

            session.Advanced.LoadStartingWithAsync <AuthorizationRole>("Authorization/Roles").
            ContinueOnSuccessInTheUIThread(data =>
            {
                AuthorizationRoles.Clear();
                foreach (var authorizationRole in data)
                {
                    AuthorizationRoles.Add(authorizationRole);
                }
                foreach (var authorizationRole in data)
                {
                    OriginalAuthorizationRoles.Add(authorizationRole);
                }

                AuthorizationRoles.CollectionChanged += (sender, args) => HasUnsavedChanges = true;
            });
        }