コード例 #1
0
        private static void GenerateLogServiceFile(string basePath, Type type, Type nullableAttributeType)
        {
            string loggedServiceName = GetLogServiceName(type.Name);

            var fileName = Path.Combine(basePath, loggedServiceName + ".cs");

            var generator = new LoggedServiceCodeGenerator(nullableAttributeType);

            var fileContent = generator.Generate(type);

            File.WriteAllText(fileName, fileContent);
        }
コード例 #2
0
        private static IEnumerable <string> GenerateLogServiceFile(string basePath, Type type, Type nullableAttributeType)
        {
            string loggedServiceName = GetLogServiceName(type.Name);

            var    isIService              = type.Name == "IService";
            var    baseClassName           = GetBaseClassName(type.Name);
            string parentLoggedServiceName = isIService ? "ILoggedService" : GetLogServiceName(type.BaseType?.Name ?? "IService");
            var    fileName = Path.Combine(basePath, loggedServiceName + ".cs");

            var generator = new LoggedServiceCodeGenerator(nullableAttributeType);

            var fileContent = generator.Generate(type);

            File.WriteAllText(fileName, fileContent);

            var list = new List <string> {
                $"$(MSBuildThisFileDirectory){Path.GetFileName(fileName)}"
            };

            return(list);
        }