diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-12-26 08:40:08 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-12-26 08:40:08 -0800 |
commit | 75d3d27ac46c373af205c725e509ad527dd7adc0 (patch) | |
tree | 6ad1218d654b2fbefa92c50952684025176e375a /src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs | |
parent | 3787e3dac06df104a8fbe4b2c2df02abadd63d74 (diff) | |
parent | 79e45f41efa4acc686ce64624c3af4b440a5cbb5 (diff) | |
download | DotNetOpenAuth-75d3d27ac46c373af205c725e509ad527dd7adc0.zip DotNetOpenAuth-75d3d27ac46c373af205c725e509ad527dd7adc0.tar.gz DotNetOpenAuth-75d3d27ac46c373af205c725e509ad527dd7adc0.tar.bz2 |
Merge branch 'v4.2'
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs')
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs index bbe28ab..388157a 100644 --- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs @@ -22,8 +22,8 @@ namespace DotNetOpenAuth.Messaging { using System.Runtime.Serialization.Json; using System.Security; using System.Security.Cryptography; - using System.Threading; using System.Text; + using System.Threading; using System.Web; using System.Web.Mvc; using System.Xml; @@ -42,13 +42,6 @@ namespace DotNetOpenAuth.Messaging { internal static readonly RandomNumberGenerator CryptoRandomDataGenerator = new RNGCryptoServiceProvider(); /// <summary> - /// Gets a random number generator for use on the current thread only. - /// </summary> - internal static Random NonCryptoRandomDataGenerator { - get { return ThreadSafeRandom.RandomNumberGenerator; } - } - - /// <summary> /// The uppercase alphabet. /// </summary> internal const string UppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -158,6 +151,13 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// Gets a random number generator for use on the current thread only. + /// </summary> + internal static Random NonCryptoRandomDataGenerator { + get { return ThreadSafeRandom.RandomNumberGenerator; } + } + + /// <summary> /// Transforms an OutgoingWebResponse to an MVC-friendly ActionResult. /// </summary> /// <param name="response">The response to send to the user agent.</param> @@ -2015,6 +2015,32 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// A thread-safe, non-crypto random number generator. + /// </summary> + private static class ThreadSafeRandom { + /// <summary> + /// The initializer of all new <see cref="Random"/> instances. + /// </summary> + private static readonly Random threadRandomInitializer = new Random(); + + /// <summary> + /// A thread-local instance of <see cref="Random"/> + /// </summary> + private static readonly ThreadLocal<Random> threadRandom = new ThreadLocal<Random>(delegate { + lock (threadRandomInitializer) { + return new Random(threadRandomInitializer.Next()); + } + }); + + /// <summary> + /// Gets a random number generator for use on the current thread only. + /// </summary> + public static Random RandomNumberGenerator { + get { return threadRandom.Value; } + } + } + + /// <summary> /// A class to convert a <see cref="Comparison<T>"/> into an <see cref="IComparer<T>"/>. /// </summary> /// <typeparam name="T">The type of objects being compared.</typeparam> @@ -2048,31 +2074,5 @@ namespace DotNetOpenAuth.Messaging { #endregion } - - /// <summary> - /// A thread-safe, non-crypto random number generator. - /// </summary> - private static class ThreadSafeRandom { - /// <summary> - /// The initializer of all new <see cref="Random"/> instances. - /// </summary> - private static readonly Random threadRandomInitializer = new Random(); - - /// <summary> - /// A thread-local instance of <see cref="Random"/> - /// </summary> - private static readonly ThreadLocal<Random> threadRandom = new ThreadLocal<Random>(delegate { - lock (threadRandomInitializer) { - return new Random(threadRandomInitializer.Next()); - } - }); - - /// <summary> - /// Gets a random number generator for use on the current thread only. - /// </summary> - public static Random RandomNumberGenerator { - get { return threadRandom.Value; } - } - } } } |