Пример #1
0
        public override object Load(ChoBaseConfigurationElement configElement, XmlNode node)
        {
            base.Load(configElement, node);

            //if (configElement.ConfigFilePath.IsNullOrWhiteSpace())
            //    UnderlyingConfigFilePath = ChoConfigurationManager.GetConfigFile(node);
            //else
            //    UnderlyingConfigFilePath = configElement.ConfigFilePath;

            UnderlyingConfigFilePath = ChoConfigurationManager.GetConfigFile(node);
            if (UnderlyingConfigFilePath.IsNullOrWhiteSpace())
            {
                configElement[ChoConfigurationConstants.FORCE_PERSIST] = true;
                UnderlyingConfigFilePath = configElement.ConfigFilePath;
            }

            ConfigElement[UNDERLYING_CONFIG_PATH] = UnderlyingConfigFilePath;

            ConfigFilePath = GetFullPath(UnderlyingConfigFilePath);

            if (IsAppConfigFile)
            {
                if (!configElement.ConfigFilePath.IsNullOrWhiteSpace())
                {
                    UnderlyingConfigFilePath = configElement.ConfigFilePath;
                    ConfigFilePath           = GetFullPath(UnderlyingConfigFilePath);
                }
            }

            if (node != null && !IsAppConfigFile)
            {
                if (configElement.Persistable)
                {
                    ChoXmlDocument.CreateXmlFileIfEmpty(ConfigFilePath);
                }

                using (ChoXmlDocument document = new ChoXmlDocument(ConfigFilePath))
                {
                    string nodeName = configElement.ConfigElementPath;
                    IncludeFilePaths = document.IncludeFiles;
                    if (document.XmlDocument != null && document.XmlDocument.DocumentElement != null)
                    {
                        ChoConfiguration configuration = document.XmlDocument.DocumentElement.ToObject <ChoConfiguration>();
                        if (configuration != null)
                        {
                            ConfigNode = ChoXmlDocument.GetXmlNode(nodeName, configuration.RestOfXmlDocumentElements);
                        }
                    }
                }
            }

            return(null);
        }
Пример #2
0
        public override object Load(ChoBaseConfigurationElement configElement, XmlNode node)
        {
            base.Load(configElement, node);

            //if (configElement.ConfigFilePath.IsNullOrWhiteSpace())
            //    UnderlyingConfigFilePath = ChoConfigurationManager.GetConfigFile(node);
            //else
            //    UnderlyingConfigFilePath = configElement.ConfigFilePath;

            UnderlyingConfigFilePath = ChoConfigurationManager.GetConfigFile(node);

            if (UnderlyingConfigFilePath.IsNullOrWhiteSpace() ||
                UnderlyingConfigFilePath != configElement.ConfigFilePath)
            {
                if (!configElement.ConfigFilePath.IsNullOrWhiteSpace() && UnderlyingConfigFilePath.IsNullOrWhiteSpace())
                {
                    configElement[ChoConfigurationConstants.FORCE_PERSIST] = true;
                    UnderlyingConfigFilePath = configElement.ConfigFilePath;
                }
            }

            ConfigElement[UNDERLYING_CONFIG_PATH] = UnderlyingConfigFilePath;
            if (ChoConfigurationManager.IsSeperateConfigFileSpecified(node))
            {
                ConfigElement[PREV_UNDERLYING_CONFIG_PATH] = UnderlyingConfigFilePath;
            }

            ConfigFilePath = GetFullPath(UnderlyingConfigFilePath);

            if (IsAppConfigFile)
            {
                if (!configElement.ConfigFilePath.IsNullOrWhiteSpace())
                {
                    UnderlyingConfigFilePath = configElement.ConfigFilePath;
                    ConfigFilePath           = GetFullPath(UnderlyingConfigFilePath);

                    ConfigElement[UNDERLYING_CONFIG_PATH] = ConfigFilePath;
                }
            }

            if (/*node != null && */ !IsAppConfigFile)
            {
                if (!IsCustomFormatDataStorage)
                {
                    if (File.Exists(ConfigFilePath))
                    {
                        using (ChoXmlDocument document = new ChoXmlDocument(ConfigFilePath))
                        {
                            string nodeName = configElement.ConfigElementPath;
                            IncludeFilePaths = document.IncludeFiles;
                            if (document.XmlDocument != null && document.XmlDocument.DocumentElement != null)
                            {
                                ChoConfiguration configuration = document.XmlDocument.DocumentElement.ToObject <ChoConfiguration>();
                                if (configuration != null)
                                {
                                    ConfigNode = ChoXmlDocument.GetXmlNode(nodeName, configuration.RestOfXmlDocumentElements);
                                }
                            }
                        }
                    }
                }
                //if (configElement.Persistable)
                //    ChoXmlDocument.CreateXmlFileIfEmpty(ConfigFilePath);

                //using (ChoXmlDocument document = new ChoXmlDocument(ConfigFilePath))
                //{
                //    string nodeName = configElement.ConfigElementPath;
                //    IncludeFilePaths = document.IncludeFiles;
                //    if (document.XmlDocument != null && document.XmlDocument.DocumentElement != null)
                //    {
                //        ChoConfiguration configuration = document.XmlDocument.DocumentElement.ToObject<ChoConfiguration>();
                //        if (configuration != null)
                //        {
                //            ConfigNode = ChoXmlDocument.GetXmlNode(nodeName, configuration.RestOfXmlDocumentElements);
                //        }
                //    }
                //}
            }

            return(null);
        }