public string Generate(MahuaEventInfo mahuaEventInfo) { var dirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ItemTemplate", "MahuaEvent"); var dir = new DirectoryInfo(dirPath); if (!dir.Exists) { Directory.CreateDirectory(dir.FullName); Thread.Sleep(100); } var mahuaEventCs = new MahuaEventCS { Session = new Dictionary <string, object> { ["Des"] = mahuaEventInfo } }; mahuaEventCs.Initialize(); var cs = mahuaEventCs.TransformText(); var className = mahuaEventInfo.Name.Substring(1); WriteFileWithUtf8Bom(cs, Path.Combine(dirPath, $"{className}.cs"), true); return($"{className}.cs"); }
public string Generate(MahuaEventInfo mahuaEventInfo) { var className = mahuaEventInfo.Name.Substring(1); var dirPath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, className); var dir = new DirectoryInfo(dirPath); if (dir.Exists) { dir.Delete(true); Thread.Sleep(100); } Directory.CreateDirectory(dir.FullName); var mahuaEventCs = new MahuaEventCS { Session = new Dictionary <string, object> { ["Des"] = mahuaEventInfo } }; mahuaEventCs.Initialize(); var cs = mahuaEventCs.TransformText(); WriteFileWithUtf8Bom(cs, Path.Combine(dirPath, $"{className}.cs"), true); var mahuaEventMyTemplateXml = new MahuaEventMyTemplateXml { Session = new Dictionary <string, object> { ["Des"] = mahuaEventInfo } }; mahuaEventMyTemplateXml.Initialize(); var xml = mahuaEventMyTemplateXml.TransformText(); WriteFileWithUtf8Bom(xml, Path.Combine(dirPath, "MyTemplate.vstemplate"), false); File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logo.png"), Path.Combine(dirPath, "__TemplateIcon.png")); File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logo.png"), Path.Combine(dirPath, "__PreviewImage.png")); Process.Start("7z.exe", $"a {className}.zip .\\{className}\\*"); return($"{className}.zip"); }
public MahuaEventInfo Resolve(Type mahuaEventType) { var method = mahuaEventType.GetMethods().Single(); var contextType = method.GetParameters().Single().ParameterType; var re = new MahuaEventInfo { Name = mahuaEventType.Name, Summary = ((DescriptionAttribute)mahuaEventType.GetCustomAttributes(typeof(DescriptionAttribute)) .First()) .Description, Type = mahuaEventType, MethodName = method.Name, MethodContextName = contextType.Name, MethodContextType = contextType }; return(re); }