示例#1
0
        public void GDCTest2()
        {
            GDC.Clear();
            Assert.False(GDC.Contains("foo"));
            Assert.Equal(string.Empty, GDC.Get("foo"));
            Assert.False(GDC.Contains("foo2"));
            Assert.Equal(string.Empty, GDC.Get("foo2"));

            GDC.Set("foo", "bar");
            GDC.Set("foo2", "bar2");

            Assert.True(GDC.Contains("foo"));
            Assert.Equal("bar", GDC.Get("foo"));

            GDC.Remove("foo");
            Assert.False(GDC.Contains("foo"));
            Assert.Equal(string.Empty, GDC.Get("foo"));

            Assert.True(GDC.Contains("foo2"));
            Assert.Equal("bar2", GDC.Get("foo2"));

            Assert.Null(GDC.GetObject("foo3"));

            Assert.Equal(string.Empty, GDC.Get("foo3", null));
        }
示例#2
0
        public void GDCTest2()
        {
            GDC.Clear();
            Assert.IsFalse(GDC.Contains("foo"));
            Assert.AreEqual(string.Empty, GDC.Get("foo"));
            Assert.IsFalse(GDC.Contains("foo2"));
            Assert.AreEqual(string.Empty, GDC.Get("foo2"));

            GDC.Set("foo", "bar");
            GDC.Set("foo2", "bar2");

            Assert.IsTrue(GDC.Contains("foo"));
            Assert.AreEqual("bar", GDC.Get("foo"));

            GDC.Remove("foo");
            Assert.IsFalse(GDC.Contains("foo"));
            Assert.AreEqual(string.Empty, GDC.Get("foo"));

            Assert.IsTrue(GDC.Contains("foo2"));
            Assert.AreEqual("bar2", GDC.Get("foo2"));
        }
示例#3
0
文件: GCD.cs 项目: tmpkus/openvss
        /// <summary>
        /// Renders the specified Global Diagnostics Context item and appends it to the specified <see cref="StringBuilder" />.
        /// </summary>
        /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param>
        /// <param name="logEvent">Logging event.</param>
        protected internal override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            string msg = GDC.Get(Item);

            builder.Append(ApplyPadding(msg));
        }
示例#4
0
文件: GCD.cs 项目: tmpkus/openvss
 /// <summary>
 /// Returns the estimated number of characters that are needed to
 /// hold the rendered value for the specified logging event.
 /// </summary>
 /// <param name="logEvent">Logging event information.</param>
 /// <returns>The number of characters.</returns>
 /// <remarks>
 /// If the exact number is not known or
 /// expensive to calculate this function should return a rough estimate
 /// that's big enough in most cases, but not too big, in order to conserve memory.
 /// </remarks>
 protected internal override int GetEstimatedBufferSize(LogEventInfo logEvent)
 {
     return(GDC.Get(Item).Length);
 }