예제 #1
0
        private string Format(string text, Language language)
        {
            string options;

            if (_dialog == null)
            {
                MessageBox.Show("Unable to read AStyle Formatter settings.", "AStyle Formatter Error");
                return(null);
            }

            if (language == Language.CSharp)
            {
                options = _dialog.CsOptions;
            }
            else if (language == Language.Cpp)
            {
                options = _dialog.CppOptions;
            }
            else
            {
                return(null);
            }

            if (String.IsNullOrEmpty(options))
            {
                return(null);
            }

            var aStyle = new AStyleInterface();

            aStyle.ErrorRaised += OnAStyleErrorRaised;

            return(aStyle.FormatSource(text, options));
        }
        private string Format(string text, Language language)
        {
            string options;

            if (_props == null) {
                MessageBox.Show("Unable to read AStyle Formatter settings.", "AStyle Formatter Error");
                return null;
            }

            if (language == Language.CSharp) {
                options = (string)_props.Item("CsOptions").Value;
            } else if (language == Language.Cpp) {
                options = (string)_props.Item("CppOptions").Value;
            } else {
                return null;
            }

            if (String.IsNullOrEmpty(options)) {
                return null;
            }

            var aStyle = new AStyleInterface();
            aStyle.ErrorRaised += OnAStyleErrorRaised;

            return aStyle.FormatSource(text, options);
        }