예제 #1
0
        private ThemeService()
        {
            lock (_lockObject)
            {
                if (!_loaded)
                {
                    XmlReader xmlReader = null;
                    try
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(MappingToolConfig));
                        string        path       = SPUtility.GetGenericSetupPath(@"ISAPI\SevenSigma\Configs\DefaultConfig.xml");
                        xmlReader = XmlTextReader.Create(path);
                        MappingToolConfig config = serializer.Deserialize(xmlReader) as MappingToolConfig;

                        //re-read to manually find the context menu sections since
                        //they aren't picked up by thedeserialization process.
                        xmlReader = XmlReader.Create(path);
                        bool foundContextMenus = xmlReader.ReadToFollowing("ContextMenus");
                        if (foundContextMenus)
                        {
                            while (xmlReader.ReadToFollowing("ContextMenu"))
                            {
                                string      contextMenuName = xmlReader.GetAttribute("Name");
                                ContextMenu cm = config.GetContextMenuByName(contextMenuName);
                                if (cm != null)
                                {
                                    cm.ContextMenuXaml = xmlReader.ReadInnerXml();
                                }
                            }
                        }
                        _loadedConfig = config;
                        _loaded       = true;
                    }
                    catch (Exception)
                    {
                        _loaded = false;
                    }
                    finally
                    {
                        if (xmlReader != null)
                        {
                            xmlReader.Close();
                        }
                    }
                }
            }
        }
예제 #2
0
        private ThemeService()
        {
            lock (_lockObject)
            {
                if (!_loaded)
                {
                    XmlReader xmlReader = null;
                    try
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(MappingToolConfig));
                        string path = SPUtility.GetGenericSetupPath(@"ISAPI\SevenSigma\Configs\DefaultConfig.xml");
                        xmlReader = XmlTextReader.Create(path);
                        MappingToolConfig config = serializer.Deserialize(xmlReader) as MappingToolConfig;

                        //re-read to manually find the context menu sections since 
                        //they aren't picked up by thedeserialization process.
                        xmlReader = XmlReader.Create(path);
                        bool foundContextMenus = xmlReader.ReadToFollowing("ContextMenus");
                        if (foundContextMenus)
                        {
                            while (xmlReader.ReadToFollowing("ContextMenu"))
                            {
                                string contextMenuName = xmlReader.GetAttribute("Name");
                                ContextMenu cm = config.GetContextMenuByName(contextMenuName);
                                if (cm != null)
                                {
                                    cm.ContextMenuXaml = xmlReader.ReadInnerXml();
                                }
                            }
                        }
                        _loadedConfig = config;
                        _loaded = true;
                    }
                    catch (Exception)
                    {
                        _loaded = false;
                    }
                    finally
                    {
                        if (xmlReader != null) 
                            xmlReader.Close();
                    }
                }
            }
        }