public void Apply(Type subject, ISubclassAttributesMapper applyTo)
        {
            string className = subject.Name;

            if (Array.IndexOf(enumsNames, className) >= 0)
            {
                applyTo.DiscriminatorValue(EnumUtil.ParseGettingUnderlyingValue(typeof(TEnum), className));
            }
            else
            {
                throw new ArgumentException("Canot find the discriminator value for the class " + subject.FullName +
                                            " using the enum " + typeof(TEnum).FullName);
            }
        }
        //6.0 TODO: Merge to ISubclassAttributesMapper<TEntity>
        public static void Extends <TEntity>(this ISubclassAttributesMapper <TEntity> mapper, string entityOrClassName)
            where TEntity : class
        {
            switch (mapper)
            {
            case SubclassCustomizer <TEntity> sc:
                sc.Extends(entityOrClassName);
                break;

            case PropertyContainerCustomizer <TEntity> pcc:
                pcc.CustomizersHolder.AddCustomizer(
                    typeof(TEntity),
                    (ISubclassMapper m) => m.Extends(entityOrClassName));
                break;

            default:
                throw new ArgumentException($@"{mapper.GetType()} requires to extend {typeof(SubclassCustomizer<TEntity>).FullName} or {typeof(PropertyContainerCustomizer<TEntity>).FullName} to support Extends(entityOrClassName).");
            }
        }
 protected override void OnBeforeMapSubclass(IModelInspector modelInspector, Type type, ISubclassAttributesMapper subclassCustomizer)
 {
     subclassCustomizer.DiscriminatorValue(GetDiscriminatorValue(modelInspector, type));
 }
Beispiel #4
0
 public static void MapSubclass(IModelInspector modelInspector, Type type, ISubclassAttributesMapper map)
 {
 }
 private void ConfigureDiscriminatorValue(
     IModelInspector modelInspector, System.Type type,
     ISubclassAttributesMapper subclassCustomizer)
 {
     subclassCustomizer.DiscriminatorValue(type.Name);
 }
 protected virtual void OnBeforeMapSubclass(IModelInspector modelInspector, Type type, ISubclassAttributesMapper subclassCustomizer)
 {
 }
Beispiel #7
0
 private static void DisciminatorValueAsClassName(IModelInspector modelInspector, Type type, ISubclassAttributesMapper subclassCustomizer)
 {
     subclassCustomizer.DiscriminatorValue(type.Name);
 }
 //6.0 TODO: Merge to ISubclassAttributesMapper
 public static void Extends(this ISubclassAttributesMapper mapper, string entityOrClassName)
 {
     ReflectHelper.CastOrThrow <SubclassMapper>(mapper, "Extends(entityOrClassName)").Extends(entityOrClassName);
 }
Beispiel #9
0
 protected virtual void OnAfterMapSubclass(IModelInspector modelInspector, Type type, ISubclassAttributesMapper subclassCustomizer)
 {
 }
 protected override void OnBeforeMapSubclass(IModelInspector modelInspector, Type type, ISubclassAttributesMapper subclassCustomizer)
 {
     subclassCustomizer.DiscriminatorValue(GetDiscriminatorValue(modelInspector, type));
 }
Beispiel #11
0
 public void InvokeCustomizers(Type type, ISubclassAttributesMapper mapper)
 {
     InvokeCustomizers(subclassCustomizers, type, mapper);
 }