Example #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);
        }
Example #2
0
        public override void Initialize()
        {
            ParentObjectMatcher = ServiceComponent.ComponentContainer.Resolve <ITextMatcher <TParent> >(Name);
            if (ParentObjectMatcher != null)
            {
                ParentObjectMatcher.Initialize();
            }

            ChildObjectMatcher = ServiceComponent.ComponentContainer.Resolve <ITextMatcher <TChild> >(Name);
            if (ChildObjectMatcher != null)
            {
                ChildObjectMatcher.Initialize();
            }
        }
Example #3
0
        /// <summary>
        /// Initializes the processor
        /// </summary>
        public override void Initialize()
        {
            // resolve the parent type using the component container and initialize it
            ParentObjectMatcher = ServiceComponent.ComponentContainer.Resolve <ITextMatcher <TParent> >(Name);
            if (ParentObjectMatcher != null)
            {
                ParentObjectMatcher.Initialize();
            }

            // resolve the child type using the component container and initialize it
            ChildObjectMatcher = ServiceComponent.ComponentContainer.Resolve <ITextMatcher <TChild> >(Name);
            if (ChildObjectMatcher != null)
            {
                ChildObjectMatcher.Initialize();
            }
        }
Example #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);
        }