Exemplo n.º 1
0
        private MetadataReader GetMetadataReader(ModuleMetadata metadata)
        {
            // TODO: right now, use reflection, but this API will be added as public API soon. when that happen, remove reflection
            var metadataReaderPropertyInfo = metadata.GetType().GetTypeInfo().GetDeclaredProperty("MetadataReader");
            var metadataReader             = (MetadataReader)metadataReaderPropertyInfo.GetValue(metadata);

            return(metadataReader);
        }
        /// <summary>
        /// 由模块元数据生成模块业务综合实现类代码
        /// </summary>
        /// <param name="module">模块元数据</param>
        /// <returns>模块业务综合实现类代码</returns>
        public virtual CodeFile GenerateServiceMainImpl(ModuleMetadata module)
        {
            string code;

            if (!_keyDict.TryGetValue(CodeType.ServiceMainImpl, out ITemplateKey key))
            {
                string template = GetInternalTemplate(CodeType.ServiceMainImpl);
                key  = GetKey(CodeType.ServiceMainImpl, template);
                code = Engine.Razor.RunCompile(template, key, module.GetType(), module);
                _keyDict.Add(CodeType.ServiceMainImpl, key);
            }
            else
            {
                code = Engine.Razor.Run(key, module.GetType(), module);
            }
            return(new CodeFile()
            {
                SourceCode = code,
                FileName = $"{module.Project.NamespacePrefix}.Core/{module.Name}/{module.Name}Service.generated.cs"
            });
        }
 private MetadataReader GetMetadataReader(ModuleMetadata metadata)
 {
     // TODO: right now, use reflection, but this API will be added as public API soon. when that happen, remove reflection
     var metadataReaderPropertyInfo = metadata.GetType().GetTypeInfo().GetDeclaredProperty("MetadataReader");
     var metadataReader = (MetadataReader)metadataReaderPropertyInfo.GetValue(metadata);
     return metadataReader;
 }