Exemplo n.º 1
0
        internal DeepLinkViewModel(Action <DeepLink> navigate)
        {
            this.navigate = navigate;
            HtmlLocation location = HtmlWindow.Current.Location;
            string       hash     = location.Hash;

            localStorageKey = UriUtility.GetServerRelativeUrl(UriUtility.GetAbsolutePath(location.Href)) + "?deepLink";
            if (!string.IsNullOrEmpty(hash))
            {
                try
                {
                    lastReceived = JsonDeserializer.Deserialize <DeepLink>(hash.Substring(1)); // ignore #
                }
                catch
                {
                }
            }

            if (lastReceived == null && HtmlWindow.Current.LocalStorage != null)
            {
                hash = HtmlWindow.Current.LocalStorage[localStorageKey];
                if (!string.IsNullOrEmpty(hash))
                {
                    try
                    {
                        lastReceived = JsonDeserializer.Deserialize <DeepLink>(hash); // ignore #
                    }
                    catch
                    {
                    }
                }
            }

            HtmlWindow.Current.AdviseHash(HashChanged);
        }