private static string GetUniqueSuffixWithinBase(ComputeForNewBaseItemsInfo info)
        {
            var baseModule = info.Dependency_Extends.Base.Module;

            return(DslUtility.NameOptionalModule(info.EntityComputedFrom.Source, baseModule)
                   + DslUtility.NameOptionalModule(info.EntityComputedFrom.Target, baseModule));
        }
        public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder)
        {
            var info         = (ComputeForNewBaseItemsInfo)conceptInfo;
            var baseDS       = info.Dependency_Extends.Base;
            var uniqueSuffix = DslUtility.NameOptionalModule(info.EntityComputedFrom.Source, baseDS.Module)
                               + DslUtility.NameOptionalModule(info.EntityComputedFrom.Target, baseDS.Module);

            string saveFilterArgument;

            if (!string.IsNullOrWhiteSpace(info.FilterSaveExpression))
            {
                string saveFilterMethodName = $"FilterSaveComputeForNewBaseItems_{uniqueSuffix}";
                var    extensionDS          = info.Dependency_Extends.Extension;

                var    parsedExpression = new ParsedExpression(info.FilterSaveExpression, new[] { $"IEnumerable<{extensionDS.FullName}>" }, info);
                string filterSaveMethod = $@"private IEnumerable<{extensionDS.FullName}> {saveFilterMethodName}{parsedExpression.MethodParametersAndBody}

        ";

                codeBuilder.InsertCode(filterSaveMethod, RepositoryHelper.RepositoryMembers, baseDS);

                saveFilterArgument = $", {saveFilterMethodName}";
            }
            else
            {
                saveFilterArgument = "";
            }


            string callRecomputeOnSave = $@"if (insertedNew.Any())
                {{
                    Guid[] insertedIds = insertedNew.Select(item => item.ID).ToArray();
                    _domRepository.{info.EntityComputedFrom.Target.FullName}.{EntityComputedFromCodeGenerator.RecomputeFunctionName(info.EntityComputedFrom)}(insertedIds{saveFilterArgument});
                }}
                ";

            codeBuilder.InsertCode(callRecomputeOnSave, WritableOrmDataStructureCodeGenerator.OnSaveTag1, baseDS);
        }
Ejemplo n.º 3
0
 public static string RecomputeFunctionName(EntityComputedFromInfo info)
 {
     return("RecomputeFrom" + DslUtility.NameOptionalModule(info.Source, info.Target.Module));
 }
 private static string GetUniqueSuffixWithinTarget(ComputeForNewItemsInfo info)
 {
     return(DslUtility.NameOptionalModule(info.EntityComputedFrom.Source, info.EntityComputedFrom.Target.Module));
 }