public SVM_Matlab(string path, double sigma, double gamma, Kernel kernel, ImageVector[] goodImages, ImageVector[] badImages) { type = "SVM"; this.goodImages = goodImages; this.badImages = badImages; learnedTrue = new bool[goodImages.Length]; learnedFalse = new bool[badImages.Length]; confidenceTrue = new double[goodImages.Length]; confidenceFalse = new double[badImages.Length]; restartTest(); userPath = path + "\\SVM_" + getKernel(kernel) + "_" + sigma; resultPath = userPath + "\\" + sigma + "_" + gamma; learn = GetLearnCommand(userPath, sigma, gamma, kernel); learn_Test = GetLearnCommand_Test(userPath, sigma, gamma, kernel,goodImages[0].getNumOfParameters()); decide = GetDecideCommand(userPath, kernel); decide_Test = GetDecideCommand_Test(userPath, kernel, goodImages[0].getNumOfParameters()); matlab = new MLApp.MLApp(); cd = "cd " + smartAlbum.getMatlabDirectory(); matlab.Execute(cd); }
public override void Compile(Kernel k) { Symbol returnSymbol = k.Lookup("+return"); if (this.Value != null) this.Value.Compile(k); else k.Emit(Opcode.PUSHNIL); var rvn = new RetrieveVariableNode(-1, -1) {VariableName = "+return"}; rvn.PrePass(k); rvn.PreCompile(k); rvn.Compile(k); uint mem = 0; Scope current = k.CurrentScope; while(current != returnSymbol.SScope) { mem += current.MemorySpace; current.PopMemory(k, false); current = current.Parent; } mem += current.MemorySpace; current.PopMemory(k, false); k.EmitPush(mem + "u").Comment = "deallocate function memory"; k.Emit(Opcode.DEALLOC); k.Emit(Opcode.JUMP).SetDebug(File, Line, Column, DebugType.Return, ""); }
public override void FinishedLaunching(UIApplication app) { Instance = this; Application application = new Application (); kernel = new Kernel (application); kernel.Run (); }
public KNN_SVM(string path, double sigma, double gamma, Kernel kernel, int k, ImageVector[] goodImages, ImageVector[] badImages) { type = "KNN & SVM"; svm = new SVM_Matlab(path, sigma, gamma, (SVM_Matlab.Kernel)kernel, goodImages, badImages); knn = new KNN_Matlab(path, k, goodImages, badImages); totalImages = 0; this.goodImages = goodImages; this.badImages = badImages; learnedTrue = new bool[goodImages.Length]; learnedFalse = new bool[badImages.Length]; restartTest(); userPath = path + "\\KNN_SVM"; resultPath = userPath + "\\sigma_" + sigma + "_gamma_" + gamma; learn = GetLearnCommand(userPath, sigma, gamma, kernel); decideSVM = GetDecideCommandSVM(userPath, kernel); decideKNN = GetDecideCommandKNN(userPath, k); matlab = new MLApp.MLApp(); cd = "cd " + smartAlbum.getMatlabDirectory(); matlab.Execute(cd); }
public override void PreCompile(Kernel k) { foreach (ICompileNode node in this.Arguments) { node.PreCompile(k); } }
//ACCEPT //Ver5.9.2 Java fix //public SockTcp(Kernel kernel, Socket s) : base(kernel){ public SockTcp(Kernel kernel, Ssl ssl, Socket s) : base(kernel) { //************************************************ //selector/channel生成 //************************************************ _socket = s; _ssl = ssl; //既に接続を完了している if (_ssl != null){ //SSL通信の場合は、SSLのネゴシエーションが行われる _oneSsl = _ssl.CreateServerStream(_socket); if (_oneSsl == null) { SetError("_ssl.CreateServerStream() faild"); return; } } //************************************************ //ここまでくると接続が完了している //************************************************ //Set(SockState.Connect, (InetSocketAddress) channel.socket().getLocalSocketAddress(), (InetSocketAddress) channel.socket().getRemoteSocketAddress()); //************************************************ //read待機 //************************************************ BeginReceive(); //接続完了処理(受信待機開始) }
public TraceDlg(Kernel kernel) { InitializeComponent(); _kernel = kernel; _colJp.Add("送受"); _colJp.Add("スレッドID"); _colJp.Add("アドレス"); _colJp.Add("データ"); _colEn.Add("Direction"); _colEn.Add("ThreadID"); _colEn.Add("Address"); _colEn.Add("Data"); //オーナー描画 foreach (var t in _colJp){ listViewTrace.Columns.Add(t); } listViewTrace.Columns[2].Width = 100; listViewTrace.Columns[3].Width = 500; _timer = new Timer{Enabled = true, Interval = 100}; _timer.Tick += TimerTick; kernel.WindowSize.Read(this);//ウインドサイズの復元 kernel.WindowSize.Read(listViewTrace);//カラム幅の復元 }
public static void Stop() { if(null != _Kernel) { _Kernel.Dispose(); _Kernel = null; } }
public static void RunKernel( Context context, Device device, Kernel kernel, int size, IEnumerable<int> indicesOfPinnedArraysToReadBack, params IPinnedArrayOfStruct[] pinnedArrays) { ErrorCode errorCode; var commandQueue = Cl.CreateCommandQueue(context, device, CommandQueueProperties.ProfilingEnable, out errorCode); errorCode.Check("CreateCommandQueue"); var setKernelArgErrorCodes = pinnedArrays.Select((pinnedArray, index) => { var ec = Cl.SetKernelArg(kernel, (uint) index, pinnedArray.Buffer); ec.Check($"SetKernelArg({index})"); return ec; }); Debug.Assert(setKernelArgErrorCodes.All(e => e == ErrorCode.Success)); var globalWorkSize = new[] {(IntPtr) size}; Event e1; errorCode = Cl.EnqueueNDRangeKernel( commandQueue, kernel, (uint)globalWorkSize.Length, // workDim null, // globalWorkOffset globalWorkSize, null, // localWorkSize 0, // numEventsInWaitList null, // eventWaitList out e1); errorCode.Check("EnqueueNDRangeKernel"); var eventsToWaitFor = new List<Event>(); foreach (var index in indicesOfPinnedArraysToReadBack) { Event e2; errorCode = Cl.EnqueueReadBuffer( commandQueue, pinnedArrays[index].Buffer, Bool.False, // blockingRead IntPtr.Zero, // offsetInBytes (IntPtr)pinnedArrays[index].Size, pinnedArrays[index].Handle, 0, // numEventsInWaitList null, // eventWaitList out e2); errorCode.Check("EnqueueReadBuffer"); eventsToWaitFor.Add(e2); } var evs = eventsToWaitFor.ToArray(); errorCode = Cl.WaitForEvents((uint)evs.Length, evs); errorCode.Check("WaitForEvents"); }
public override void PreCompile(Kernel k) { if(this.Value != null) { this.Value.PreCompile(k); } }
public static Object CreateInstance(Kernel kernel, string path, string className, Object[] param) { if (File.Exists(path)){ var dllName = Path.GetFileNameWithoutExtension(path); try{ var asm = Assembly.LoadFile(path); if (asm != null){ return asm.CreateInstance(dllName + "." + className, true, BindingFlags.Default, null, param, null, null); } } catch (Exception ex){ //Ver6.1.7 if (ex.InnerException != null) { throw new Exception(ex.InnerException.Message); } var logger = kernel.CreateLogger("CreateInstance", false, null); logger.Set(LogKind.Error, null, 9000051, string.Format("DLL={0} CLASS={1} {2}", dllName, className, ex.Message)); return null; } } return null; }
public override void PreCompile(Kernel k) { foreach (ICompileNode node in this.Values) { node.PrePass(k); } }
public SetupServiceDlg(Kernel kernel) { InitializeComponent(); _setupService = new SetupService(kernel); _kernel = kernel; Text = (kernel.IsJp()) ?"サービス設定ダイアログ":"Setting Service"; groupBoxInstall.Text = (kernel.IsJp()) ? "サービスへのインストール" : "Registration"; buttonInstall.Text = (kernel.IsJp()) ? "登録" : "Install"; buttonUninstall.Text = (kernel.IsJp()) ? "削除" : "Uninstall"; groupBoxStatus.Text = (kernel.IsJp()) ? "状態" : "Service status"; buttonStart.Text = (kernel.IsJp()) ? "開始" : "Start"; buttonStop.Text = (kernel.IsJp()) ? "停止" : "Stop"; buttonRestart.Text = (kernel.IsJp()) ? "再起動" : "Restart"; groupBoxStartupType.Text = (kernel.IsJp()) ? "スタートアップの種類" : "Startup type"; buttonAutomatic.Text = (kernel.IsJp()) ? "自動" : "Auto"; buttonManual.Text = (kernel.IsJp()) ? "手動" : "Manual"; buttonDisable.Text = (kernel.IsJp()) ? "無効" : "Disable"; DispInit(); }
public ExperienceChecker(Kernel kernel) { this.Client = kernel.Client; _Active = false; ExperienceTimer = new Timer(1000, -1); ExperienceTimer.Execute += ExperienceTimer_Execute; }
/// <summary> /// Represents the entry point to the sample application. /// </summary> /// <param name="args">The command line arguments, that were passed to the program. Are not used.</param> public static void Main(string[] args) { // Creates a new Simple IoC kernel Kernel kernel = new Kernel(); // Binds the vehicles to the kernel kernel.Bind<IVehicle>().ToType<Car>(); kernel.Bind<IVehicle>().ToType<Motorcycle>().WhenInjectedInto<SuperCoolPerson>(); // Obviously super cool people drive motorcycles! // Creates some persons Person person = kernel.Resolve<Person>(); Person superCoolPerson = kernel.Resolve<SuperCoolPerson>(); Person namedPerson = kernel.Resolve<NamedPerson>("Bob"); // Prints out the personal information about the persons that were created System.Console.WriteLine(person); System.Console.WriteLine(superCoolPerson); System.Console.WriteLine(namedPerson); // Demonstrates singleton scope, where the resolved instance is always the same kernel.Bind<DateTime>().ToFactory(() => DateTime.UtcNow).InSingletonScope(); System.Console.WriteLine(kernel.Resolve<DateTime>().Ticks); Thread.Sleep(1000); System.Console.WriteLine(kernel.Resolve<DateTime>().Ticks); // Waits for a key stroke, before the application is quit System.Console.WriteLine("Press any key to quit..."); System.Console.ReadKey(); }
public static LogLevel ConvertLogLevel(Kernel.Logging.LogLevel logLevel) { switch (logLevel) { case Kernel.Logging.LogLevel.Debug: return LogLevel.Debug; case Kernel.Logging.LogLevel.Error: return LogLevel.Error; case Kernel.Logging.LogLevel.Fatal: return LogLevel.Fatal; case Kernel.Logging.LogLevel.Information: return LogLevel.Info; case Kernel.Logging.LogLevel.Trace: return LogLevel.Trace; case Kernel.Logging.LogLevel.Warning: return LogLevel.Warn; default: return LogLevel.Off; } }
public override void Compile(Kernel k) { Symbol symbol = k.Lookup(this.VariableName); if(this.Value == null) { k.Emit(Opcode.PUSHNIL).Comment = "set variable to nil"; } else { this.Value.Compile(k); } if (symbol.SScope == k.CurrentScope) { k.EmitPush(symbol.Id.ToString() + "u").Comment = "store into variable " + this.VariableName; k.Emit(Opcode.STLO).SetDebug(File, Line, Column, DebugType.Set, this.VariableName); } else { uint mem = k.CurrentScope.WalkMemoryBack(symbol.SScope); mem -= symbol.Id; k.EmitPush(mem.ToString() + "u").Comment = "store into variable " + this.VariableName; k.Emit(Opcode.STNLO).SetDebug(File, Line, Column, DebugType.Set, this.VariableName); } }
public override void Compile(Kernel k) { k.EmitPush("1u"); k.Emit(Opcode.ALLOC).SetDebug(File, Line, Column, DebugType.Define, this.VariableName); k.CurrentScope.MemorySpace += 1; Symbol symbol = new Symbol() { Name = this.VariableName, SMode = Symbol.Mode.Intern, SType = Symbol.Type.Variable, Id = k.CurrentScope.RequestId() }; k.RegisterSymbol(symbol); if (this.Value == null) { k.Emit(Opcode.PUSHNIL).Comment = "clear memory for variable"; } else { this.Value.Compile(k); } k.EmitPush(symbol.Id.ToString() + "u"); k.Emit(Opcode.STLO).SetDebug(File, Line, Column, DebugType.Set, this.VariableName); }
/// <summary> /// The Init method is called when the plug-in is loaded by MediaBrowser. You should perform all your specific initializations /// here - including adding your theme to the list of available themes. /// </summary> /// <param name="kernel"></param> public override void Init(Kernel kernel) { try { //the AddTheme method will add your theme to the available themes in MediaBrowser. You need to call it and send it //resx references to your mcml pages for the main "Page" selector and the MovieDetailPage for your theme. //The template should have generated some default pages and values for you here but you will need to create all the //specific mcml files for the individual views (or, alternatively, you can reference existing views in MB. kernel.AddTheme("Classic", "resx://Classic/Classic.Resources/Page#PageClassic", "resx://Classic/Classic.Resources/DetailMovieView#ClassicMovieView"); //The AddConfigPanel method will allow you to extend the config page of MediaBrowser with your own options panel. //You must create this as an mcml UI that fits within the standard config panel area. It must take Application and //FocusItem as parameters. The project template should have generated an example ConfigPage.mcml that you can modify //or, if you don't wish to extend the config, remove it and the following call to AddConfigPanel //kernel.AddConfigPanel("Classic Options", "resx://Classic/Classic.Resources/ConfigPanel#ConfigPanel"); //The AddStringData method will allow you to extend the localized strings used by MediaBrowser with your own. //This is useful for adding descriptive text to go along with your theme options. If you don't have any theme- //specific options or other needs to extend the string data, remove the following call. //kernel.StringData.AddStringData(MyStrings.FromFile(MyStrings.GetFileName("Classic-"))); //Tell the log we loaded. Logger.ReportInfo("Classic Theme Loaded."); } catch (Exception ex) { Logger.ReportException("Error adding theme - probably incompatable MB version", ex); } }
public override void Init(Kernel config) { var trailers = new ITunesTrailerFolder(); trailers.Name = "Trailers"; trailers.Path = ""; trailers.Id = TrailersGuid; config.RootFolder.AddVirtualChild(trailers); }
public override void FinishedLaunching(UIApplication app) { Instance = this; application = new Application (); kernel = new Kernel (application); kernel.Run (); application.SupportedOrientation = SUPPORTED_ORIENTATION; }
public override void FinishedLaunching(UIApplication app) { Instance = this; Application application = new Application (); kernel = new Kernel (application); kernel.SplashStream =System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ChangeSplash.DarkC.png"); kernel.Run (); }
public override void Compile(Kernel k) { k.CurrentScope.PushMemory(k); Scope ifScope = k.PushScope(); ifScope.Name = "if" + ifScope.Parent.RequestLabelId(); string trueLabel = "sl_if_" + k.GetScopeName(); string falseLabel = "sl_fe_" + k.GetScopeName(); string endLabel = "sl_fh_" + k.GetScopeName(); this.Check.Compile(k); k.Emit(Opcode.GOTOF, '"' + trueLabel + '"').SetDebug(File, Line, Column, DebugType.Branch, ""); k.Emit(Opcode.GOTO, '"' + falseLabel + '"'); k.Emit(Opcode.LABEL, trueLabel); k.CurrentScope.PushMemory(k); Scope trueScope = k.PushScope(); trueScope.Name = "true"; if (this.BranchTrue != null) this.BranchTrue.Compile(k); k.PopScope(); k.CurrentScope.PopMemory(k); if(this.BranchFalse == null) { k.Emit(Opcode.LABEL, falseLabel).Comment = "no else block, used as end label"; } else if(this.BranchFalse != null) { k.Emit(Opcode.GOTO, '"' + endLabel + '"'); k.Emit(Opcode.LABEL, falseLabel); k.CurrentScope.PushMemory(k); Scope falseScope = k.PushScope(); falseScope.Name = "false"; this.BranchFalse.Compile(k); k.PopScope(); k.CurrentScope.PopMemory(k); k.Emit(Opcode.LABEL, endLabel).Comment = "end if"; } k.PopScope(); k.CurrentScope.PopMemory(k); }
public void Load(Kernel kernel) { kernel.Register<ICompactComponent, CompactComponent>(); kernel.Register<IFunctionComponent, FunctionComponent>(); kernel.Register<IMathComponent, MathComponent>(); kernel.Register<IObjectComponent, ObjectComponent>(); kernel.Register<IStringComponent, StringComponent>(); kernel.Register<Module.Utility>(); }
private OnePage Page1(string name, string title,Kernel kernel) { var onePage = new OnePage(name, title); var key = "dir"; onePage.Add(new OneVal(key, "", Crlf.Nextline, new CtrlFolder(Lang.Value(key),40,kernel))); key = "useDetailsLog"; onePage.Add(new OneVal(key, false, Crlf.Nextline, new CtrlCheckBox((Lang.Value(key))))); return onePage; }
public override void PrePass(Kernel k) { base.PrePass(k); this.Value.Attributes .Check("value"); this.Value.PrePass(k); }
public override void Init(Kernel kernel) { PluginOptions = new PluginConfiguration<PluginOptions>(kernel, this.GetType().Assembly); PluginOptions.Load(); kernel.MetadataProviderFactories.Add(new MetadataProviderFactory(typeof(DvrmsMetadataProvider))); Logger.ReportInfo(Name + " (version " + Version + ") Loaded."); }
public void MapConstructorParamsValid03Params() { Action act = () => Kernel.Map <IAnimal>().To <AnimalDuck>(150, true, DateTime.Now); act.Should().NotThrow("It is a valid map"); }
public void MapConstructorParamsInvalidInvalidParamType() { Action act = () => Kernel.Map <IAnimal>().To <AnimalDuck>(150, "Fail", DateTime.Now); act.Should().Throw <Exception>("It isn't a valid map"); }
public void MapConstructorParamsInvalidWithNoParams() { Action act = () => Kernel.Map <IAnimal>().To <AnimalDuck>(); act.Should().Throw <Exception>("It isn't a valid map"); }
public sceUsbstor_internal(Kernel kernel) : base(kernel) { }
public DataBaseRead() { Kernel.Resolve(this); }
// 1 回の処理 async Task <int> PerformOnceAsync(CancellationToken cancel = default) { CoresRuntimeStat runtimeStat = new CoresRuntimeStat(); runtimeStat.Refresh(); string[]? globalIpList = null; try { globalIpList = (await LocalNet.GetLocalHostPossibleIpAddressListAsync(cancel)).Select(x => x.ToString()).ToArray(); } catch { } InstanceStat stat = new InstanceStat { DaemonName = this.Settings.DaemonName, CommitId = this.Variables.CurrentCommitId, CommitInfo = this.Variables.CurrentCommitInfo, InstanceArguments = this.Variables.CurrentInstanceArguments, RuntimeStat = runtimeStat, EnvInfo = new EnvInfoSnapshot(), StatFlag = this.Variables.StatFlag, TcpIpHostData = LocalNet.GetTcpIpHostDataJsonSafe(true), GlobalIpList = globalIpList, PauseFlag = Variables.PauseFlag, MetaStatusDictionary = GlobalDaemonStateManager.MetaStatusDictionary, DaemonSecret = GlobalDaemonStateManager.DaemonSecret, }; // リクエストメッセージの組立て RequestMsg req = new RequestMsg { AppId = this.Settings.AppId, HostName = this.Settings.HostName, Guid = this.Settings.HostGuid, Stat = stat, }; // サーバーに送付し応答を受信 ResponseMsg res = await Rpc.KeepAliveAsync(req); // 応答メッセージの分析 res.Normalize(); // ローカル IP アドレスを覚える GlobalDaemonStateManager.SetDaemonClientLocalIpAddress(RpcClient.LastLocalIp); // FileBrowser の URL が分かればこれを DaemonCenter に送付する if (GlobalDaemonStateManager.FileBrowserHttpsPortNumber != 0) { IPAddress ip = GlobalDaemonStateManager.DaemonClientLocalIpAddress; string hostname = ip.ToString(); if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { // ipv6 hostname = $"[{hostname}]"; } try { // FQDN を DNS 解決する string?fqdn = req.Stat.TcpIpHostData.FqdnHostName; if (fqdn._IsFilled()) { DnsResponse dnsReply = await LocalNet.QueryDnsAsync(new DnsGetIpQueryParam(fqdn, timeout : Consts.Timeouts.Rapid), cancel); if (dnsReply.IPAddressList.Where(x => x == ip).Any()) { // DNS 解決に成功し、同一の IP アドレスを指していることが分かったので URL には FQDN を埋め込む hostname = fqdn; } } } catch { } // url string url = $"https://{hostname}:{GlobalDaemonStateManager.FileBrowserHttpsPortNumber}/{GlobalDaemonStateManager.DaemonSecret}/"; GlobalDaemonStateManager.MetaStatusDictionary[Consts.DaemonMetaStatKeys.CurrentLogFileBrowserUrl] = url; } else { GlobalDaemonStateManager.MetaStatusDictionary.TryRemove(Consts.DaemonMetaStatKeys.CurrentLogFileBrowserUrl, out _); } if (res.OsRebootRequested) { // OS そのものの再起動が要求されたので再起動を行なう if (Env.IsAdmin) { try { Kernel.RebootOperatingSystemForcefullyDangerous(); } catch { } } } if (res.NextCommitId._IsFilled() || res.NextInstanceArguments._IsFilled() || res.NextPauseFlag != PauseFlag.None || res.RebootRequested) { // 再起動が要求された this.RestartCb(res); return(-1); } // 次回 KeepAlive 間隔の応答 return(res.NextKeepAliveMsec); }
public void ResolveObjectValidUnmapedTypeNoForce() { var animal = Kernel.Resolve <AnimalCat>(true, false); animal.Should().BeNull("There isn't a mapped class, but the kernel wasn't force to resolve"); }
public override void Load() { Kernel.Bind <ProjectDbContext>().To <ProjectDbContext>(); Kernel.Bind <ProjectService>().To <ProjectService>(); }
public CoinKernelViewModel(Guid id) { _id = id; this.AddEnvironmentVariable = new DelegateCommand(() => { VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, new EnvironmentVariable())); }); this.EditEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => { VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, environmentVariable)); }); this.RemoveEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => { this.ShowDialog(message: $"您确定删除环境变量{environmentVariable.Key}吗?", title: "确认", onYes: () => { this.EnvironmentVariables.Remove(environmentVariable); EnvironmentVariables = EnvironmentVariables.ToList(); }, icon: IconConst.IconConfirm); }); this.AddSegment = new DelegateCommand(() => { VirtualRoot.Execute(new InputSegmentEditCommand(this, new InputSegment())); }); this.EditSegment = new DelegateCommand <InputSegment>((segment) => { VirtualRoot.Execute(new InputSegmentEditCommand(this, segment)); }); this.RemoveSegment = new DelegateCommand <InputSegment>((segment) => { this.ShowDialog(message: $"您确定删除片段{segment.Name}吗?", title: "确认", onYes: () => { this.InputSegments.Remove(segment); InputSegments = InputSegments.ToList(); }, icon: IconConst.IconConfirm); }); this.RemoveFileWriter = new DelegateCommand <FileWriterViewModel>((writer) => { this.ShowDialog(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => { this.FileWriterVms.Remove(writer); List <Guid> writerIds = new List <Guid>(this.FileWriterIds); writerIds.Remove(writer.Id); this.FileWriterIds = writerIds; }, icon: IconConst.IconConfirm); }); this.RemoveFragmentWriter = new DelegateCommand <FragmentWriterViewModel>((writer) => { this.ShowDialog(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => { this.FragmentWriterVms.Remove(writer); List <Guid> writerIds = new List <Guid>(this.FragmentWriterIds); writerIds.Remove(writer.Id); this.FragmentWriterIds = writerIds; }, icon: IconConst.IconConfirm); }); this.Save = new DelegateCommand(() => { if (NTMinerRoot.Instance.CoinKernelSet.Contains(this.Id)) { VirtualRoot.Execute(new UpdateCoinKernelCommand(this)); } CloseWindow?.Invoke(); }); this.Edit = new DelegateCommand <FormType?>((formType) => { VirtualRoot.Execute(new CoinKernelEditCommand(formType ?? FormType.Edit, this)); }); this.Remove = new DelegateCommand(() => { if (this.Id == Guid.Empty) { return; } this.ShowDialog(message: $"您确定删除{Kernel.Code}币种内核吗?", title: "确认", onYes: () => { VirtualRoot.Execute(new RemoveCoinKernelCommand(this.Id)); Kernel.OnPropertyChanged(nameof(Kernel.SupportedCoins)); }, icon: IconConst.IconConfirm); }); this.SortUp = new DelegateCommand(() => { CoinKernelViewModel upOne = AppContext.Instance.CoinKernelVms.AllCoinKernels.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber < this.SortNumber); if (upOne != null) { int sortNumber = upOne.SortNumber; upOne.SortNumber = this.SortNumber; VirtualRoot.Execute(new UpdateCoinKernelCommand(upOne)); this.SortNumber = sortNumber; VirtualRoot.Execute(new UpdateCoinKernelCommand(this)); if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm)) { coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels)); } this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels)); AppContext.Instance.CoinVms.OnPropertyChanged(nameof(AppContext.CoinViewModels.MainCoins)); } }); this.SortDown = new DelegateCommand(() => { CoinKernelViewModel nextOne = AppContext.Instance.CoinKernelVms.AllCoinKernels.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber > this.SortNumber); if (nextOne != null) { int sortNumber = nextOne.SortNumber; nextOne.SortNumber = this.SortNumber; VirtualRoot.Execute(new UpdateCoinKernelCommand(nextOne)); this.SortNumber = sortNumber; VirtualRoot.Execute(new UpdateCoinKernelCommand(this)); if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm)) { coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels)); } this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels)); AppContext.Instance.CoinVms.OnPropertyChanged(nameof(AppContext.CoinViewModels.MainCoins)); } }); }
public bool alloc_and_compute_diag(Kernel k, SWIGTYPE_p_double v, int num) { bool ret = modshogunPINVOKE.TanimotoKernelNormalizer_alloc_and_compute_diag(swigCPtr, Kernel.getCPtr(k), SWIGTYPE_p_double.getCPtr(v), num); if (modshogunPINVOKE.SWIGPendingException.Pending) { throw modshogunPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public void ResolveGenericValidNoForceAndNoForce() { var animal01 = Kernel.Resolve <IAnimal>(false, false); animal01.Should().BeNull("There isn't a mapped class, but the Kernel doesn't use cache and doesn't force to resolve"); }
public ObjectEntity(Kernel kernel, int objectId) { Kernel = kernel; ObjectId = objectId; Scaling = new Vector3(1, 1, 1); }
public void MapConstructorParamsValid01Param() { Action act = () => Kernel.Map <IAnimal>().To <AnimalDog>(150); act.Should().NotThrow("It is a valid map"); }
public void ResolveGenericInvalidUnmapedType() { Action act = () => Kernel.Resolve <IAnimal>(); act.Should().Throw <Exception>("There isn't a class mapped for that interface"); }
public void ResolveObjectInvalidUnmapedTypeForce() { Action act = () => Kernel.Resolve <AnimalCat>(); act.Should().Throw <Exception>("There isn't a mapped class"); }
public override void Load() { Bind <ILinqCommandHandler>() .To <LinqCommandHandler>(); Bind <ILinqRequestHandler>() .To <LinqRequestHandler>(); Bind <IProjector>() .To <AutoMapperProjector>(); Bind(typeof(ISingleLinqConvertor <>)) .To(typeof(SingleLinqConvertor <>)); Bind(typeof(IEnumLinqConvertor <>)) .To(typeof(EnumLinqConvertor <>)); //Bind(typeof(INativeSingleLinqConvertor<>)) // .To(typeof(NativeLinqConvertor<>)); //Bind(typeof(INativeEnumLinqConvertor<>)) // .To(typeof(NativeEnumLinqConvertor<>)); //Bind(typeof(IDtoSingleLinqConvertor<>)) // .To(typeof(DtoSingleLinqConvertor<>)); //Bind(typeof(IDtoEnumLinqConvertor<>)) // .To(typeof(DtoEnumLinqConvertor<>)); //Bind(typeof(ISingleLinqConvertor<>)) // .To(typeof(DtoSingleLinqConvertor<>)); //Bind(typeof(IEnumLinqConvertor<>)) // .To(typeof(EnumAutomapperConvertor<>)); Bind(typeof(IPageConvertor <>)) .To(typeof(PageConvertor <>)); //Bind(typeof(IPageConvertor<>)) // .To(typeof(ConventionPageConvertor<>)); //Bind(typeof(IQueryStub<,>)) // .To(typeof(IdQueryStub<,>)); //*** Queries *** // Поиск по Id => IByIdQuery Bind(typeof(IByIdQuery <>)) .To(typeof(ConventionIdQuery <>)); // постраничный вывод по умолчанию для сущностей, помеченных атрибутом EntityMapAttribute var conventionalTypes = GetType().Assembly .GetTypes() .Where(t => t.GetTypeInfo().GetCustomAttribute <EntityMapAttribute>()?.ConventionQuery != null); foreach (Type t in conventionalTypes) { BindPageQuery(t, typeof(ConventionPagedQuery <,>)); } // IQuery Kernel.Bind(x => x.FromThisAssembly() .SelectAllClasses() .InheritedFrom(typeof(IQuery <,>)) .BindAllInterfaces() ); //Commands Kernel.Bind(x => x.FromThisAssembly() .SelectAllClasses() .InheritedFrom(typeof(ICommand <>)) .BindAllInterfaces() ); }
public override void Load() { Kernel.Bind <IFeedbackService>().To <FeedbackService>(); }
public override void Load() { Kernel.Bind <IMailHostSettingsProvider>().To <SmtpHostSettingsProvider>(); }
protected override void AfterContainerCreated() { var host = (IDiagnosticsHost)Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey); diagnostic = host.GetDiagnostic <IAllServicesDiagnostic>(); }
public static ObjectEntity FromSpawnPoint(Kernel kernel, SpawnPoint.Entity spawnPoint) => new ObjectEntity(kernel, spawnPoint.ObjectId) { Position = new Vector3(spawnPoint.PositionX, -spawnPoint.PositionY, -spawnPoint.PositionZ), Rotation = new Vector3(spawnPoint.RotationX, spawnPoint.RotationY, spawnPoint.RotationZ), };
public void MapSimpleInvalidAbstractToInterface() { Action act = () => Kernel.Map <IAnimal>().To <Vehicle>(); act.Should().Throw <Exception>("It isn't a valid map"); }
public void MapSimpleInvalidAbstractToClassThatDoesImplement() { Action act = () => Kernel.Map <Vehicle>().To <AnimalDog>(); act.Should().Throw <Exception>("It isn't a valid map"); }
public KernelTest() { Kernel.Reset(); }
public void MapSimpleInvalidInterfaceToClassThatDoesImplement() { Action act = () => Kernel.Map <IAnimal>().To <VehicleCar>(); act.Should().Throw <Exception>("It isn't a valid map"); }
/// <summary cref="Accelerator.EstimateGroupSizeInternal( /// Kernel, Func{int, int}, int, out int)"/> protected override int EstimateGroupSizeInternal( Kernel kernel, Func <int, int> computeSharedMemorySize, int maxGroupSize, out int minGridSize) => throw new NotSupportedException();
public override void Load() { Kernel.Bind <INordVPNService>().To <NordVPNService>(); }
public override void Load() { var configuration = new ConfigurationService(); Bind <ConfigurationService>() .ToMethod(context => configuration); Bind <IAppConfiguration>() .ToMethod(context => configuration.Current); Bind <PoliteCaptcha.IConfigurationSource>() .ToMethod(context => configuration); Bind <Lucene.Net.Store.Directory>() .ToMethod(_ => LuceneCommon.GetDirectory(configuration.Current.LuceneIndexLocation)) .InSingletonScope(); ConfigureSearch(configuration); if (!String.IsNullOrEmpty(configuration.Current.AzureStorageConnectionString)) { Bind <ErrorLog>() .ToMethod(_ => new TableErrorLog(configuration.Current.AzureStorageConnectionString)) .InSingletonScope(); } else { Bind <ErrorLog>() .ToMethod(_ => new SqlErrorLog(configuration.Current.SqlConnectionString)) .InSingletonScope(); } Bind <ICacheService>() .To <HttpContextCacheService>() .InRequestScope(); Bind <IContentService>() .To <ContentService>() .InSingletonScope(); Bind <IEntitiesContext>() .ToMethod(context => new EntitiesContext(configuration.Current.SqlConnectionString, readOnly: configuration.Current.ReadOnlyMode)) .InRequestScope(); Bind <IEntityRepository <User> >() .To <EntityRepository <User> >() .InRequestScope(); Bind <IEntityRepository <CuratedFeed> >() .To <EntityRepository <CuratedFeed> >() .InRequestScope(); Bind <IEntityRepository <CuratedPackage> >() .To <EntityRepository <CuratedPackage> >() .InRequestScope(); Bind <IEntityRepository <PackageRegistration> >() .To <EntityRepository <PackageRegistration> >() .InRequestScope(); Bind <IEntityRepository <Package> >() .To <EntityRepository <Package> >() .InRequestScope(); Bind <IEntityRepository <PackageDependency> >() .To <EntityRepository <PackageDependency> >() .InRequestScope(); Bind <IEntityRepository <PackageStatistics> >() .To <EntityRepository <PackageStatistics> >() .InRequestScope(); Bind <IEntityRepository <Credential> >() .To <EntityRepository <Credential> >() .InRequestScope(); Bind <ICuratedFeedService>() .To <CuratedFeedService>() .InRequestScope(); Bind <IUserService>() .To <UserService>() .InRequestScope(); Bind <IPackageService>() .To <PackageService>() .InRequestScope(); Bind <EditPackageService>().ToSelf(); Bind <IFormsAuthenticationService>() .To <FormsAuthenticationService>() .InSingletonScope(); Bind <IControllerFactory>() .To <NuGetControllerFactory>() .InRequestScope(); Bind <INuGetExeDownloaderService>() .To <NuGetExeDownloaderService>() .InRequestScope(); Bind <IStatusService>() .To <StatusService>() .InRequestScope(); var mailSenderThunk = new Lazy <IMailSender>( () => { var settings = Kernel.Get <ConfigurationService>(); if (settings.Current.SmtpUri != null && settings.Current.SmtpUri.IsAbsoluteUri) { var smtpUri = new SmtpUri(settings.Current.SmtpUri); var mailSenderConfiguration = new MailSenderConfiguration { DeliveryMethod = SmtpDeliveryMethod.Network, Host = smtpUri.Host, Port = smtpUri.Port, EnableSsl = smtpUri.Secure }; if (!String.IsNullOrWhiteSpace(smtpUri.UserName)) { mailSenderConfiguration.UseDefaultCredentials = false; mailSenderConfiguration.Credentials = new NetworkCredential( smtpUri.UserName, smtpUri.Password); } return(new MailSender(mailSenderConfiguration)); } else { var mailSenderConfiguration = new MailSenderConfiguration { DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory, PickupDirectoryLocation = HostingEnvironment.MapPath("~/App_Data/Mail") }; return(new MailSender(mailSenderConfiguration)); } }); Bind <IMailSender>() .ToMethod(context => mailSenderThunk.Value); Bind <IMessageService>() .To <MessageService>(); Bind <IPrincipal>().ToMethod(context => HttpContext.Current.User); switch (configuration.Current.StorageType) { case StorageType.FileSystem: case StorageType.NotSpecified: ConfigureForLocalFileSystem(); break; case StorageType.AzureStorage: ConfigureForAzureStorage(configuration); break; } Bind <IFileSystemService>() .To <FileSystemService>() .InSingletonScope(); Bind <IPackageFileService>() .To <PackageFileService>(); Bind <IEntityRepository <PackageOwnerRequest> >() .To <EntityRepository <PackageOwnerRequest> >() .InRequestScope(); Bind <IUploadFileService>() .To <UploadFileService>(); // todo: bind all package curators by convention Bind <IAutomaticPackageCurator>() .To <WebMatrixPackageCurator>(); Bind <IAutomaticPackageCurator>() .To <Windows8PackageCurator>(); // todo: bind all commands by convention Bind <IAutomaticallyCuratePackageCommand>() .To <AutomaticallyCuratePackageCommand>() .InRequestScope(); Bind <IPackageIdsQuery>() .To <PackageIdsQuery>() .InRequestScope(); Bind <IPackageVersionsQuery>() .To <PackageVersionsQuery>() .InRequestScope(); }
/// <summary> /// Creates our OpenGL Window. /// </summary> /// <param name="title"> /// The title to appear at the top of the window. /// </param> /// <param name="width"> /// The width of the GL window or fullscreen mode. /// </param> /// <param name="height"> /// The height of the GL window or fullscreen mode. /// </param> /// <param name="bits"> /// The number of bits to use for color (8/16/24/32). /// </param> /// <param name="fullscreenflag"> /// Use fullscreen mode (<c>true</c>) or windowed mode (<c>false</c>). /// </param> /// <returns> /// <c>true</c> on successful window creation, otherwise <c>false</c>. /// </returns> private static bool CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag) { int pixelFormat; // Holds The Results After Searching For A Match fullscreen = fullscreenflag; // Set The Global Fullscreen Flag form = null; // Null The Form GC.Collect(); // Request A Collection // This Forces A Swap Kernel.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); if (fullscreen) // Attempt Fullscreen Mode? { Gdi.DEVMODE dmScreenSettings = new Gdi.DEVMODE(); // Device Mode // Size Of The Devmode Structure dmScreenSettings.dmSize = (short)Marshal.SizeOf(dmScreenSettings); dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel dmScreenSettings.dmFields = Gdi.DM_BITSPERPEL | Gdi.DM_PELSWIDTH | Gdi.DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (User.ChangeDisplaySettings(ref dmScreenSettings, User.CDS_FULLSCREEN) != User.DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode. if (MessageBox.Show("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?", "NeHe GL", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { fullscreen = false; // Windowed Mode Selected. Fullscreen = false } else { // Pop up A Message Box Lessing User Know The Program Is Closing. MessageBox.Show("Program Will Now Close.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); // Return false } } } form = new Lesson12(); // Create The Window if (fullscreen) // Are We Still In Fullscreen Mode? { form.FormBorderStyle = FormBorderStyle.None; // No Border Cursor.Hide(); // Hide Mouse Pointer } else // If Windowed { form.FormBorderStyle = FormBorderStyle.Sizable; // Sizable Cursor.Show(); // Show Mouse Pointer } form.Width = width; // Set Window Width form.Height = height; // Set Window Height form.Text = title; // Set Window Title Gdi.PIXELFORMATDESCRIPTOR pfd = new Gdi.PIXELFORMATDESCRIPTOR(); // pfd Tells Windows How We Want Things To Be pfd.nSize = (short)Marshal.SizeOf(pfd); // Size Of This Pixel Format Descriptor pfd.nVersion = 1; // Version Number pfd.dwFlags = Gdi.PFD_DRAW_TO_WINDOW | // Format Must Support Window Gdi.PFD_SUPPORT_OPENGL | // Format Must Support OpenGL Gdi.PFD_DOUBLEBUFFER; // Format Must Support Double Buffering pfd.iPixelType = (byte)Gdi.PFD_TYPE_RGBA; // Request An RGBA Format pfd.cColorBits = (byte)bits; // Select Our Color Depth pfd.cRedBits = 0; // Color Bits Ignored pfd.cRedShift = 0; pfd.cGreenBits = 0; pfd.cGreenShift = 0; pfd.cBlueBits = 0; pfd.cBlueShift = 0; pfd.cAlphaBits = 0; // No Alpha Buffer pfd.cAlphaShift = 0; // Shift Bit Ignored pfd.cAccumBits = 0; // No Accumulation Buffer pfd.cAccumRedBits = 0; // Accumulation Bits Ignored pfd.cAccumGreenBits = 0; pfd.cAccumBlueBits = 0; pfd.cAccumAlphaBits = 0; pfd.cDepthBits = 16; // 16Bit Z-Buffer (Depth Buffer) pfd.cStencilBits = 0; // No Stencil Buffer pfd.cAuxBuffers = 0; // No Auxiliary Buffer pfd.iLayerType = (byte)Gdi.PFD_MAIN_PLANE; // Main Drawing Layer pfd.bReserved = 0; // Reserved pfd.dwLayerMask = 0; // Layer Masks Ignored pfd.dwVisibleMask = 0; pfd.dwDamageMask = 0; hDC = User.GetDC(form.Handle); // Attempt To Get A Device Context if (hDC == IntPtr.Zero) // Did We Get A Device Context? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Create A GL Device Context.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } pixelFormat = Gdi.ChoosePixelFormat(hDC, ref pfd); // Attempt To Find An Appropriate Pixel Format if (pixelFormat == 0) // Did Windows Find A Matching Pixel Format? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Find A Suitable PixelFormat.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!Gdi.SetPixelFormat(hDC, pixelFormat, ref pfd)) // Are We Able To Set The Pixel Format? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Set The PixelFormat.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } hRC = Wgl.wglCreateContext(hDC); // Attempt To Get The Rendering Context if (hRC == IntPtr.Zero) // Are We Able To Get A Rendering Context? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Create A GL Rendering Context.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!Wgl.wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Activate The GL Rendering Context.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } form.Show(); // Show The Window form.TopMost = true; // Topmost Window form.Focus(); // Focus The Window if (fullscreen) // This Shouldn't Be Necessary, But Is { Cursor.Hide(); } ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen if (!InitGL()) // Initialize Our Newly Created GL Window { KillGLWindow(); // Reset The Display MessageBox.Show("Initialization Failed.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); // Success }
void StartServer(Kernel remoteKernel, string pipeName) => remoteKernel.UseNamedPipeKernelServer(pipeName, new DirectoryInfo(Environment.CurrentDirectory));
public sceUsbBus_driver(Kernel kernel) : base(kernel) { }
public override void PreCompile(Kernel k) { foreach (ICompileNode node in this.Children) { node.PreCompile(k); } }
public override void PreCompile(Kernel k) { if (this.Body != null) this.Body.PreCompile(k); this.Check.PreCompile(k); }
protected override void OnStop() { _kernel.Menu.EnqueueMenu("StartStop_Stop", true/*synchro*/); _kernel.Dispose(); _kernel = null; }