public static NodeConfig <TNodeData> AddNode <TNodeData>(this IUFrameContainer container, string tag = null) where TNodeData : GenericNode { var config = container.AddNode <TNodeData, ScaffoldNode <TNodeData> .ViewModel, ScaffoldNode <TNodeData> .Drawer>(tag); return(config); }
public static GraphItemViewModel GetNodeViewModel(this IUFrameContainer container, IGraphItem item, DiagramViewModel diagram) { var vm = InvertApplication.Container.ResolveRelation <ViewModel>(item.GetType(), new object[] { item, diagram }) as GraphItemViewModel; return(vm); }
public static void RegisterConnectable <TOutput, TInput>(this IUFrameContainer container) { container.RegisterInstance <RegisteredConnection>(new RegisteredConnection() { TInputType = typeof(TInput), TOutputType = typeof(TOutput) }, typeof(TOutput).Name + typeof(TInput).Name); }
public static WorkspaceConfiguration AddWorkspaceConfig <TWorkspaceType>(this IUFrameContainer container, string title, string description = null) { var config = new WorkspaceConfiguration(typeof(TWorkspaceType), title, description); container.RegisterInstance(config, typeof(TWorkspaceType).Name); return(config); }
public static void RegisterViewModel <TViewModel>(this IUFrameContainer container, TViewModel viewModel, string identifier) where TViewModel : ViewModel { container.Register <TViewModel, TViewModel>(); container.RegisterInstance <ViewModel>(viewModel, identifier); container.RegisterInstance(typeof(TViewModel), viewModel, identifier); }
public static void RegisterConnectable(this IUFrameContainer container, Type outputType, Type inputType) { container.RegisterInstance <RegisteredConnection>(new RegisteredConnection() { TInputType = inputType, TOutputType = outputType }, outputType.Name + inputType.Name); }
public static NodeConfig <TGraphNode> AddGraph <TGraphType, TGraphNode>(this IUFrameContainer container, string name) where TGraphType : IGraphData where TGraphNode : GenericNode, new() { container.Register <IGraphData, TGraphType>(name); return(AddNode <TGraphNode>(container, name)); }
//public static IEnumerable<IDiagramNode> GetContainingNodesInProject(this IGraphFilter filter, IProjectRepository repository) //{ // return GetContainerNodesInProjectInternal(filter, repository).Distinct(); //} //private static IEnumerable<IDiagramNode> GetContainerNodesInProjectInternal(IGraphFilter filter, IProjectRepository repository) //{ // foreach (var item in repository.Graphs) // { // var positionData = item.PositionData; // FilterLocations locations; // if (positionData.Positions.TryGetValue(filter.Identifier, out locations)) // { // foreach (var node in repository.NodeItems) // { // if (node == filter) continue; // if (locations.Keys.Contains(node.Identifier)) // { // yield return node; // } // } // } // } //} //public static IEnumerable<IDiagramNode> GetParentNodes(this IDiagramNode node) //{ // foreach (var item in node.Project.PositionData.Positions) // { // if (item.Value.Keys.Contains(node.Identifier)) // { // yield return node.Project.NodeItems.FirstOrDefault(p => p.Identifier == item.Key); // } // } //} //public static IEnumerable<IDiagramNode> GetContainingNodesResursive(this IDiagramFilter filter, INodeRepository repository) //{ // foreach (var item in filter.GetContainingNodes(repository)) // { // yield return item; // if (item is IDiagramFilter) // { // var result = GetContainingNodesResursive(item as IDiagramFilter, repository); // foreach (var subItem in result) // yield return subItem; // } // } //} public static void RegisterFilterNode <TFilterData, TAllowedItem>(this IUFrameContainer container) { if (!FilterExtensions.AllowedFilterNodes.ContainsKey(typeof(TFilterData))) { FilterExtensions.AllowedFilterNodes.Add(typeof(TFilterData), new List <Type>()); } FilterExtensions.AllowedFilterNodes[typeof(TFilterData)].Add(typeof(TAllowedItem)); }
public static void RegisterFilterNode(this IUFrameContainer container, Type filter, Type tnode) { if (!FilterExtensions.AllowedFilterNodes.ContainsKey(filter)) { FilterExtensions.AllowedFilterNodes.Add(filter, new List <Type>()); } FilterExtensions.AllowedFilterNodes[filter].Add(tnode); }
public static IUFrameContainer AddTypeItem <TNodeData, TViewModel, TDrawer>(this IUFrameContainer container) where TNodeData : ITypedItem { container.AddItem <TNodeData>(); container.RegisterChildGraphItem <TNodeData, TViewModel, TDrawer>(); return(container); }
public static void RegisterViewModelManager <TViewModel>(this IUFrameContainer container, IViewModelManager <TViewModel> manager) { container.RegisterInstance <IViewModelManager>(manager, typeof(TViewModel).Name.Replace("ViewModel", "")); container.RegisterInstance <IViewModelManager>(manager, typeof(TViewModel).Name); container.RegisterInstance <IViewModelManager <TViewModel> >(manager, typeof(TViewModel).Name.Replace("ViewModel", "")); container.RegisterInstance <IViewModelManager <TViewModel> >(manager); }
public static WindowFactory <TWindow> RegisterWindow <TWindow>(this IUFrameContainer container, string name) where TWindow : class, IWindow { var factory = new WindowFactory <TWindow>(container, name); container.RegisterInstance(factory, name); container.RegisterInstance <IWindowFactory>(factory, name); //container.RegisterInstance<IWindowFactory<TWindow>>(factory,name); return(factory); }
public static void RegisterController <TController>(this IUFrameContainer container, TController controller) where TController : Controller { container.RegisterInstance <Controller>(controller, controller.GetType().Name, false); container.RegisterInstance <ISystemService>(controller, controller.GetType().Name, false); container.RegisterInstance <TController>(controller, false); // Todo Convention hack make it prettier :) container.RegisterInstance <Controller>(controller, typeof(TController).Name.ReplaceLast("Controller", "ViewModel")); }
public static IUFrameContainer Connectable <TSource, TTarget>(this IUFrameContainer container, Color color, bool oneToMany = true) where TSource : class, IConnectable where TTarget : class, IConnectable { container.RegisterConnectable <TSource, TTarget>(); //if (oneToMany) //container.RegisterInstance<IConnectionStrategy>(new CustomInputOutputStrategy<TSource, TTarget>(color), typeof(TSource).Name + "_" + typeof(TTarget).Name + "Connection"); //else //{ // container.RegisterInstance<IConnectionStrategy>(new OneToOneConnectionStrategy<TSource, TTarget>(), typeof(TSource).Name + "_" + typeof(TTarget).Name + "Connection"); //} return(container); }
private static void InitializeContainer(IUFrameContainer container) { _plugins = null; container.RegisterInstance <IUFrameContainer>(container); var pluginTypes = GetDerivedTypes <ICorePlugin>(false, false).ToArray(); // Load all plugins foreach (var diagramPlugin in pluginTypes) { if (pluginTypes.Any(p => p.BaseType == diagramPlugin)) { continue; } var pluginInstance = Activator.CreateInstance((Type)diagramPlugin) as ICorePlugin; if (pluginInstance == null) { continue; } container.RegisterInstance(pluginInstance, diagramPlugin.Name, false); container.RegisterInstance(pluginInstance.GetType(), pluginInstance); if (pluginInstance.Enabled) { foreach (var item in diagramPlugin.GetInterfaces()) { ListenFor(item, pluginInstance); } } } container.InjectAll(); foreach (var diagramPlugin in Plugins.OrderBy(p => p.LoadPriority).Where(p => !p.Ignore)) { if (diagramPlugin.Enabled) { var start = DateTime.Now; diagramPlugin.Container = Container; diagramPlugin.Initialize(Container); } } foreach (var diagramPlugin in Plugins.OrderBy(p => p.LoadPriority).Where(p => !p.Ignore)) { if (diagramPlugin.Enabled) { var start = DateTime.Now; container.Inject(diagramPlugin); diagramPlugin.Loaded(Container); diagramPlugin.LoadTime = DateTime.Now.Subtract(start); } } SignalEvent <ISystemResetEvents>(_ => _.SystemRestarted()); }
public static NodeConfigBase GetNodeConfig(this IUFrameContainer container, Type nodeType) { var config = container.Resolve <NodeConfigBase>(nodeType.Name); if (config == null) { var nodeconfigType = typeof(NodeConfig <>).MakeGenericType(nodeType); var nodeConfig = Activator.CreateInstance(nodeconfigType, container) as NodeConfigBase; nodeConfig.NodeType = nodeType; container.RegisterInstance <NodeConfigBase>(nodeConfig, nodeType.Name); //nodeConfig.Section(string.Empty, _ => _.PersistedItems.OfType<GenericConnectionReference>(), false); return(nodeConfig); } return(config); }
public static IDrawer CreateDrawer <TDrawerBase>(this IUFrameContainer container, ViewModel viewModel) where TDrawerBase : IDrawer { if (_drawers != null) { } if (viewModel == null) { InvertApplication.LogError("Data is null."); return(null); } var drawer = container.ResolveRelation <TDrawerBase>(viewModel.GetType(), new object[] { viewModel }); if (drawer == null) { InvertApplication.Log(String.Format("Couldn't Create drawer for {0}.", viewModel.GetType())); } return(drawer); }
public static void RegisterFilterItem <TFilterData, TAllowedItem>(this IUFrameContainer container) { container.RegisterRelation <TFilterData, IDiagramNodeItem, TAllowedItem>(); }
protected NodeConfigBase(IUFrameContainer container) { Container = container; }
public static WorkspaceConfiguration WorkspaceConfig <TWorkspaceType>(this IUFrameContainer container) { return(container.Resolve <WorkspaceConfiguration>(typeof(TWorkspaceType).Name) ?? container.AddWorkspaceConfig <TWorkspaceType>(typeof(TWorkspaceType).Name)); }
public static void RegisterViewModelController <TController, TViewModel>(this IUFrameContainer container, TController controller) where TController : Controller { }
public static GraphItemViewModel CreateViewModel(this IUFrameContainer container, object data) { return(container.ResolveRelation <ViewModel>(data.GetType(), new object[] { data, null }) as GraphItemViewModel); }
public static IDrawer CreateDrawer(this IUFrameContainer container, ViewModel viewModel) { return(CreateDrawer <IDrawer>(container, viewModel)); }
//public static IUFrameContainer ConnectionStrategy<TSource, TTarget>(this IUFrameContainer container, Color connectionColor, // Func<TSource, TTarget, bool> isConnected, Action<TSource, TTarget> apply, Action<TSource, TTarget> remove) where TSource : class, IConnectable where TTarget : class, IConnectable //{ // container.RegisterInstance<IConnectionStrategy>(new CustomConnectionStrategy<TSource, TTarget>(connectionColor,isConnected,apply,remove), typeof(TSource).Name + "_" + typeof(TTarget).Name + "CustomConnection"); // return container; //} public static IUFrameContainer RegisterGraphItem <TModel, TViewModel>(this IUFrameContainer container) { container.RegisterRelation <TModel, ViewModel, TViewModel>(); return(container); }
public static IUFrameContainer RegisterConnectionStrategy <TConnectionStrategy>(this IUFrameContainer container) where TConnectionStrategy : IConnectionStrategy, new() { container.RegisterInstance <IConnectionStrategy>(new TConnectionStrategy(), typeof(TConnectionStrategy).Name); return(container); }
public static IUFrameContainer RegisterDataChildViewModel <TModel, TViewModel>(this IUFrameContainer container) { container.RegisterRelation <TModel, ItemViewModel, TViewModel>(); return(container); }
public static IUFrameContainer Connectable <TSource, TTarget>(this IUFrameContainer container, bool oneToMany = true) where TSource : class, IConnectable where TTarget : class, IConnectable { return(Connectable <TSource, TTarget>(container, Color.white, oneToMany)); }
public static uFrameBindingType AddBindingMethod(this IUFrameContainer container, Type type, string methodName, Func <ITypedItem, bool> canBind) { return(container.AddBindingMethod(new uFrameBindingType(type, methodName, canBind), methodName)); }
public static uFrameBindingType AddBindingMethod(this IUFrameContainer container, uFrameBindingType info, string name) { container.RegisterInstance <uFrameBindingType>(info, name, true); return(info); }
public static IUFrameContainer RegisterCodeTemplate <TFor, TTemplateType>(this IUFrameContainer container) { container.RegisterRelation <TFor, CodeGenerator, TTemplateType>(); return(container); }