public VisualTreeRunContext(
     IDIIntegration diIntegration, DependencyObject root, string targetMethodName,
     IEnumerable <object?> inputParameters)
 {
     DIIntegration    = diIntegration;
     Root             = root;
     TargetMethodName = targetMethodName;
     InputParameters  = inputParameters.ToArray();
     Targets          = TargetSelector.ResolveTarget(
         Root, diIntegration.GetRequired <TargetListCompositeExpander>());
     CandidateParameters =
         DIIntegration.GetRequired <ParameterListCompositeExpander>()
         .Expand(InputParameters.Concat(Targets));
 }
Example #2
0
 public UIElement ViewFromViewModel(object model, IDIIntegration diContainer)
 {
     try
     {
         var viewTypeName = ViewTypeNameFromModel(model) ??
                            throw new InvalidOperationException($"{model.GetType()} does not contain \"ViewModel\".");
         var targetType = ViewTypeFromName(model, viewTypeName) ??
                          throw new InvalidOperationException($"Could Not Find Type {viewTypeName}.");
         return((CreateView(targetType, diContainer) is UIElement elt) ? elt :
                DisplayMessage($"{viewTypeName} is not a UIElement."));
     }
     catch (InvalidOperationException e)
     {
         return(DisplayMessage(e.Message));
     }
 }
Example #3
0
 public static void AttachDiRoot(this Application app, IDIIntegration value) =>
 app.Resources.Add(rootDiKey, value);
Example #4
0
 public static void SetContainer(DependencyObject obj, IDIIntegration value) =>
 obj.SetValue(CoontainerProperty, value);
Example #5
0
 protected virtual object CreateView(Type targetType, IDIIntegration di) =>
 di.Get(targetType) ??
 DisplayMessage("DI container failed to create type " + targetType.Name);
Example #6
0
 public object?Create(IDIIntegration di, DependencyObject sender, object?[] args)
 {
     return(value);
 }
Example #7
0
 public object?Create(IDIIntegration di, DependencyObject sender, object?[] args)
 {
     return(di.Get(requestedParameter));
 }
Example #8
0
 public object?Create(IDIIntegration di, DependencyObject sender, object?[] args) => factory(sender, args);
Example #9
0
 public static T GetRequired <T>(this IDIIntegration di) => (T)di.Get(typeof(T)) ??