Add mutex lock to PropertyDictionary
It was pointed out that since the PropertyDictionary is caching the properties of types using a static dictionary, it must be made thread safe.
This commit is contained in:
parent
016161a777
commit
80824c4e4b
|
@ -1,10 +1,6 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("mustache-sharp.test")]
|
[assembly: AssemblyTitle("mustache-sharp.test")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
@ -13,23 +9,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("9975f293-f972-4751-9c8c-e25b17c0c8bc")]
|
[assembly: Guid("9975f293-f972-4751-9c8c-e25b17c0c8bc")]
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
[assembly: AssemblyVersion("0.0.0.0")]
|
[assembly: AssemblyVersion("0.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("0.0.0.0")]
|
[assembly: AssemblyFileVersion("0.0.0.0")]
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("mustache-sharp")]
|
[assembly: AssemblyTitle("mustache-sharp")]
|
||||||
[assembly: AssemblyDescription("A extension of the mustache text template engine for .NET.")]
|
[assembly: AssemblyDescription("A extension of the mustache text template engine for .NET.")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
@ -15,25 +12,8 @@ using System.Runtime.CompilerServices;
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("e5a4263d-d450-4d85-a4d5-44c0a2822668")]
|
[assembly: Guid("e5a4263d-d450-4d85-a4d5-44c0a2822668")]
|
||||||
|
[assembly: AssemblyVersion("0.2.5.0")]
|
||||||
// Version information for an assembly consists of the following four values:
|
[assembly: AssemblyFileVersion("0.2.5.0")]
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("0.2.4.0")]
|
|
||||||
[assembly: AssemblyFileVersion("0.2.4.0")]
|
|
||||||
[assembly: InternalsVisibleTo("mustache-sharp.test")]
|
[assembly: InternalsVisibleTo("mustache-sharp.test")]
|
|
@ -29,10 +29,13 @@ namespace Mustache
|
||||||
_typeCache = new Dictionary<string, Func<object, object>>();
|
_typeCache = new Dictionary<string, Func<object, object>>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (_cache)
|
||||||
{
|
{
|
||||||
_typeCache = getCacheType(_instance);
|
_typeCache = getCacheType(_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Dictionary<string, Func<object, object>> getCacheType(object instance)
|
private static Dictionary<string, Func<object, object>> getCacheType(object instance)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue