public void SaveMetaDataConfiguration(string title, string description, string keywords, bool inherit, IDictionary extendedTags) { if (CanEdit) { ContentDetails details = GetCurrentContentDetails(); string cacheKey = GetCacheKey(details.FileName); using (MemoryStream buffer = new MemoryStream(10000)) { var data = new MetaData() { InheritData = inherit, ApplicationId = details.ApplicationId.GetValueOrDefault(Guid.Empty), ContainerId = details.ContainerId.GetValueOrDefault(Guid.Empty), ContainerTypeId = details.ContainerTypeId.GetValueOrDefault(Guid.Empty), Title = title, Description = description, Keywords = keywords, ExtendedMetaTags = new SerializableDictionary<string, string>(extendedTags.Keys.Cast<string>() .ToDictionary(name => name, name => extendedTags[name] as string)) }; //Translate the URL's if any have been uploaded _metaDataSerializer.Serialize(buffer, data); buffer.Seek(0, SeekOrigin.Begin); MetaDataStore.AddFile("", details.FileName + ".xml", buffer, false); } CacheService.Remove(cacheKey, CacheScope.All); } }
private MetaData GetCurrentMetaData(ContentDetails details) { string cacheKey = GetCacheKey(details.FileName); MetaData result = CacheService.Get(cacheKey, CacheScope.All) as MetaData; if (result == null && MetaDataStore != null) { ICentralizedFile file = MetaDataStore.GetFile("", details.FileName + ".xml"); if (file != null) { using (Stream stream = file.OpenReadStream()) { result = ((MetaData)_metaDataSerializer.Deserialize(stream)); //FIlter out any tags that have oreviously been configured but then removed var lookup = _metaConfig.ExtendedEntries.ToLookup(f => f); foreach (var tag in result.ExtendedMetaTags.Keys) { if (!lookup.Contains(tag)) result.ExtendedMetaTags.Remove(tag); } } } if (result == null) { result = new MetaData() { InheritData = true, ContainerId = details.ContainerId.GetValueOrDefault(Guid.Empty), ContainerTypeId = details.ContainerTypeId.GetValueOrDefault(Guid.Empty) }; } CacheService.Put(cacheKey, result, CacheScope.All); } return result; }