Beispiel #1
0
        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);
        }
Beispiel #2
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);
        }