Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Pipeline / CollectionAdapters.cs / 1305376 / CollectionAdapters.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CollectionAdapters ** ** Purpose: Provides methods to convert from IListto IListContract ** and vice versa. ** ===========================================================*/ using System; using System.Collections.Generic; using System.AddIn.Contract; using System.AddIn; namespace System.AddIn.Pipeline { public static class CollectionAdapters { // Create a IListContract wrapper for an IList. This is typically done // by an addin adapter that wants to pass a list of objects to the host, // or vice versa. public static IListContract ToIListContract ( IList collection, Converter viewContractAdapter, Converter contractViewAdapter) { if (collection == null) return null; return new ListContractAdapter (collection, viewContractAdapter, contractViewAdapter); } public static IListContract ToIListContract (IList collection) { if (collection == null) return null; Converter c = new Converter (IdentityConverter ); return ToIListContract(collection, c, c); } // Create an IList that wraps a IContractList. The returned IList will // have a lifetimeToken for the remote IContractList. Its finalizer // will revoke the lifetimeToken. public static IList ToIList ( IListContract collection, Converter contractViewAdapter, Converter viewContractAdapter) { if (collection == null) return null; return new ContractListAdapter (collection, contractViewAdapter, viewContractAdapter); } public static IList ToIList (IListContract collection) { if (collection == null) return null; Converter c = new Converter (IdentityConverter ); return ToIList(collection, c, c); } private static T IdentityConverter (T item) { return item; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CollectionAdapters ** ** Purpose: Provides methods to convert from IList to IListContract ** and vice versa. ** ===========================================================*/ using System; using System.Collections.Generic; using System.AddIn.Contract; using System.AddIn; namespace System.AddIn.Pipeline { public static class CollectionAdapters { // Create a IListContract wrapper for an IList. This is typically done // by an addin adapter that wants to pass a list of objects to the host, // or vice versa. public static IListContract ToIListContract ( IList collection, Converter viewContractAdapter, Converter contractViewAdapter) { if (collection == null) return null; return new ListContractAdapter (collection, viewContractAdapter, contractViewAdapter); } public static IListContract ToIListContract (IList collection) { if (collection == null) return null; Converter c = new Converter (IdentityConverter ); return ToIListContract(collection, c, c); } // Create an IList that wraps a IContractList. The returned IList will // have a lifetimeToken for the remote IContractList. Its finalizer // will revoke the lifetimeToken. public static IList ToIList ( IListContract collection, Converter contractViewAdapter, Converter viewContractAdapter) { if (collection == null) return null; return new ContractListAdapter (collection, contractViewAdapter, viewContractAdapter); } public static IList ToIList (IListContract collection) { if (collection == null) return null; Converter c = new Converter (IdentityConverter ); return ToIList(collection, c, c); } private static T IdentityConverter (T item) { return item; } } } // 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
- DescriptionAttribute.cs
- WebPartEditorApplyVerb.cs
- PLINQETWProvider.cs
- WebResourceUtil.cs
- TimeZone.cs
- FolderBrowserDialog.cs
- SamlAdvice.cs
- EditingMode.cs
- WizardPanel.cs
- ExpressionContext.cs
- CodeMethodInvokeExpression.cs
- XmlDictionary.cs
- ToolStripStatusLabel.cs
- DiscoveryClientOutputChannel.cs
- MessageSmuggler.cs
- MenuItemStyleCollection.cs
- EventToken.cs
- SharedPerformanceCounter.cs
- IIS7WorkerRequest.cs
- Emitter.cs
- DeviceContext.cs
- ListControl.cs
- DateTimeValueSerializer.cs
- CompilerErrorCollection.cs
- CodeValidator.cs
- ConfigurationSection.cs
- IChannel.cs
- MarshalDirectiveException.cs
- DataServiceQueryProvider.cs
- AttributeProviderAttribute.cs
- DiagnosticTrace.cs
- XComponentModel.cs
- DrawingCollection.cs
- Deserializer.cs
- ExpressionCopier.cs
- DoWorkEventArgs.cs
- StorageModelBuildProvider.cs
- ModifierKeysValueSerializer.cs
- SimpleWebHandlerParser.cs
- LogicalTreeHelper.cs
- DataGridPageChangedEventArgs.cs
- ConfigXmlComment.cs
- ViewLoader.cs
- MessageDescriptionCollection.cs
- SimpleModelProvider.cs
- CrossAppDomainChannel.cs
- TextBox.cs
- EncodingNLS.cs
- RulePatternOps.cs
- CacheMemory.cs
- SoundPlayer.cs
- WindowsFormsSectionHandler.cs
- ProfileSection.cs
- FloatSumAggregationOperator.cs
- LogExtentCollection.cs
- FontFamily.cs
- VectorCollectionConverter.cs
- XmlCountingReader.cs
- BitVector32.cs
- SvcMapFile.cs
- ValueChangedEventManager.cs
- ThreadPool.cs
- FormViewDeleteEventArgs.cs
- HostSecurityManager.cs
- SafeNativeMethodsOther.cs
- ResourceContainer.cs
- InputProcessorProfilesLoader.cs
- RightsManagementEncryptedStream.cs
- OleDbMetaDataFactory.cs
- RequestQueue.cs
- ItemType.cs
- HttpWrapper.cs
- ResourceAttributes.cs
- RuntimeWrappedException.cs
- MediaElementAutomationPeer.cs
- ChannelSettingsElement.cs
- UndirectedGraph.cs
- ConnectionStringsExpressionBuilder.cs
- VoiceSynthesis.cs
- XmlSchemaSequence.cs
- ToolTipAutomationPeer.cs
- UInt16.cs
- WebPartDisplayModeEventArgs.cs
- FileSystemWatcher.cs
- FormattedText.cs
- PiiTraceSource.cs
- SecureConversationVersion.cs
- TypeUnloadedException.cs
- UndirectedGraph.cs
- SecurityTokenInclusionMode.cs
- ExecutionEngineException.cs
- x509utils.cs
- SchemaElementLookUpTableEnumerator.cs
- ConnectionOrientedTransportChannelFactory.cs
- Stacktrace.cs
- SafeFindHandle.cs
- NavigateEvent.cs
- SerializationObjectManager.cs
- OrderByBuilder.cs
- DataControlReference.cs