Exemplo n.º 1
0
        /// <summary>
        /// Adds a capability resource. The resource returned can be used to define the actions allowed for it by chaining the Allow methods
        /// Possible options are: AllowAll, AllowPublish, AllowPresence and AllowSubscribe
        /// A Resource can be a channel "channel" or a namespace "namespace:*". Please consult the rest documentation
        /// </summary>
        /// <code>
        /// var capability = new Capability();
        ///
        /// capability.AddResource("name").AllowPublish();
        /// </code>
        /// <param name="name">name of the resource</param>
        /// <returns>CapabilityResource</returns>
        public CapabilityResource AddResource(string name)
        {
            var resource = new CapabilityResource(name);

            Resources.Add(resource);

            return(resource);
        }
Exemplo n.º 2
0
 private static JArray GetResourceValue(CapabilityResource resource)
 {
     if (resource.AllowsAll)
     {
         return(new JArray(CapabilityResource.AllowedOps.All));
     }
     if (resource.AllowedOperations.Count == 1)
     {
         return(new JArray(resource.AllowedOperations.First()));
     }
     return(new JArray(resource.AllowedOperations.ToArray()));
 }
Exemplo n.º 3
0
        private static CapabilityResource GetResource(JProperty child)
        {
            var resource          = new CapabilityResource(child.Name);
            var allowedOperations = child.Value as JArray;

            if (allowedOperations != null)
            {
                foreach (JToken token in allowedOperations)
                {
                    resource.AllowedOperations.Add((string)token);
                }
            }
            return(resource);
        }