Пример #1
0
        public string GetTemplateLink(string repositoryId, string type, IDictionary <string, object> parameters)
        {
            string template = (string)templateCache.Get(new string[] { repositoryId, type });

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

            StringBuilder result = new StringBuilder();
            StringBuilder param  = new StringBuilder();

            bool paramMode = false;

            for (int i = 0; i < template.Length; i++)
            {
                char c = template[i];

                if (paramMode)
                {
                    if (c == '}')
                    {
                        paramMode = false;

                        object paramValue;
                        if (parameters.TryGetValue(param.ToString(), out paramValue))
                        {
                            result.Append(paramValue == null ? "" : Uri.EscapeDataString(UrlBuilder.NormalizeParameter(paramValue)));
                        }

                        param = new StringBuilder();
                    }
                    else
                    {
                        param.Append(c);
                    }
                }
                else
                {
                    if (c == '{')
                    {
                        paramMode = true;
                    }
                    else
                    {
                        result.Append(c);
                    }
                }
            }

            return(result.ToString());
        }
Пример #2
0
 public string GetRepositoryLink(string repositoryId, string rel)
 {
     return((string)repositoryLinkCache.Get(new string[] { repositoryId, rel }));
 }
Пример #3
0
 public string GetCollection(string repositoryId, string collection)
 {
     return((string)collectionLinkCache.Get(new string[] { repositoryId, collection }));
 }
Пример #4
0
 public string GetTypeLink(string repositoryId, string id, string rel, string type)
 {
     return((string)typeLinkCache.Get(new string[] { repositoryId, id, rel, type }));
 }
Пример #5
0
 public ITypeDefinition Get(string repositoryId, string typeId)
 {
     return((ITypeDefinition)cache.Get(new string[] { repositoryId, typeId }));
 }
Пример #6
0
 public IRepositoryInfo Get(string repositoryId)
 {
     return((IRepositoryInfo)cache.Get(new string[] { repositoryId }));
 }