1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace Microsoft.Activities.Presentation.Xaml
10 using System.Collections.Generic;
12 internal class ResolverCache
14 private Dictionary<Type, WeakReference> cache;
16 public ResolverCache()
18 this.cache = new Dictionary<Type, WeakReference>();
21 public void Update(Type type, ResolverResult result)
23 SharedFx.Assert(type != null, "type should not be null");
24 SharedFx.Assert(result != null, "result should not be null");
26 if (this.cache.ContainsKey(type))
28 this.cache[type] = new WeakReference(result);
32 this.cache.Add(type, new WeakReference(result));
36 public ResolverResult Lookup(Type type)
38 SharedFx.Assert(type != null, "type should not be null");
41 if (this.cache.TryGetValue(type, out value))
43 return value.Target as ResolverResult;