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
- PrintingPermissionAttribute.cs
- PenLineJoinValidation.cs
- XPathNodeIterator.cs
- StackBuilderSink.cs
- SamlAuthenticationClaimResource.cs
- FontResourceCache.cs
- WebConfigurationManager.cs
- Encoding.cs
- KeySpline.cs
- FocusWithinProperty.cs
- TreeNodeCollection.cs
- CategoryAttribute.cs
- SmiEventSink_DeferedProcessing.cs
- DataGridTextColumn.cs
- Certificate.cs
- ProfessionalColorTable.cs
- httpserverutility.cs
- XmlValidatingReader.cs
- File.cs
- EpmContentSerializer.cs
- StylusPointCollection.cs
- GenerateScriptTypeAttribute.cs
- SerialStream.cs
- CanonicalFontFamilyReference.cs
- HttpRequestContext.cs
- ModuleElement.cs
- DataServiceRequest.cs
- TemplateParser.cs
- Size.cs
- KeyFrames.cs
- UInt32Converter.cs
- MediaCommands.cs
- KeyedCollection.cs
- EventLogPermissionAttribute.cs
- CategoryNameCollection.cs
- cookieexception.cs
- XmlEncodedRawTextWriter.cs
- SmtpDigestAuthenticationModule.cs
- ECDiffieHellmanCng.cs
- ProxyManager.cs
- DataFormat.cs
- AdRotatorDesigner.cs
- ObservableDictionary.cs
- TrustLevel.cs
- documentation.cs
- PolicyLevel.cs
- ScriptingProfileServiceSection.cs
- GZipDecoder.cs
- PermissionAttributes.cs
- TableSectionStyle.cs
- FlagsAttribute.cs
- HtmlAnchor.cs
- MemberProjectionIndex.cs
- ProfilePropertySettings.cs
- SqlDataSourceAdvancedOptionsForm.cs
- EncodingTable.cs
- GeneralTransform.cs
- SQLDecimalStorage.cs
- Registry.cs
- LogReserveAndAppendState.cs
- ContentOperations.cs
- ScopedKnownTypes.cs
- CompositeActivityTypeDescriptorProvider.cs
- ValidationSummary.cs
- Label.cs
- Table.cs
- ReachUIElementCollectionSerializerAsync.cs
- ClientSettingsSection.cs
- FileDialog_Vista.cs
- InvokeWebService.cs
- ApplicationTrust.cs
- PropertyChangedEventArgs.cs
- SystemUdpStatistics.cs
- UnconditionalPolicy.cs
- WindowsToolbarItemAsMenuItem.cs
- DataControlCommands.cs
- SafeRightsManagementQueryHandle.cs
- HtmlFormWrapper.cs
- InvalidProgramException.cs
- SafeProcessHandle.cs
- NestedContainer.cs
- SystemTcpConnection.cs
- CodeDOMProvider.cs
- CompositeTypefaceMetrics.cs
- GeometryHitTestResult.cs
- FastPropertyAccessor.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- SystemException.cs
- SkipQueryOptionExpression.cs
- PlatformCulture.cs
- CellTreeNodeVisitors.cs
- UpdatePanel.cs
- SoapAttributeAttribute.cs
- SamlDoNotCacheCondition.cs
- ParameterCollection.cs
- SchemaImporterExtension.cs
- TextServicesDisplayAttribute.cs
- ColorConverter.cs
- Baml2006ReaderContext.cs
- ArgumentNullException.cs