Example #1
0
        /// <summary>
        /// Render the given GraphViz code into a string. Some rendering methods output
        /// text rather than images
        /// </summary>
        /// <param name="dotSourceText"></param>
        /// <param name="returnType"></param>
        /// <returns></returns>
        public string RenderToText(string dotSourceText, GvTextOutputFormat returnType)
        {
            var byteArray = RenderGraph(dotSourceText, returnType);

            return(byteArray.Length == 0
                ? String.Empty
                : Encoding.Default.GetString(byteArray));
        }
Example #2
0
        /// <summary>
        /// Render the given GraphViz code into a string and also save it to file.
        /// </summary>
        /// <param name="dotSourceText"></param>
        /// <param name="returnType"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public string RenderToTextAndFile(string dotSourceText, GvTextOutputFormat returnType, string filePath)
        {
            var byteArray = RenderGraph(dotSourceText, returnType);

            if (byteArray.Length == 0)
            {
                return(String.Empty);
            }

            try
            {
                File.WriteAllBytes(filePath, byteArray);
            }
            catch (Exception e)
            {
                _errorsList.Add(e.Message);
            }

            return(Encoding.Default.GetString(byteArray));
        }