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
- CompiledQuery.cs
- ObjectRef.cs
- ExpandSegment.cs
- XsdBuilder.cs
- XMLUtil.cs
- PassportAuthentication.cs
- KeyNotFoundException.cs
- Int32Rect.cs
- AbsoluteQuery.cs
- TimeIntervalCollection.cs
- ParserHooks.cs
- ApplicationFileParser.cs
- ZipIOModeEnforcingStream.cs
- Color.cs
- WebConfigurationHostFileChange.cs
- AppDomainFactory.cs
- DirectionalAction.cs
- CriticalHandle.cs
- TableColumn.cs
- SqlNodeAnnotations.cs
- ErrorFormatterPage.cs
- SHA256Cng.cs
- MultiSelectRootGridEntry.cs
- SyndicationFeedFormatter.cs
- RedistVersionInfo.cs
- CheckPair.cs
- Executor.cs
- XmlSchemaElement.cs
- XmlDictionaryReader.cs
- XamlSerializerUtil.cs
- TextMetrics.cs
- LocatorManager.cs
- SecurityCriticalDataForSet.cs
- MessageBox.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- TableFieldsEditor.cs
- AnnotationObservableCollection.cs
- BooleanFacetDescriptionElement.cs
- StreamReader.cs
- SspiSecurityTokenParameters.cs
- IntSecurity.cs
- precedingsibling.cs
- RelationshipEndMember.cs
- UserControlAutomationPeer.cs
- UpdateTranslator.cs
- PageHandlerFactory.cs
- SelectionPattern.cs
- recordstatefactory.cs
- GlobalAllocSafeHandle.cs
- DataGridViewUtilities.cs
- SizeAnimationClockResource.cs
- SystemTcpConnection.cs
- DataAdapter.cs
- GlyphsSerializer.cs
- GradientSpreadMethodValidation.cs
- HtmlElementEventArgs.cs
- Quaternion.cs
- OrderedEnumerableRowCollection.cs
- AssociatedControlConverter.cs
- OleDbException.cs
- ReceiveContent.cs
- XamlTreeBuilder.cs
- Publisher.cs
- CombinedGeometry.cs
- InvalidPropValue.cs
- ProgressBar.cs
- ImmutableObjectAttribute.cs
- GZipStream.cs
- Binding.cs
- StorageTypeMapping.cs
- QilNode.cs
- ItemContainerPattern.cs
- CustomLineCap.cs
- RectValueSerializer.cs
- WindowsAltTab.cs
- NetTcpSection.cs
- StrongNameUtility.cs
- TimeZoneInfo.cs
- TreeViewEvent.cs
- MsmqIntegrationInputChannel.cs
- Debugger.cs
- ManagementBaseObject.cs
- TimeZone.cs
- ImmutableObjectAttribute.cs
- QueryStack.cs
- XmlJsonWriter.cs
- TextParagraph.cs
- TagElement.cs
- DateTimeParse.cs
- X509CertificateInitiatorServiceCredential.cs
- ExpressionVisitor.cs
- AnimationTimeline.cs
- InstanceDataCollection.cs
- ImportContext.cs
- EmptyControlCollection.cs
- HorizontalAlignConverter.cs
- List.cs
- VirtualDirectoryMappingCollection.cs
- NumberSubstitution.cs
- HwndMouseInputProvider.cs