Ejemplo n.º 1
0
        /// <summary>
        ///     Converts the specified <see cref="IHasGetOptions" /> to a <see cref="GetOptions" />
        /// </summary>
        public static GetOptions ToGetOptions(this IHasGetOptions options,
                                              ExpandOptions?defaultExpand = ExpandOptions.All, List <string> defaultChildResources = null)
        {
            if (options == null)
            {
                return(null);
            }

            var embedValue = options.Embed;

            if (!embedValue.HasValue())
            {
                if (defaultChildResources != null && defaultChildResources.Any())
                {
                    return(GetOptions.Custom(defaultChildResources));
                }

                return(new GetOptions(defaultExpand ?? ExpandOptions.All));
            }

            if (embedValue.EqualsIgnoreCase(HasGetOptions.EmbedNone))
            {
                return(GetOptions.None);
            }

            if (embedValue.EqualsIgnoreCase(HasGetOptions.EmbedAll))
            {
                return(GetOptions.All);
            }

            var values = options.Embed
                         .SafeSplit(GetOptions.EmbedRequestParamDelimiter)
                         .Select(value => value.ToLowerInvariant().Trim())
                         .ToList();

            return(GetOptions.Custom(values));
        }
Ejemplo n.º 2
0
 public static HasGetOptions Custom <TResource>(params Expression <Func <TResource, object> >[] resourceProperties)
 {
     return(GetOptions.Custom(resourceProperties).ToHasGetOptions());
 }