Exemple #1
0
        //private static object CreateSettingsForProject(ITreeConfigNode node, AppProject tt, Dictionary<string, object> dic_apgs, bool isShortVersion)
        //{
        //    TypeBuilder tbAppGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for app generators
        //    foreach (var ttt in tt.ListAppProjectGenerators)
        //    {
        //        if (!string.IsNullOrWhiteSpace(ttt.PluginGuid))
        //        {
        //            if (!string.IsNullOrWhiteSpace(ttt.PluginGeneratorGuid))
        //            {
        //                Dictionary<string, object> dic_gs = new Dictionary<string, object>();

        //                object objGen = null;
        //                objGen = CreateSettingsForAppProjectGenerator(node, ttt, dic_gs, isShortVersion);

        //                if (dic_gs.Count > 0)
        //                {
        //                    dic_apgs[ttt.Name] = objGen;
        //                    SettingsTypeBuilder.CreateProperty(tbAppGen, ttt.Name, typeof(Object), ttt.NameUi, ttt.Description);
        //                }
        //            }
        //        }
        //    }
        //    SettingsTypeBuilder.CreateToString(tbAppGen, "Project");
        //    Type apgsType = tbAppGen.CreateType();
        //    var objAppGen = Activator.CreateInstance(apgsType);
        //    foreach (var dt in dic_apgs)
        //    {
        //        apgsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objAppGen, new object[] { dt.Value });
        //    }
        //    return objAppGen;
        //}
        private static object CreateSettingsForAppProjectGenerator(ITreeConfigNode node, AppProjectGenerator ttt, Dictionary <string, object> dic_gs, bool isShortVersion)
        {
            var         nds   = (IGetNodeSetting)node;
            TypeBuilder tbGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for generators

            foreach (var tttt in ttt.ListGenerators)
            {
                if (tttt.Generator == null)
                {
                    continue;
                }
                if (isShortVersion && (tttt.Guid != ttt.PluginGeneratorGuid))
                {
                    continue;
                }
                IvPluginGenerator gen = tttt.Generator;
                var nsettings         = nds.GetSettings(ttt.Guid);
                if (nsettings == null)
                {
                    continue;
                }
                SettingsTypeBuilder.CreateProperty(tbGen, gen.Name, nsettings.GetType(), gen.NameUi, gen.Description);
                dic_gs[gen.Name] = nsettings;
            }
            SettingsTypeBuilder.CreateToString(tbGen, "Generator");
            Type settingsType = tbGen.CreateType();
            var  objGen       = Activator.CreateInstance(settingsType);

            foreach (var dt in dic_gs)
            {
                settingsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objGen, new object[] { dt.Value });
            }
            return(objGen);
        }
Exemple #2
0
        partial void OnPluginGeneratorGuidChanging(ref string to)
        {
            if (!this.IsNotifying)
            {
                return;
            }
            if (cfg._DicActiveAppProjectGenerators.ContainsKey(this.Guid))
            {
                cfg._DicActiveAppProjectGenerators.Remove(this.Guid);
            }
            var nv = new ModelVisitorNodeGenSettings();

            nv.NodeGenSettingsApplyAction(cfg, (p) =>
            {
                p.RemoveNodeAppGenSettings(this.Guid);
            });
            this.GeneratorSettings    = string.Empty;
            this.DescriptionGenerator = string.Empty;
            //this.DicGenNodeSettings.TryRemove(this.Guid);
            this._PluginGenerator = null;
            cfg.Model._DicGenNodeSettings.TryRemove(this.Guid);
            this.DynamicGeneratorSettings   = null;
            this.DynamicMainConnStrSettings = null;
            this.DynamicModelNodeSettings   = null;
        }
 public PluginGenerator(ITreeConfigNode parent, IvPluginGenerator plugin)
     : this(parent)
 {
     Contract.Requires(plugin != null);
     this.Guid             = plugin.Guid.ToString();
     this._Name            = plugin.Name;
     this.Description      = plugin.Description;
     this.Generator        = plugin;
     this.Generator.Parent = this;
     this.IsEditable       = false;
 }
 public void SetGenerator(IvPluginGenerator generator)
 {
     Contract.Requires(generator != null);
     this.Generator        = generator;
     this.Generator.Parent = this;
 }
        private void SearchPathAndAdd(AppProjectGenerator appgen, INodeGenSettings ngs, IvPluginGenerator gen)
        {
            foreach (var t in gen.GetListNodeGenerationSettings())
            {
                string modelPath     = this.ModelPath;
                var    searchPattern = t.SearchPathInModel;
                var    is_found      = SearchInModelPathByPattern(modelPath, searchPattern);

                if (is_found)
                {
                    GeneratorSettings gs = new GeneratorSettings(this);
                    gs.NodeSettingsVmGuid = t.Guid;
                    gs.AppGeneratorGuid   = appgen.Guid;
                    _logger.LogTrace("Adding Node Settings. {Path} NodeSettingsVmGuid={NodeSettingsVmGuid} Name={Name}".CallerInfo(), t.SearchPathInModel, gs.NodeSettingsVmGuid, appgen.Name);
#if DEBUG
                    foreach (var ttt in ngs.ListGeneratorsSettings)
                    {
                        if (ttt.AppGeneratorGuid == appgen.Guid)
                        {
                            throw new Exception();
                        }
                    }
#endif
                    ngs.ListGeneratorsSettings.Add(gs);
                    gs.SettingsVm = t.GetAppGenerationNodeSettingsVm(gs.Settings);
                    break;
                }
            }
        }