예제 #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)));
 }