Exemplo n.º 1
0
        /// <summary>Sets the permissions for the specified service operation.</summary>
        /// <param name="name">The name of the service operation for which to set permissions.</param>
        /// <param name="rights">The access rights to be granted to this resource, passed as a <see cref="T:Microsoft.OData.Service.ServiceOperationRights" /> value.</param>
        public void SetServiceOperationAccessRule(string name, ServiceOperationRights rights)
        {
            this.CheckNotSealed();
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            WebUtil.CheckServiceOperationRights(rights, "rights");
            if (name == "*")
            {
                this.rightsForUnspecifiedServiceOperation = rights;
            }
            else
            {
                ServiceOperation serviceOperation;
                if (!this.provider.TryResolveServiceOperation(name, out serviceOperation) || serviceOperation == null)
                {
                    throw new ArgumentException(Strings.DataServiceConfiguration_ServiceNameNotFound(name), "name");
                }

                this.serviceOperationRights[serviceOperation.Name] = rights;
            }
        }