コード例 #1
0
        public static void RegisterThemeFromStorage(ThemeStorageType storageType, string themeLocation)
        {
            XMLThemeReader xmlThemeReader = new XMLThemeReader();

            if (storageType == ThemeStorageType.File)
            {
                Theme theme = xmlThemeReader.Read(themeLocation);
                if (theme == null)
                {
                    return;
                }
                ThemeRepository.Add(theme);
            }
            else
            {
                using (Stream manifestResourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(themeLocation))
                {
                    Theme theme = xmlThemeReader.Read(manifestResourceStream);
                    if (theme == null || string.IsNullOrEmpty(theme.Name))
                    {
                        return;
                    }
                    ThemeRepository.Add(theme);
                }
            }
        }
コード例 #2
0
        public Theme Read(Stream stream)
        {
            Theme          theme          = new Theme();
            XMLThemeReader xmlThemeReader = new XMLThemeReader(this.storeFullPropertyName);

            using (XmlTextReader xmlTextReader = new XmlTextReader(stream))
            {
                xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
                if (xmlTextReader.Read() && xmlTextReader.NodeType != XmlNodeType.XmlDeclaration || xmlTextReader.Read() && (xmlTextReader.NodeType != XmlNodeType.Element || xmlTextReader.Depth != 0 || xmlTextReader.Name != "RadThemePackage"))
                {
                    return(theme);
                }
                do
                {
                    ;
                }while (xmlTextReader.Read() && (xmlTextReader.NodeType != XmlNodeType.Element || xmlTextReader.Depth != 1 || !(xmlTextReader.Name == "Streams")));
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.Depth > 1)
                    {
                        if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.Name == "RadArchiveStream")
                        {
                            xmlTextReader.Read();
                            if (xmlTextReader.Name == "ZippedBytes")
                            {
                                int content = (int)xmlTextReader.MoveToContent();
                                xmlTextReader.Read();
                                using (MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(xmlTextReader.Value)))
                                {
                                    using (DeflateStream deflateStream = new DeflateStream((Stream)memoryStream, CompressionMode.Decompress, true))
                                    {
                                        xmlThemeReader.Read(theme, new XmlTextReader((Stream)deflateStream));
                                        memoryStream.Close();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(theme);
        }