private void BindShowzup() { Log.Info("Binding Showzup"); // These bindings are rather standard for all projects and you Container.Bind <IScoreEvaluator, ScoreEvaluator>().AsSingle(); Container.Bind <IViewResolver, ViewResolver>().AsSingle(); Container.Bind <IViewLoader, ViewLoader>().AsSingle(); Container.BindInstance <IInjectionAdapter>(new InjectionAdapter(Container)); // This binding registers the Manifest asset, which contains mappings between // all Models > ViewModels > Views > Prefabs. Container.BindInstance <IManifest>(Manifest); // This binding scans the currently assembly and registers all view models // so that they can be instantiated automatically at run-time Container.BindToSelfAll <IViewModel>(GetType().Assembly); // This binding defines the groups of variants used by the app to refine visuals depending // on context. Variant groups are totally custom for each app (in this case, we define // Display, Form and Platform), but it is recommended to have at least a Display group (or // some equivalent). Have a look at these three classes to see what variants are part of // each group. Container.BindInstance(VariantProvider.From <Display, Form, Platform>()); }
public void TestGetVariant() { const string variantData = "Пусть это будут данные варианта. То, что это на самом деле строка, не принципиально."; var allowedVersion = new Version(1, 0, 234, 999); var dataServiceMock = new Mock <IVariantProviderServiceClient>(MockBehavior.Strict); var taskVariantInfo = new TaskVariantDto { Data = Encoding.UTF8.GetBytes(variantData), GeneratorVersion = allowedVersion.ToString(), Id = 7, Number = "test", Version = 1 }; dataServiceMock .Setup(srv => srv.GetVariantAsync(It.Is <long>(l => l == TaskId), It.Is <Guid>(g => g == _sessionGuid))) .Callback(() => dataServiceMock.Raise(mock => mock.GetVariantCompleted += null, new GetVariantCompletedEventArgs(new object[] { taskVariantInfo }, null, false, null))) .Verifiable(); SetupCloseAsync(dataServiceMock); using (var wrapper = DisposableWcfClientWrapper.Create(dataServiceMock.Object)) { var variantProvider = new VariantProvider( TaskId, _sessionGuid, new[] { new Version(allowedVersion.Major, allowedVersion.Minor + 1) }, wrapper); using (var flag = new AutoResetEvent(false)) { var handled = false; EventHandler <VariantDownloadedEventArgs> handler = (sender, args) => { Assert.AreSame(sender, variantProvider); Assert.NotNull(args); Assert.That(args.Data.SequenceEqual(taskVariantInfo.Data)); Assert.AreEqual(taskVariantInfo.Number, args.Number); Assert.AreEqual(taskVariantInfo.Number, args.Number); handled = true; flag.Set(); }; variantProvider.VariantDownloaded += handler; variantProvider.DownloadVariantAsync(); flag.WaitOne(1000); variantProvider.VariantDownloaded -= handler; Assert.IsTrue(handled); } } dataServiceMock.Verify(); }
// ReSharper restore StaticFieldInGenericType #endregion /// <summary> Инициализировать ViewModel и записаться во view.DataContext </summary> public void Initialize(TView view, InitParams startupParameters, bool sendReportOnEveryAction) { StartupParameters = startupParameters; VariantProvider = new VariantProvider(StartupParameters.TaskId, StartupParameters.SessionGuid, AllowedGeneratorVersions, VariantProviderServiceClient); VariantProvider.VariantDownloaded += (s, e) => OnTaskLoadingComleteInternal(e); UserActionsManager = new UserActionsManager(StartupParameters.TaskId, StartupParameters.SessionGuid, ActionsRegistratorClient, DateTimeService) { SendReportOnEveryAction = sendReportOnEveryAction }; UserActionsManager.TaskFinished += (s, e) => TransferToNextTask(); view.DataContext = this; View = view; OnInitialized(); }
public void TestInvalidVersion() { const string variantData = "Пусть это будут данные варианта. То, что это на самом деле строка, не принципиально."; var allowedVersion = new Version(1, 0); var dataServiceMock = new Mock <IVariantProviderServiceClient>(MockBehavior.Strict); var taskVariantInfo = new TaskVariantDto { Data = Encoding.UTF8.GetBytes(variantData), GeneratorVersion = allowedVersion.ToString(), Id = 7, Number = "test", Version = 1 }; Assert.Throws <Exception>(() => { dataServiceMock .Setup( srv => srv.GetVariantAsync(It.Is <long>(l => l == TaskId), It.Is <Guid>(g => g == _sessionGuid))) .Callback(() => dataServiceMock.Raise(mock => mock.GetVariantCompleted += null, new GetVariantCompletedEventArgs(new object[] { taskVariantInfo }, null, false, null))) .Verifiable(); SetupCloseAsync(dataServiceMock); using (var wrapper = DisposableWcfClientWrapper.Create(dataServiceMock.Object)) { var variantProvider = new VariantProvider( TaskId, _sessionGuid, new[] { new Version(allowedVersion.Major + 1, allowedVersion.Minor) }, wrapper); variantProvider.DownloadVariantAsync(); } }); }
//добавление-удаление /// <summary> Инициализация </summary> protected override void OnInitialized() { base.OnInitialized(); InitToolBarCommands(); OnLoadedCmd = new DelegateCommand( o => { VariantProvider.DownloadVariantAsync(); ToolBarCommands.ForEach(c => c.RefreshState()); }, o => true); var outV = new Vertex("a"); VertexClickCmd = new DelegateCommand( o => { if (_state == State.AddEdge1) { outV = GivenGraph.Vertices.Single(v => v.Name == ((IVertex)o).Name) as Vertex; VertVisCol.Single(v => v.Name == outV.Name).Radius = 23; VertVisCol.Single(v => v.Name == outV.Name).Background = new SolidColorBrush(Colors.Magenta); UserActionsManager.RegisterInfo(string.Format("Выходная вершина - [{0}]. Выберите входную вершину.", ((IVertex)o).Name)); _state = State.AddEdge2; return; } if (_state == State.AddEdge2) { var inV = GivenGraph.Vertices.Single(v => v.Name == ((IVertex)o).Name) as Vertex; UserActionsManager.RegisterInfo(string.Format("Входная вершина - [{0}]. Добавьте другое ребро или выйдете из режима добавления ребер", ((IVertex)o).Name)); var newEdge = new DirectedEdge(outV, inV); if (GivenGraph.Edges.Any(newEdge.Equals)) { ReportMistake("Указанная дуга уже существует."); return; } VertVisCol.Single(v => v.Name == outV.Name).Radius = 20; VertVisCol.Single(v => v.Name == outV.Name).Background = new SolidColorBrush(Colors.LightGray); GivenGraph.AddEdge(newEdge); _state = State.AddEdge1; } if (_state == State.RemoveVertex) { GivenGraph.RemoveVertex(GivenGraph.Vertices.Single(v => v.Name == ((IVertex)o).Name)); UserActionsManager.RegisterInfo(string.Format("Вершина [{0}] удалена со всеми связями", ((IVertex)o).Name)); } }, o => true); VisualizerClickCmd = new DelegateCommand( o => { if (_state == State.AddVertex) { UserActionsManager.RegisterInfo((string.Format("Вершина добавлена"))); var vertex = (Graphs.UIComponents.Visualization.Vertex)o; vertex.Name = (GivenGraph.VerticesCount).ToString(); int i = 0; while (GivenGraph.Vertices.Any(vertex.Equals)) { i = i + 1; vertex.Name = (i).ToString(); } } }, o => true); }
/// <summary> Начать загрузку варианта </summary> public void StartVariantDownload() { VariantProvider.DownloadVariantAsync(); }
public List <Variant> getAllVariants() { return(VariantProvider.getAllVariants()); }
/// <summary> Начать загрузку варианта </summary> public void StartVariantDownload() { VariantProvider.DownloadVariantAsync(); //OnTaskLoadingComlete(e); }