示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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));
        }