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

莒县网站设计佛山网站开发招聘

莒县网站设计,佛山网站开发招聘,搭建网站服务器,专业做推广的公司现在依赖注入在.Net里面已经普及#xff0c;自己常写一些简单的demo倒是无所谓#xff0c;但偶尔写一点正式的工程#xff0c;也免不了要使用一下#xff0c;于是总结了一下在WPF里面使用依赖注入。 在写简单Demo时候#xff0c;通常是在MainWindow的构造函数里面直接做初…现在依赖注入在.Net里面已经普及自己常写一些简单的demo倒是无所谓但偶尔写一点正式的工程也免不了要使用一下于是总结了一下在WPF里面使用依赖注入。 在写简单Demo时候通常是在MainWindow的构造函数里面直接做初始化各种变量也都丢在MainWindow类里面。在使用依赖注入后我发现在App里面完成一些初始化内容更合适包括MainWindow也通过容器生成需要注意的是记得把App.xaml中的 StartupUri更改为 Startup并把值改为自定义的启动函数在启动函数里面调用MainWindow的Show方法。 App.xaml.cs using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog; using NLog.Extensions.Logging; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Net.WebSockets; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows;namespace TradeClient {/// summary/// Interaction logic for App.xaml/// /summarypublic partial class App : Application{public App(){LogManager.Configuration.Variables[ProgramName] System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;LogManager.Configuration.Variables[StartTime] DateTime.Now.ToString(yyyyMMdd-HHmmss);var config new ConfigurationBuilder().Build();var servicesCollection new ServiceCollection();servicesCollection.AddLogging(loggingBuilder loggingBuilder.AddNLog(config));servicesCollection.AddSingletonApiDatas();servicesCollection.AddSingletonTradeSpiImpl();servicesCollection.AddSingletonTradeSpiMiddle();servicesCollection.AddSingletonMainWindow();ServiceProvider servicesCollection.BuildServiceProvider();TradeSpiMiddle tradeSpiMiddle ServiceProvider.GetRequiredServiceTradeSpiMiddle();tradeSpiMiddle.InitTradeSpi(ref TradeSpi);int size Marshal.SizeOf(TradeSpi);TradeSpiPoint Marshal.AllocHGlobal(size);Marshal.StructureToPtr(TradeSpi, TradeSpiPoint, true);}public void ApplicationStartUp(object sender, StartupEventArgs e){TradeApi.CreateTradeApi();TradeApi.RegisterSpi(TradeSpiPoint);TradeApi.RegisterFront(127.0.0.1, 10001);TradeApi.Init();MainWindow mainWindow ServiceProvider.GetRequiredServiceMainWindow();mainWindow.Show();}private TradeSpi TradeSpi new();private IntPtr TradeSpiPoint;private ServiceProvider ServiceProvider;} }
http://www.dnsts.com.cn/news/230624.html

相关文章:

  • 网站性能wordpress带搜索主题
  • 选择做网站销售的优势wordpress 自定义侧边栏
  • 百度商桥网站网络营销是什么加什么
  • 网站内链符号运动网站开发的需求分析
  • 国外空间设计网站网页界面设计的概念
  • 私人定制网站建设网站首页网址
  • 电影网站织梦模版外贸都是在哪些网站做
  • 南山模板网站建设公司决定网站打开的速度吗
  • 网站制作app开发公司国外设计网站排名
  • 网站建设的英语wordpress关键词
  • 成都建站推广免费咨询律师在线
  • 在xampp下搭建本地网站seo优化怎么做
  • 织梦做的网站别人提交给我留的言我去哪里看wordpress 拖动分类
  • 兰州快速seo整站优化招商互联网公司排名最新
  • 哈尔滨建站在线咨询wordpress 多人编辑
  • dede 后门暴网站建设网站对服务器有什么要求吗
  • 网站建设的基本流程是什么东莞饭堂承包东莞网站建设
  • 需要做网站的公司有哪些芜湖十大企业排名
  • 网加思维做网站推广怎么创建网站?
  • 微信后台网站建设wordpress分站点
  • 网站免费推广策划方案宁夏建设网站的公司
  • 沈阳高端做网站建设dede 网站入侵
  • 福田建设网站域名解析后怎么建网站
  • 南京快速建设企业网站律师网站模版
  • 个人成立公司怎么做企业网站登陆wordpress忘记密码
  • seo免费自学的网站wordpress网站网速慢
  • 可信赖的手机网站设计产品推广平台
  • 辽宁网站建站优化公司中信建设有限责任公司 联系方式
  • 筑梦网站建设重庆企业网站建设哪家好
  • 自适应网站建设都找全网天下做外贸的网站有那些