Ejemplo n.º 1
0
 public object ResolveOrigin(string id, JsonResolveLinkContext resolveContext)
 {
     if (id == null)
     {
         return(resolveContext.CreateEmpty(""));
     }
     return(Options.GetLinkProvider(resolveContext.Type).ResolveOrigin(id, resolveContext));
 }
            public TValue ResolveLink(string path, JsonResolveLinkContext resolveContext)
            {
                string untypedPath = GetUntypedLink(path);
                TValue value;

                if (!_pathToValue.TryGetValue(untypedPath, out value))
                {
                    Log.Trace("  {0} - created link in {1}".Fmt(path, resolveContext.Context.StackString));
                    value = (TValue)resolveContext.CreateEmpty(path);
                    _pathToValue[untypedPath] = value;
                    _valueToPath[value]       = untypedPath;
                    _unresolvedLinks.Add(untypedPath);
                }
                else
                {
                    Log.Trace("  {0} - resolved link in {1}".Fmt(path, resolveContext.Context.StackString));
                }
                return(value);
            }
            public TValue ResolveOrigin(string id, JsonResolveLinkContext resolveContext)
            {
                string untypedId = GetUntypedLink(id);
                string path      = _linkProvider.GenerateLink(resolveContext.Context);

                path = !path.IsNullOrEmpty() ? path + JsonLinkedContext.LinkPathSeparator + untypedId : untypedId;
                TValue value;

                if (!_pathToValue.TryGetValue(path, out value))
                {
                    Log.Trace("  {0} - created origin in {1}".Fmt(path, resolveContext.Context.StackString));
                    value = (TValue)resolveContext.CreateEmpty(id);
                    _pathToValue[path]  = value;
                    _valueToPath[value] = path;
                }
                else
                {
                    _unresolvedLinks.Remove(path);
                    Log.Trace("  {0} - resolved origin in {1}".Fmt(path, resolveContext.Context.StackString));
                }
                return(value);
            }
            private object GetValue(string link, JsonResolveLinkContext resolveContext, bool isOrigin)
            {
                string untypedLink = GetUntypedLink(link);
                TValue value;

                if (!_links.TryGetValue(untypedLink, out value))
                {
                    Log.Trace("  {0} - created  ({1})".Fmt(link, resolveContext.Context.StackString));
                    _links[untypedLink] = value = (TValue)resolveContext.CreateEmpty(link);
                    if (!isOrigin)
                    {
                        _unresolvedLinks.Add(untypedLink);
                    }
                }
                else
                {
                    Log.Trace("  {0} - resolved ({1})".Fmt(link, resolveContext.Context.StackString));
                    if (isOrigin)
                    {
                        _unresolvedLinks.Remove(untypedLink);
                    }
                }
                return(value);
            }
Ejemplo n.º 5
0
 public object ResolveOrigin (string id, JsonResolveLinkContext resolveContext)
 {
     if (id == null)
         return resolveContext.CreateEmpty("");
     return Options.GetLinkProvider(resolveContext.Type).ResolveOrigin(id, resolveContext);
 }