public void ResolvesViewFromViewModelWhenViewModelIsRegisteredWithViewType() { var builder = new ContainerBuilder(); builder.RegisterType<MockViewModel>().SingleInstance(); builder.RegisterType<MockView>().SingleInstance(); var container = builder.Build(); var viewFactory = new ViewFactory(container); viewFactory.Register<MockViewModel, MockView>(); MockViewModel viewModel; var view = viewFactory.Resolve<MockViewModel>(out viewModel, x => x.Title = "Test Title"); Assert.That(view, Is.Not.Null); Assert.That(view, Is.TypeOf<MockView>()); Assert.That(viewModel, Is.Not.Null); Assert.That(viewModel.Title, Is.EqualTo("Test Title")); view = viewFactory.Resolve<MockViewModel>(x => x.Title = "Test Title 2"); Assert.That(view, Is.Not.Null); Assert.That(viewModel.Title, Is.EqualTo("Test Title 2")); view = viewFactory.Resolve<MockViewModel>(viewModel); Assert.That(view, Is.Not.Null); Assert.That(view, Is.TypeOf<MockView>()); }
protected virtual IEnumerable<object> assemblyInner(ViewFactory factory, BuildContext context) { var resultList = new List<object>(); XElement parentNode = context.CurrentNode; foreach (XElement childNode in context.CurrentNode.Elements()) { BaseBuilder childBuilder = factory.GetBuilder(childNode.Name.LocalName); if (childBuilder != null) { XElement fullChildNode = applyParentParameters(parentNode, childNode); context.CurrentNode = fullChildNode; object childBuildResult = childBuilder.Assembly(factory, context); resultList.AddRange(getFlatResult(childBuildResult)); } } context.CurrentNode = parentNode; return resultList; }
protected override object create(ViewFactory factory, BuildContext context) { //Rect="left,top,right,bottom" var place = (Place)getAttributeValue(context.CurrentNode, typeof(Place), "Rect"); return Far.Net.CreateDialog(place.Left, place.Top, place.Right, place.Bottom); }
public override object Assembly(ViewFactory factory, BuildContext context) { object control = base.Assembly(factory, context); assemblyInner(factory, context); return control; }
protected JessModule(string basePath = "") { Routes = new List<JessicaRoute>(); Before = new BeforeFilters(); After = new AfterFilters(); Response = new ResponseFactory(AppDomain.CurrentDomain.BaseDirectory); _viewFactory = new ViewFactory(Jess.ViewEngines, AppDomain.CurrentDomain.BaseDirectory); _basePath = basePath; }
protected virtual void applyBindingExpression( BindingExpression be, ViewFactory factory, Dictionary<string, string> parameters) { if (parameters.ContainsKey("Converter")) be.Converter = factory.GetBindingConverter(parameters["Converter"]); if (parameters.ContainsKey("ConverterParameter")) be.ConverterParameter = parameters["ConverterParameter"]; factory.CreateBinding(be); }
protected virtual void setPropertyIfHasControl(Type typeOfDlg, object dialog, XElement node, ViewFactory factory, string name) { var controlName = (string)getAttributeValue(node, typeof(string), name); if (string.IsNullOrEmpty(controlName) == false) { var control = factory.GetControl(controlName); if (control != null) getProperty(typeOfDlg, name).SetValue(dialog, control, null); } }
public override object Assembly(ViewFactory factory, BuildContext context) { var item = (SetItem)base.Assembly(factory, context); // save node inner value as FarItem.Data or FarItem.Text if (string.IsNullOrEmpty(item.Text)) item.Text = context.CurrentNode.Value; else item.Data = context.CurrentNode.Value; return item; }
protected override object create(ViewFactory factory, BuildContext context) { //Box //Rect="left,top,right,bottom" var place = (Place)getAttributeValue(context.CurrentNode, typeof(Place), "Rect"); if (place.Right < 0) place.Right = place.Left - place.Right; object resultControl = context.Dialog.AddBox(place.Left, place.Top, place.Right, place.Bottom, string.Empty); return resultControl; }
protected virtual void addEventHandler( Type typeOfControl, object control, ViewFactory factory, BuildContext context, PropertyMap pm) { var name = pm.Name; var eventHandlerName = (string)getAttributeValue(context.CurrentNode, typeof(string), name); if (string.IsNullOrEmpty(eventHandlerName) == false) { var ei = getEvent(typeOfControl, name); var mi = getEventHandler(context.TypeOfView, eventHandlerName); if (ei != null && mi != null) { ei.AddEventHandler(control, Delegate.CreateDelegate(ei.EventHandlerType, context.View, mi)); } } }
public virtual object Assembly(ViewFactory factory, BuildContext context) { object control = create(factory, context); var mapping = factory.GetMapping(TypeOfResult); //Name="nameOfControl" applyMapping(control.GetType(), control, mapping, factory, context); if (mapping.HasName) { string name = (string)getAttributeValue(context.CurrentNode, typeof(string), "Name"); if (string.IsNullOrEmpty(name) == false) { BindingHelper.SetValueIfViewHasProperty(context.TypeOfView, context.View, name, control); } } return control; }
/// <summary>Function to provide clean up for the plugin.</summary> protected override void OnShutdown() { try { if ((_settings?.WriteSettingsCommand != null) && (_settings.WriteSettingsCommand.CanExecute(null))) { // Persist any settings. _settings.WriteSettingsCommand.Execute(null); } ViewFactory.Unregister <ISettings>(); foreach (IDisposable codec in _codecs.Codecs.OfType <IDisposable>()) { codec.Dispose(); } } catch (Exception ex) { // We don't care if it crashes. The worst thing that'll happen is your settings won't persist. CommonServices.Log.LogException(ex); } }
public void Run() { WorkflowType selection; while (true) { Console.Title = Utilities.ProgramTitle; MainMenu.Display(); selection = MainMenu.GetSelection(); if (selection == WorkflowType.Quit) { break; } IView view = ViewFactory.Create(selection); Response response = view.MakeRequest(selection); view.DisplayFeedback(response); Utilities.Continue(); } }
public override object Assembly(ViewFactory factory, BuildContext context) { var dialog = (IDialog)base.Assembly(factory, context); var typeOfDlg = dialog.GetType(); var mapping = factory.GetMapping(TypeOfResult); context.Dialog = dialog; assemblyInner(factory, context); //Cancel="IButton" //Default="IControl" //Focused="IControl" foreach (var pm in mapping.PropertyMaps) { if (pm.Kind == PropertyMap.EKind.Control) setPropertyIfHasControl(typeOfDlg, dialog, context.CurrentNode, factory, pm.Name); } return dialog; }
public IActionResult NoteAction(ActionParameters parameters) { string noteSubject = string.Empty; if (parameters.ContainsKey("NoteSubject")) { _noteSubject = parameters.Get <string>("NoteSubject"); } if (parameters.ContainsKey("ParentObjectName")) { _parentObjectName = parameters.Get <string>("ParentObjectName"); } if (parameters.ObjectName == "Note") { NoteId = parameters.ObjectId; } else { ObjectType = parameters.ObjectName; this.ObjectId = parameters.ObjectId; } var detailView = ViewFactory.CreateView("DefaultNoteDetailView") as INoteDetailForm; _detailView = detailView; _noteView = detailView; if (parameters.ContainsKey("PutNoteEnable")) { string putNoteEnable = string.Empty; putNoteEnable = parameters.Get <string>("PutNoteEnable"); if (putNoteEnable.Equals("false")) { _noteView.SetDescriptionVisible(false); } } OnViewSet(); return(new ModalViewResult(detailView)); }
private static void InitNavigation() { var navigation = RootPage.Navigation; RootPage.Subscribe <NavigateBackMessage>(async delegate { await navigation.PopAsync(); }); RootPage.Subscribe <NavigateToPageMessage>( message => { navigation.PushAsync(message.Page, true); }); RootPage.Subscribe <LoginSuccess>(async message => { var pageToNaviagte = message.FirstTimeLogin ? ViewFactory <PreferencesPage, PreferencesViewModel> .CreatePage() as Page : ViewFactory <HomePage, HomeViewModel> .CreatePage(); await navigation.PopToRootAsync(); await navigation.PushAsync(pageToNaviagte, true); }); RootPage.Subscribe <LoginCanceled>(async message => { await navigation.PushAsync(new WelcomePage()); }); RootPage.Subscribe <LoginFailed>( async(x) => { await RootPage.DisplayAlert("Login failed", "Login failed !", "Ok"); }); RootPage.Subscribe <LogoutSuccess>(message => { navigation.PopToRootAsync(true); }); }
private static void OnExecuteImagingToolsCommand(object sender, EventArgs e) { try { if (manageInstallationsView == null || manageInstallationsView.IsDisposed) { manageInstallationsViewModel?.Dispose(); #pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread - invoked in UI thread. And ThreadHelper.ThrowIfNotOnUIThread() just emits another warning. shellService.GetProperty((int)__VSSPROPID2.VSSPROPID_VisualStudioDir, out object documentsDirObj); #pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread manageInstallationsViewModel = ViewModelFactory.CreateManageInstallations(documentsDirObj?.ToString()); manageInstallationsView = ViewFactory.CreateView(manageInstallationsViewModel); } manageInstallationsView.Show(); } catch (Exception ex) { manageInstallationsView?.Dispose(); manageInstallationsViewModel?.Dispose(); manageInstallationsView = null; ShellDialogs.Error(serviceProvider, Res.ErrorMessageUnexpectedError(ex.Message)); } }
/// <summary> /// Match the views under the stream to the list of view specications passed in. The method changes the view /// specifications list passed in and removes those specifications for which matcing views have been found. /// If none of the views under the stream matches the first view specification passed in, the method returns /// the stream itself and leaves the view specification list unchanged. If one view under the stream matches, /// the view's specification is removed from the list. The method will then attempt to determine if any child /// views of that view also match specifications. /// </summary> /// <param name="rootViewable">is the top rootViewable event stream to which all views are attached as child views. This parameter is changed by this method, ie. specifications are removed if they match existing views.</param> /// <param name="viewFactories">is the view specifications for making views</param> /// <returns> /// a pair of (A) the stream if no views matched, or the last child view that matched (B) the full listof parent views /// </returns> protected internal static Pair <Viewable, IList <View> > MatchExistingViews(Viewable rootViewable, IList <ViewFactory> viewFactories) { Viewable currentParent = rootViewable; IList <View> matchedViewList = new List <View>(); bool foundMatch; if (viewFactories.IsEmpty()) { return(new Pair <Viewable, IList <View> >(rootViewable, Collections.GetEmptyList <View>())); } do // while ((foundMatch) && (specifications.Count > 0)); { foundMatch = false; foreach (View childView in currentParent.Views) { ViewFactory currentFactory = viewFactories[0]; if (!(currentFactory.CanReuse(childView))) { continue; } // The specifications match, check current data window size viewFactories.RemoveAt(0); currentParent = childView; foundMatch = true; matchedViewList.Add(childView); break; } }while ((foundMatch) && (viewFactories.IsNotEmpty())); return(new Pair <Viewable, IList <View> >(currentParent, matchedViewList)); }
private async void DoLogIn(object obj) { try { //await Navigation.PopToRootAsync(); //await Navigation.PushAsync(new MainMasterDetailPage()); //NavigationService.NavigateTo<MainMasterDetailPageViewModel>(); //await Resolver.Resolve<INavigation>().PopAsync(); //await Resolver.Resolve<INavigation>().PushAsync((Page)ViewFactory.CreatePage<MainMasterDetailPageViewModel, MainMasterDetailPage>(), true); //await Navigation.PushModalAsync((Page)ViewFactory.CreatePage<MainMasterDetailPageViewModel, MainMasterDetailPage>()); //Resolver.Resolve<INavigationService>().NavigateTo<MainMasterDetailPageViewModel>(); //NavigationService.NavigateTo<MainMasterDetailPageViewModel>(); //Application.Current.MainPage = new NavigationPage((Page)ViewFactory.CreatePage<MainMasterDetailPageViewModel, MainMasterDetailPage>()); //await Navigation.PopToRootAsync(); Application.Current.MainPage = new NavigationPage((Page)ViewFactory.CreatePage <MainMasterDetailPageViewModel, MainMasterDetailPage>()); } catch (Exception e) { } }
/// <summary> /// Creates a soldier around the selected barrack /// </summary> public void SpawnSoldier() { if (_selectedProduct != null && _selectedProduct.name.Contains("Barrack")) { GameObject emptyGroundTile = _selectedProduct.GetComponent <BuildingViewModel>() .GetEmptyGroundTileNearTheSelectedBarrack(_createdGroundTileModels); if (emptyGroundTile != null) { emptyGroundTile.GetComponent <GroundTileViewModel>().IsWalkable = false; IProduct product = new SoldierUnit("Soldier Unit", ProductType.Soldier, false, 1f); var createdProduct = ViewFactory.Create <IProduct, SoldierViewModel>(product, Resources.Load <GameObject>("Prefabs/SoldierUnit"), null); createdProduct.name = "SoldierUnit"; SoldierViewModel soldierViewModel = createdProduct.GetComponent <SoldierViewModel>(); soldierViewModel.SetPosition(new Vector2(emptyGroundTile.transform.position.x, emptyGroundTile.transform.position.y)); soldierViewModel.SetCurrentGroundTile(emptyGroundTile); } else { GameManager.Instance.GiveNotSuitableAreaForSpawnWarning(); } } }
public void Attach( EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories) { var validated = ViewFactorySupport.Validate( ViewName, parentEventType, statementContext, _viewParameters, true); if (_viewParameters.Count != 2) { throw new ViewParameterException(ViewParamMessage); } if (!validated[0].ExprEvaluator.ReturnType.IsNumeric()) { throw new ViewParameterException(ViewParamMessage); } _timestampExpression = validated[0]; _timeDeltaComputationFactory = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDeltaFactory( ViewName, statementContext, _viewParameters[1], ViewParamMessage, 1); _timestampExpressionEvaluator = _timestampExpression.ExprEvaluator; _eventType = parentEventType; }
public override object Assembly(ViewFactory factory, BuildContext context) { object control = base.Assembly(factory, context); string controlName = (string)getAttributeValue(context.CurrentNode, typeof(string), "Name"); if (string.IsNullOrEmpty(controlName) == false) { factory.AddControl(controlName, (IControl)control); } // add color wrapper if (context.CurrentNode.Attributes().Select(a => a.Name.LocalName).Any(a => a.StartsWith("Background") || a.StartsWith("Foreground"))) { var colorWrapper = new FarControlColorWrapper((IControl)control); applyMapping(colorWrapper.GetType(), colorWrapper, factory.GetMapping(typeof(ColorControlMap)), factory, context); } // save node inner value as IControl.Data ((IControl)control).Data = context.CurrentNode.Value; return control; }
/// <summary>Function to provide clean up for the plugin.</summary> protected override void OnShutdown() { try { if (_settings != null) { // Persist any settings. ContentPlugInService.WriteContentSettings(typeof(SpriteEditorPlugIn).FullName, _settings, new JsonSharpDxRectConverter()); } } catch (Exception ex) { // We don't care if it crashes. The worst thing that'll happen is your settings won't persist. CommonServices.Log.LogException(ex); } _rtv?.Dispose(); _bgPattern?.Dispose(); _noImage?.Dispose(); ViewFactory.Unregister <ISpriteContent>(); base.OnShutdown(); }
private void ContactsCommandHandler(object sender, EventArgs e) { IView view = ViewFactory.GetView("ProjectContactView"); view.Show(); }
public override void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories) { ExprNode[] validated = Validate("Trend spotter view", parentEventType, statementContext, _viewParameters, false); const string message = "Trend spotter view accepts a single integer or double value"; if (validated.Length != 1) { throw new ViewParameterException(message); } var resultType = validated[0].ExprEvaluator.ReturnType; if ((resultType != typeof(int?)) && (resultType != typeof(int)) && (resultType != typeof(double?)) && (resultType != typeof(double))) { throw new ViewParameterException(message); } _expression = validated[0]; _eventType = MyTrendSpotterView.CreateEventType(statementContext); }
public FrameworkElement CreateView() { return(ViewFactory?.Invoke(ViewType)); }
protected override object create(ViewFactory factory, BuildContext context) { return new ItemCollection(); }
public static void VisitViewContained(ViewDataVisitorContained viewDataVisitor, ViewFactory viewFactory, View[] views) { viewDataVisitor.VisitPrimary(viewFactory.ViewName, views.Length); for (int i = 0; i < views.Length; i++) { viewDataVisitor.VisitContained(i, views[i]); } }
public View CloneView() { return(ViewFactory.MakeView(_agentInstanceContext)); }
/// <summary> /// Forwards the <code>DocumentEvent</code> to the give child view. /// </summary> protected void forwardUpdateToView(View @v, DocumentEvent @e, Shape @a, ViewFactory @f) { }
protected override bool tryParseComplexValue(Type typeOfControl, object control, ViewFactory factory, BuildContext context, PropertyMap pm) { return base.tryParseComplexValue(typeOfControl, control, factory, context, pm); }
public SparkViewRegistry() { viewFactory = new ViewFactory(); }
public ApplicationViewModel(Messenger messenger, ViewFactory viewFactory) { this._Messenger = messenger; this._ViewFactory = viewFactory; }
public DescriptorBuildingFixture() { this.viewFolder = new InMemoryViewFolder(); this.factory = new ViewFactory(null) {ViewFolder = viewFolder}; this.actionContext = new ActionContext(A.Fake<HttpContextBase>(), "Bar"); }
protected abstract object create( ViewFactory factory, BuildContext context);
public App() { RegisterViews(); MainPage = new NavigationPage((Page)ViewFactory.CreatePage <HomeViewModel, Home>()); }
protected virtual void applyMapping( Type controlType, object control, BaseMap mapping, ViewFactory factory, BuildContext context) { foreach (var pm in mapping.PropertyMaps) { if (tryParseComplexValue(controlType, control, factory, context, pm)) continue; switch (pm.Kind) { case PropertyMap.EKind.Value: setControlProperty(controlType, control, factory, context, pm); break; case PropertyMap.EKind.Event: addEventHandler(controlType, control, factory, context, pm); break; } } }
/// <summary> /// Gives notification from the document that attributes were changed /// in a location that this view is responsible for. /// </summary> public void changedUpdate(DocumentEvent @e, Shape @a, ViewFactory @f) { }
public void AggiungiComandi(MenuRibbon.RibbonMenuTab tab, bool editItem) { if (editItem) { var pnlTipoDoc = tab.Add("Tipo documento"); var fattCortesia = pnlTipoDoc.Add(PulsanteCambioTipoDoc, StrumentiMusicali.Core.Properties.ImageIcons.Edit, false); fattCortesia.Click += (a, e) => { EventAggregator.Instance().Publish <FatturaCambiaTipoDoc>(new FatturaCambiaTipoDoc()); }; } var pnlStampa = tab.Add("Stampa"); var ribStampa = pnlStampa.Add("Avvia stampa", StrumentiMusicali.Core.Properties.ImageIcons.Print_48, true); ribStampa.Click += (a, e) => { if (editItem) { StampaFattura(EditItem); } else { StampaFattura(SelectedItem); } }; var ribStampaXml = pnlStampa.Add("Genera fattura xml", StrumentiMusicali.Core.Properties.ImageIcons.Fattura_xml_48, true); ribStampaXml.Click += (a, e) => { if (editItem) { GeneraFatturaXml(EditItem); } else { GeneraFatturaXml(SelectedItem); } }; if (!editItem) { pnlStampa.Add("Genera Ordine Carico", StrumentiMusicali.Core.Properties.ImageIcons.OrdineDiCarico, true) .Click += (a, e) => { GeneraOrdineCarico(); }; } if (!editItem) { pnlStampa.Add("Genera Giacenze da Ordine di carico", StrumentiMusicali.Core.Properties.ImageIcons.OrdineDiCarico, true).Click += (a, e) => { GeneraMovimentiDaOrdineDiCarico(); }; } if (!editItem) { pnlStampa.Add("Genera Fattura da ordine di Scarico", StrumentiMusicali.Core.Properties.ImageIcons.OrdineDiCarico, true) .Click += (a, e) => { GeneraFatturaDaOrdineScarico(); }; } var pnlCliente = tab.Add("Anagrafica cliente"); var ribCust = pnlCliente.Add("Visualizza cliente", StrumentiMusicali.Core.Properties.ImageIcons.Customer_48, true); ribCust.Click += (x, e) => { using (var controllerCl = new ControllerClienti()) { using (var uof = new UnitOfWork()) { var idFatt = 0; if (editItem) { idFatt = (EditItem).ID; } else { idFatt = (SelectedItem).ID; } var cliente = uof.FatturaRepository.Find(a => a.ID == idFatt).Select(a => a.ClienteFornitore).First(); ///impostato per la save. controllerCl.EditItem = cliente; //var frm = ViewFactory.GetView(enAmbienti.Cliente); //if (frm == null) { var view = new GenericSettingView(cliente); view.OnSave += (d, b) => { view.Validate(); EventAggregator.Instance().Publish <Save <Soggetto> > (new Save <Soggetto>(controllerCl)); }; ShowView(view, enAmbiente.Cliente, null, false); ViewFactory.AddView(enAmbiente.Cliente, view); } } } }; }
protected override object create(ViewFactory factory, BuildContext context) { return new SetItem(); }
protected override void applyBindingExpression( BindingExpression be, ViewFactory factory, Dictionary<string, string> parameters) { base.applyBindingExpression(be, factory, parameters); // update UpdateTarget immediately in applyMapping call be.UpdateTarget(EventArgs.Empty); }
public IView GetView() { return(ViewFactory.CreateView(this)); }
public override object Assembly(ViewFactory factory, BuildContext context) { var ic = (ItemCollection)base.Assembly(factory, context); BaseMap mapping = factory.GetMapping(TypeOfResult); //applyMapping(ic.GetType(), ic, mapping, factory, context); if (ic.Items == null || !ic.Items.Cast<object>().Any()) return null; BaseBuilder childBuilder = factory.GetBuilder(ic.TypeOfItem); if (childBuilder == null) return null; if (childBuilder.TypeOfResult == ic.Items.Cast<object>().First().GetType()) { return ic.Items; } // build new xml XElement etalonNode = new XElement(context.CurrentNode); foreach (PropertyMap pm in mapping.PropertyMaps) { var attr = etalonNode.Attribute(pm.Name); if (attr != null) attr.Remove(); } bool isFirstItem = true; foreach (object childItem in ic.Items) { var childNode = new XElement(ic.TypeOfItem); // calc Rect var rect = new Place(); if (ic.Orientation == 0) { // in one line if (isFirstItem) { rect = ic.StartPlace; isFirstItem = false; } } else if (ic.Orientation == 1) { // line by line rect = ic.StartPlace; } // add rect childNode.Add(new XAttribute("Rect", string.Empty)); childNode.Attribute("Rect").Value = string.Format("{0},{1},{2},{3}", rect.Left, rect.Top, rect.Right, rect.Bottom); // add text childNode.Add(new XAttribute("Text", string.Empty)); childNode.Attribute("Text").Value = childItem.ToString(); etalonNode.Add(childNode); } XElement currentNode = context.CurrentNode; context.CurrentNode = etalonNode; var buildResult = assemblyInner(factory, context); int index = 0; foreach (object result in buildResult) { if (result is IControl) ((IControl)result).Data = index++; } context.CurrentNode = currentNode; return buildResult; }
/// <summary> /// Constructor. /// </summary> /// <param name="viewFactory"></param> /// <param name="agentInstanceContext">contains required view services</param> /// <param name="xFieldName">is the field name of the field providing X data points</param> /// <param name="yFieldName">is the field name of the field providing X data points</param> /// <param name="eventType">Type of the event.</param> /// <param name="additionalProps">The additional props.</param> public RegressionLinestView(ViewFactory viewFactory, AgentInstanceContext agentInstanceContext, ExprNode xFieldName, ExprNode yFieldName, EventType eventType, StatViewAdditionalProps additionalProps) : base(viewFactory, agentInstanceContext, xFieldName, yFieldName, eventType, additionalProps) { }
private void CreateNewTask(object obj) { var createTaskPage = ViewFactory <ClientsPage, ClientsViewModel> .CreatePage(); this.Publish(new NavigateToPageMessage(createTaskPage)); }
private void CreateMenu() { Pages.Add(MenuType.Test, ViewFactory.CreatePage <MainViewModel, MainView>() as Page); Pages.Add(MenuType.TestTwo, ViewFactory.CreatePage <MainViewModel, MainView>() as Page); Pages.Add(MenuType.TestThree, ViewFactory.CreatePage <MainViewModel, MainView>() as Page); }
public ViewFactoryChain CreateFactories(int streamNum, EventType parentEventType, ViewSpec[] viewSpecDefinitions, StreamSpecOptions options, StatementContext context, bool isSubquery, int subqueryNumber) { // Clone the view spec list to prevent parameter modification IList <ViewSpec> viewSpecList = new List <ViewSpec>(viewSpecDefinitions); // Inspect views and add merge views if required ViewServiceHelper.AddMergeViews(viewSpecList); // Instantiate factories, not making them aware of each other yet var viewFactories = ViewServiceHelper.InstantiateFactories(streamNum, viewSpecList, context, isSubquery, subqueryNumber); ViewFactory parentViewFactory = null; IList <ViewFactory> attachedViewFactories = new List <ViewFactory>(); for (var i = 0; i < viewFactories.Count; i++) { var factoryToAttach = viewFactories[i]; try { factoryToAttach.Attach(parentEventType, context, parentViewFactory, attachedViewFactories); attachedViewFactories.Add(viewFactories[i]); parentEventType = factoryToAttach.EventType; } catch (ViewParameterException ex) { var text = "Error attaching view to parent view"; if (i == 0) { text = "Error attaching view to event stream"; } throw new ViewProcessingException(text + ": " + ex.Message, ex); } } // obtain count of data windows var dataWindowCount = 0; var firstNonDataWindowIndex = -1; for (var i = 0; i < viewFactories.Count; i++) { var factory = viewFactories[i]; if (factory is DataWindowViewFactory) { dataWindowCount++; continue; } if ((factory is GroupByViewFactoryMarker) || (factory is MergeViewFactory)) { continue; } if (firstNonDataWindowIndex == -1) { firstNonDataWindowIndex = i; } } var isAllowMultipleExpiry = context.ConfigSnapshot.EngineDefaults.ViewResources.IsAllowMultipleExpiryPolicies; var isRetainIntersection = options.IsRetainIntersection; var isRetainUnion = options.IsRetainUnion; // Set the default to retain-intersection unless allow-multiple-expiry is turned on if ((!isAllowMultipleExpiry) && (!isRetainUnion)) { isRetainIntersection = true; } // handle multiple data windows with retain union. // wrap view factories into the union view factory and handle a group-by, if present if ((isRetainUnion || isRetainIntersection) && dataWindowCount > 1) { viewFactories = GetRetainViewFactories(parentEventType, viewFactories, isRetainUnion, context); } return(new ViewFactoryChain(parentEventType, viewFactories)); }
public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories) { this._eventType = parentEventType; }
public void ControllerConstructorException() { Assert.Throws <InvalidOperationException>(() => ViewFactory .Create <MockView <ConstructorExceptionThrowingController>, ConstructorExceptionThrowingController>()); }
void RegistView <T>(string abName) { Type t = typeof(T); ViewFactory.Register(abName, t.Name, t); }
void OnListViewCreating(object sender, ListViewCreatingEventArgs args) { args.View = ViewFactory.CreateListView(this, args.ViewID, args.CollectionSource, args.IsRoot); }
protected virtual void setControlProperty( Type typeOfControl, object control, ViewFactory factory, BuildContext context, PropertyMap pm) { var name = pm.Name; PropertyInfo property = getProperty(typeOfControl, name); if (property == null || property.CanWrite == false) return; object value = getAttributeValue(context.CurrentNode, property.PropertyType, name); if (value != null) property.SetValue(control, value, null); }
public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories) { _criteriaExpressions = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, ViewParameters, false); if (_criteriaExpressions.Length == 0) { String errorMessage = ViewName + " view requires a one or more expressions provinding unique values as parameters"; throw new ViewParameterException(errorMessage); } _eventType = parentEventType; }
void OnDetailViewCreating(object sender, DetailViewCreatingEventArgs args) { args.View = ViewFactory.CreateDetailView(this, args.ViewID, args.Obj, args.ObjectSpace, args.IsRoot); }
public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories) { ExprNode[] validated = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, _viewParameters, true); if (validated.Length < 2) { throw new ViewParameterException(ViewParamMessage); } if ((!validated[0].ExprEvaluator.ReturnType.IsNumeric()) || (!validated[1].ExprEvaluator.ReturnType.IsNumeric())) { throw new ViewParameterException(ViewParamMessage); } _fieldNameX = validated[0]; _fieldNameWeight = validated[1]; _additionalProps = StatViewAdditionalProps.Make(validated, 2, parentEventType); _eventType = WeightedAverageView.CreateEventType(statementContext, _additionalProps, _streamNumber); }
protected virtual bool tryParseComplexValue( Type typeOfControl, object control, ViewFactory factory, BuildContext context, PropertyMap pm) { var name = pm.Name; var binding = ComplexParser.GetValue( getAttributeValue(context.CurrentNode, typeof(string), name), "Binding", "Path"); if (binding != null) { object source = null; PropertyInfo sourceProperty = null; // будет работать только если контрол, на который биндимся уже создали (пока что и так хватит) if (binding.ContainsKey("SourceControl")) { source = factory.GetControl(binding["SourceControl"]); sourceProperty = getProperty(source.GetType(), binding["Path"]); } else { source = context.View; sourceProperty = getProperty(context.TypeOfView, binding["Path"]); } object target = control; PropertyInfo targetProperty = getProperty(typeOfControl, name); // тут targetProperty или sourceProperty могут быть фиктивными и потому не надо делать жосткой проверки // базовый BindingExpression сам выбросить исключение если надо if (source != null && target != null) { EBingingMode mode = EBingingMode.OneTime; if (binding.ContainsKey("Mode")) mode = (EBingingMode)ValueParser.GetValue(typeof(EBingingMode), binding["Mode"]); BindingExpression be = createBindingExpression( mode, source, sourceProperty, target, targetProperty); applyBindingExpression( be, factory, binding); } return true; } var resource = ComplexParser.GetValue( getAttributeValue(context.CurrentNode, typeof(string), name), "Resource", "Key"); if (resource != null) { var property = getProperty(typeOfControl, name); var value = factory.GetLocalString(resource["Key"]); if (property != null && property.CanWrite) { property.SetValue(control, value, null); } return true; } return false; }
internal static void SetViewFactory(DependencyObject obj, ViewFactory value) { obj.SetValue(ViewFactoryProperty, value); }
public void ComposeTest() { var host = new AddinHost(); var importer = new ViewFactory(); host.Compose(importer); }
private void RegisterViews() { ViewFactory.Register <MainView, MainViewModel>(); ViewFactory.Register <Home, HomeViewModel>(); }
/// <summary> /// Gives notification that something was removed from the document /// in a location that this view is responsible for. /// </summary> public void removeUpdate(DocumentEvent @e, Shape @a, ViewFactory @f) { }