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
- WorkflowOperationAsyncResult.cs
- InternalConfigEventArgs.cs
- UnicodeEncoding.cs
- SystemIcmpV4Statistics.cs
- FormClosingEvent.cs
- MappingModelBuildProvider.cs
- DispatchOperation.cs
- UndoManager.cs
- ServicesExceptionNotHandledEventArgs.cs
- BamlResourceContent.cs
- ExclusiveCanonicalizationTransform.cs
- PageAdapter.cs
- FrameworkElement.cs
- DataGridViewColumn.cs
- ResetableIterator.cs
- DateTimeUtil.cs
- ConfigXmlWhitespace.cs
- PersonalizationState.cs
- AutoGeneratedFieldProperties.cs
- PageTheme.cs
- TransformDescriptor.cs
- RootProjectionNode.cs
- HttpProfileBase.cs
- FixedSOMLineCollection.cs
- OrderPreservingPipeliningSpoolingTask.cs
- XmlSchemaAnnotation.cs
- OutputScopeManager.cs
- XmlnsPrefixAttribute.cs
- GridView.cs
- TextParaLineResult.cs
- GcSettings.cs
- SizeKeyFrameCollection.cs
- DigestComparer.cs
- WebPartCollection.cs
- SystemParameters.cs
- Deflater.cs
- TemplateDefinition.cs
- CodeMemberProperty.cs
- SerializationTrace.cs
- XmlSecureResolver.cs
- StringConverter.cs
- DataGridViewRowStateChangedEventArgs.cs
- ControlValuePropertyAttribute.cs
- DeclarativeExpressionConditionDeclaration.cs
- IsolatedStorageException.cs
- ReliableMessagingVersion.cs
- TableLayoutSettingsTypeConverter.cs
- HoistedLocals.cs
- QueryExpr.cs
- RuleConditionDialog.Designer.cs
- CategoryState.cs
- CapabilitiesUse.cs
- NumberFormatInfo.cs
- Size.cs
- XmlCountingReader.cs
- ToolBarPanel.cs
- TrackingStringDictionary.cs
- DrawingImage.cs
- ServiceModelConfigurationSectionCollection.cs
- Vector3DAnimationBase.cs
- TextProperties.cs
- WindowsIPAddress.cs
- XmlSchemaParticle.cs
- RandomNumberGenerator.cs
- SecurityRuntime.cs
- ContentPropertyAttribute.cs
- HTTPNotFoundHandler.cs
- TextTreeUndoUnit.cs
- WebPartConnectionsDisconnectVerb.cs
- Decorator.cs
- Pair.cs
- ScrollEvent.cs
- ISAPIApplicationHost.cs
- SqlMethodTransformer.cs
- DataListItemCollection.cs
- X509Extension.cs
- TraceListeners.cs
- SessionStateUtil.cs
- PrintPreviewControl.cs
- DateTimeParse.cs
- OracleParameterBinding.cs
- MouseActionValueSerializer.cs
- SelectionWordBreaker.cs
- DesignerForm.cs
- TagNameToTypeMapper.cs
- ServiceModelEnumValidator.cs
- WsiProfilesElement.cs
- HScrollProperties.cs
- TransportChannelFactory.cs
- ExternalException.cs
- RefreshEventArgs.cs
- EntityCommandDefinition.cs
- Pts.cs
- HwndSourceParameters.cs
- ComponentResourceKeyConverter.cs
- UserControlBuildProvider.cs
- HiddenFieldPageStatePersister.cs
- EncoderNLS.cs
- AnimationLayer.cs
- SamlSecurityTokenAuthenticator.cs