Ejemplo n.º 1
0
        public async Task SetProperties(FormDataCollection form)
        {
            IDictionary <string, object> values;

            if (form == null)
            {
                // Try as JSON.
                using (var stream = await Request.Content.ReadAsStreamAsync())
                {
                    stream.Seek(0, SeekOrigin.Begin);

                    using (var reader = new StreamReader(stream))
                    {
                        var json = await reader.ReadToEndAsync();

                        values = JsonConvert.DeserializeObject <IDictionary <string, object> >(json);
                    }
                }
            }
            else
            {
                values = form.ToDictionary(x => x.Key, x => (object)x.Value);
            }

            CurrentVisitor.SetProperties(values);
        }
        /// <summary>
        /// Get the child nodes of a tree node.
        /// </summary>
        private async Task <TreeNodeCollection> GetChildren(Tree tree, int id, FormDataCollection querystring)
        {
            if (tree == null)
            {
                throw new ArgumentNullException(nameof(tree));
            }

            // the method we proxy has an 'id' parameter which is *not* in the querystring,
            // we need to add it for the proxy to work (else, it does not find the method,
            // when trying to run auth filters etc).
            var d = querystring?.ToDictionary(x => x.Key, x => x.Value) ?? new Dictionary <string, string>();

            d["id"] = null;
            var proxyQuerystring = new FormDataCollection(d);

            var controller = (TreeControllerBase) await GetApiControllerProxy(tree.TreeControllerType, "GetNodes", proxyQuerystring);

            return(controller.GetNodes(id.ToInvariantString(), querystring));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Converts the FormCollection to a dictionary
 /// </summary>
 /// <param name="items"></param>
 /// <returns></returns>
 public static IDictionary <string, object> ToDictionary(this FormDataCollection items)
 {
     return(items.ToDictionary(x => x.Key, x => (object)x.Value));
 }
Ejemplo n.º 4
0
 public static IDictionary<string, object> ToDictionary(FormDataCollection col)
 {
     return col.ToDictionary(p => p.Key, p => (object)p.Value);
 }