static void bgwChannel_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Channel.Channel objChannel = (Channel.Channel)e.Result; IProtocal objChannelProtocal = (IProtocal)objChannel.GetProtocal(); objChannelProtocal.SendMsgEvent += objChannelProtocal_SendMsgEvent; objChannelProtocal.StartCreateData(); }
public static Channel CreateChannel(string strChannelName) { string strAssemblyName = Assembly.GetExecutingAssembly().Location.Substring(Assembly.GetExecutingAssembly().Location.LastIndexOf("\\")); Configuration config = ConfOperator.GetConfig(strAssemblyName); Channel objChannel = new Channel(strChannelName); string strProtocalName = GetProtocalName(config, strChannelName); // 根据配置文件中的协议名称动态加载同名的dll,利用反射生成同名的协议类 string strDLLPath = ConfOperator.GetPath(config.AppSettings.Settings["DLLPath"].Value) + "\\" + strProtocalName + ".dll"; Assembly objAssembly = Assembly.LoadFrom(strDLLPath); Type objProtocalType = (from g in objAssembly.GetTypes() where g.Name == strProtocalName select g).First(); IProtocal objProtocal = Activator.CreateInstance(objProtocalType) as IProtocal; objChannel.SetProtocal(objProtocal); return(objChannel); }
static void Test4() { var builder = new ContainerBuilder(); builder.RegisterModule(new LogModule()); builder.Register(c => new ProtocalV1()).As <IProtocal>().As <ITest>().ExternallyOwned(); var container = builder.Build(); var watch = Stopwatch.StartNew(); IProtocal d = null; for (int i = 0; i < 1000000; i++) { d = container.Resolve <IProtocal>(); } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); Console.ReadLine(); string s = string.Empty; }
public static void NavigateToPage(String panelName, String pageName, Boolean isStacked) { PageDataExchange context = PageDataExchange.getInstance(); if (context.IsPageLoaded(pageName)) { //prtocal.navigateToPage(panelName, pageName); return; } IProtocal prtocal = MainWindow.getProtocalInstance(); prtocal.navigateToPage(panelName, pageName); if (sPageNameMaps == null) { InitPageNamePathMaps(); } String path; sPageNameMaps.TryGetValue(pageName, out path); if (path != null) { context.CommandObserver(PageStatus.TAG, PageStatus.PATH, path); } if (panelName.Equals(MainWindow.sFrameReportName)) { if (isStacked && !String.IsNullOrEmpty(sCurrentPath)) { if (ToolbarParameter.sBackPageStack.Count == 0) { ToolbarParameter.sBackPageStack.Push(sCurrentPath); } else if (!sCurrentPath.Equals(ToolbarParameter.sBackPageStack.Peek())) { ToolbarParameter.sBackPageStack.Push(sCurrentPath); } } sCurrentPath = pageName; } }
public MainWindow() { InitializeComponent(); mGlobalWindow = this; mAdsClient = new TcAdsClient(); menu.RegisterObeserver(this); sRedLight = new BitmapImage(new Uri("/image/debug_light_red.png", UriKind.Relative)); sGreenLight = new BitmapImage(new Uri("/image/debug_light_green.png", UriKind.Relative)); sDisableLight = new BitmapImage(new Uri("/image/debug_light_disable.png", UriKind.Relative)); sEnableLight = new BitmapImage(new Uri("/image/debug_light_enable.png", UriKind.Relative)); sSwitchOn = new BitmapImage(new Uri("/image/SwitchOn.bmp", UriKind.Relative)); sSwitchOff = new BitmapImage(new Uri("/image/SwitchOff.bmp", UriKind.Relative)); tmUserLogout.Tick += new EventHandler(tmLogout_Tick); tmUserLogout.Interval = TimeSpan.FromSeconds(300); InitBeckHoff(); }
public ProtocalViewModel(IProtocal protocal) : this() { _protocal = protocal; _kvsgs = new List <ProtocalKvSg>(); ProtocalKVViewModels = new ObservableCollection <ProtocalKVViewModel>(); ProtocalMonitorViewModels = new ObservableCollection <ProtocalMonitorViewModel>(); var protocalKvs = protocal.GetProtocalSetting().PluginKVs; var protocalMonitors = protocal.GetProtocalSetting().PluginMonitors; _protocalTitle = protocal.GetProtocalSetting().Title; var tempKvsgs = _repo.GetProtocalKvSgs(_hostConfig.MinePluginConfig.Id.ToString(), _protocalTitle); if (tempKvsgs != null) { _kvsgs.AddRange(tempKvsgs); } foreach (var item in protocalKvs) { if (_kvsgs.Exists(p => p.Key == item.Key)) { item.Value = _kvsgs.FirstOrDefault(p => p.Key == item.Key).Value; } //添加配置信息 var kvm = new ProtocalKVViewModel(item); //Initialize ProtocalKVs ProtocalKVViewModels.Add(kvm); kvm.PropertyChanged += Kvm_PropertyChanged; } //Initialize Database DatabaseViewModel = new DatabaseViewModel(_protocalTitle); SelectedPluginMonitorVm = new ProtocalMonitorViewModel(protocal.GetProtocalSetting().PluginMonitors.FirstOrDefault()); IsEnable = _repo.GetProtocalEnable(_hostConfig.MinePluginConfig.Id.ToString(), _protocalTitle); SendMessage(); }
public void SetProtocal(IProtocal objProtocal) { m_objProtocal = objProtocal; }
public static BeckHoff GetBeckHoffInstance() { IProtocal protocal = MainWindow.getProtocalInstance(); return(protocal.GetBeckHoff()); }
static void objChannelProtocal_SendMsgEvent(IProtocal sender, SendMsgEventArgs e) { Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + e.StrMsg); }