public FuncLocatorAdapter()
     : base((s) =>
 {
     // note_ this will throw an exception if the resource with the given key is not found
     // also here we have cached the ResourceLocator instance, this means no additional round trips
     var _resourceLocator = string.IsNullOrEmpty(s)
                                    ? ResourceLocator.GetResourceLocator <T>()
                                    : ResourceLocator.GetResourceLocator <T>(s);
     return(new Func <T>(() => (T)_resourceLocator.GetResourceInstance()));
 })
 { }
Пример #2
0
 public LazyMetadataLocatorAdapter()
     : base((s) =>
 {
     // note_ this will throw an exception if the resource with the given key is not found
     // also note_ the use ResourceMeta as TMetadata
     var _resourceLocator = string.IsNullOrEmpty(s)
                                               ? ResourceLocator.GetResourceLocator <T>()
                                               : ResourceLocator.GetResourceLocator <T>(s);
     return(new Lazy <T, TMetadata>(() => (T)_resourceLocator.GetResourceInstance(),
                                    _resourceLocator.ResourceMeta as TMetadata));
 })
 { }
 public FutureLocatorAdapter()
     : base((s) =>
 {
     // note_ this will throw an exception if the resource with the given key is not found
     return(new Future <T>(
                () => string.IsNullOrEmpty(s)
                 ? Resource.IsResourceRegistered(typeof(T), true)
                 : Resource.IsResourceRegistered(typeof(T), s),
                () => (T)(string.IsNullOrEmpty(s)
                 ? ResourceLocator.GetResourceLocator <T>()
                 : ResourceLocator.GetResourceLocator <T>(s)).GetResourceInstance()
                ));
 }
            )
 { }