protected void CreateContentByConfiguration(IEnumerable <GraphItemConfiguration> graphItemConfigurations, GenericNode node = null) { foreach (var item in graphItemConfigurations.OrderBy(p => p.OrderIndex)) { var proxyConfig = item as ConfigurationProxyConfiguration; if (proxyConfig != null) { if (!IsVisible(proxyConfig.Visibility)) { continue; } CreateContentByConfiguration(proxyConfig.ConfigSelector(DataObject as GenericNode)); continue; } var inputConfig = item as NodeInputConfig; if (inputConfig != null) { if (inputConfig.IsOutput) { AddOutput(inputConfig, node); } else if (inputConfig.IsInput) { AddInput(inputConfig, node); } } var sectionConfig = item as NodeConfigSectionBase; if (sectionConfig != null) { AddSection(sectionConfig); } } }
//public class CodeGeneratorFactory : DesignerGeneratorFactory<TNode> //{ // public override IEnumerable<OutputGenerator> CreateGenerators(IGraphConfiguration graphConfig, TNode item) // { // if (item.Precompiled) yield break; // if (!item.IsValid) yield break; // var config = Container.GetNodeConfig<TNode>(); // if (config.CodeGenerators == null) yield break; // var generatorArgs = new ConfigCodeGeneratorSettings() // { // Data = item, // }; // foreach (var outputGenerator in config.OutputGenerators) // { // var generator = outputGenerator(); // generator.ObjectData = item; // yield return generator; // } // foreach (var generatorMethod in config.CodeGenerators) // { // var result = generatorMethod(generatorArgs); // if (result != null) // { // if (config.TypeGeneratorConfigs != null && config.TypeGeneratorConfigs.ContainsKey(result.GetType())) // { // var generatorConfig = // config.TypeGeneratorConfigs[result.GetType()] as NodeGeneratorConfig<TNode>; // if (generatorConfig != null) // { // if (generatorConfig.Condition != null && !generatorConfig.Condition(item)) continue; // if (result.IsDesignerFile) // { // if (generatorConfig.DesignerFilename != null) // result.Filename = generatorConfig.DesignerFilename.GetValue(item); // } // else // { // if (generatorConfig.Filename != null) // result.Filename = generatorConfig.Filename.GetValue(item); // } // } // } // yield return result; // } // } // } //} //public NodeConfig<TNode> AddFlag(string flag) //{ // Container.RegisterInstance<IDiagramNodeCommand>(new GraphItemFlagCommand<TNode>(flag, flag), typeof(TNode).Name + flag + "FlagCommand"); // return this; //} //public NodeConfig<TNode> AddFlag(string flag, Func<TNode, bool> get, Action<TNode, bool> set) //{ // Container.RegisterInstance<IDiagramNodeCommand>(new GraphItemFlagCommand<TNode>(flag, flag) // { // IsProperty = true, // Get = get, // Set = set // }, flag + "Command"); // return this; //} public override bool IsValid(GenericNode node) { return(!Validate(node as TNode).Any()); }