Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / CompMod / System / ComponentModel / Design / Serialization / CodeMethodMap.cs / 1 / CodeMethodMap.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.ComponentModel.Design.Serialization {
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Design;
using System.Diagnostics;
///
/// This structure is used by IntegrateStatements to put statements in the right place.
///
internal class CodeMethodMap {
private CodeStatementCollection _container;
private CodeStatementCollection _begin;
private CodeStatementCollection _end;
private CodeStatementCollection _statements;
private CodeStatementCollection _locals;
private CodeStatementCollection _fields;
private CodeStatementCollection _variables;
private CodeStatementCollection _targetStatements;
private CodeMemberMethod _method;
internal CodeMethodMap(CodeMemberMethod method) : this(null, method){
}
internal CodeMethodMap(CodeStatementCollection targetStatements, CodeMemberMethod method) {
_method = method;
if (targetStatements != null) {
_targetStatements = targetStatements;
}
else {
_targetStatements = _method.Statements;
}
}
internal CodeStatementCollection BeginStatements {
get {
if (_begin == null) _begin = new CodeStatementCollection();
return _begin;
}
}
internal CodeStatementCollection EndStatements {
get {
if (_end == null) _end = new CodeStatementCollection();
return _end;
}
}
internal CodeStatementCollection ContainerStatements {
get {
if (_container == null) _container = new CodeStatementCollection();
return _container;
}
}
internal CodeMemberMethod Method {
get {
return _method;
}
}
internal CodeStatementCollection Statements {
get {
if (_statements == null) _statements = new CodeStatementCollection();
return _statements;
}
}
internal CodeStatementCollection LocalVariables {
get {
if (_locals == null) _locals = new CodeStatementCollection();
return _locals;
}
}
internal CodeStatementCollection FieldAssignments {
get {
if (_fields == null) _fields = new CodeStatementCollection();
return _fields;
}
}
//
internal CodeStatementCollection VariableAssignments {
get {
if (_variables == null) _variables = new CodeStatementCollection();
return _variables;
}
}
internal void Add(CodeStatementCollection statements) {
foreach (CodeStatement statement in statements) {
string isContainer = statement.UserData["IContainer"] as string;
if (isContainer != null && isContainer == "IContainer") {
ContainerStatements.Add(statement);
}
else if (statement is CodeAssignStatement && ((CodeAssignStatement)statement).Left is CodeFieldReferenceExpression) {
FieldAssignments.Add(statement);
}
else if (statement is CodeAssignStatement && ((CodeAssignStatement)statement).Left is CodeVariableReferenceExpression) {
VariableAssignments.Add(statement);
}
else if (statement is CodeVariableDeclarationStatement) {
LocalVariables.Add(statement);
}
else {
string order = statement.UserData["statement-ordering"] as string;
if (order != null) {
switch (order) {
case "begin":
BeginStatements.Add(statement);
break;
case "end":
EndStatements.Add(statement);
break;
case "default":
default:
Statements.Add(statement);
break;
}
}
else {
Statements.Add(statement);
}
}
}
}
internal void Combine() {
if (_container != null) _targetStatements.AddRange(_container);
if (_locals != null) _targetStatements.AddRange(_locals);
if (_fields != null) _targetStatements.AddRange(_fields);
if (_variables != null) _targetStatements.AddRange(_variables);
if (_begin != null) _targetStatements.AddRange(_begin);
if (_statements != null) _targetStatements.AddRange(_statements);
if (_end != null) _targetStatements.AddRange(_end);
}
}
}
// 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
- TextWriterTraceListener.cs
- VectorAnimationUsingKeyFrames.cs
- ApplicationSecurityInfo.cs
- UpnEndpointIdentity.cs
- DbProviderConfigurationHandler.cs
- ButtonPopupAdapter.cs
- FormsAuthenticationConfiguration.cs
- PTProvider.cs
- FileRecordSequenceCompletedAsyncResult.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- EventDriven.cs
- errorpatternmatcher.cs
- MissingSatelliteAssemblyException.cs
- FreezableOperations.cs
- LinearKeyFrames.cs
- SiteMapNode.cs
- CachedBitmap.cs
- FontWeightConverter.cs
- AutomationIdentifier.cs
- LayoutSettings.cs
- AxisAngleRotation3D.cs
- FileSecurity.cs
- CodePropertyReferenceExpression.cs
- AccessText.cs
- IPipelineRuntime.cs
- SafeHandles.cs
- UInt64Storage.cs
- MetadataCache.cs
- WriteableBitmap.cs
- AspNetPartialTrustHelpers.cs
- EntitySqlQueryCacheKey.cs
- DataSourceListEditor.cs
- DataBindingList.cs
- DecoderBestFitFallback.cs
- SessionEndingCancelEventArgs.cs
- StructuralCache.cs
- MarkupCompilePass2.cs
- RSAOAEPKeyExchangeFormatter.cs
- SequentialWorkflowHeaderFooter.cs
- EncryptedReference.cs
- ColumnHeaderCollectionEditor.cs
- HtmlWindow.cs
- Win32PrintDialog.cs
- ReadOnlyDataSourceView.cs
- MultiViewDesigner.cs
- RadioButton.cs
- PreProcessInputEventArgs.cs
- XmlDocumentFragment.cs
- PageClientProxyGenerator.cs
- RoleService.cs
- Utility.cs
- ToolboxComponentsCreatedEventArgs.cs
- IndexOutOfRangeException.cs
- Mappings.cs
- PerformanceCounterPermissionAttribute.cs
- BooleanAnimationBase.cs
- RowBinding.cs
- coordinator.cs
- DynamicArgumentDesigner.xaml.cs
- IdnMapping.cs
- WebCategoryAttribute.cs
- ForwardPositionQuery.cs
- TheQuery.cs
- ServicePoint.cs
- DataGridViewCellValidatingEventArgs.cs
- ConditionalExpression.cs
- DataGridItemEventArgs.cs
- Control.cs
- BitmapSizeOptions.cs
- ReflectPropertyDescriptor.cs
- TextTreeObjectNode.cs
- Switch.cs
- XamlClipboardData.cs
- WebEventCodes.cs
- TypeSource.cs
- ValidatorCompatibilityHelper.cs
- SafeThreadHandle.cs
- TypedElement.cs
- ParenthesizePropertyNameAttribute.cs
- ChannelTracker.cs
- InlineObject.cs
- ObjectConverter.cs
- RootProfilePropertySettingsCollection.cs
- MultitargetUtil.cs
- NamespaceDisplay.xaml.cs
- MustUnderstandBehavior.cs
- WSDualHttpBinding.cs
- UniqueIdentifierService.cs
- XmlCharCheckingWriter.cs
- ProxyAttribute.cs
- RegionIterator.cs
- Vector.cs
- IItemContainerGenerator.cs
- TextFormatterHost.cs
- ValueHandle.cs
- SuppressMessageAttribute.cs
- TypeConverter.cs
- DPAPIProtectedConfigurationProvider.cs
- CrossContextChannel.cs
- StrokeNodeOperations.cs