private void QueueMessageHandler(IChoQueuedMsgServiceObject <ChoStandardQueuedMsg <object> > msgObject)
        {
            if (msgObject == null)
            {
                return;
            }

            lock (_syncRoot)
            {
                if (msgObject.State.Msg == null)
                {
                    if (!_readOnly)
                    {
                        ChoNestedDictionary <string, XmlNode> xmlFileList = ContractIncludes(_xmlDocument, _filePath);

                        foreach (string fileName in xmlFileList.Keys)
                        {
                            if (_lastWriteTimeCache.GetValue(fileName) <= File.GetLastWriteTime(fileName))
                            {
                                ChoXmlDocument.Save(xmlFileList[fileName], fileName, true);
                            }
                        }
                    }
                }
                else if (msgObject.State.Msg is ChoConfigurationCompositeFileChangedEventArgs)
                {
                    ChoConfigurationCompositeFileChangedEventArgs e = msgObject.State.Msg as ChoConfigurationCompositeFileChangedEventArgs;
                    if (e != null)
                    {
                        try
                        {
                            ChoXmlDocumentChangingEventArgs xmlDocumentChangingEventArgs = new ChoXmlDocumentChangingEventArgs(_filePath, e.ModifiedIncludeFiles);
                            DocumentChanging.Raise(this, xmlDocumentChangingEventArgs);

                            if (xmlDocumentChangingEventArgs.IgnoreLoadDocument)
                            {
                                return;
                            }

                            _xmlDocument = null;
                            Load();

                            DocumentChanged.Raise(this, new ChoXmlDocumentChangedEventArgs(_filePath, e.ModifiedIncludeFiles));
                        }
                        catch
                        {
                            DocumentLoaded = false;
                            throw;
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void QueueMessageHandler(IChoQueuedMsgServiceObject <object> msgObject)
        {
            if (msgObject == null)
            {
                return;
            }

            lock (_syncRoot)
            {
                if (msgObject.State == null)
                {
                    if (!_readOnly)
                    {
                        SaveInternal();
                    }
                }
                else if (msgObject.State is ChoConfigurationCompositeFileChangedEventArgs)
                {
                    ChoConfigurationCompositeFileChangedEventArgs e = msgObject.State as ChoConfigurationCompositeFileChangedEventArgs;
                    if (e != null)
                    {
                        try
                        {
                            ChoXmlDocumentChangingEventArgs xmlDocumentChangingEventArgs = new ChoXmlDocumentChangingEventArgs(_filePath, e.ModifiedIncludeFiles);
                            DocumentChanging.Raise(this, xmlDocumentChangingEventArgs);

                            if (xmlDocumentChangingEventArgs.IgnoreLoadDocument)
                            {
                                return;
                            }

                            _xmlDocument = null;
                            Load();

                            DocumentChanged.Raise(this, new ChoXmlDocumentChangedEventArgs(_filePath, e.ModifiedIncludeFiles));
                        }
                        catch
                        {
                            DocumentLoaded = false;
                            throw;
                        }
                    }
                }
            }
        }