public IdentifierPathInfo GetIdentifierInfo(INextPath path)
        {
            if (!string.IsNullOrEmpty(_config.DictionaryReferencePrefix) && path.Raw.StartsWith(_config.DictionaryReferencePrefix))
            {
                return(new IdentifierPathInfo
                {
                    IsDictionary = true,
                    Value = null,
                    Name = path.GetCoded(_config.DictionaryReferencePrefix.Length)
                });
            }

            int equalsIndex = path.Raw.IndexOf('=');

            if (_config.EnableEquals && equalsIndex > 0)
            {
                // see https://stackoverflow.com/a/20386425/369247

                return(new IdentifierPathInfo
                {
                    IsDictionary = false,
                    Value = path.GetCoded(equalsIndex + 1),
                    Name = path.GetCoded(0, equalsIndex)
                });
            }

            return(new IdentifierPathInfo
            {
                IsDictionary = false,
                Value = path.Raw,
                Name = null
            });
        }
Exemple #2
0
        public IRestEndpoint Next(INextPath resourceName)
        {
            IRestResource resource = Directory.GetChild(resourceName.GetCoded());

            if (resource == null)
            {
                return(null);
            }

            return(Context.Services.EndpointResolver.GetFromResource(Context, resource));
        }
Exemple #3
0
        public IRestEndpoint Next(INextPath path)
        {
            var identifierInfo = Context.Services.UrlHelper.GetIdentifierInfo(path);

            if (identifierInfo.IsDictionary)
            {
                IRestDictionary dictionary = Collection.ToDictionary(identifierInfo.Name);
                return(new RestDictionaryEndpoint(Context, dictionary));
            }
            else
            {
                IRestItem item = Collection.GetItem(identifierInfo.Value, identifierInfo.Name);
                return(new RestItemEndpoint(Context, item));
            }
        }
Exemple #4
0
        public IRestEndpoint Next(INextPath fieldName)
        {
            IRestResource resource = Item.GetField(fieldName.GetCoded());

            return(Context.Services.EndpointResolver.GetFromResource(Context, resource));
        }
Exemple #5
0
 public IRestEndpoint Next(INextPath nextPath)
 {
     throw new InvalidOperationException("No further paths are allowed after a scalar property.");
 }
Exemple #6
0
        public IRestEndpoint Next(INextPath identifier)
        {
            IRestItem item = Dictionary.GetItem(identifier.GetCoded());

            return(new RestItemEndpoint(Context, item));
        }