private void ImportRouteSettings(ImportContentContext context, CacheSettingsPart part)
        {
            var partElement = context.Data.Element(part.PartDefinition.Name);

            // Don't do anything if the tag is not specified.
            if (partElement == null)
                return;

            var routesElement = partElement.Element("Routes");

            if (routesElement == null)
                return;

            var routeConfigs = routesElement.Elements().Select(x => new CacheRouteConfig {
                RouteKey = x.Attr("Key"),
                Duration = x.Attr<int?>("Duration"),
                Priority = x.Attr<int>("Priority"),
                Url = x.Attr("Url"),
                MaxAge = x.Attr<int?>("MaxAge"),
                GraceTime = x.Attr<int?>("GraceTime"),
                FeatureName = x.Attr("FeatureName")
            });

            _cacheService.SaveRouteConfigs(routeConfigs);
        }
 public CacheSettings(CacheSettingsPart part) {
     DefaultCacheDuration = part.DefaultCacheDuration;
     DefaultCacheGraceTime = part.DefaultCacheGraceTime;
     DefaultMaxAge = part.DefaultMaxAge;
     VaryByQueryStringParameters = String.IsNullOrWhiteSpace(part.VaryByQueryStringParameters) ? null : part.VaryByQueryStringParameters.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
     VaryByRequestHeaders = String.IsNullOrWhiteSpace(part.VaryByRequestHeaders) ? new HashSet<string>() : new HashSet<string>(part.VaryByRequestHeaders.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray());
     VaryByRequestHeaders.Add("HOST"); // Always vary by host name/tenant.
     IgnoredUrls = String.IsNullOrWhiteSpace(part.IgnoredUrls) ? null : part.IgnoredUrls.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
     IgnoreNoCache = part.IgnoreNoCache;
     VaryByCulture = part.VaryByCulture;
     CacheAuthenticatedRequests = part.CacheAuthenticatedRequests;
     VaryByAuthenticationState = part.VaryByAuthenticationState;
     DebugMode = part.DebugMode;
 }
        private void ExportRouteSettings(ExportContentContext context, CacheSettingsPart part)
        {
            var routes = _cacheService.GetRouteConfigs();
            var routesElement = new XElement("Routes",
                routes.Select(x => new XElement("Route")
                    .Attr("Key", x.RouteKey)
                    .Attr("Url", x.Url)
                    .Attr("Priority", x.Priority)
                    .Attr("Duration", x.Duration)
                    .Attr("GraceTime", x.GraceTime)
                    .Attr("MaxAge", x.MaxAge)
                    .Attr("FeatureName", x.FeatureName)));

            context.Element(part.PartDefinition.Name).Add(routesElement);
        }
 public CacheSettings(CacheSettingsPart part)
 {
     DefaultCacheDuration        = part.DefaultCacheDuration;
     DefaultCacheGraceTime       = part.DefaultCacheGraceTime;
     DefaultMaxAge               = part.DefaultMaxAge;
     VaryByQueryStringParameters = String.IsNullOrWhiteSpace(part.VaryByQueryStringParameters) ? null : part.VaryByQueryStringParameters.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
     VaryByRequestHeaders        = String.IsNullOrWhiteSpace(part.VaryByRequestHeaders) ? new HashSet <string>() : new HashSet <string>(part.VaryByRequestHeaders.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray());
     VaryByRequestHeaders.Add("HOST"); // Always vary by host name/tenant.
     IgnoredUrls   = String.IsNullOrWhiteSpace(part.IgnoredUrls) ? null : part.IgnoredUrls.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
     IgnoreNoCache = part.IgnoreNoCache;
     VaryByCulture = part.VaryByCulture;
     CacheAuthenticatedRequests = part.CacheAuthenticatedRequests;
     VaryByAuthenticationState  = part.VaryByAuthenticationState;
     DebugMode = part.DebugMode;
 }