logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1531076 - in /logging/log4net/trunk/src: Core/StackFrameItem.cs Util/ThreadContextProperties.cs
Date Thu, 10 Oct 2013 18:55:19 GMT
Author: bodewig
Date: Thu Oct 10 18:55:19 2013
New Revision: 1531076

URL: http://svn.apache.org/r1531076
Log:
LOG4NET-399 doesn't build on CF 2.0

Modified:
    logging/log4net/trunk/src/Core/StackFrameItem.cs
    logging/log4net/trunk/src/Util/ThreadContextProperties.cs

Modified: logging/log4net/trunk/src/Core/StackFrameItem.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Core/StackFrameItem.cs?rev=1531076&r1=1531075&r2=1531076&view=diff
==============================================================================
--- logging/log4net/trunk/src/Core/StackFrameItem.cs (original)
+++ logging/log4net/trunk/src/Core/StackFrameItem.cs Thu Oct 10 18:55:19 2013
@@ -1,3 +1,4 @@
+#if !NETCF
 #region Apache License
 //
 // Licensed to the Apache Software Foundation (ASF) under one or more 
@@ -29,9 +30,7 @@ namespace log4net.Core
     /// as that would require that the containing assembly is loaded.
     /// </summary>
     /// 
-#if !NETCF
     [Serializable]
-#endif
     public class StackFrameItem
     {
         #region Public Instance Constructors
@@ -194,3 +193,4 @@ namespace log4net.Core
         #endregion Private Static Fields
     }
 }
+#endif

Modified: logging/log4net/trunk/src/Util/ThreadContextProperties.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Util/ThreadContextProperties.cs?rev=1531076&r1=1531075&r2=1531076&view=diff
==============================================================================
--- logging/log4net/trunk/src/Util/ThreadContextProperties.cs (original)
+++ logging/log4net/trunk/src/Util/ThreadContextProperties.cs Thu Oct 10 18:55:19 2013
@@ -18,6 +18,9 @@
 #endregion
 
 using System;
+#if NETCF
+using System.Collections;
+#endif
 
 namespace log4net.Util
 {
@@ -35,11 +38,18 @@ namespace log4net.Util
 	{
 		#region Private Instance Fields
 
+#if NETCF
+		/// <summary>
+		/// The thread local data slot to use to store a PropertiesDictionary.
+		/// </summary>
+		private readonly static LocalDataStoreSlot s_threadLocalSlot = System.Threading.Thread.AllocateDataSlot();
+#else
 		/// <summary>
 		/// Each thread will automatically have its instance.
 		/// </summary>
 		[ThreadStatic]
 		private static PropertiesDictionary _dictionary;
+#endif
 
 		#endregion Private Instance Fields
 
@@ -76,6 +86,9 @@ namespace log4net.Util
 		{
 			get
 			{
+#if NETCF
+				PropertiesDictionary _dictionary = GetProperties(false);
+#endif
 				if (_dictionary != null)
 				{
 					return _dictionary[key];
@@ -84,11 +97,7 @@ namespace log4net.Util
 			}
 			set
 			{
-				if (_dictionary == null)
-				{
-					_dictionary = new PropertiesDictionary();
-				}
-				_dictionary[key] = value;
+				GetProperties(true)[key] = value;
 			}
 		}
 
@@ -107,6 +116,9 @@ namespace log4net.Util
 		/// </remarks>
 		public void Remove(string key)
 		{
+#if NETCF
+			PropertiesDictionary _dictionary = GetProperties(false);
+#endif
 			if (_dictionary != null)
 			{
 				_dictionary.Remove(key);
@@ -122,6 +134,9 @@ namespace log4net.Util
 		/// <returns>a set of the defined keys</returns>
 		public string[] GetKeys()
 		{
+#if NETCF
+			PropertiesDictionary _dictionary = GetProperties(false);
+#endif
 			if (_dictionary != null)
 			{
 				return _dictionary.GetKeys();
@@ -139,6 +154,9 @@ namespace log4net.Util
 		/// </remarks>
 		public void Clear()
 		{
+#if NETCF
+			PropertiesDictionary _dictionary = GetProperties(false);
+#endif
 			if (_dictionary != null)
 			{
 				_dictionary.Clear();
@@ -163,9 +181,15 @@ namespace log4net.Util
 		/// </remarks>
 		internal PropertiesDictionary GetProperties(bool create)
 		{
-			if (_dictionary != null && create)
-			{
-				return new PropertiesDictionary(_dictionary);
+#if NETCF
+			PropertiesDictionary _dictionary = (PropertiesDictionary)System.Threading.Thread.GetData(s_threadLocalSlot);
+#endif
+			if (_dictionary == null && create)
+			{
+				_dictionary  = new PropertiesDictionary();
+#if NETCF
+				System.Threading.Thread.SetData(s_threadLocalSlot, _dictionary);
+#endif
 			}
 			return _dictionary;
 		}



Mime
View raw message