add support for Dynamic Entity Registration in DbContext by Provides IXEntityRegisterar interface and XBaseEntityRegisterar as an abstract Implementation ...
all other requirements handled inside Module.
This commit is contained in:
@@ -63,5 +63,38 @@ namespace xDataService.Extensions {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a Type is XBaseEntity or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsXEntity(this Type source)
|
||||
{
|
||||
//
|
||||
var result = !source.IsNull();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
var baseType = source.BaseType;
|
||||
while(!baseType.IsNull() && baseType != typeof(object))
|
||||
{
|
||||
//
|
||||
if (baseType.IsGenericType &&
|
||||
baseType.GetGenericTypeDefinition() == typeof(XBaseEntity<>))
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
baseType = baseType.BaseType;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user