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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HandleCollector.cs
- GridViewCancelEditEventArgs.cs
- Guid.cs
- AttributeEmitter.cs
- DataGridViewSelectedColumnCollection.cs
- control.ime.cs
- QilPatternFactory.cs
- FieldBuilder.cs
- PeerCustomResolverElement.cs
- ActionFrame.cs
- OracleRowUpdatedEventArgs.cs
- LocalFileSettingsProvider.cs
- VariantWrapper.cs
- WebReference.cs
- LoadedEvent.cs
- DragEvent.cs
- EventLogPermission.cs
- EmissiveMaterial.cs
- LambdaCompiler.Generated.cs
- TokenFactoryCredential.cs
- SrgsItemList.cs
- ListViewCancelEventArgs.cs
- CodeConstructor.cs
- ResumeStoryboard.cs
- ExpressionBindingCollection.cs
- CreatingCookieEventArgs.cs
- FormsAuthenticationCredentials.cs
- StylusPointPropertyInfoDefaults.cs
- OleDbFactory.cs
- TreeNodeCollection.cs
- SQLDateTimeStorage.cs
- DataServiceSaveChangesEventArgs.cs
- BorderGapMaskConverter.cs
- ToolConsole.cs
- RSAPKCS1SignatureDeformatter.cs
- RootProfilePropertySettingsCollection.cs
- categoryentry.cs
- SmiSettersStream.cs
- PolicyConversionContext.cs
- SuppressMergeCheckAttribute.cs
- MarginCollapsingState.cs
- MimePart.cs
- SessionState.cs
- XmlSecureResolver.cs
- DbProviderSpecificTypePropertyAttribute.cs
- Form.cs
- InternalRelationshipCollection.cs
- UriScheme.cs
- Serializer.cs
- CheckedListBox.cs
- GenericPrincipal.cs
- FileSystemInfo.cs
- SqlFunctionAttribute.cs
- XmlAttributeAttribute.cs
- objectquery_tresulttype.cs
- PreviewPageInfo.cs
- ConstraintEnumerator.cs
- SpellerStatusTable.cs
- ZoneIdentityPermission.cs
- PersonalizableTypeEntry.cs
- QilPatternVisitor.cs
- LocationSectionRecord.cs
- EtwTrace.cs
- MessageHeaderInfoTraceRecord.cs
- InputProcessorProfilesLoader.cs
- ProfileSettingsCollection.cs
- RuleAction.cs
- PeerResolverBindingElement.cs
- oledbmetadatacolumnnames.cs
- SettingsPropertyCollection.cs
- OleDbCommand.cs
- UniqueConstraint.cs
- XComponentModel.cs
- SharedStatics.cs
- SubMenuStyle.cs
- Visual3DCollection.cs
- DecimalKeyFrameCollection.cs
- MemoryMappedViewStream.cs
- AbstractExpressions.cs
- XXXOnTypeBuilderInstantiation.cs
- HighlightVisual.cs
- FixedPage.cs
- Convert.cs
- SoapSchemaExporter.cs
- HandleTable.cs
- CharacterShapingProperties.cs
- TargetControlTypeAttribute.cs
- DESCryptoServiceProvider.cs
- VectorConverter.cs
- ECDsa.cs
- EmissiveMaterial.cs
- ErrorHandlingReceiver.cs
- HttpChannelListener.cs
- messageonlyhwndwrapper.cs
- ResourcesChangeInfo.cs
- Material.cs
- MetadataCache.cs
- ResXDataNode.cs
- BitmapInitialize.cs
- ServicePoint.cs