小编Hen*_*ous的帖子

Blazor按钮,使用父组件@onclick

是否可以使用父组件方法@onclick,或者我需要从子组件中调用它?

假设我想调用父方法 Foo()。

家长

@page "/"

// Custom component button
<Button Text="Some text" @onclick="Foo" Apperance="@Style.secondary" /> 


@code {
    async Task Foo() 
    {
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

孩子

<button class="btn @_cssClass"><span>@Text</span></button>

@code {
    public enum Style
    {
        primary,
        secondary,
        tertiary,
        danger
    }

    [Parameter]
    public string Text { get; set; }
    [Parameter]
    public Style Apperance { get; set; }
    private string _cssClass { get; set; }

    protected override void OnInitialized()
    {
        _cssClass = Apperance switch
        {
            Style.secondary => "btn--secondary",
            Style.tertiary => "btn--tertiary", …
Run Code Online (Sandbox Code Playgroud)

blazor

7
推荐指数
2
解决办法
1万
查看次数

docker-compose 与rabbitmq

我正在尝试设置一个 docker-compose 脚本 - 启动一个虚拟的:网站、API、网关和 RabbitMQ。(微服务方式)

请求管道:

网站>>网关>>API>>RabbitMQ

我的 docker-compose 看起来像这样:

version: "3.4"

services:
  web:
    image: webclient
    build:
      context: ./WebClient
      dockerfile: dockerfile
    ports:
      - "4000:4000"  
    depends_on:
     - gateway

  gateway:
    image: gatewayapi
    build:
      context: ./GateWayApi
      dockerfile: dockerfile
    ports:
      - "5000:5000"
    depends_on:
     - ordersapi

  ordersapi:
    image: ordersapi
    build:
      context: ./ExampleOrders
      dockerfile: dockerfile
    ports:
      - "6002:6002" 
    depends_on:
      - rabbitmq

  rabbitmq:
    image: rabbitmq:3.7-management
    container_name: rabbitmq
    hostname: rabbitmq
    volumes:
      - rabbitmqdata:/var/lib/rabbitmq
    ports:
      - "7000:15672"
      - "7001:5672"
    environment:
      - RABBITMQ_DEFAULT_USER=rabbitmquser
      - RABBITMQ_DEFAULT_PASS=some_password
Run Code Online (Sandbox Code Playgroud)

这个管道的工作原理:

网站>>网关>>API

我从网站上的 API …

rabbitmq docker .net-core docker-compose

6
推荐指数
1
解决办法
1万
查看次数

用于 OpenStreetMap 的 Xamarin SDK

我试图让概念(C#)为基本图形的地图的证明,作为一种替代谷歌地图的AndriodiOS版设备的- 因为谷歌开始对其 API 收费(据我了解,目前仅影响网络)。

我不需要特别高级,只需一个显示基本地图的 GUI,您可以在其中绘制:

  • 标记
  • 线
  • 多边形

我唯一的要求是它应该是开源的,或者成本尽可能低

到目前为止,我所做的是使用来自http://openstreetmap.org 的数据- 并在单独的 linux 机器上设置一个 tile-server https://switch2osm.org/serving-tiles/

此外,使用 OpenLayers.js 和 Leaflet.js 连接到自定义 tile-server 并满足要求,创建一个简单的 Web 应用程序相当快。

我现在需要做的是为 Xamarin for Android 和 iOS 找到一个免费或便宜的移动 SDK。我设法从我自己的 tile-server 渲染了一张地图,并通过从 2014 年的这个 zip 中引用 .dll 来添加标记(仅针对 Andriod 进行了测试):https : //github.com/OsmSharp/ui/releases/tag/v4.2.0 .723

 using OsmSharp.Android.UI;
 using OsmSharp.Android.UI.Data.SQLite;
 using OsmSharp.Math.Geo;
 using OsmSharp.UI.Map;
 using OsmSharp.UI.Map.Layers;

 [Activity(Label = "@string/app_name", MainLauncher = true)]
 public class MainActivity : AppCompatActivity …
Run Code Online (Sandbox Code Playgroud)

gis openstreetmap xamarin

5
推荐指数
0
解决办法
3734
查看次数

添加Azure AD身份验证时出现CORS错误

尝试将Azure AD身份验证添加到具有.net core 2.1后端的Angular 7 Webapp中。

但是,我在请求期间收到CORS错误。

“ 从来源” https://访问位于' https://login.microsoftonline.com/ .......(从' https:// localhost:5001 / api / auth / login ' 重定向)的XMLHttpRequest 本地主机:5001 '已被CORS策略阻止:所请求的资源上没有'Access-Control-Allow-Origin'标头。”

因此,我尝试在启动管道中添加一些CORS策略。

启动文件

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }    

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(config => config
             .AddPolicy("SiteCorsPolicy", builder => builder
               .AllowAnyHeader()
               .AllowAnyMethod()
               .AllowAnyOrigin()
               .AllowCredentials()
              )
           ); // <--- CORS policy - allow all for now

            services.AddAuthentication(options =>
            {
                options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
                options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; …
Run Code Online (Sandbox Code Playgroud)

azure-active-directory angular .net-core-2.1 angular7

5
推荐指数
1
解决办法
2968
查看次数