113 lines
3.3 KiB
C#
113 lines
3.3 KiB
C#
using xCommons.Extensions;
|
|
using xDataService.Models;
|
|
|
|
namespace xDataService.Extensions
|
|
{
|
|
public static class XRepositoryDescriptorExtensions
|
|
{
|
|
/// <summary>
|
|
/// Validate a Descriptor ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XRepositoryDescriptor source)
|
|
{
|
|
var result =
|
|
!source.IsNull() &&
|
|
!source.Key.IsNull() &&
|
|
!source.Entity.IsNull();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Descriptor Has Events Service or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool HasEvents(this XRepositoryDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
source.IsValid() &&
|
|
!source.EventsService.IsNull() &&
|
|
!source.EventsImplementation.IsNull();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Descriptor Has EF Core Context or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool HasContext(this XRepositoryDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
source.IsValid() &&
|
|
!source.Context.IsNull();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Descriptor Has GraphQL Support or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool HasGraphSupport(this XRepositoryDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
source.IsValid() &&
|
|
!source.GraphType.IsNull() &&
|
|
!source.GraphSchema.IsNull() &&
|
|
!source.GraphTypeKey.IsNull() &&
|
|
!source.GraphQueryService.IsNull() &&
|
|
!source.GraphTypeHelperService.IsNull() &&
|
|
!source.GraphQueryImplementation.IsNull() &&
|
|
!source.GraphTypeHelperImplementation.IsNull();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Descriptor Has Key Generator Service or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool HasKeyGenerator(this XRepositoryDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
source.IsValid() &&
|
|
!source.KeyGeneratorService.IsNull() &&
|
|
!source.KeyGeneratorImplementation.IsNull();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Descriptor Has Repository Service or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool HasRepository(this XRepositoryDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
source.IsValid() &&
|
|
!source.RepositoryService.IsNull() &&
|
|
!source.RepositoryImplementation.IsNull();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
} |