public AppLauncher(MessagePipe messagePipe, UpdatePipe updatePipe, params Assembly[] appControlAssemblies) { var types = LaunchableTypes(appControlAssemblies); types.Do(type => _apps.Add(new KeyValuePair<Type, string>(type.Key, type.Value))); _messagePipe = messagePipe; _updatePipe = updatePipe; AppLines = _apps.Select(pair => (AppLine)new SingleAppLine(pair.Value)).ToList(); //get all of the class that implement IAppControl }
public void Navigate(Type type) { var grid = (Grid) Content; grid.Children.Clear(); var typeDict = new Dictionary<Type, object>(); typeDict[typeof (MessagePipe)] = new MessagePipe(this); var constructor = type.GetConstructors().Single(); constructor .GetParameters() .Where(parameter => !typeDict.ContainsKey(parameter.ParameterType)) .Do(parameter => { typeDict[parameter.ParameterType] = parameter.ParameterType.NewInstance<object>(); }); var parameters = constructor.GetParameters().Select(parameter => typeDict[parameter.ParameterType]).ToArray(); _ctrl = (IAppControl) constructor.Invoke(parameters); grid.Children.Add(_ctrl.GetControl()); }
public AppLauncherControl(MessagePipe messagePipe) { _messagePipe = messagePipe; }