Inheritance: StructuredProperty
示例#1
0
        protected virtual Func<PomonaContext, PomonaResponse> ResolveGetCollectionProperty(ResourcePropertyRoute route,
                                                                                           ResourceProperty property,
                                                                                           ResourceType resourceItemType)
        {
            if (this.capabilityResolver.PropertyIsMapped(property.PropertyInfo) || property.GetPropertyFormula() != null)
            {
                return
                    pr =>
                    {
                        // Check existance of parent here, cannot differentiate between an empty collection and not found.
                        var parent = pr.Node.Parent;
                        if (parent.Route.IsSingle)
                        {
                            if (!parent.Exists)
                                throw new ResourceNotFoundException("Resource not found.");
                        }

                        return new PomonaResponse(
                            parent
                                .Query()
                                .OfTypeIfRequired(pr.Node.Route.InputType)
                                .SelectManyEx(x => x.Apply(property.CreateGetterExpression))
                                .WrapActionResult(defaultPageSize : property.ExposedAsRepository ? (int?)null : int.MaxValue));
                    };
            }
            else
            {
                return
                    pr =>
                    {
                        var parentNode = pr.Node.Parent;
                        if (parentNode.Route.IsSingle)
                            return new PomonaResponse(((IEnumerable)property.GetValue(parentNode.Get())).AsQueryable());
                        return new PomonaResponse(
                            pr.Node.Parent
                              .Query()
                              .OfTypeIfRequired(pr.Node.Route.InputType)
                              .ToListDetectType()
                              .AsQueryable()
                              .SelectManyEx(x => x.Apply(property.CreateGetterExpression))
                              .WrapActionResult(defaultPageSize : property.ExposedAsRepository ? (int?)null : int.MaxValue));
                    };
            }
        }
示例#2
0
 public ResourcePropertyRoute(ResourceProperty property, Route parent)
     : base(0, parent)
 {
     Property = property;
 }
示例#3
0
 public override ResourcePropertyDetails LoadResourcePropertyDetails(ResourceProperty property)
 {
     var propInfo = property.PropertyInfo;
     return new ResourcePropertyDetails(Filter.ClientPropertyIsExposedAsRepository(propInfo),
                                        NameUtils.ConvertCamelCaseToUri(Filter.GetPropertyMappedName(property.ReflectedType,
                                                                                                     propInfo)));
 }
示例#4
0
 public abstract ResourcePropertyDetails LoadResourcePropertyDetails(ResourceProperty property);