public object RunInitOption(InitOption opts) { try { //if no path provided, we default into current directory if (string.IsNullOrEmpty(opts.Path)) { var workingPath = _environmentService.GetCurrentDirectory(); _localVersionService.Init(workingPath); _traceService.Info($"Initialized {workingPath}."); } else { _localVersionService.Init(opts.Path); _traceService.Info($"Initialized {opts.Path}."); } } catch (Exception ex) { _traceService.Error($"Failed to execute init function. {Environment.NewLine}{ex.ToString()}"); throw; } return(0); }
public void Test_Init_Option_With_Explicit_Workspace_Path() { //arrange var traceService = new Mock <ITraceService>(); var environmentService = new Mock <IEnvironmentService>(); environmentService.Setup(s => s.GetCurrentDirectory()).Returns(@"c:\temp\yuniql"); var workspaceService = new Mock <IWorkspaceService>(); var configurationService = new Mock <IConfigurationService>(); configurationService.Setup(s => s.GetValueOrDefault(@"c:\temp\yuniql", ENVIRONMENT_VARIABLE.YUNIQL_WORKSPACE, @"c:\temp\yuniql")).Returns(@"c:\temp\yuniql"); var migrationService = new Mock <IMigrationService>(); var migrationServiceFactory = new Mock <CLI.IMigrationServiceFactory>(); migrationServiceFactory.Setup(s => s.Create("sqlserver")).Returns(migrationService.Object); var dataService = new Mock <IDataService>(); var dataServiceFactory = new Mock <CLI.IDataServiceFactory>(); dataServiceFactory.Setup(s => s.Create("sqlserver")).Returns(dataService.Object); //act var option = new InitOption { Workspace = @"c:\temp\yuniql" }; var sut = new CommandLineService(migrationServiceFactory.Object, dataServiceFactory.Object, workspaceService.Object, environmentService.Object, traceService.Object, configurationService.Object); sut.RunInitOption(option); //assert workspaceService.Verify(s => s.Init(@"c:\temp\yuniql")); }
public int RunInitOption(InitOption opts) { try { opts.Workspace = _configurationService.GetValueOrDefault(opts.Workspace, ENVIRONMENT_VARIABLE.YUNIQL_WORKSPACE, defaultValue: _environmentService.GetCurrentDirectory()); _workspaceService.Init(opts.Workspace); _traceService.Success($"Initialized {opts.Workspace}."); return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute init function", opts.IsDebug)); } }
public Chunk(Int3 position, World world, InitOption option = InitOption.Build) { Position = position; World = world; switch (option) { case InitOption.Build: Build(world.DaylightBrightness); break; case InitOption.AllocateUnique: EnableFullArray(); break; default: EnableCopyOnWrite(StaticChunkPool.GetAirChunk()); break; } }
public OglVertexArray Init(Action <InitOption> option, Action <VertexDataBuilder> builder) { if (option != null) { var initOption = new InitOption(this); option(initOption); //data = initOption.databytes; vao = 0; vbo = 0; } if (builder != null) { var vartexDataBuilder = new VertexDataBuilder(this); builder(vartexDataBuilder); data = vartexDataBuilder.buildResult.ToArray(); } InitBuffer(); return(this); }
public void Test_Init_Option_With_Explicit_Workspace_Path() { //arrange var traceService = new Mock <ITraceService>(); var environmentService = new Mock <IEnvironmentService>(); var localVersionService = new Mock <ILocalVersionService>(); var migrationService = new Mock <IMigrationService>(); var migrationServiceFactory = new Mock <CLI.IMigrationServiceFactory>(); migrationServiceFactory.Setup(s => s.Create("sqlserver")).Returns(migrationService.Object); //act var option = new InitOption { Path = @"c:\temp\yuniql-ex" }; var sut = new CommandLineService(migrationServiceFactory.Object, localVersionService.Object, environmentService.Object, traceService.Object); sut.RunInitOption(option); //assert localVersionService.Verify(s => s.Init(@"c:\temp\yuniql-ex")); }
public int RunInitOption(InitOption opts) { try { //if no path provided, we default into current directory if (string.IsNullOrEmpty(opts.Path)) { var workingPath = _environmentService.GetCurrentDirectory(); _localVersionService.Init(workingPath); _traceService.Info($"Initialized {workingPath}."); } else { _localVersionService.Init(opts.Path); _traceService.Success($"Initialized {opts.Path}."); } return(0); } catch (Exception ex) { return(OnException(ex, "Failed to execute init function", opts.Debug, _traceService)); } }
public async Task Initialize(InitOption option) { if (option.HasFlag(InitOption.DropTableIfExists)) { using (var conn = _connector()) { conn.Open(); var cmd = conn.CreateCommand(); cmd.CommandText = string.Format(SqlDropTable, _config.TableName); await cmd.ExecuteNonQueryAsync(); } } if (option.HasFlag(InitOption.CreateTableIfNotExists)) { await CreateTableIfNotExists(); } if (option.HasFlag(InitOption.LoadData)) { await Load(); } }
public void InitAnimation(InitOption Option) { if (compositor != null) { if (Option == InitOption.AroundImage) { for (int i = Flip.SelectedIndex > 2 ? Flip.SelectedIndex - 2 : 0; i < Flip.SelectedIndex + 2 && i < Flip.Items.Count; i++) { if (Flip.ContainerFromIndex(i) is UIElement Element) { var Visual = ElementCompositionPreview.GetElementVisual(Element); CenterPointAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("CenterPoint", CenterPointAnimation); Visual.StopAnimation("Scale.X"); ScaleAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("Scale.X", ScaleAnimation); Visual.StartAnimation("Scale.Y", ScaleAnimation); } } } else { foreach (var Visual in from Item in Flip.Items let Element = Flip.ContainerFromItem(Item) as UIElement where Element != null select ElementCompositionPreview.GetElementVisual(Element)) { CenterPointAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("CenterPoint", CenterPointAnimation); Visual.StopAnimation("Scale.X"); ScaleAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("Scale.X", ScaleAnimation); Visual.StartAnimation("Scale.Y", ScaleAnimation); } } } }