コード例 #1
0
        public void Format_FewValidSentences_ReturnsListOfSentences()
        {
            var formatter = new XmlTextFormatter();
            var sentences = new List <Sentence>
            {
                new Sentence(new List <string>
                {
                    "a",
                    "had",
                    "lamb",
                    "little",
                    "Mary"
                }),
                new Sentence(new List <string>
                {
                    "Aesop",
                    "and",
                    "called",
                    "came",
                    "for",
                    "Peter",
                    "the",
                    "wolf"
                }),
                new Sentence(new List <string> {
                    "Cinderella", "likes", "shoes"
                })
            };
            var text = formatter.Format(sentences);

            var expectedXml = new StringBuilder();

            expectedXml.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
            expectedXml.AppendLine("<text>");
            expectedXml.AppendLine("    <sentence>");
            expectedXml.AppendLine("        <word>a</word>");
            expectedXml.AppendLine("        <word>had</word>");
            expectedXml.AppendLine("        <word>lamb</word>");
            expectedXml.AppendLine("        <word>little</word>");
            expectedXml.AppendLine("        <word>Mary</word>");
            expectedXml.AppendLine("    </sentence>");
            expectedXml.AppendLine("    <sentence>");
            expectedXml.AppendLine("        <word>Aesop</word>");
            expectedXml.AppendLine("        <word>and</word>");
            expectedXml.AppendLine("        <word>called</word>");
            expectedXml.AppendLine("        <word>came</word>");
            expectedXml.AppendLine("        <word>for</word>");
            expectedXml.AppendLine("        <word>Peter</word>");
            expectedXml.AppendLine("        <word>the</word>");
            expectedXml.AppendLine("        <word>wolf</word>");
            expectedXml.AppendLine("    </sentence>");
            expectedXml.AppendLine("    <sentence>");
            expectedXml.AppendLine("        <word>Cinderella</word>");
            expectedXml.AppendLine("        <word>likes</word>");
            expectedXml.AppendLine("        <word>shoes</word>");
            expectedXml.AppendLine("    </sentence>");
            expectedXml.Append("</text>");

            Assert.AreEqual(expectedXml.ToString(), text);
        }
コード例 #2
0
        public void Format_EmptyText_ReturnsEmptyXml()
        {
            var xml = new XDocument(
                new XDeclaration("1.0", "UTF-8", "yes"),
                new XElement("text")
                );
            var expectedXml = new StringBuilder()
                              .AppendLine(xml.Declaration.ToString())
                              .Append(xml)
                              .ToString();

            var formatter = new XmlTextFormatter();
            var text      = formatter.Format(new List <Sentence>());

            Assert.AreEqual(expectedXml, text);
        }
コード例 #3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            //
            // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic
            //   since it tells you how to set up an ambient parse request dispatcher within your
            //   application OnStartup code, and add related cleanup in your application OnExit code.
            //   These steps are essential to having the add-on perform well.
            //

            editor.Document.Language = new XmlSyntaxLanguage();
            XmlTextFormatter formatter = editor.Document.Language.GetTextFormatter() as XmlTextFormatter;

            if (formatter != null)
            {
                formatter.AttributeSpacingMode = XmlAttributeSpacingMode.NormalizeWhitespace;
                formatter.ElementSpacingMode   = XmlElementSpacingMode.NormalizeEmptyLines;
                formatter.TagWrapLength        = 120;
            }
        }
コード例 #4
0
ファイル: DeployWizard.cs プロジェクト: No-pe/nupack
        private void SetBoxes()
        {
            if (_assemblyInfo != null)
            {
                txtAssemblyVersion.Text    = _assemblyInfo.Version;
                txtAssemblyVersion.Enabled = !_assemblyInfo.Version.Contains("*");
            }

            txtPackageVersion.Text = _package.Metadata.Version.IsEmptyOrPlaceHolder() ? _assemblyInfo?.Version.Replace(".*", "") : _package.Metadata.Version;
            txtNote.Text           = XmlTextFormatter.Decode(_package.Metadata.ReleaseNotes);

            foreach (var source in _nuGetConfig.Sources)
            {
                sourceBox.Items.Add(source.Url);
            }

            txtNugetPath.Text = _nuGetConfig.NugetPath;
            txtOutputDir.Text = _projectConfig.PackageOutputDirectory;

            chkSyncDep.Checked = _projectConfig.SyncPackageVersionToProjectsDependedOn;
        }
コード例 #5
0
ファイル: DeployWizard.cs プロジェクト: No-pe/nupack
        private void SaveNuSpec()
        {
            var note = XmlTextFormatter.Encode(txtNote.Text);

            if (_package.Metadata.Version != txtPackageVersion.Text.Trim())
            {
                _packageOldVersion        = _package.Metadata.Version;
                _package.Metadata.Version = txtPackageVersion.Text.Trim();
            }
            if (_package.Metadata.ReleaseNotes != note)
            {
                _package.Metadata.ReleaseNotes = note;
            }

            var sc = Host.Instance.SourceControl;

            sc?.CheckOut(Path.GetDirectoryName(Host.Instance.DTE.Solution.FullName), _nuspecFile);

            //partly update
            _xmlDoc.UpdateMetadata(_package.Metadata);
            _xmlDoc.Save(_nuspecFile);
        }