Inheritance: ISingletonPlugin
示例#1
0
        public void Register(IRestEndpointController restRoutes)
        {
            IThemeUtilities utilites = PluginManager.GetSingleton <IThemeUtilities>();

            if (utilites == null || !utilites.EnableThemePageControls)
            {
                return;
            }

            restRoutes.Add(2, "themeutility/reset", HttpMethod.Post, request =>
            {
                var response = new RestResponse();

                try
                {
                    string action = request.Request.QueryString["action"];

                    if (string.IsNullOrEmpty(action))
                    {
                        throw new ArgumentException("Action parameter is required ('theme' or 'cache').");
                    }

                    ThemeUtility themeUtility = PluginManager.GetSingleton <ThemeUtility>();

                    if (themeUtility != null)
                    {
                        if (action.Equals("theme", StringComparison.OrdinalIgnoreCase))
                        {
                            themeUtility.RevertTheme();
                        }

                        if (action.Equals("cache", StringComparison.OrdinalIgnoreCase))
                        {
                            themeUtility.ResetCache();
                        }
                    }
                }
                catch (Exception ex)
                {
                    response.Errors = new [] { ex.Message };
                }

                return(response);
            });
        }
示例#2
0
        public void Initialize()
        {
            ThemeUtility    themeUtility = PluginManager.GetSingleton <ThemeUtility>();
            IThemeUtilities utilites     = PluginManager.GetSingleton <IThemeUtilities>();

            if (themeUtility == null || utilites == null || !utilites.EnableFileSystemWatcher)
            {
                return;
            }

            _siteThemeName = CSContext.Current.SiteTheme;

            InitialiseFileSystemWatcher(Constants.DefaultWidgets, themeUtility.ResetCache);
            InitialiseFileSystemWatcher(Constants.FactoryDefaultConfigurations,
                                        () => themeUtility.RevertTheme(ReversionType.Configuration), _siteThemeName);
            InitialiseFileSystemWatcher(Constants.FactoryDefaultPages,
                                        () => themeUtility.RevertTheme(ReversionType.Layouts), _siteThemeName);
            InitialiseFileSystemWatcher(Constants.ThemeFiles, () => themeUtility.RevertTheme(ReversionType.Files),
                                        string.Format(@"s\fd\{0}", _siteThemeName));
        }