first commit

This commit is contained in:
alexandre-spieser
2017-10-22 00:24:46 +00:00
commit 0dc4240d2c
69 changed files with 17455 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
using AspNetCore.Identity.MongoDbCore.Models;
using MongoDB.Bson.Serialization.Conventions;
using System;
using System.Threading;
namespace AspNetCore.Identity.MongoDbCore
{
internal static class MongoConfig
{
private static bool _initialized = false;
private static object _initializationLock = new object();
private static object _initializationTarget;
public static void EnsureConfigured()
{
EnsureConfiguredImpl();
}
private static void EnsureConfiguredImpl()
{
LazyInitializer.EnsureInitialized(ref _initializationTarget, ref _initialized, ref _initializationLock, () =>
{
Configure();
return null;
});
}
private static void Configure()
{
RegisterConventions();
}
private static void RegisterConventions()
{
var pack = new ConventionPack
{
new IgnoreIfNullConvention(false),
new CamelCaseElementNameConvention(),
};
ConventionRegistry.Register("AspNetCore.Identity.MongoDB", pack, IsConventionApplicable);
}
private static bool IsConventionApplicable(Type type)
{
return type == typeof(MongoIdentityUser<>);
}
}
}