private List <TChild> CheckForMatches(string text)
        {
            List <TChild> childObjs = new List <TChild>();

            if (ParentProperty != null)
            {
                List <TParent> parentObjs = ParentObjectMatcher.GetMatches(text);

                if (parentObjs != null && parentObjs.Count > 0)
                {
                    foreach (TParent parentObj in parentObjs)
                    {
                        object parentPropertyValue = ParentProperty.GetValue(parentObj, null);

                        if (ChildProperty != null)
                        {
                            List <TChild> childObjMatches = ChildObjectMatcher.GetMatches(text);

                            if (childObjMatches != null && childObjMatches.Count > 0)
                            {
                                foreach (TChild childObj in childObjMatches)
                                {
                                    ChildProperty.SetValue(childObj, parentPropertyValue, null);
                                    childObjs.Add(childObj);
                                }
                            }
                        }
                    }
                }
            }

            return(childObjs);
        }
Exemple #2
0
        public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            var parentObject = ParentProperty.GetValue(obj, invokeAttr, binder, index, culture);

            if (parentObject == null)
            {
                return(null);
            }
            return(Property.GetValue(parentObject, invokeAttr, binder, index, culture));
        }
Exemple #3
0
        public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            var parentObject = ParentProperty.GetValue(obj, invokeAttr, binder, index, culture);

            if (parentObject == null)
            {
                throw new ArgumentNullException("Could not set nested property value: Parent object was null");
            }
            Property.SetValue(ParentProperty.GetValue(obj, invokeAttr, binder, index, culture), value, invokeAttr, binder, index, culture);
        }
Exemple #4
0
        /// <summary>
        /// Checks the text for matches
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private List <TChild> CheckForMatches(string text)
        {
            // create a list of child objects
            List <TChild> childObjs = new List <TChild>();

            if (ParentProperty != null)
            {
                // get parent object matches
                List <TParent> parentObjs = ParentObjectMatcher.GetMatches(text);

                // if there were any parent matches, get child objects
                if (parentObjs != null && parentObjs.Count > 0)
                {
                    // for each parent, check for children
                    foreach (TParent parentObj in parentObjs)
                    {
                        // get the value of the parent linking property
                        object parentPropertyValue = ParentProperty.GetValue(parentObj, null);

                        // if the child property is set
                        if (ChildProperty != null)
                        {
                            // find child object matches
                            List <TChild> childObjMatches = ChildObjectMatcher.GetMatches(text);

                            // if any child matches were found, add them to the collection
                            if (childObjMatches != null && childObjMatches.Count > 0)
                            {
                                // for each child match, set the child's parent property and add to the collection
                                foreach (TChild childObj in childObjMatches)
                                {
                                    ChildProperty.SetValue(childObj, parentPropertyValue, null);
                                    childObjs.Add(childObj);
                                }
                            }
                        }
                    }
                }
            }

            return(childObjs);
        }
Exemple #5
0
        public IyTreeModel CreateModel(IList list)
        {
            var genericList = list.Cast <TNode>().Where(x => ParentProperty.GetValue(x, null) == null).ToList();

            return(new RecursiveTreeModel <TNode>(genericList, this));
        }