Beispiel #1
0
 internal static Lazy <T> CreateStronglyTypedLazyOfT <T>(Export export)
 {
     if (export is IDisposable disposable)
     {
         return(new DisposableLazy <T>(
                    () => ExportServices.GetCastedExportedValue <T>(export),
                    disposable,
                    LazyThreadSafetyMode.PublicationOnly));
     }
     else
     {
         return(new Lazy <T>(() => ExportServices.GetCastedExportedValue <T>(export), LazyThreadSafetyMode.PublicationOnly));
     }
 }
        internal static Lazy <T> CreateStronglyTypedLazyOfT <T>(Export export)
        {
            IDisposable disposable = export as IDisposable;

            if (disposable != null)
            {
                return(new DisposableLazy <T>(
                           () => ExportServices.GetCastedExportedValue <T>(export),
                           disposable));
            }
            else
            {
                return(new Lazy <T>(() => ExportServices.GetCastedExportedValue <T>(export), false));
            }
        }
Beispiel #3
0
 internal static Lazy <T, M> CreateStronglyTypedLazyOfTM <T, M>(Export export)
 {
     if (export is IDisposable disposable)
     {
         return(new DisposableLazy <T, M>(
                    () => ExportServices.GetCastedExportedValue <T>(export),
                    AttributedModelServices.GetMetadataView <M>(export.Metadata),
                    disposable,
                    LazyThreadSafetyMode.PublicationOnly));
     }
     else
     {
         return(new Lazy <T, M>(
                    () => ExportServices.GetCastedExportedValue <T>(export),
                    AttributedModelServices.GetMetadataView <M>(export.Metadata),
                    LazyThreadSafetyMode.PublicationOnly));
     }
 }
        internal static Lazy <T, M> CreateStronglyTypedLazyOfTM <T, M>(Export export)
        {
            IDisposable disposable = export as IDisposable;

            if (disposable != null)
            {
                return(new DisposableLazy <T, M>(
                           () => ExportServices.GetCastedExportedValue <T>(export),
                           AttributedModelServices.GetMetadataView <M>(export.Metadata),
                           disposable));
            }
            else
            {
                return(new Lazy <T, M>(
                           () => ExportServices.GetCastedExportedValue <T>(export),
                           AttributedModelServices.GetMetadataView <M>(export.Metadata),
                           false));
            }
        }
Beispiel #5
0
        internal static Lazy <object, object> CreateSemiStronglyTypedLazy <T, M>(Export export)
        {
            IDisposable disposable = export as IDisposable;

            if (disposable != null)
            {
                return(new DisposableLazy <object, object>(
                           () => ExportServices.GetCastedExportedValue <T>(export),
                           AttributedModelServices.GetMetadataView <M>(export.Metadata),
                           disposable,
                           LazyThreadSafetyMode.PublicationOnly));
            }
            else
            {
                return(new Lazy <object, object>(
                           () => ExportServices.GetCastedExportedValue <T>(export),
                           AttributedModelServices.GetMetadataView <M>(export.Metadata),
                           LazyThreadSafetyMode.PublicationOnly));
            }
        }