节点与节点之间的通信 c#_节点,开发与生产之间的区别

节点与节点之间的通信 c#

You can have different configurations for production and development environments.

您可以为生产和开发环境使用不同的配置。

Node assumes it’s always running in a development environment. You can signal Node.js that you are running in production by setting the NODE_ENV=production environment variable.

Node假定它始终在开发环境中运行。 您可以通过设置NODE_ENV=production环境变量来向Node.js发出正在生产中运行的信号。

This is usually done by executing the command

通常通过执行命令来完成

export NODE_ENV=production

in the shell, but it’s better to put it in your shell configuration file (e.g. .bash_profile with the Bash shell) because otherwise the setting does not persist in case of a system restart.

在shell中,但是最好将其放入您的shell配置文件(例如,带有Bash shell的.bash_profile )中,因为否则在系统重启时该设置将不会保留。

You can also apply the environment variable by prepending it to your application initialization command:

您还可以通过将环境变量放在应用程序初始化命令之前来应用它:

NODE_ENV=production node app.js

This environment variable is a convention that is widely used in external libraries as well.

此环境变量是一个约定,在外部库中也广泛使用。

Setting the environment to production generally ensures that

设置production环境通常可以确保

  • logging is kept to a minimum, essential level

    日志记录保持在最低水平
  • more caching levels take place to optimize performance

    发生更多的缓存级别以优化性能

For example Pug, the templating library used by Express, compiles in debug mode if NODE_ENV is not set to production. Express views are compiled in every request in development mode, while in production they are cached. There are many more examples.

例如,如果未将NODE_ENV设置为production ,则Express使用的模板库Pug会以调试模式进行编译。 Express视图在开发模式下的每个请求中都进行编译,而在生产环境中则将其缓存。 还有更多示例。

Express provides configuration hooks specific to the environment, which are automatically called based on the NODE_ENV variable value:

Express提供了特定于环境的配置挂钩,这些挂钩根据NODE_ENV变量值自动调用:

app.configure('development', () => {
  //...
})
app.configure('production', () => {
  //...
})
app.configure('production', 'staging', () => {
  //...
})

For example you can use this to set different error handlers for different mode:

例如,您可以使用它为不同的模式设置不同的错误处理程序:

app.configure('development', () => {
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
})

app.configure('production', () => {
  app.use(express.errorHandler())
})

翻译自: https://flaviocopes.com/node-difference-dev-prod/

节点与节点之间的通信 c#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C#中的TreeView控件可以通过拖拽节点的方式来实现节点的移动和排序。在TreeView控件上启用节点拖拽功能需要设置AllowDrop属性为true,然后通过处理控件的DragEnter、DragOver和DragDrop事件来实现节点的拖拽。 具体实现步骤如下: 1. 设置TreeView控件的AllowDrop属性为true,启用拖拽功能。 2. 处理TreeView控件的DragEnter事件,在该事件中设置允许拖拽的效果。 3. 处理TreeView控件的DragOver事件,在该事件中实现节点拖拽时的效果。 4. 处理TreeView控件的DragDrop事件,在该事件中实现节点拖拽完成后的效果。 以下是一个简单的实现代码示例: ``` private void treeView1_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Move; } private void treeView1_DragOver(object sender, DragEventArgs e) { Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y)); TreeNode targetNode = treeView1.GetNodeAt(targetPoint); if (targetNode != null) { TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); if (!draggedNode.Equals(targetNode) && !ContainsNode(draggedNode, targetNode)) { targetNode.BackColor = Color.LightGreen; e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } } } private void treeView1_DragDrop(object sender, DragEventArgs e) { Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y)); TreeNode targetNode = treeView1.GetNodeAt(targetPoint); TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); if (targetNode != null && !draggedNode.Equals(targetNode) && !ContainsNode(draggedNode, targetNode)) { draggedNode.Remove(); targetNode.Nodes.Add(draggedNode); targetNode.BackColor = Color.White; } } private bool ContainsNode(TreeNode node1, TreeNode node2) { if (node2.Parent == null) return false; if (node2.Parent.Equals(node1)) return true; return ContainsNode(node1, node2.Parent); } ``` 注意:以上代码仅提供参考,实际使用中还需要根据具体需求进行适当的调整和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值