Пример #1
0
        private dynamic GetBody(PropertyInfo pr)
        {
            dynamic expando = new System.Dynamic.ExpandoObject();

            if (pr.PropertyType.IsPrimitive || pr.PropertyType == typeof(string))
            {
                ((IDictionary <string, object>)expando)[pr.Name] = pr.PropertyType.FullName;
                return(expando);
            }

            var type  = TypeLoader.Find(pr.PropertyType.FullName, _assemblies);
            var props = PropLoader.Get(type);

            foreach (var pr2 in props)
            {
                if (pr2.PropertyType.IsPrimitive || pr2.PropertyType == typeof(string))
                {
                    ((IDictionary <string, object>)expando)[pr2.Name] = pr2.PropertyType.FullName;
                }
                else
                {
                    ((IDictionary <string, object>)expando)[pr2.Name] = GetBody(pr2);
                }
            }

            return(expando);
        }
Пример #2
0
        private dynamic GetBody(ParameterInfo p)
        {
            dynamic expando = new System.Dynamic.ExpandoObject();

            if (p.ParameterType.IsPrimitive || p.ParameterType == typeof(string))
            {
                ((IDictionary <string, object>)expando)[p.Name] = p.ParameterType.FullName;
                return(expando);
            }

            try {
                var type  = TypeLoader.Find(p.ParameterType.FullName, _assemblies);
                var props = PropLoader.Get(type);

                foreach (var pr in props)
                {
                    if (pr.PropertyType.IsPrimitive || pr.PropertyType == typeof(string))
                    {
                        ((IDictionary <string, object>)expando)[pr.Name] = pr.PropertyType.FullName;
                    }
                    else
                    {
                        ((IDictionary <string, object>)expando)[pr.Name] = GetBody(pr);
                    }
                }

                return(expando);
            } catch (Exception e) {
                var abc = e;
            }

            throw new Exception("Something has gone wrong!");
        }