Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Hosting / PipelineDeploymentState.cs / 1305376 / PipelineDeploymentState.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: PipelineDeploymentState ** ** Purpose: Represents all the add-in pipeline components ** in a directory structure. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.IO; using System.Text; using System.Reflection; using System.AddIn.MiniReflection; using System.Diagnostics.Contracts; namespace System.AddIn.Hosting { [Serializable] internal sealed class PipelineDeploymentState : DeploymentState { private List_hostAdapters; private List _contracts; private List _addinAdapters; private List _addinBases; private List _partialTokens; private List _fileCounts; internal PipelineDeploymentState() { _hostAdapters = new List (); _contracts = new List (); _addinAdapters = new List (); _addinBases = new List (); _fileCounts = new List (new int[]{0,0,0,0}); } internal List HostAdapters { get { return _hostAdapters; } } internal List Contracts { get { return _contracts; } } internal List AddInAdapters { get { return _addinAdapters; } } internal List AddInBases { get { return _addinBases; } } internal List PartialTokens { get { return _partialTokens; } } internal List FileCounts { get { return _fileCounts; } } internal void ConnectPipeline(Collection warnings) { List result = new List (); // For ease of maintanence & debugging for users of the add-in // model, we must make it easy to report which parts are not // usable, due to missing connections with other parts of the // pipeline. // Real connect loop. foreach (HostAdapter hostAdapter in HostAdapters) { foreach (ContractComponent contract in Contracts) { if (!hostAdapter.Constructors.Contains(contract.TypeInfo)) continue; hostAdapter.ConnectedToNeighbors = true; foreach (AddInAdapter addinAdapter in AddInAdapters) { if (!addinAdapter.Contracts.Contains(contract.TypeInfo)) continue; contract.ConnectedToNeighbors = true; foreach (AddInBase addinBase in AddInBases) { if (!addinAdapter.CanConnectTo(addinBase)) continue; addinAdapter.ConnectedToNeighbors = true; addinBase.ConnectedToNeighbors = true; PartialToken partialToken = new PartialToken(hostAdapter, contract, addinAdapter, addinBase); result.Add(partialToken); } // foreach addinBase } // foreach addinAdapter } // foreach contract } // foreach hostAdapter // Look for unconnected parts. int unconnectedParts = 0; unconnectedParts += LookForUnconnectedParts(HostAdapters, warnings); unconnectedParts += LookForUnconnectedParts(Contracts, warnings); unconnectedParts += LookForUnconnectedParts(AddInAdapters, warnings); unconnectedParts += LookForUnconnectedParts(AddInBases, warnings); #if ADDIN_VERBOSE_WARNINGS warnings.Add(String.Format(CultureInfo.CurrentCulture, "PipelineDeploymentState::Connect: Found {0} valid pipelines.", result.Count)); #endif if (unconnectedParts > 0) warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.CouldntConnectNInvalidParts, unconnectedParts)); _partialTokens = result; } private static int LookForUnconnectedParts (IEnumerable parts, Collection warnings) where T : PipelineComponent { int numUnconnected = 0; foreach (PipelineComponent part in parts) { if (!part.ConnectedToNeighbors) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.CouldntConnectOnePart, part.ToString())); numUnconnected++; } } return numUnconnected; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: PipelineDeploymentState ** ** Purpose: Represents all the add-in pipeline components ** in a directory structure. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.IO; using System.Text; using System.Reflection; using System.AddIn.MiniReflection; using System.Diagnostics.Contracts; namespace System.AddIn.Hosting { [Serializable] internal sealed class PipelineDeploymentState : DeploymentState { private List _hostAdapters; private List _contracts; private List _addinAdapters; private List _addinBases; private List _partialTokens; private List _fileCounts; internal PipelineDeploymentState() { _hostAdapters = new List (); _contracts = new List (); _addinAdapters = new List (); _addinBases = new List (); _fileCounts = new List (new int[]{0,0,0,0}); } internal List HostAdapters { get { return _hostAdapters; } } internal List Contracts { get { return _contracts; } } internal List AddInAdapters { get { return _addinAdapters; } } internal List AddInBases { get { return _addinBases; } } internal List PartialTokens { get { return _partialTokens; } } internal List FileCounts { get { return _fileCounts; } } internal void ConnectPipeline(Collection warnings) { List result = new List (); // For ease of maintanence & debugging for users of the add-in // model, we must make it easy to report which parts are not // usable, due to missing connections with other parts of the // pipeline. // Real connect loop. foreach (HostAdapter hostAdapter in HostAdapters) { foreach (ContractComponent contract in Contracts) { if (!hostAdapter.Constructors.Contains(contract.TypeInfo)) continue; hostAdapter.ConnectedToNeighbors = true; foreach (AddInAdapter addinAdapter in AddInAdapters) { if (!addinAdapter.Contracts.Contains(contract.TypeInfo)) continue; contract.ConnectedToNeighbors = true; foreach (AddInBase addinBase in AddInBases) { if (!addinAdapter.CanConnectTo(addinBase)) continue; addinAdapter.ConnectedToNeighbors = true; addinBase.ConnectedToNeighbors = true; PartialToken partialToken = new PartialToken(hostAdapter, contract, addinAdapter, addinBase); result.Add(partialToken); } // foreach addinBase } // foreach addinAdapter } // foreach contract } // foreach hostAdapter // Look for unconnected parts. int unconnectedParts = 0; unconnectedParts += LookForUnconnectedParts(HostAdapters, warnings); unconnectedParts += LookForUnconnectedParts(Contracts, warnings); unconnectedParts += LookForUnconnectedParts(AddInAdapters, warnings); unconnectedParts += LookForUnconnectedParts(AddInBases, warnings); #if ADDIN_VERBOSE_WARNINGS warnings.Add(String.Format(CultureInfo.CurrentCulture, "PipelineDeploymentState::Connect: Found {0} valid pipelines.", result.Count)); #endif if (unconnectedParts > 0) warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.CouldntConnectNInvalidParts, unconnectedParts)); _partialTokens = result; } private static int LookForUnconnectedParts (IEnumerable parts, Collection warnings) where T : PipelineComponent { int numUnconnected = 0; foreach (PipelineComponent part in parts) { if (!part.ConnectedToNeighbors) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.CouldntConnectOnePart, part.ToString())); numUnconnected++; } } return numUnconnected; } } } // 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
- PerformanceCounters.cs
- XmlBinaryReader.cs
- Parser.cs
- SHA384CryptoServiceProvider.cs
- RepeaterDataBoundAdapter.cs
- DateTimeOffset.cs
- sitestring.cs
- OracleCommandBuilder.cs
- ShimAsPublicXamlType.cs
- Assert.cs
- ProgressBarHighlightConverter.cs
- EntitySqlQueryCacheEntry.cs
- InterleavedZipPartStream.cs
- Storyboard.cs
- TextWriter.cs
- EntityConnectionStringBuilder.cs
- ControlCollection.cs
- ImageListDesigner.cs
- InvalidateEvent.cs
- EntitySetBaseCollection.cs
- ObjectPropertyMapping.cs
- EventRouteFactory.cs
- RelatedImageListAttribute.cs
- MobileUserControlDesigner.cs
- ColorDialog.cs
- MobileControl.cs
- _DisconnectOverlappedAsyncResult.cs
- GuidelineSet.cs
- Rijndael.cs
- ObjectHandle.cs
- CommonXSendMessage.cs
- WindowsTreeView.cs
- XmlQueryRuntime.cs
- LayoutEngine.cs
- Clipboard.cs
- EventSetterHandlerConverter.cs
- DbUpdateCommandTree.cs
- DataTableReaderListener.cs
- SinglePhaseEnlistment.cs
- XmlBoundElement.cs
- MachineSettingsSection.cs
- ToolStripControlHost.cs
- SafeNativeMethods.cs
- DoubleLinkListEnumerator.cs
- WebScriptEnablingElement.cs
- CodeVariableReferenceExpression.cs
- ServiceOperationDetailViewControl.cs
- RepeaterItemEventArgs.cs
- InputMethodStateTypeInfo.cs
- _IPv6Address.cs
- CachedFontFace.cs
- DEREncoding.cs
- DataReaderContainer.cs
- ChangeToolStripParentVerb.cs
- ListViewSelectEventArgs.cs
- HtmlInputControl.cs
- DependencyPropertyChangedEventArgs.cs
- StreamFormatter.cs
- ScriptRegistrationManager.cs
- XmlSerializerFormatAttribute.cs
- IntersectQueryOperator.cs
- TransformerInfoCollection.cs
- RowToParametersTransformer.cs
- XmlSignificantWhitespace.cs
- TextModifier.cs
- SecurityTokenValidationException.cs
- XpsS0ValidatingLoader.cs
- DataGridItemCollection.cs
- RevocationPoint.cs
- exports.cs
- FixedPage.cs
- RegularExpressionValidator.cs
- DynamicValueConverter.cs
- BufferedMessageData.cs
- GridViewUpdateEventArgs.cs
- ScriptResourceMapping.cs
- PtsHelper.cs
- ExceptionHelpers.cs
- DesignerObjectListAdapter.cs
- ToolStripItemBehavior.cs
- LinearQuaternionKeyFrame.cs
- Run.cs
- StorageAssociationSetMapping.cs
- Animatable.cs
- BitmapMetadata.cs
- XmlSerializationGeneratedCode.cs
- glyphs.cs
- ServiceNameElement.cs
- MainMenu.cs
- XmlTextReader.cs
- TextDecorationCollectionConverter.cs
- Camera.cs
- NativeObjectSecurity.cs
- shaperfactoryquerycachekey.cs
- ToolboxDataAttribute.cs
- TimeSpanSecondsConverter.cs
- LocatorPartList.cs
- RewritingPass.cs
- XPathNavigator.cs
- XmlKeywords.cs