public static void RegisterThemeFromStorage(
            ThemeStorageType storageType,
            ThemeResolutionService.ResourceParams resourceParams)
        {
            ThemeSource themeSource = new ThemeSource();
            Assembly    assembly    = resourceParams.UserAssembly;

            if ((object)assembly == null)
            {
                assembly = resourceParams.CallingAssembly;
            }
            themeSource.CallingAssembly = assembly;
            themeSource.StorageType     = storageType;
            themeSource.ThemeLocation   = resourceParams.ResourcePath;
            themeSource.ReloadThemeFromStorage();
        }
        public static bool LoadPackageResource(
            ThemeResolutionService.ResourceParams resourceParams,
            bool throwOnError)
        {
            Assembly assembly     = resourceParams.UserAssembly;
            string   resourcePath = resourceParams.ResourcePath;

            if ((object)assembly == null)
            {
                assembly = resourceParams.CallingAssembly;
                if ((object)assembly == null)
                {
                    assembly = Assembly.GetCallingAssembly();
                }
            }
            Stream manifestResourceStream = assembly.GetManifestResourceStream(resourcePath);

            if (manifestResourceStream == null)
            {
                Assembly executingAssembly = resourceParams.ExecutingAssembly;
                if ((object)executingAssembly == null)
                {
                    executingAssembly = Assembly.GetExecutingAssembly();
                }
                manifestResourceStream = executingAssembly.GetManifestResourceStream(resourcePath);
            }
            if (manifestResourceStream == null)
            {
                if (throwOnError)
                {
                    throw new ArgumentException("Specified resource does not exist in the provided assembly.");
                }
                return(false);
            }
            using (manifestResourceStream)
            {
                Theme theme = new TSSPThemeReader().Read(manifestResourceStream);
                if (theme != null)
                {
                    ThemeRepository.Add(theme);
                    return(true);
                }
            }
            return(false);
        }