Пример #1
0
        public void MapPinningRule(WebMap webMap, string registeredSectionUri = null)
        {
            var sectionUri = registeredSectionUri ?? webMap.Section.GetMappingUrl();

            if (registeredSectionUri == null)
            {
                RegisterEmptyHandler(sectionUri);
            }

            string token  = webMap.GetMappingToken();
            string mapUri = webMap.GetMappingUrl();

            // map URI for empty Catch URI on the blending token
            if (webMap.Url != null && !Blender.IsMapped(sectionUri, token))
            {
                Blender.MapUri(sectionUri, token);
            }

            // map URI for WebMap's Catch URI on the same blending token;
            // this will be calling by WebsiteProvider
            if (!Blender.IsMapped(mapUri, token))
            {
                RegisterEmptyHandler(mapUri);
                Blender.MapUri(mapUri, token);
            }

            // map URI for WebMap's Pin URI on the same token
            Blender.MapUri(webMap.ForeignUrl, token);
        }
Пример #2
0
        public void UnmapPinningRule(WebMap webMap)
        {
            if (webMap.Section?.Template == null)
            {
                // if the Blending Point (WebSection) or the Surface (WebTemplate) was deleted earlier
                return;
            }
            string token  = webMap.GetMappingToken();
            string mapUri = webMap.GetMappingUrl();

            Blender.UnmapUri(webMap.ForeignUrl, token);

            if (webMap.Url != null)
            {
                var uriByTokenCount = Blender.ListAll().Where(x => x.Key == token).SelectMany(x => x.Value).Count();
                if (uriByTokenCount == 2) // one URI for empty WebMap's handler and another one for empty WebSection's handler
                {
                    Blender.UnmapUri(mapUri, token);
                    Handle.UnregisterHttpHandler("GET", mapUri);
                }
            }
        }