public static NodeConfig <TType> Inheritable <TType>(this NodeConfig <TType> config, string label = "Base") where TType : GenericInheritableNode { //config.Container.RegisterConnectable<TType, BaseClassReference>(); //config.Input<TType, BaseClassReference>(n => //{ // var inheritable = n.Node as GenericInheritableNode; // if (inheritable != null) // { // var baseNode = inheritable.BaseNode; // if (baseNode == null) return label; // return "Derived From: " + inheritable.BaseNode.Name; // } // return label; //},false, (o, i) => //{ // return o is TType && i is BaseClassReference && i.Node != o.Node; //}); //config.Container.RegisterInstance<IConnectionStrategy>(new InheritanceConnectionStrategy<TType>(), typeof(TType).Name + "_" + typeof(TType).Name + "InheritanceConnection"); return(config); }
//public NodeConfig<TNode> Validator(Func<TNode, bool> validate, string message, ValidatorType validatorType = ValidatorType.Warning) //{ // Validators.Add(new NodeValidator<TNode>() // { // Validate = validate, // Message = message, // Type = validatorType // }); // return this; //} #if !SERVER public NodeConfig<TNode> LoadDerived<TViewModel>(Action<NodeConfig<TNode>, Type> configure = null) { foreach (var item in InvertApplication.GetDerivedTypes<TNode>(false, false)) { Container.RegisterRelation(item, typeof(ViewModel), typeof(TViewModel)); var config = new NodeConfig<TNode>(Container); config.NodeType = item; Container.RegisterInstance<NodeConfigBase>(config, item.Name); config.Name = item.Name.Replace("Shell", "").Replace("Node", ""); //config.Tags.Add(config.Name); if (configure != null) { configure(config, item); } else { HasSubNode(item); } } return this; }
public static void AddCodeTemplate <TNode, TGeneratorTemplate>(this NodeConfig <TNode> nodeConfig) where TGeneratorTemplate : class, IClassTemplate <TNode>, new() where TNode : GenericNode { RegisteredTemplateGeneratorsFactory.RegisterTemplate <TNode, TGeneratorTemplate>(); }