Exemplo n.º 1
0
 internal object GetValueFromMethodResultByObjectType(DataMethodResult MethodResult, string ObjectType, string PropertyName)
 {
     ObjectType = ObjectType.ToLower();
     // the closest children first.
     if (MethodResult.HasChildren)
     {
         foreach (var item in MethodResult.Children)
         {
             var result = GetValueFromMethodResultByObjectType(item.Value, ObjectType, PropertyName);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     if (MethodResult.ObjectType == ObjectType)
     {
         var result = getMember(MethodResult.Value, PropertyName);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Exemplo n.º 2
0
        private static DataMethodResult ExecuteSubViewDataMethod(Render.FrontContext Context, object itemvalue, List <ViewDataMethod> Children)
        {
            DataMethodResult dataresult = new DataMethodResult();

            dataresult.Value = itemvalue;

            DataContext parentcontext = new DataContext(Context.RenderContext);

            parentcontext.Push("", itemvalue);

            foreach (var item in Children)
            {
                var subResult = ExecuteViewDataMethod(Context, item, parentcontext);

                if (subResult != null)
                {
                    if (subResult is DataMethodResult)
                    {
                        dataresult.Children.Add(item.AliasName, subResult as DataMethodResult);
                    }
                    else
                    {
                        DataMethodResult subMethodResult = new DataMethodResult();
                        subMethodResult.Value = subResult;
                        dataresult.Children.Add(item.AliasName, subMethodResult);
                    }
                }
            }
            return(dataresult);
        }
Exemplo n.º 3
0
        private static List <DataMethodResult> ConvertToMethodResultList(object data)
        {
            List <DataMethodResult> result = new List <DataMethodResult>();
            var itemcollection             = ((IEnumerable)data).Cast <object>().ToList();

            foreach (var item in itemcollection)
            {
                DataMethodResult oneresult = new DataMethodResult();
                oneresult.Value = item;
            }
            return(null);
        }
Exemplo n.º 4
0
        private object getObjectProperty(object obj, string PropertyName)
        {
            if (obj is DataMethodResult)
            {
                DataMethodResult methodresult = obj as DataMethodResult;

                object value = getObjectProperty(methodresult.Value, PropertyName);

                if (value == null)
                {
                    value = getDictProperty(methodresult.Children, PropertyName);
                }

                return(value);
            }
            else
            {
                int dotindex = PropertyName.IndexOf(".");
                if (dotindex > -1)
                {
                    string key         = PropertyName.Substring(0, dotindex);
                    string subProperty = PropertyName.Substring(dotindex + 1);

                    object value = getMember(obj, key);

                    if (value == null)
                    {
                        return(null);
                    }
                    else
                    {
                        return(getObjectProperty(value, subProperty));
                    }
                }
                else
                {
                    return(getMember(obj, PropertyName));
                }
            }
        }