public EntityType Get( Type type, bool createIfNotFound, PersonAlias personAlias )
{
var entityType = Get( type.FullName );
if ( entityType != null )
{
return entityType;
}
if ( createIfNotFound )
{
// Create a new context so type can be saved independing of current context
using ( var rockContext = new RockContext() )
{
var EntityTypeService = new EntityTypeService( rockContext );
entityType = new EntityType();
entityType.Name = type.FullName;
entityType.FriendlyName = type.Name.SplitCase();
entityType.AssemblyName = type.AssemblyQualifiedName;
EntityTypeService.Add( entityType );
rockContext.SaveChanges();
}
// Read type using current context
return this.Get( entityType.Id );
}
return null;
}