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
- ListControl.cs
- XPathNodeInfoAtom.cs
- GradientBrush.cs
- ApplicationFileCodeDomTreeGenerator.cs
- EmbeddedMailObjectsCollection.cs
- WeakRefEnumerator.cs
- GenericEnumConverter.cs
- ObjectReaderCompiler.cs
- MenuItemStyle.cs
- RichTextBox.cs
- TraceProvider.cs
- MarkupExtensionParser.cs
- MeasurementDCInfo.cs
- __Filters.cs
- CodeAccessPermission.cs
- InputBindingCollection.cs
- codemethodreferenceexpression.cs
- ArraySortHelper.cs
- Soap.cs
- MailMessageEventArgs.cs
- PrintingPermissionAttribute.cs
- WindowsAuthenticationEventArgs.cs
- AliasedSlot.cs
- MimeFormImporter.cs
- XmlSerializationGeneratedCode.cs
- DiffuseMaterial.cs
- SubMenuStyleCollection.cs
- ZipArchive.cs
- DragEvent.cs
- JsonCollectionDataContract.cs
- IntegerValidatorAttribute.cs
- MetadataSource.cs
- WorkerRequest.cs
- ProviderConnectionPoint.cs
- dbdatarecord.cs
- TreeView.cs
- CompiledRegexRunner.cs
- IisTraceListener.cs
- DbConnectionPool.cs
- EnumerableRowCollectionExtensions.cs
- mediaclock.cs
- BindingNavigator.cs
- AutomationIdentifier.cs
- TextSegment.cs
- SystemIPAddressInformation.cs
- unitconverter.cs
- Update.cs
- TreeChangeInfo.cs
- HttpCacheVary.cs
- Section.cs
- ElementProxy.cs
- ObjectDisposedException.cs
- AlignmentYValidation.cs
- ClientConfigurationSystem.cs
- LiteralLink.cs
- InputScopeConverter.cs
- StrokeRenderer.cs
- ComEventsMethod.cs
- BindingOperations.cs
- PropertyPathWorker.cs
- OdbcError.cs
- ConfigXmlSignificantWhitespace.cs
- Facet.cs
- MailDefinition.cs
- FormatVersion.cs
- QilReplaceVisitor.cs
- FieldNameLookup.cs
- HtmlDocument.cs
- ElementAction.cs
- WebPartDescription.cs
- WorkflowMarkupSerializationProvider.cs
- SecurityHeaderTokenResolver.cs
- UserCancellationException.cs
- DesignerActionPanel.cs
- MetadataUtil.cs
- DataObject.cs
- WebPartCloseVerb.cs
- NativeMsmqMessage.cs
- XmlHierarchyData.cs
- ProcessThread.cs
- CriticalExceptions.cs
- ScriptResourceAttribute.cs
- InternalMappingException.cs
- StateDesigner.Helpers.cs
- InputElement.cs
- Substitution.cs
- HttpListenerContext.cs
- DatagridviewDisplayedBandsData.cs
- Base64Stream.cs
- LineMetrics.cs
- MulticastIPAddressInformationCollection.cs
- Environment.cs
- RubberbandSelector.cs
- SettingsBase.cs
- SymmetricKeyWrap.cs
- UnmanagedMemoryStreamWrapper.cs
- NavigateUrlConverter.cs
- SqlClientMetaDataCollectionNames.cs
- Label.cs
- XmlBinaryReader.cs