Beispiel #1
0
        public void Merge()
        {
            MergeWorkerState state = InitialWork();

            while (null != state)
            {
                state.Execute();
                _targetXmlDoc = state.NavigatorMerge.MergedXmlDoc;
                state         = StateFactory(state);
            }
        }
Beispiel #2
0
        protected MergeWorkerState InitialWork()
        {
            MergeWorkerState workerstate = null;

            if (!(null == _xpathMergeRoot ||
                  null == _xpathMergeRoot.Merges ||
                  null == _xpathMergeRoot.Merges.Merge))
            {
                var asm   = Assembly.GetExecutingAssembly();
                var types = new List <Type>();
                types.AddRange(asm.GetTypes());

                string stateName = string.Empty;
                foreach (XpathMergeRootMergesMerge merge in _xpathMergeRoot.Merges.Merge)
                {
                    stateName = string.Format(@"{0}State", merge.Action.Name);
                    foreach (var type in types)
                    {
                        if (stateName == type.Name)
                        {
                            var navigationXpathDictionary = new Dictionary <string, string>();
                            merge.NavitationXpath.ForEach(content => navigationXpathDictionary.Add(content.LocalName, content.Namespace));
                            var instance = Activator.CreateInstance(type, new object[] { _logger,
                                                                                         new XpathNavigatorMerge(_targetXmlDoc),
                                                                                         navigationXpathDictionary,
                                                                                         _targetXmlDoc,
                                                                                         _sourceXmlDoc })
                                           as MergeWorkerState;
                            if (null != instance)
                            {
                                (instance as MergeWorkerState).MergeAction = merge.Action;
                                _stateQueue.Enqueue(instance);
                            }
                        }
                    }
                }

                _stateQueue.TryDequeue(out workerstate);
            }

            return(workerstate);
        }
Beispiel #3
0
        public MergeWorkerState StateFactory(MergeWorkerState args)
        {
            MergeWorkerState state = null;
            var currentState       = args as MergeWorkerState;

            _stateQueue.TryDequeue(out state);
            while (null != state &&
                   currentState.Success &&
                   (state as MergeWorkerState).MergeAction.SkipOnLastSuccess)
            {
                _stateQueue.TryDequeue(out state);
            }

            if (null != state)
            {
                (state as MergeWorkerState).NavigatorMerge.MergedXmlDoc = (currentState as MergeWorkerState).NavigatorMerge.MergedXmlDoc;
            }

            return(state);
        }