Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Hosting / AddInController.cs / 1305376 / AddInController.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: AddInController ** ** Purpose: Allows you to shut down an add-in, which may unload ** an AppDomain or kill an out-of-process add-in. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Reflection; using System.Runtime.ConstrainedExecution; using System.Runtime.Remoting; using System.Runtime.Remoting.Lifetime; using System.Runtime.Serialization; using System.Security.Permissions; using System.Security; using System.Diagnostics; using System.AddIn.Contract; using System.AddIn.Pipeline; using System.Diagnostics.Contracts; namespace System.AddIn.Hosting { // Wrapper on AddInControllerImpl so that a ref count is kept on the Contract // keeping the addin alive while an AddInController object is alive in the host. public sealed class AddInController { private AddInControllerImpl _impl; // keep the addin alive while the controller is alive [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification="Needed to prevent remoting failures")] private Object _hostViewOfAddIn; // Prevent the addin domain from being torn down while there is a controller still alive when, for example, // Dispose is called on the HVA and the hostAdapter releases its LifetimeToken. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification="Needed for finalizer behavior")] private ContractHandle _contractHandle; internal AddInController(AddInControllerImpl impl, Object hostViewOfAddIn, ContractHandle contractHandle) { System.Diagnostics.Contracts.Contract.Requires(impl != null); _impl = impl; _hostViewOfAddIn = hostViewOfAddIn; _contractHandle = contractHandle; } // Takes a host add-in view (HAV) and maps that to an add-in controller. public static AddInController GetAddInController(Object addIn) { return AddInControllerImpl.GetAddInController(addIn); } [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] public void Shutdown() { _impl.Shutdown(); } // This will not be usable for OOP scenarios. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId="AppDomain")] public AppDomain AppDomain { get { return _impl.AppDomain; } } public AddInToken Token { get { return _impl.Token; } } public AddInEnvironment AddInEnvironment { get { return _impl.AddInEnvironment; } } internal AddInControllerImpl AddInControllerImpl { get { return _impl; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: AddInController ** ** Purpose: Allows you to shut down an add-in, which may unload ** an AppDomain or kill an out-of-process add-in. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Reflection; using System.Runtime.ConstrainedExecution; using System.Runtime.Remoting; using System.Runtime.Remoting.Lifetime; using System.Runtime.Serialization; using System.Security.Permissions; using System.Security; using System.Diagnostics; using System.AddIn.Contract; using System.AddIn.Pipeline; using System.Diagnostics.Contracts; namespace System.AddIn.Hosting { // Wrapper on AddInControllerImpl so that a ref count is kept on the Contract // keeping the addin alive while an AddInController object is alive in the host. public sealed class AddInController { private AddInControllerImpl _impl; // keep the addin alive while the controller is alive [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification="Needed to prevent remoting failures")] private Object _hostViewOfAddIn; // Prevent the addin domain from being torn down while there is a controller still alive when, for example, // Dispose is called on the HVA and the hostAdapter releases its LifetimeToken. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification="Needed for finalizer behavior")] private ContractHandle _contractHandle; internal AddInController(AddInControllerImpl impl, Object hostViewOfAddIn, ContractHandle contractHandle) { System.Diagnostics.Contracts.Contract.Requires(impl != null); _impl = impl; _hostViewOfAddIn = hostViewOfAddIn; _contractHandle = contractHandle; } // Takes a host add-in view (HAV) and maps that to an add-in controller. public static AddInController GetAddInController(Object addIn) { return AddInControllerImpl.GetAddInController(addIn); } [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] public void Shutdown() { _impl.Shutdown(); } // This will not be usable for OOP scenarios. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId="AppDomain")] public AppDomain AppDomain { get { return _impl.AppDomain; } } public AddInToken Token { get { return _impl.Token; } } public AddInEnvironment AddInEnvironment { get { return _impl.AddInEnvironment; } } internal AddInControllerImpl AddInControllerImpl { get { return _impl; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HtmlEmptyTagControlBuilder.cs
- CancelEventArgs.cs
- DataGridViewTextBoxEditingControl.cs
- HandleRef.cs
- WindowsTokenRoleProvider.cs
- XmlElementAttribute.cs
- HwndHost.cs
- RegexStringValidatorAttribute.cs
- AsyncCompletedEventArgs.cs
- StorageFunctionMapping.cs
- X509Chain.cs
- XmlNamespaceMappingCollection.cs
- URLMembershipCondition.cs
- Query.cs
- SqlServer2KCompatibilityAnnotation.cs
- Material.cs
- XmlCompatibilityReader.cs
- GlyphTypeface.cs
- BitmapEffectrendercontext.cs
- WebConfigurationManager.cs
- NoClickablePointException.cs
- AuthStoreRoleProvider.cs
- XmlDataProvider.cs
- ZoneButton.cs
- ContentTextAutomationPeer.cs
- XmlTextAttribute.cs
- PresentationSource.cs
- ButtonStandardAdapter.cs
- CacheMemory.cs
- EntityClientCacheKey.cs
- ProfileGroupSettingsCollection.cs
- PersonalizationStateInfo.cs
- Line.cs
- WorkerRequest.cs
- ComponentGuaranteesAttribute.cs
- DBConnectionString.cs
- UInt32Converter.cs
- QilName.cs
- GregorianCalendarHelper.cs
- EmptyStringExpandableObjectConverter.cs
- TextAdaptor.cs
- DataServiceRequest.cs
- CodeObject.cs
- SimpleHandlerFactory.cs
- NTAccount.cs
- TextRenderer.cs
- InertiaExpansionBehavior.cs
- XPathNodeInfoAtom.cs
- DependencyPropertyKind.cs
- HostedElements.cs
- SymLanguageVendor.cs
- DefaultPrintController.cs
- FormViewRow.cs
- ToolStripDropDownMenu.cs
- TextComposition.cs
- SpeechUI.cs
- ScrollItemPatternIdentifiers.cs
- TemplatePartAttribute.cs
- BitmapSourceSafeMILHandle.cs
- DefaultSettingsSection.cs
- SqlDependencyUtils.cs
- ExtendedPropertyCollection.cs
- DispatchWrapper.cs
- DesignerTransaction.cs
- CompareValidator.cs
- BamlResourceDeserializer.cs
- CollectionChangedEventManager.cs
- GenericPrincipal.cs
- ListItem.cs
- Buffer.cs
- BmpBitmapDecoder.cs
- indexingfiltermarshaler.cs
- DataGridViewComponentPropertyGridSite.cs
- FontStyleConverter.cs
- AssemblyResolver.cs
- SafeCertificateStore.cs
- IntranetCredentialPolicy.cs
- PrtTicket_Public_Simple.cs
- BooleanStorage.cs
- ACE.cs
- Converter.cs
- StateDesigner.Helpers.cs
- BuilderElements.cs
- EncryptedReference.cs
- Compiler.cs
- RequestCachePolicy.cs
- EdmPropertyAttribute.cs
- DeviceSpecificChoiceCollection.cs
- VectorValueSerializer.cs
- HttpDebugHandler.cs
- SharedDp.cs
- InstanceContextManager.cs
- SafeEventLogWriteHandle.cs
- TimeoutTimer.cs
- XpsS0ValidatingLoader.cs
- ServicePoint.cs
- WebRequestModuleElementCollection.cs
- OutputCacheProfile.cs
- DataServiceHostFactory.cs
- TextBlockAutomationPeer.cs