Пример #1
0
        public string BuildRouteApiUrl(string language, bool?hasRouteError)
        {
            string baseUrl = $"{_uriHelper.GetBaseUri()}/data/routes";

            string relativeUrl = $"{_uriHelper.ToBaseRelativePath(_uriHelper.GetBaseUri(), _uriHelper.GetAbsoluteUri())}";

            //Incorrect url
            if (hasRouteError.HasValue && hasRouteError.Value)
            {
                return($"{baseUrl}/error/{language}.json");
            }

            ISitecoreItem rootItem = _sitecoreItemService.GetSitecoreItemRootMock(language);

            if (rootItem.GetItSelfAndDescendants().Any(item => item.Url == "/" + relativeUrl) || relativeUrl == "")
            {
                if (relativeUrl.Length <= language.Length)
                {
                    return($"{baseUrl}/{language}.json");
                }

                return($"{baseUrl}{relativeUrl.Substring(language.Length)}/{language}.json");
            }


            return($"{baseUrl}/error/{language}.json");
        }
Пример #2
0
        public async Task RefreshData(Task <AuthenticationState> authenticationStateTask)
        {
            var auth = await authenticationStateTask;

            if (auth.User.Identity.IsAuthenticated)
            {
                //Pobranie danych użytkownika
                _emial    = auth.User.Identity.Name;
                _imageUrl = await http.GetStringAsync("/api/accounts/image/" + _emial);

                _imageUrl = Uri.GetBaseUri() + "Image/" + _imageUrl;
                imSub.OnNext(_imageUrl);
                //Pobranie kumpli
                await RefreshFriends();
            }
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().AddNewtonsoftJson();
            services.AddRazorPages();

            services.AddServerSideBlazor();

            // Server Side Blazor doesn't register HttpClient by default
            if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped <HttpClient>(s =>
                {
                    // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                    IUriHelper uriHelper = s.GetRequiredService <IUriHelper>();
                    return(new HttpClient
                    {
                        BaseAddress = new Uri(uriHelper.GetBaseUri())
                    });
                });
            }

            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });
        }
Пример #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor();

            // Server Side Blazor doesn't register HttpClient by default
            if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped <HttpClient>(s =>
                {
                    // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                    IUriHelper uriHelper = s.GetRequiredService <IUriHelper>();
                    return(new HttpClient
                    {
                        BaseAddress = new Uri(uriHelper.GetBaseUri())
                    });
                });
            }

            services.AddBlazorPrettyCode(defaults =>
            {
                defaults.DefaultTheme    = "SolarizedDark";
                defaults.ShowLineNumbers = true;
            });
            services.AddBootstrapCSS();
        }
Пример #5
0
        public static string WithBaseUrl_UglyHackForGithub(this string url, IUriHelper uriHelper)
        {
            if (url.StartsWith("/"))
            {
                url = url.Substring(1);
            }

            return(new Uri(new Uri(uriHelper.GetBaseUri()), url).ToString());
        }
Пример #6
0
        public string GetServiceBaseUrl()
        {
            if (_uriHelper.GetBaseUri().Contains("localhost"))
            {
                return("http://localhost:7071");
            }

            return("https://blazorfourinarowfunctionapp.azurewebsites.net");
        }
Пример #7
0
        public static string AddBaseUrl(this string url, IUriHelper uriHelper)
        {
            if (url.StartsWith("/"))
            {
                url = url.Substring(1);
            }

            return(new Uri(new Uri(uriHelper.GetBaseUri()), url).ToString());
        }
Пример #8
0
        private string GetCurrentUrl()
        {
            string currentUrl       = "/" + uri.ToBaseRelativePath(uri.GetBaseUri(), uri.GetAbsoluteUri());
            int    indexOfReturnUrl = currentUrl.IndexOf("?returnUrl");

            if (indexOfReturnUrl >= 0)
            {
                currentUrl = currentUrl.Substring(0, indexOfReturnUrl);
            }

            return(currentUrl);
        }
Пример #9
0
 public async Task Init()
 {
     if (references == null)
     {
         references = new List <MetadataReference>();
         foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
         {
             references.Add(
                 MetadataReference.CreateFromStream(
                     await this._http.GetStreamAsync(_uriHelper.GetBaseUri() + "/_framework/_bin/" + assembly.Location)));
         }
     }
 }
Пример #10
0
        public async Task Initialise()
        {
            int done = 10;

            while (done-- > 0)
            {
                if (ComponentContext.IsConnected)
                {
                    try
                    {
                        await LocalisationHelper.BuildLocalCulture();

                        await LocalisationHelper.BuildLocalTimeZone();

                        if (!HasApiKey)
                        {
                            SetApiKey(await LocalStorage.GetItemAsync <string>("GitterKey"));
                        }
                        break;
                    }
                    catch (Exception ex)
                    {
                        if (done == 1)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }

                await Task.Delay(1000);
            }
            if (HasApiKey)
            {
                initialised = true;
            }
            else
            {
                var currentUri  = UriHelper.GetAbsoluteUri();
                var baseUri     = UriHelper.GetBaseUri();
                var currentPage = UriHelper.ToBaseRelativePath(baseUri, currentUri);
                if (!currentPage.Equals(LOGINPAGE, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(currentPage))
                {
                    UriHelper.NavigateTo(LOGINPAGE);
                }
            }
        }
 public async Task Init()
 {
     if (references == null)
     {
         references = new List <MetadataReference>();
         foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
         {
             if (assembly.IsDynamic)
             {
                 continue;
             }
             var name = assembly.GetName().Name + ".dll";
             Console.WriteLine(name);
             references.Add(
                 MetadataReference.CreateFromStream(
                     await this._http.GetStreamAsync(_uriHelper.GetBaseUri() + "/_framework/_bin/" + name)));
         }
     }
 }
        private void UriHelper_OnLocationChanged(object sender, string e)
        {
            if (calledNavigateTo)
            {
                Debug.WriteLine("navigated via link");

                calledNavigateTo = false;
                navigated.OnNext(CurrentViewModel);
            }
            else  //pressed back or forward (or maybe typed in url)
            {
                var    relativeUri = e.Substring(uriHelper.GetBaseUri().Length);
                object vm          = null;
                //check backstack
                if (BackStack.TryPeek(out vm))
                {
                    if (VerifyPath(relativeUri, vm))
                    {
                        Debug.WriteLine("Went back");
                        ForwardStack.Push(CurrentViewModel); //store current vm
                        vm = BackStack.Pop();
                        CurrentViewModel = vm;
                        navigated.OnNext(CurrentViewModel);
                        return;
                    }
                }
                //check forward stack
                if (ForwardStack.TryPeek(out vm))
                {
                    if (VerifyPath(relativeUri, vm))
                    {
                        Debug.WriteLine("Went forward");
                        BackStack.Push(CurrentViewModel); //store current vm
                        vm = ForwardStack.Pop();
                        CurrentViewModel = vm;
                        navigated.OnNext(CurrentViewModel);
                        return;
                    }
                }
            }
        }
Пример #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor();

            // Server Side Blazor doesn't register HttpClient by default
            if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped <HttpClient>(s =>
                {
                    // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                    IUriHelper uriHelper = s.GetRequiredService <IUriHelper>();
                    return(new HttpClient
                    {
                        BaseAddress = new Uri(uriHelper.GetBaseUri())
                    });
                });
            }

            services.AddServicesForSampleSites();
        }
        private static void EnsureHttpClient(IServiceCollection aServices)
        {
            var jsRuntimeLocation = new JsRuntimeLocation();

            // Server Side Blazor doesn't register HttpClient by default
            if (jsRuntimeLocation.IsServerSide)
            {
                // Double check that nothing is registered.
                if (!aServices.Any(aServiceDescriptor => aServiceDescriptor.ServiceType == typeof(HttpClient)))
                {
                    // Setup HttpClient for server side in a client side compatible fashion
                    aServices.AddScoped <HttpClient>(aServiceProvider =>
                    {
                        // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                        IUriHelper uriHelper = aServiceProvider.GetRequiredService <IUriHelper>();
                        return(new HttpClient
                        {
                            BaseAddress = new Uri(uriHelper.GetBaseUri())
                        });
                    });
                }
            }
        }
Пример #15
0
 public OidcHttpClient(OidcSettings settings, IUriHelper uriHelper)
 {
     BaseAddress = new Uri(uriHelper.GetBaseUri());
     Timeout     = settings.HttpClientTimeout;
 }
Пример #16
0
 public static void Navigate(this IUriHelper helper, string path)
 {
     helper.NavigateTo($"{helper.GetBaseUri()}{path}");
 }
Пример #17
0
 public GithubUri CreateGithubUriModel(string uri)
 {
     uri = uri.StartsWith(_uriHelper.GetBaseUri()) ? uri : (_uriHelper.GetBaseUri() + uri);
     return(new GithubUri(GetUriParts(uri)));
 }