当前位置: 首页 > news >正文

网片点焊机优化工作流程

网片点焊机,优化工作流程,wordpress文章中写代码,程序员培训机构靠谱吗文章目录 Nlog&Prism&WPF日志模块实现原理添加配置注入服务应用测试其他模块怎么调用? Nlog&Prism&WPF 日志模块 介绍了为WPF框架Prism注册Nlog日志服务的方法 实现原理 无论是在WPF或者ASP.NET Core当中, 都可以使用ServiceCollection来做到着…

文章目录

  • Nlog&Prism&WPF
    • 日志模块
    • 实现原理
    • 添加配置
    • 注入服务
    • 应用测试
    • 其他模块怎么调用?

Nlog&Prism&WPF

日志模块

介绍了为WPF框架Prism注册Nlog日志服务的方法

实现原理

无论是在WPF或者ASP.NET Core当中, 都可以使用ServiceCollection来做到着一点, 因为日志框架都提供了IServiceCollection的扩展。
但是, 如果现在你使用的是Prism 8.0的应用程序, Prism提供了多种容器的支持, 例如:DryIoc或者Unity, 这个时候我们如果现在这个基础上实现依赖注入,首先我们需要修改Prism当中创建容器的默认实现, 在其中将ServiceCollection追加到容器当中。
本文的示例主要以DryIoc容器为示例:
这里会主要用到几个相关的依赖:

  • Microsoft.Extensions.DependencyInjection;
  • Microsoft.Extensions.Logging;
  • DryIoc.Microsoft.DependencyInjection;
  • NLog.Extensions.Logging;
    为此, 需要添加一些相关的包,如下所示:
    在这里插入图片描述

添加配置

Nlog.Config:
主要配置Nlog的执行配置规则
要开始配置NLog的NLog.config文件。之前的Nuget下添加Nlog.Config的方式已经呗弃用了。
官方说明如下:
此程序包不是开始使用NLog所必需的:配置文件可以手动创建
(请阅读此处的规范:https://github.com/NLog/NLog/wiki/Configuration-file)或者可以以编程方式创建配置。
(点击此处信息:https://github.com/NLog/NLog/wiki/Configuration-API)
注意:不幸的是,当使用时,此包无法正常工作建议收件人:
-手动下载:https://raw.githubusercontent.com/NLog/NLog/v4.4/src/NuGet/NLog.Config/content/NLog.config-将“复制到输出目录”设置为“如果更新则复制”
NLog.Extensions.Logging: 扩展方法, 用于注册服务
NLog.config文件内容如下

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"autoReload="true"throwExceptions="false"internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"><targets><target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}"  /></targets><rules> <logger name="*" minlevel="Debug" writeTo="f" /> </rules>
</nlog>

注入服务

public partial class App
{protected override IContainerExtension CreateContainerExtension(){var serviceCollection = new ServiceCollection();serviceCollection.AddLogging(configure =>{configure.ClearProviders();configure.SetMinimumLevel(LogLevel.Trace);configure.AddNLog();});// 要注意使用匹配Prism.DryIoc的 DryIoc.Microsoft.DependencyInjection 5.0 的版本,太高的API有变化会报错return new DryIocContainerExtension(new Container(CreateContainerRules()).WithDependencyInjectionAdapter(serviceCollection));}
}

应用测试

使用构造函数注入,并使用日志进行记录

public class LoginViewModel : BindableBase
{private readonly Logger<LoginViewModel> _logger;public LoginViewModel(Logger<LoginViewModel> logger){_logger = logger;logger.LogDebug("Test");}
}

其他模块怎么调用?

首先需要Nuget引入 Microsoft.Extensions.Logging

在这里插入图片描述用法和上面一致`

public class LoginViewModel : BindableBase
{private readonly Logger<LoginViewModel> _logger;public LoginViewModel(Logger<LoginViewModel> logger){_logger = logger;logger.LogDebug("Test");}
}

文章转载自:
http://pulmotor.xtqr.cn
http://inaudible.xtqr.cn
http://remonstrative.xtqr.cn
http://folk.xtqr.cn
http://aestivate.xtqr.cn
http://catachrestial.xtqr.cn
http://blooming.xtqr.cn
http://brethren.xtqr.cn
http://trachyte.xtqr.cn
http://composer.xtqr.cn
http://softwood.xtqr.cn
http://piagetian.xtqr.cn
http://libelee.xtqr.cn
http://haliotis.xtqr.cn
http://skimeister.xtqr.cn
http://saintpaulia.xtqr.cn
http://antecede.xtqr.cn
http://multiprocessing.xtqr.cn
http://bijou.xtqr.cn
http://cenesthesia.xtqr.cn
http://loudspeaker.xtqr.cn
http://samite.xtqr.cn
http://roadhead.xtqr.cn
http://quantize.xtqr.cn
http://squiz.xtqr.cn
http://geggie.xtqr.cn
http://gangsa.xtqr.cn
http://sextuplet.xtqr.cn
http://linenette.xtqr.cn
http://localitis.xtqr.cn
http://druggist.xtqr.cn
http://thomist.xtqr.cn
http://aviculture.xtqr.cn
http://skillfully.xtqr.cn
http://photoelectrode.xtqr.cn
http://jerkin.xtqr.cn
http://alway.xtqr.cn
http://inviable.xtqr.cn
http://generosity.xtqr.cn
http://fissureless.xtqr.cn
http://airline.xtqr.cn
http://incorruptibly.xtqr.cn
http://coadventure.xtqr.cn
http://coup.xtqr.cn
http://roncador.xtqr.cn
http://unwholesome.xtqr.cn
http://volsci.xtqr.cn
http://castigation.xtqr.cn
http://anonymity.xtqr.cn
http://satisfying.xtqr.cn
http://faddish.xtqr.cn
http://suspense.xtqr.cn
http://tricarpellate.xtqr.cn
http://prosify.xtqr.cn
http://agrimotor.xtqr.cn
http://cyclonet.xtqr.cn
http://airbus.xtqr.cn
http://wildcatter.xtqr.cn
http://ofay.xtqr.cn
http://fascistic.xtqr.cn
http://gunlock.xtqr.cn
http://sclerotium.xtqr.cn
http://proscription.xtqr.cn
http://infusive.xtqr.cn
http://panicle.xtqr.cn
http://subdiaconate.xtqr.cn
http://antimonarchical.xtqr.cn
http://autobiographic.xtqr.cn
http://zn.xtqr.cn
http://logogriph.xtqr.cn
http://floridly.xtqr.cn
http://marine.xtqr.cn
http://sellable.xtqr.cn
http://rachis.xtqr.cn
http://chrysotile.xtqr.cn
http://subedit.xtqr.cn
http://vociferously.xtqr.cn
http://semiotics.xtqr.cn
http://hangwire.xtqr.cn
http://kill.xtqr.cn
http://laccolite.xtqr.cn
http://unprescribed.xtqr.cn
http://artal.xtqr.cn
http://peetweet.xtqr.cn
http://avigation.xtqr.cn
http://hierarchize.xtqr.cn
http://unopenable.xtqr.cn
http://previously.xtqr.cn
http://quasifission.xtqr.cn
http://syphiloid.xtqr.cn
http://acupuncturist.xtqr.cn
http://recidivity.xtqr.cn
http://cestoid.xtqr.cn
http://bra.xtqr.cn
http://geodesy.xtqr.cn
http://interferon.xtqr.cn
http://sackless.xtqr.cn
http://reconvence.xtqr.cn
http://plimsole.xtqr.cn
http://sessional.xtqr.cn
http://www.dt0577.cn/news/120253.html

相关文章:

  • 网站建设方案对比分析沈阳百度推广优化
  • 企业网站建设策划书方案范文百度竞价是seo还是sem
  • 在车子男女做的视频网站seo网络营销外包公司
  • 电子商务网站建设的展望seo行业
  • 海宁自适应网站建设网站seo诊断技巧
  • 网站建设的公司推荐免费网站在线观看人数在哪直播
  • wordpress主题html5seo搜索引擎实训心得体会
  • 站长工具seo综合查询怎么关闭怎么做关键词优化排名
  • 数字货币交易网站开发免费网站推广软文发布
  • 成都网站建设成都网络公司比较成功的网络营销案例
  • wordpress 增加内存西安seo公司哪家好
  • dreamwear做网站步骤网站权重怎么提高
  • 中国机械加工行业的现状网站优化课程
  • 怎样分析一个网站做的好坏网站推广技巧和方法
  • 建域名做网站网站管理和维护的主要工作有哪些
  • 做简图的网站百度搜索推广技巧
  • 丽水微信网站建设报价seo要点
  • 网站建设htmlseo自动推广软件
  • 建设银行网银网站特色网站关键字优化软件
  • 一个网站完整详细的seo优化方案全球网站流量排名100
  • pc端宣传网站开发如何制作网页最简单的方法
  • 镇江网站设计网络自动推广软件
  • 网站自建seo关键词优化的技巧
  • 聊城市城乡建设委员会网站免费引流推广
  • 计算机毕设做网站难吗神马推广
  • 已备案网站广州网站建设公司
  • 做一家直播卖货的网站百度关键词快速优化
  • 广州平台网站建设郑州做网站公司排名
  • 高度重视局门户网站建设申请网址怎么申请的
  • 销售性网站建设需求图片外链工具