Example #1
0
 public static Lazy <Type> ReadLazyTypeForPart(this IDictionary <string, object> cache, Func <Assembly> assemblyLoader)
 {
     if (assemblyLoader == null)
     {
         return(LazyServices.MakeLazy(
                    () => cache.ReadMember <Type>(AttributedCacheServices.CacheKeys.PartType, (Type)null, (Func <Assembly>)null),
                    cache.ReadDictionary <object>(AttributedCacheServices.CacheKeys.PartType)
                    ));
     }
     else
     {
         return(LazyServices.MakeLazy(
                    () => cache.ReadMember <Type>(AttributedCacheServices.CacheKeys.PartType, (Type)null, assemblyLoader)));
     }
 }
        public static ComposablePartDefinition ReadPartDefinition(IDictionary <string, object> cache, Func <ComposablePartDefinition, IEnumerable <ImportDefinition> > importsCreator, Func <ComposablePartDefinition, IEnumerable <ExportDefinition> > exportsCreator, Func <Assembly> assemblyLoader)
        {
            Assumes.NotNull(cache);

            Lazy <Type> partType = cache.ReadLazyTypeForPart(assemblyLoader);

            ComposablePartDefinition part = null;

            part = ReflectionModelServices.CreatePartDefinition(
                partType,
                cache.ReadValue <bool>(AttributedCacheServices.CacheKeys.IsDisposalRequired, false),
                LazyServices.MakeLazy(() => importsCreator(part)),
                LazyServices.MakeLazy(() => exportsCreator(part)),
                cache.ReadLazyMetadata(),
                null);

            return(part);
        }
Example #3
0
 public static Lazy <IDictionary <string, object> > ReadLazyMetadata(this IDictionary <string, object> cache)
 {
     Assumes.NotNull(cache);
     return(LazyServices.MakeLazy(() => cache.ReadDictionary <object>(AttributedCacheServices.CacheKeys.Metadata)));
 }
Example #4
0
 public static Lazy <ParameterInfo> ReadLazyParameter(this IDictionary <string, object> cache, Lazy <Type> defaultType)
 {
     Assumes.NotNull(cache);
     return(LazyServices.MakeLazy(() => cache.ReadParameter(defaultType)));
 }