Exemplo n.º 1
0
        public void UnloadContent()
        {
            foreach (IResource resource in Items)
            {
                resource.UnloadContent();
            }

            lastMethod = ResourceMethod.UnloadContent;
        }
Exemplo n.º 2
0
 public Request(ResourceMethod method, RecordTemplate input, Dictionary <string, List <string> > headers, Dictionary <string, object> queryParams, string baseUrlTemplate, Dictionary <string, object> pathKeys)
 {
     this.method          = method;
     this.input           = input;
     this.headers         = headers.ToDictionary(_ => _.Key, _ => (IReadOnlyList <string>)_.Value);
     this.queryParams     = queryParams;
     this.baseUrlTemplate = baseUrlTemplate;
     this.pathKeys        = pathKeys;
 }
Exemplo n.º 3
0
        public string RouteName(ResourceMethod method, string on = "")
        {
            string scope = this.Scope.IsNullOrEmpty() ? string.Empty : "{0}".FormatWith(this.Scope.ToLowerInvariant());

            string parent = this.Parent == null ? string.Empty : this.Parent.RouteName(method);

            return "{0}{1}{2}{3}{4}".FormatWith(
                parent, scope, this.Name.ToLowerInvariant(), method.ToString().ToLowerInvariant(), on.ToLowerInvariant());
        }
Exemplo n.º 4
0
        public void Dispose()
        {
            foreach (IResource resource in Items)
            {
                resource.Dispose();
            }

            lastMethod = ResourceMethod.Release;
            GC.SuppressFinalize(this);
        }
Exemplo n.º 5
0
        public void Initialize(Device managedDevice)
        {
            device = managedDevice;

            foreach (IResource resource in Items)
            {
                resource.Initialize(device);
            }

            lastMethod = ResourceMethod.Initialize;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Maps a Rest.li Resource Method to the corresponding HTTP Method.
        /// </summary>
        /// <param name="resourceMethod">The resource method</param>
        /// <returns>The corresponding HTTP method</returns>
        public static HttpMethod GetHttpMethod(ResourceMethod resourceMethod)
        {
            switch (resourceMethod)
            {
            case ResourceMethod.CREATE:
                return(HttpMethod.POST);

            case ResourceMethod.GET:
            case ResourceMethod.FINDER:
                return(HttpMethod.GET);

            default:
                throw new ArgumentException(String.Format("Unrecognized resource method: {0}", resourceMethod.ToString()));
            }
        }
 private void Map(ResourceData resource, ResourceMethod method, string url, string on = "", HttpVerbs verb = HttpVerbs.Get)
 {
     this.Routes.MapRoute(resource.RouteName(method, on), url,
         new { controller = resource.Name, action = method.ToString().ToLowerInvariant() });
 }