Code:
/ 4.0 / 4.0 / 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. 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 List types = 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
- HttpUnhandledOperationInvoker.cs
- DefaultBinder.cs
- MarkupCompilePass2.cs
- GroupBoxAutomationPeer.cs
- ButtonFlatAdapter.cs
- RowParagraph.cs
- MulticastIPAddressInformationCollection.cs
- CoreSwitches.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- X509CertificateRecipientClientCredential.cs
- DateTimeConverter2.cs
- XmlTextAttribute.cs
- DataError.cs
- BaseDataBoundControl.cs
- Rect3D.cs
- VoiceChangeEventArgs.cs
- QuotedPrintableStream.cs
- TargetControlTypeCache.cs
- StateRuntime.cs
- PenCursorManager.cs
- ClientBuildManagerCallback.cs
- DataGridViewRowCancelEventArgs.cs
- ProcessingInstructionAction.cs
- ReferenceSchema.cs
- ListenUriMode.cs
- CompileLiteralTextParser.cs
- GridViewSelectEventArgs.cs
- ImageSource.cs
- ClientRoleProvider.cs
- WebPartDescription.cs
- ControlBuilder.cs
- WindowsIdentity.cs
- XmlnsCache.cs
- ManagementObjectCollection.cs
- ColorTransformHelper.cs
- XmlSchemaValidator.cs
- ProfileBuildProvider.cs
- SymbolResolver.cs
- AssemblyResourceLoader.cs
- NotCondition.cs
- RewritingPass.cs
- BroadcastEventHelper.cs
- WebEncodingValidator.cs
- ObjectDataSourceFilteringEventArgs.cs
- GraphicsState.cs
- MasterPageParser.cs
- Preprocessor.cs
- ToolStripContentPanel.cs
- BoundPropertyEntry.cs
- CompositeClientFormatter.cs
- MetadataCacheItem.cs
- SemanticTag.cs
- DataTable.cs
- Rect3DConverter.cs
- ClientSideQueueItem.cs
- HuffCodec.cs
- BindingBase.cs
- Rectangle.cs
- MatchingStyle.cs
- UrlAuthFailedErrorFormatter.cs
- DataBinder.cs
- ScriptingJsonSerializationSection.cs
- MailSettingsSection.cs
- hwndwrapper.cs
- SkipStoryboardToFill.cs
- CheckBoxFlatAdapter.cs
- XmlAttributeCollection.cs
- dbenumerator.cs
- ErrorHandlerModule.cs
- Condition.cs
- FixedBufferAttribute.cs
- GlobalItem.cs
- DecimalAnimationBase.cs
- Material.cs
- AttributeProviderAttribute.cs
- SelectionProviderWrapper.cs
- JsonReader.cs
- WindowsSpinner.cs
- CaseStatement.cs
- EncodingTable.cs
- UpDownEvent.cs
- _CacheStreams.cs
- ComponentResourceManager.cs
- TypeSource.cs
- AssemblyCollection.cs
- EventDescriptor.cs
- LinqDataSourceStatusEventArgs.cs
- UnknownWrapper.cs
- ViewSimplifier.cs
- EdmPropertyAttribute.cs
- MemberAssignment.cs
- FixedLineResult.cs
- Error.cs
- SpellerHighlightLayer.cs
- MediaElementAutomationPeer.cs
- WebFaultClientMessageInspector.cs
- DbBuffer.cs
- ProgressChangedEventArgs.cs
- ConfigurationManager.cs
- DataGridToolTip.cs