internal protected virtual bool OnIsReadOnly(Type type, ModifiableEntity entity) { EntitySettings es = EntitySettings.TryGetC(type); if (es != null) { if (es.OnIsReadonly()) { return(true); } } if (IsReadOnly != null) { foreach (var isReadOnly in IsReadOnly.GetInvocationListTyped()) { if (isReadOnly(type, entity)) { return(true); } } } return(false); }
internal protected virtual bool OnIsFindable(Type type) { if (!Finder.IsFindable(type)) { return(false); } EntitySettings es = EntitySettings.TryGetC(type); if (es != null && !es.OnIsFindable()) { return(false); } if (IsFindable != null) { foreach (var isCreable in IsFindable.GetInvocationListTyped()) { if (!isCreable(type)) { return(false); } } } return(true); }
internal protected virtual bool OnIsCreable(Type type, bool?isSearch) { EntitySettings es = EntitySettings.TryGetC(type); if (es == null) { return(true); } if (isSearch.HasValue && !es.OnIsCreable(isSearch.Value)) { return(false); } if (IsCreable != null) { foreach (var isCreable in IsCreable.GetInvocationListTyped()) { if (!isCreable(type)) { return(false); } } } return(true); }
internal protected virtual bool OnIsViewable(Type type, ModifiableEntity entity, string partialViewName) { EntitySettings es = EntitySettings.TryGetC(type); return(es != null && IsViewableBase(type, entity) && es.OnIsViewable(partialViewName)); }
private static string OnPartialViewName(TypeContext tc) { EntitySettings es = Navigator.EntitySettings(tc.UntypedValue.GetType()); var result = es.OnPartialViewName((ModifiableEntity)tc.UntypedValue); tc.ViewOverrides = es.GetViewOverrides(); return(result); }
internal protected virtual bool OnIsFindable(Type type) { if (!Finder.IsFindable(type)) { return(false); } EntitySettings es = EntitySettings.TryGetC(type); if (es != null && !es.OnIsFindable()) { return(false); } return(true); }
internal protected virtual EntitySettings AssertViewableEntitySettings(ModifiableEntity entity) { EntitySettings es = EntitySettings.TryGetC(entity.GetType()); if (es == null) { throw new InvalidOperationException("No EntitySettings for type {0}".FormatWith(entity.GetType().Name)); } if (es.OnPartialViewName(entity) == null) { throw new InvalidOperationException("No view has been set in the EntitySettings for {0}".FormatWith(entity.GetType().Name)); } if (!IsViewableBase(entity.GetType(), entity)) { throw new InvalidOperationException("Entities of type {0} are not viewable".FormatWith(entity.GetType().Name)); } return(es); }
protected internal virtual string ResolveWebTypeName(Type type) { var es = EntitySettings.TryGetC(type); if (es != null) { return(es.WebTypeName); } if (type.IsEntity()) { var cleanName = TypeLogic.TryGetCleanName(type); if (cleanName != null) { return(cleanName); } } throw new InvalidOperationException("Impossible to resolve WebTypeName for '{0}' because is not registered in Navigator's EntitySettings".FormatWith(type.Name) + (type.IsEntity() ? " or the Schema" : null)); }
public static void AddSetting(EntitySettings settings) { Navigator.Manager.EntitySettings.AddOrThrow(settings.StaticType, settings, "EntitySettings for {0} already registered"); }