コード例 #1
0
 /// <summary>
 /// <see cref="M:System.IDisposable.Dispose"/>
 /// </summary>
 /// <param name="disposing">False if unmanaged resources must be disposed, false otherwise.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         ContainerSimple.Dispose();
         ContainerFactory.Dispose();
     }
 }
コード例 #2
0
 /// <summary>
 /// Creates the specified object or throws an error if not possible.
 /// </summary>
 /// <typeparam name="T">The type to the object to be created.</typeparam>
 /// <param name="contractName">The MEF contract name.</param>
 /// <returns>An object to be specified.</returns>
 public T CreateRequiredObject <T>(string contractName) where T : class
 {
     return(CoreExceptionProcessor.ProcessCore <T>(
                () =>
     {
         try
         {
             return ContainerSimple.GetExportedValue <T>(contractName);
         }
         catch (ImportCardinalityMismatchException icme)
         {
             throw new System.ArgumentNullException(String.Format(System.Globalization.CultureInfo.InvariantCulture, Resources.ExceptionCanNotCreateObject, icme.Message), icme);
         }
     }
                ));
 }
コード例 #3
0
 /// <summary>
 /// Get all types for a typen given given a contract name.
 /// </summary>
 /// <typeparam name="T">Type to search for.</typeparam>
 /// <param name="contractName">Contract name to search for.</param>
 /// <returns>A list of T type objects.</returns>
 public IEnumerable <Lazy <T> > GetExports <T>(string contractName)
 {
     return(CoreExceptionProcessor.ProcessCore <IEnumerable <Lazy <T> > >(
                () => ContainerSimple.GetExports <T>(contractName)
                ));
 }
コード例 #4
0
 /// <summary>
 /// Creates the specified object or default if can not be constructed.
 /// </summary>
 /// <typeparam name="T">The type to the object to be created.</typeparam>
 /// <param name="contractName">The MEF contract name.</param>
 /// <returns>Created object.</returns>
 public T CreateObject <T>(string contractName) where T : class
 {
     return(CoreExceptionProcessor.ProcessCore <T>(
                () => ContainerSimple.GetExportedValueOrDefault <T>(contractName)
                ));
 }