Пример #1
0
        public static void ContractNSave(XmlNode xmlNode, string xmlFilePath)
        {
            ChoNestedDictionary <string, XmlNode> xmlFileList = ContractIncludes(xmlNode, xmlFilePath);

            foreach (string fileName in xmlFileList.Keys)
            {
                ChoXmlDocument.Save(xmlFileList[fileName], fileName, true);
            }
        }
Пример #2
0
        private void SaveInternal()
        {
            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);
                }
            }
        }
Пример #3
0
        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;
                        }
                    }
                }
            }
        }
Пример #4
0
        public static void SaveAsChild(this XmlNode node, object target)
        {
            if (node == null)
            {
                return;
            }

            if (target == null)
            {
                return;
            }

            Type type = target.GetType();

            string  elementName = type.Name;
            XmlNode elementNode = null;

            ChoXPathAttribute xpathAttribute = type.GetCustomAttribute <ChoXPathAttribute>();

            if (xpathAttribute == null)
            {
                XmlRootAttribute rootAttribute = type.GetCustomAttribute <XmlRootAttribute>();
                elementName = rootAttribute != null ? rootAttribute.ElementName : type.Name;
                elementNode = node.SelectSingleNode("/{0}".FormatString(elementName));
            }
            else
            {
                elementNode = node.SelectSingleNode(xpathAttribute.XPath);
            }

            XmlNode configNode = node.MakeXPath(elementName);

            if (configNode != null)
            {
                string configXml = target.ToNullNSXml();
                if (configXml.IsNullOrEmpty())
                {
                    return;
                }

                ChoXmlDocument.SetOuterXml(configNode, configXml);
            }
        }
Пример #5
0
 internal ChoXmlDocument(string filePathOrXml, ChoXmlDocument parentXmlDocument)
     : this(filePathOrXml)
 {
 }