小编Edw*_*win的帖子

更改文本框的文本时执行方法

我的界面中有这些文本框:

图片

其中Total和Change框是只读的.我的问题是,当用户输入付款时,如何执行计算变更的方法?

有界付款文本框是这样的:

private decimal _cartPayment;
public decimal CartPayment {
    get { return _cartPayment; }
    set { 
    _cartPayment = value;
    //this.NotifyPropertyChanged("CartPayment");
    }
}
Run Code Online (Sandbox Code Playgroud)

我的XAML如下:

<TextBox Text="{Binding Path=CartPayment, Mode=TwoWay}" />
Run Code Online (Sandbox Code Playgroud)

我的ViewModel已INotifyPropertyChanged实现,但我不知道如何从这里开始

c# wpf mvvm

5
推荐指数
2
解决办法
6405
查看次数

Laravel 5.5带松弛的按需通知

根据此页面,我们可以根据需要发送通知,而无需通过模型.我如何使用松弛做同样的事情?

我想做这样的事情:

$emailAddress = 'my email address';
Notification::route('mail', $emailAddress)
            ->route('slack', 'what do I put here?')
            ->notify(new TestNotification());
Run Code Online (Sandbox Code Playgroud)

代码在没有slack线的情况下工作.

编辑:此StackOverflow问题使用按需方法

slack laravel-5.5

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

表列名称设计

假设我有以下表格:CustomerStaff.

Customer (CusID, CusName, CusAddres, CusGender)
Staff (StaID, StaName, StaAddress, StaGender)
Run Code Online (Sandbox Code Playgroud)

VS

Customer(ID, Name, Address, Gender)
Staff(ID, Name, Address, Gender)
Run Code Online (Sandbox Code Playgroud)

哪种设计更受欢迎?为什么?

database database-design

3
推荐指数
1
解决办法
1017
查看次数

ObservableCollection.CollectionChanged没有触发

我有以下界面:

数据网格

当一个项目被添加到其中时DataGrid,Total column将根据(价格*数量)更新,并且总数TextBox也将具有添加的所有行的总数.

但是,当我更改一行的数量时,Total column更新,但总数TextBox没有.

这是我的代码,提前谢谢.

 public partial class pgCheckout : Page {

    ObservableCollection<SaleItem> items = new ObservableCollection<SaleItem>();

    public pgCheckout() {
        InitializeComponent();
        dgItems.ItemsSource = items;
        dgItems.Loaded += SetMinWidths;
        items.CollectionChanged += setTotal;
    }

    public void setTotal(object source, EventArgs e) {
        decimal total = 0;
        foreach(SaleItem i in items) {
            total += i.Total;
        }

        txtTotal.Text = total.ToString();
    }


    public void SetMinWidths(object source, EventArgs e) {
        foreach (var column in dgItems.Columns) {
            if …
Run Code Online (Sandbox Code Playgroud)

c# wpf datagrid observablecollection

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

NestJS HttpService 调用多个端点

我通常是一个 PHP 开发人员,几乎没有使用 javascript/typescript 的经验。刚开始使用 NestJS - 我想要一个端点,该端点返回requisitions通过其端点从另一个系统检索到的列表。

粗略的想法:

  1. 使用凭据调用登录端点
  2. requisition使用来自登录端点的令牌调用列表端点
  3. 返回结果

我已经尝试过像这样调用端点:

const url ='https://the-requisition-endpoint';
const config: AxiosRequestConfig = {
      headers: {
        'Accept': 'application/json',
        'Authorization': 'a_hard_coded_token_string' // hard coded for experimentation
      }
    };
let result = this.httpService.get(url, config);
result.subscribe(response =>
  console.log(response.data);
});

Run Code Online (Sandbox Code Playgroud)

现在我需要更改它,以便令牌不被硬编码 - 使用来自登录端点的令牌。

我不确定如何强制仅在登录端点返回令牌后才调用请求端点。我搜索并发现 aPromise.all()调用的函数zip可能会有所帮助,但我不知道如何使其工作。

typescript axios nestjs

3
推荐指数
1
解决办法
2560
查看次数

我能正确理解装饰器模式吗?

我正在学习装饰模式.我写了这个程序来测试我的知识.我做对了吗?

public interface Logger {
    void log(String msg);
}

public class BasicLogger implements Logger {

    @Override
    public void log(String msg) {
        System.out.println("BasicLogger: " + msg);
    }
}
Run Code Online (Sandbox Code Playgroud)

这里是我开始感到困惑的地方,如果我要在HTMLLogger课程中覆盖它,那么装饰器中的logger.log(msg)有什么意义呢?

public class LoggerDecorator implements Logger {
    Logger logger;
    public LoggerDecorator(Logger logger) {
        this.logger = logger;
    }

    @Override
    public void log(String msg) {
        logger.log(msg);
    }
}
Run Code Online (Sandbox Code Playgroud)

我甚至支持复制该logger.log(msg);行(或者装饰者有什么)?

public class HTMLLogger extends LoggerDecorator {
    public HTMLLogger(Logger logger) {
        super(logger);
    }

    @Override
    public void log(String msg) {
        logger.log(msg);
        System.out.println("<HTML> HTML Logger" …
Run Code Online (Sandbox Code Playgroud)

java design-patterns decorator

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

使用dplyr按多个组进行汇总

我正在尝试使用dplyr来总结基于2组的数据集:"年"和"区域".这就是数据集的样子:

  Year   Area Num
1 2000 Area 1  99
2 2001 Area 3  85
3 2000 Area 1  60
4 2003 Area 2  90
5 2002 Area 1  40
6 2002 Area 3  30
7 2004 Area 4  10
...
Run Code Online (Sandbox Code Playgroud)

最终结果应如下所示:

  Year    Area Mean
1 2000 Area 1  100
2 2000 Area 2   80
3 2000 Area 3   89
4 2001 Area 1   80
5 2001 Area 2   85
6 2001 Area 3   59
7 2002 Area 1   90
8 …
Run Code Online (Sandbox Code Playgroud)

r

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

Ubuntu 16.04 Xenial中的PHP5.6-dev

我的开发计算机在Ubuntu 16.04上,我们使用php5.6。我按照本指南安装php5.6。

现在,我正在尝试通过PECL安装mongodb PHP驱动程序,但是当我运行时

pecl install mongodb

出现此错误:

Starting to download mongodb-1.1.8.tgz (806,900 bytes)
.....................................................done: 806,900 bytes
360 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize' failed
Run Code Online (Sandbox Code Playgroud)

我通过这个问题发现我必须做

sudo apt-get install php5-dev

但是,php5-dev不再可用,并且显然不包含在ondrej的php5.6 PPA中。

php mongodb

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

NestJS:每个模块导入 HttpModule 的新实例

我的nestjs系统是一个通过API调用连接多个系统的系统。

对于每个系统,我创建了一个模块来处理它们的进程。这些模块中的每一个都导入HttpModule.

我想为每个模块的 HttpModule 都有单独的 Axios 拦截器。

这是我测试功能的尝试:

a.module.ts

@Module({
  imports: [
    HttpModule,
    // Other imports
  ],
  // controllers, providers and exports here
})
export class ModuleA implements OnModuleInit {
  constructor(private readonly httpService: HttpService) { }
  public onModuleInit() {
    this.httpService.axiosRef.interceptors.request.use(async (config: Axios.AxiosRequestConfig) => {
      console.log('Module A Interceptor');    
      return config;
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

模块 B 的模块类类似,但调用中的消息不同console.log

我尝试使用模块 B 中的服务对系统 B 进行 http 调用,但两条消息都显示在控制台中。

我认为http模块是整个系统中的单例,那么如何HttpModule为模块A和模块B单独实例化呢?

typescript axios nestjs

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

Automapper 不适用于列表?

我有两个班级,SaleSaleDTO.

当我使用 automapper 映射这两个类的对象时,它将起作用。

但是,如果我这样做:

List<Sale> s = GetSalesFromDatabaseMethod();
List<SaleDTO> sa = Mapping.Map<List<Sale>, List<SaleDTO>>(s);
Run Code Online (Sandbox Code Playgroud)

sa会变成空的。难道我做错了什么?

Map方法基本上是映射的快捷方式:

public static H Map<T, H>(T i) {
    Mapper.CreateMap<T, H>();
    return Mapper.Map<T, H>(i);
}
Run Code Online (Sandbox Code Playgroud)

c# automapper

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

文本框绑定属性值不会立即更新

我有一个文本框绑定到这样的属性ItemID.

private string _itemID;
public string ItemID {
    get { return _itemID; }
    set { 
        _itemID = value;
    }
}
Run Code Online (Sandbox Code Playgroud)

文本框的XAML如下:

<TextBox Text="{Binding Path=ItemID, Mode=TwoWay}" Name="txtItemID" />
Run Code Online (Sandbox Code Playgroud)

问题是,ItemID当我输入时,值不立即更新,
导致Add按钮被禁用(命令),直到我通过按Tab键失去文本框的焦点.

c# wpf mvvm

0
推荐指数
1
解决办法
245
查看次数