public string ToPng(C4DocumentBase doc, string outputFolder) { string imageFileName = Path.ChangeExtension(Path.Combine(outputFolder, doc.Name), ".png"); string encString = Encoder.EncodeUrl(doc.ToString()); WebRenderer r = new WebRenderer(); var bytes = r.Render(encString); File.WriteAllBytes(imageFileName, bytes); return(imageFileName); }
private int HandleCommand(string assembly, string outputFolder) { try { if (!string.IsNullOrEmpty(assembly)) { System.Reflection.Assembly loaded = System.Reflection.Assembly.LoadFrom(assembly); if (loaded != null) { var type = typeof(C4DocumentBase); string saveToFolder = Path.GetDirectoryName(assembly); if (!string.IsNullOrEmpty(outputFolder)) { saveToFolder = outputFolder; } // https://stackoverflow.com/questions/26733/getting-all-types-that-implement-an-interface Type[] types = loaded.GetTypes().Where(p => type.IsAssignableFrom(p) && !p.IsInterface).ToArray(); foreach (Type t in types) { C4DocumentBase instance = (C4DocumentBase)Activator.CreateInstance(t); ShowImage(ToPng(instance, saveToFolder)); } } } } catch (Exception ex) { Console.WriteLine(ex); return(1); } return(0); }
public string ToPuml(C4DocumentBase doc) { return(doc.ToString()); }