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
- ActivityDesignerHelper.cs
- mediaclock.cs
- ObjectListItem.cs
- HeaderedItemsControl.cs
- AnimatedTypeHelpers.cs
- Vector3DCollectionConverter.cs
- GeneralTransform3DCollection.cs
- SqlComparer.cs
- HtmlLink.cs
- XamlTypeWithExplicitNamespace.cs
- EntityDataSourceViewSchema.cs
- DbSourceParameterCollection.cs
- SystemFonts.cs
- TreeNodeClickEventArgs.cs
- SchemaElementDecl.cs
- LambdaCompiler.Lambda.cs
- SqlClientWrapperSmiStreamChars.cs
- Int64AnimationUsingKeyFrames.cs
- EntityCommandExecutionException.cs
- QilXmlReader.cs
- TrustLevel.cs
- IgnoreFlushAndCloseStream.cs
- ImpersonateTokenRef.cs
- Activation.cs
- ViewBase.cs
- DebugView.cs
- AnimationStorage.cs
- XmlCompatibilityReader.cs
- DrawItemEvent.cs
- TextEffectCollection.cs
- MessageSmuggler.cs
- XamlContextStack.cs
- DocumentApplicationJournalEntry.cs
- HttpListenerRequest.cs
- IIS7UserPrincipal.cs
- ExecutionContext.cs
- CheckableControlBaseAdapter.cs
- TextBoxBase.cs
- Effect.cs
- SafeFileMappingHandle.cs
- RsaSecurityTokenParameters.cs
- AsyncWaitHandle.cs
- Grammar.cs
- DynamicQueryStringParameter.cs
- ToolStripPanel.cs
- ReaderWriterLock.cs
- OverrideMode.cs
- SSmlParser.cs
- UnionExpr.cs
- ColumnResizeAdorner.cs
- DataGridDesigner.cs
- ActiveXHost.cs
- DBSqlParser.cs
- _UriSyntax.cs
- MsmqIntegrationInputMessage.cs
- ContextMarshalException.cs
- TemplateInstanceAttribute.cs
- FileVersion.cs
- MatrixCamera.cs
- UIElementPropertyUndoUnit.cs
- WebServiceData.cs
- SafeNativeMethods.cs
- NameValuePermission.cs
- StopRoutingHandler.cs
- DataPagerFieldCollection.cs
- DataGridViewRow.cs
- SqlDataSourceConnectionPanel.cs
- XmlValidatingReaderImpl.cs
- NetCodeGroup.cs
- ViewBox.cs
- HttpListenerContext.cs
- FormattedTextSymbols.cs
- ConsumerConnectionPointCollection.cs
- RequestQueryProcessor.cs
- InfiniteTimeSpanConverter.cs
- ZipIOExtraFieldZip64Element.cs
- RadialGradientBrush.cs
- Expander.cs
- Executor.cs
- _HeaderInfo.cs
- ClientApiGenerator.cs
- DataGridViewRowsAddedEventArgs.cs
- FieldReference.cs
- ObjectContext.cs
- ObjRef.cs
- filewebresponse.cs
- UndoManager.cs
- TCEAdapterGenerator.cs
- _LocalDataStoreMgr.cs
- SoapIgnoreAttribute.cs
- DataGridViewRowPrePaintEventArgs.cs
- SafeHandles.cs
- SyntaxCheck.cs
- PhotoPrintingIntent.cs
- Primitive.cs
- MsmqNonTransactedPoisonHandler.cs
- NamespaceQuery.cs
- DynamicRendererThreadManager.cs
- BeginStoryboard.cs
- AnyAllSearchOperator.cs