/// <summary>
 /// Releases all resources used by the <see cref="DisposableIsolatingComposablePart"/> object.
 /// </summary>
 /// <param name="disposing">True if disposing, else false to release unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     foreach (var disposableValue in ExportedValues)
     {
         PartHostManager.ReleaseInstance(disposableValue);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Marks the host as faulted.
        /// </summary>
        /// <param name="exception">The exception.</param>
        internal void MarkFaulted(Exception exception)
        {
            lock (this._syncObject)
            {
                // if host is already marked, do nothing
                if (this.Faulted)
                {
                    return;
                }

                this.Faulted = true;


                try
                {
                    PartHostManager.OnFaulted(this, exception);
                }
                catch { }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the exported object described by the specified <see cref="T:System.ComponentModel.Composition.Primitives.ExportDefinition"/> object.
        /// </summary>
        /// <param name="definition">One of the <see cref="T:System.ComponentModel.Composition.Primitives.ExportDefinition"/> objects from the <see cref="P:System.ComponentModel.Composition.Primitives.ComposablePart.ExportDefinitions"/> property that describes the exported object to return.</param>
        /// <returns>
        /// The exported object described by <paramref name="definition"/>.
        /// </returns>
        /// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.ComponentModel.Composition.Primitives.ComposablePart"/> object has been disposed of.</exception>
        /// <exception cref="T:System.ArgumentNullException">
        ///     <paramref name="definition"/> is null.</exception>
        /// <exception cref="T:System.ComponentModel.Composition.Primitives.ComposablePartException">An error occurred getting the exported object described by the <see cref="T:System.ComponentModel.Composition.Primitives.ExportDefinition"/>.</exception>
        /// <exception cref="T:System.ArgumentException">
        ///     <paramref name="definition"/> did not originate from the <see cref="P:System.ComponentModel.Composition.Primitives.ComposablePart.ExportDefinitions"/> property on the <see cref="T:System.ComponentModel.Composition.Primitives.ComposablePart"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">One or more prerequisite imports, indicated by <see cref="P:System.ComponentModel.Composition.Primitives.ImportDefinition.IsPrerequisite"/>, have not been set.</exception>
        public override object GetExportedValue(ExportDefinition definition)
        {
            if (definition == null)
            {
                throw new ArgumentNullException("definition");
            }

            if (this._values.ContainsKey(definition))
            {
                return(this._values[definition]);
            }

            Lazy <Type> type = ReflectionModelServices.GetPartType(this._definition);

            string contractName = definition.ContractName;

            object partProxy = PartHostManager.CreateInstance(type.Value, this._isolationMetadata.ConfigFileBaseName, contractName);

            this._values[definition] = partProxy;

            return(partProxy);
        }