public void It_should_remove_keys() { var x = new CacheManagerService(); x.AddRepository <SimpleRepo>(); var d = x.GetRepository <SimpleRepo>(); d.Set("somekey", "somevalue"); Assert.Equal("somevalue", d.Get("somekey")); d.Delete("somekey"); Assert.Null(d.Get("somekey")); }
public StorageService(ConfigurationService configService, CacheManagerService cacheManagerService) { if (configService == null) { throw new ArgumentNullException("configService"); } if (cacheManagerService == null) { throw new ArgumentNullException("cacheManagerService"); } _configService = configService; _cacheManagerService = cacheManagerService; }
public void It_should_handle_multiple_repo() { var x = new CacheManagerService(); x.AddRepository <SimpleRepo>(); x.AddRepository <SimpleRepo2>(); var d = x.GetRepository <SimpleRepo>(); d.Set("somekey", "somevalue"); var d1 = x.GetRepository <SimpleRepo2>(); d1.Set("somekey1", "somevalue1"); Assert.Equal("somevalue", d.Get("somekey")); Assert.Equal("somevalue1", d1.Get("somekey1")); }
public void It_should_store_some_infos() { var x = new CacheManagerService(); x.AddRepository <SimpleRepo>(); var repo = x.ServiceContainer.GetInstance <SimpleRepo>(); Assert.NotNull(repo); Assert.Equal(CACHES.FASTREFERENCE, repo.CacheProvider); var d = x.GetRepository <SimpleRepo>(); d.Set("somekey", "somevalue"); Assert.Equal("somevalue", d.Get("somekey")); d.Set("somekey1", "somevalue1"); Assert.Equal("somevalue1", d.Get("somekey1")); }
/// <summary> /// Get body scripts /// </summary> /// <returns>Contents of multi-line text field as a string</returns> public static string GetBodyScripts() { try { if (CacheManagerService.GetObject(Constants.BodyScriptsCacheKey) == null) { var commonScripts = _analyticsService.GetCommonScripts(); if (commonScripts != null) { CacheManagerService.SetObject(Constants.BodyScriptsCacheKey, commonScripts.BodyScripts); return(commonScripts.BodyScripts); } } return(CacheManagerService.GetObject(Constants.BodyScriptsCacheKey).ToString()); } catch (Exception ex) { _logService.Error("Sample.Feature.Analytics -> GetBodyScripts -> Exception Occured", ex); } return(string.Empty); }
/// <summary> /// Get head scripts /// </summary> /// <returns>Contents of multi-line text field as a string</returns> public static string GetHeadScripts() { try { //check if we have this value cached for the current site or not if (CacheManagerService.GetObject(Constants.HeadScriptsCacheKey) == null) { //if it wasn't previously cached and there's a value present, lets set it in cache for next time var commonScripts = _analyticsService.GetCommonScripts(); if (commonScripts != null) { CacheManagerService.SetObject(Constants.HeadScriptsCacheKey, commonScripts.HeadScripts); return(commonScripts.HeadScripts); } } //grab the value from cache for the current site return(CacheManagerService.GetObject(Constants.HeadScriptsCacheKey).ToString()); } catch (Exception ex) { _logService.Error("Sample.Feature.Analytics -> GetHeadScripts -> Exception Occured", ex); } return(string.Empty); }
/// <summary> /// Called when the Plugin is being loaded which happens on startup of KeePass /// </summary> /// <returns>True if the plugin loaded successfully, false if not</returns> public override bool Initialize(IPluginHost pluginHost) { if (_host != null) { Terminate(); } if (pluginHost == null) { return(false); } //if (NativeLib.IsUnix()) return false; _host = pluginHost; // Load the configuration _configService = new ConfigurationService(pluginHost); _configService.Load(); // Initialize CacheManager _cacheManagerService = new CacheManagerService(_configService, _host); _cacheManagerService.RegisterEvents(); // Initialize storage providers _storageService = new StorageService(_configService, _cacheManagerService); _storageService.RegisterPrefixes(); // Initialize UIService _uiService = new UIService(_configService, _storageService); // Initialize KeePass-Resource Service _kpResources = new KpResources(_host); // Add "Open from Cloud Drive..." to File\Open menu. var fileMenu = _host.MainWindow.MainMenu.Items["m_menuFile"] as ToolStripMenuItem; if (fileMenu != null) { var openMenu = fileMenu.DropDownItems["m_menuFileOpen"] as ToolStripMenuItem; if (openMenu != null) { _tsOpenFromCloudDrive = new ToolStripMenuItem("Open from Cloud Drive...", PluginResources.KeeAnywhere_16x16); _tsOpenFromCloudDrive.Click += OnOpenFromCloudDrive; _tsOpenFromCloudDrive.ShortcutKeys = Keys.Control | Keys.Alt | Keys.O; openMenu.DropDownItems.Add(_tsOpenFromCloudDrive); } var saveMenu = fileMenu.DropDownItems["m_menuFileSaveAs"] as ToolStripMenuItem; if (saveMenu != null) { var index = saveMenu.DropDownItems.IndexOfKey("m_menuFileSaveAsSep0"); _tsSaveToCloudDrive = new ToolStripMenuItem("Save to Cloud Drive...", PluginResources.KeeAnywhere_16x16); _tsSaveToCloudDrive.Click += OnSaveToCloudDrive; saveMenu.DropDownItems.Insert(index, _tsSaveToCloudDrive); _tsSaveCopyToCloudDrive = new ToolStripMenuItem("Save Copy to Cloud Drive...", PluginResources.KeeAnywhere_16x16); _tsSaveCopyToCloudDrive.Click += OnSaveToCloudDrive; saveMenu.DropDownItems.Add(_tsSaveCopyToCloudDrive); } } if (_configService.IsUpgraded) { _uiService.ShowChangelog(); } // Indicate that the plugin started successfully return(true); }
public override void Process(HttpRequestArgs args) { HttpContext context = HttpContext.Current; if (context == null) { return; } string requestUrl = context.Request.Url.ToString(); if (string.IsNullOrEmpty(requestUrl) || !requestUrl.ToLower().EndsWith("sitemap.xml")) { return; } string siteMapContent = string.Empty; if (Sitecore.Context.Site != null && Sitecore.Context.Database != null) { Item siteTenantItem = SiteExtensions.GetTenantItem(Sitecore.Context.Site); Item homeItem = SiteExtensions.GetStartItem(Sitecore.Context.Site); if (siteTenantItem != null && homeItem != null) { var logService = ServiceLocator.ServiceProvider.GetService <ILogService>(); var glassMapperService = ServiceLocator.ServiceProvider.GetService <IGlassMapperService>(); //grab the base domain to use in each page item var siteMapBaseDomain = siteTenantItem.Fields[Constants.SitemapBaseDomainField].Value; var homeSiteMapItem = glassMapperService.GetItem <ISiteMapItem>(homeItem.Paths.Path); //Cached "per site" string siteCacheKey = string.Format("{0}_{1}", Sitecore.Context.Site.Name, Constants.SitemapContentCacheKey); if (CacheManagerService.GetObject(siteCacheKey) == null) { List <ISiteMapItem> allPageItemsFlattened = new List <ISiteMapItem>(); if (homeSiteMapItem.IncludeInSitemap) { allPageItemsFlattened.Add(homeSiteMapItem); } var flattenedSiteMapItems = GetRecursiveFlattenedSiteMapItems(homeSiteMapItem, allPageItemsFlattened); if (flattenedSiteMapItems != null) { siteMapContent = GenerateSiteMapXML(flattenedSiteMapItems, siteMapBaseDomain, logService, glassMapperService); CacheManagerService.SetObject(siteCacheKey, siteMapContent); } } else { siteMapContent = CacheManagerService.GetObject(siteCacheKey).ToString(); } } } context.Response.ContentType = "text/xml"; context.Response.Write(siteMapContent); context.Response.End(); }