Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Compiler / TypeSystem / CodeDomLoader.cs / 1305376 / CodeDomLoader.cs
namespace System.Workflow.ComponentModel.Compiler { using System; using System.CodeDom; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Diagnostics; internal class CodeDomLoader: IDisposable { private TypeProvider typeProvider = null; private CodeCompileUnit codeCompileUnit = null; private Listtypes = new List (); internal CodeDomLoader(TypeProvider typeProvider, CodeCompileUnit codeCompileUnit) { this.typeProvider = typeProvider; this.codeCompileUnit = codeCompileUnit; AddTypes(); } internal void Refresh(EventHandler refresher) { RemoveTypes(); refresher(this.typeProvider, EventArgs.Empty); AddTypes(); } private void AddTypes() { if (this.typeProvider != null && this.types != null) { this.types.Clear(); foreach (CodeNamespace codeNamespace in this.codeCompileUnit.Namespaces) { foreach (CodeTypeDeclaration codeTypeDeclaration in codeNamespace.Types) { // Look for partial type string typename = Helper.EnsureTypeName(codeTypeDeclaration.Name); if(codeNamespace.Name.Length > 0) typename = (Helper.EnsureTypeName(codeNamespace.Name) + "." + typename); DesignTimeType partialType = this.typeProvider.GetType(typename, false) as DesignTimeType; if ( partialType == null ) { partialType = new DesignTimeType(null, codeTypeDeclaration.Name, codeNamespace.Imports, codeNamespace.Name, this.typeProvider); this.types.Add(partialType); this.typeProvider.AddType(partialType); } partialType.AddCodeTypeDeclaration(codeTypeDeclaration); } } Queue nestedQueue = new Queue(this.types); while (nestedQueue.Count != 0) { Type type = nestedQueue.Dequeue() as Type; if(type.DeclaringType != null) this.types.Add(type); foreach (Type nestedType2 in type.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) nestedQueue.Enqueue(nestedType2); } } } private void RemoveTypes() { if (this.typeProvider != null && this.types != null) { this.typeProvider.RemoveTypes(this.types.ToArray()); this.types.Clear(); } } #region IDisposable Members public void Dispose() { RemoveTypes(); this.typeProvider = null; this.types = null; } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GetPageNumberCompletedEventArgs.cs
- Int64Animation.cs
- DataColumnPropertyDescriptor.cs
- XmlProcessingInstruction.cs
- DependencyPropertyConverter.cs
- TextAdaptor.cs
- XhtmlBasicPageAdapter.cs
- Int16.cs
- ContainerControlDesigner.cs
- ExpressionSelection.cs
- EpmCustomContentSerializer.cs
- XmlCompatibilityReader.cs
- UnsafeNativeMethodsCLR.cs
- DataGridViewLinkCell.cs
- Char.cs
- ResourceProviderFactory.cs
- NetworkInterface.cs
- PathFigureCollectionValueSerializer.cs
- RoutedPropertyChangedEventArgs.cs
- DesignerAutoFormatStyle.cs
- WmlObjectListAdapter.cs
- ImagingCache.cs
- EntityDataSourceContextDisposingEventArgs.cs
- RequestReplyCorrelator.cs
- ToolStripGripRenderEventArgs.cs
- SystemFonts.cs
- FileCodeGroup.cs
- PackWebResponse.cs
- StringComparer.cs
- XmlSiteMapProvider.cs
- DockingAttribute.cs
- LogEntryUtils.cs
- ConfigurationElement.cs
- ProfilePropertyMetadata.cs
- MarkerProperties.cs
- TextEditorParagraphs.cs
- DataGridViewColumnConverter.cs
- GraphicsState.cs
- hresults.cs
- DataControlFieldCell.cs
- TextRangeSerialization.cs
- RoutedEventConverter.cs
- PointHitTestParameters.cs
- SystemFonts.cs
- Size.cs
- GenericsInstances.cs
- RedirectionProxy.cs
- DataBindEngine.cs
- CardSpacePolicyElement.cs
- DbProviderFactories.cs
- RectangleF.cs
- Encoder.cs
- ElementAtQueryOperator.cs
- SqlDeflator.cs
- ExpressionEditorAttribute.cs
- ParallelTimeline.cs
- SizeFConverter.cs
- SymmetricAlgorithm.cs
- IdentityModelStringsVersion1.cs
- WebPartDisplayModeCancelEventArgs.cs
- BooleanFunctions.cs
- DataServiceHostFactory.cs
- TableCellAutomationPeer.cs
- ServiceModelStringsVersion1.cs
- XmlParserContext.cs
- PipelineComponent.cs
- BindingListCollectionView.cs
- BamlResourceContent.cs
- relpropertyhelper.cs
- DictionaryKeyPropertyAttribute.cs
- ForEachDesigner.xaml.cs
- _RequestCacheProtocol.cs
- NamedPipeTransportBindingElement.cs
- ListViewHitTestInfo.cs
- CodeDirectoryCompiler.cs
- ThicknessAnimation.cs
- PropertyInfoSet.cs
- ReflectTypeDescriptionProvider.cs
- UnitySerializationHolder.cs
- HttpCachePolicyWrapper.cs
- Util.cs
- SystemPens.cs
- ComponentDispatcher.cs
- ExpanderAutomationPeer.cs
- WriteableOnDemandStream.cs
- oledbconnectionstring.cs
- DisplayNameAttribute.cs
- InkPresenter.cs
- CrossSiteScriptingValidation.cs
- StateItem.cs
- HttpVersion.cs
- StylusPointProperties.cs
- PolicyLevel.cs
- RelatedView.cs
- AsymmetricKeyExchangeDeformatter.cs
- DiagnosticEventProvider.cs
- IpcPort.cs
- StorageSetMapping.cs
- Buffer.cs
- TargetControlTypeCache.cs