private void RenderRepository(bool hasRepository, string domainEntityLabel)
        {
            var repositoryCode     = string.Empty;
            var repositoryAutoCode = string.Empty;

            if (hasRepository)
            {
                repositoryCode = @"

    /// <summary>
    /// $domainEntityLabel$ 仓库类。
    /// 负责 $domainEntityLabel$ 类的查询、保存。
    /// </summary>
    public partial class $domainEntityName$Repository : $domainBaseEntityName$Repository
    {
        /// <summary>
        /// 单例模式,外界不可以直接构造本对象。
        /// </summary>
        protected $domainEntityName$Repository() { }
    }"
                                 .Replace("$domainEntityLabel$", domainEntityLabel)
                                 .Replace("$domainEntityName$", _domainEntityName)
                                 .Replace("$domainBaseEntityName$", _domainBaseEntityName);

                repositoryAutoCode = ItemCodeTemplate.GetRepositoryCoreCode(_domainEntityName);
            }
            _replacementsDictionary.Add("$repositoryCode$", repositoryCode);
            _replacementsDictionary.Add("$repositoryAutoCode$", repositoryAutoCode);
        }
Exemple #2
0
        private void RenderViewConfiguration(bool isConfigView, string domainEntityLabel)
        {
            var viewConfiguration = string.Empty;

            if (isConfigView)
            {
                viewConfiguration = ItemCodeTemplate.GetViewConfigurationCode(domainEntityLabel, _domainEntityName);
            }
            _replacementsDictionary.Add("$viewConfiguration$", viewConfiguration);
        }
Exemple #3
0
        private void RenderParentRefProperty(string entityKeyType)
        {
            var parentRefPropertyCode = string.Empty;

            if (_isChild)
            {
                parentRefPropertyCode = ItemCodeTemplate.GetRefPropertyCode(
                    _domainEntityName, _parentEntityName, _parentEntityName, entityKeyType, true, true
                    );
            }
            _replacementsDictionary.Add("$refProperties$", parentRefPropertyCode);
        }
Exemple #4
0
        private void RenderRepository(bool hasRepository, string domainEntityLabel)
        {
            var repositoryCode     = string.Empty;
            var repositoryAutoCode = string.Empty;

            if (hasRepository)
            {
                repositoryCode     = ItemCodeTemplate.GetRepositoryCodeInEntityFile(_domainEntityName, domainEntityLabel, _domainBaseEntityName);
                repositoryAutoCode = ItemCodeTemplate.GetRepositoryFileCoreAutoCode(_domainEntityName);
            }
            _replacementsDictionary.Add("$repositoryCode$", repositoryCode);
            _replacementsDictionary.Add("$repositoryAutoCode$", repositoryAutoCode);
        }
Exemple #5
0
        private void WriteChildrenProperty(Document doc)
        {
            var textSelection = doc.Selection as TextSelection;

            if (textSelection != null)
            {
                textSelection.StartOfDocument(false);
                var found = textSelection.FindText("#region 子属性") || textSelection.FindText("#region 组合子属性");
                if (found)
                {
                    var childrenPropertyCode = @"#region 组合子属性" + ItemCodeTemplate.GetChildrenPropertyCode(_parentEntityName, _domainEntityName);
                    textSelection.Insert(childrenPropertyCode);
                }
            }
        }
        public override void RunStarted(
            object automationObject,
            Dictionary <string, string> replacementsDictionary,
            WizardRunKind runKind, object[] customParams)
        {
            _replacementsDictionary = replacementsDictionary;

            base.RunStarted(automationObject, _replacementsDictionary, runKind, customParams);

            var repoNamespace = _replacementsDictionary["$rootnamespace$"];
            var dnsItems      = repoNamespace.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

            var vm = new DomainEntityRepositoryWizardWindowViewModel();

            //如果文件的名称中没有以 Repository 结尾,则主动加上 Repository。
            var safeItemName = _replacementsDictionary["$safeitemname$"];

            if (safeItemName.EndsWith(Consts.RepositorySuffix))
            {
                vm.EntityTypeName = safeItemName.Substring(0, safeItemName.Length - Consts.RepositorySuffix.Length);
            }
            else
            {
                vm.EntityTypeName = safeItemName;
            }
            vm.BaseTypeName = dnsItems.Last() + Consts.EntityRepositorySuffix;
            vm.DTE          = automationObject as DTE;

            //显示向导窗口
            var win = new DomainEntityRepositoryWizardWindow();

            win.DataContext = vm;
            var res = win.ShowDialog();

            if (res != true)
            {
                _canceled = true;
                return;
            }

            //输出
            var repositoryAutoCode = ItemCodeTemplate.GetRepositoryCoreCode(vm.EntityTypeName);

            _replacementsDictionary.Add("$repositoryAutoCode$", repositoryAutoCode);
            _replacementsDictionary.Add("$domainNamespace$", vm.DomainNamespace);
            _replacementsDictionary.Add("$domainEntityName$", vm.EntityTypeName);
            _replacementsDictionary.Add("$baseRepositoryName$", vm.BaseTypeName);
        }