Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

DefaultProcessorType - makes static and adds lock #224

Merged
merged 2 commits into from
Sep 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ internal class DittoProcessorRegistry
/// <summary>
/// The default processor type, (defaults to `UmbracoProperty`).
/// </summary>
private Type DefaultProcessorType = typeof(UmbracoPropertyAttribute);
private static Type DefaultProcessorType = typeof(UmbracoPropertyAttribute);

/// <summary>
/// The lock object to make DefaultProcessorType access thread safe.
/// </summary>
private static readonly object DefaultProcessorTypeLock = new object();

/// <summary>
/// Prevents a default instance of the <see cref="DittoProcessorRegistry"/> class from being created.
Expand Down Expand Up @@ -57,7 +62,10 @@ public static DittoProcessorRegistry Instance
public void RegisterDefaultProcessorType<TProcessorAttributeType>()
where TProcessorAttributeType : DittoProcessorAttribute, new()
{
this.DefaultProcessorType = typeof(TProcessorAttributeType);
lock (DefaultProcessorTypeLock)
{
DefaultProcessorType = typeof(TProcessorAttributeType);
}
}

/// <summary>
Expand Down Expand Up @@ -108,7 +116,7 @@ public Type GetDefaultProcessorType(Type objectType)
return attr.ProcessorType;
}

return this.DefaultProcessorType;
return DefaultProcessorType;
}

/// <summary>
Expand Down