Code:
/ FX-1434 / FX-1434 / 1.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
- TypeUtil.cs
- StringKeyFrameCollection.cs
- ListCollectionView.cs
- ManipulationDeltaEventArgs.cs
- HttpRequestWrapper.cs
- WebServiceHost.cs
- GraphicsPathIterator.cs
- SiteMapPath.cs
- WindowsListViewItem.cs
- XslTransform.cs
- ProbeMatchesMessage11.cs
- NamespaceCollection.cs
- LinqDataSourceUpdateEventArgs.cs
- ProfileBuildProvider.cs
- SelectedDatesCollection.cs
- DataKey.cs
- HttpMethodConstraint.cs
- TypedCompletedAsyncResult.cs
- _emptywebproxy.cs
- SafeHandle.cs
- CodeNamespaceImportCollection.cs
- TextEditor.cs
- InvalidContentTypeException.cs
- ClassImporter.cs
- BrowserCapabilitiesFactory.cs
- JoinSymbol.cs
- RuleProcessor.cs
- BamlLocalizer.cs
- PointCollectionConverter.cs
- ColorKeyFrameCollection.cs
- LongTypeConverter.cs
- StatusInfoItem.cs
- HtmlPhoneCallAdapter.cs
- TypeGenericEnumerableViewSchema.cs
- HebrewCalendar.cs
- CodeChecksumPragma.cs
- Clock.cs
- IdentityHolder.cs
- Event.cs
- RadioButtonList.cs
- TextServicesHost.cs
- ProgressiveCrcCalculatingStream.cs
- BinaryObjectInfo.cs
- infer.cs
- InvokeMemberBinder.cs
- OAVariantLib.cs
- NotSupportedException.cs
- PropertyChangedEventManager.cs
- SafeEventHandle.cs
- XPathEmptyIterator.cs
- COM2Enum.cs
- UrlMapping.cs
- WebPartsPersonalizationAuthorization.cs
- XamlPathDataSerializer.cs
- CreateUserWizardStep.cs
- AbsoluteQuery.cs
- Transform3DGroup.cs
- SqlGenerator.cs
- FlowNode.cs
- ImageListUtils.cs
- DtrList.cs
- Partitioner.cs
- Main.cs
- ContentPlaceHolder.cs
- SrgsToken.cs
- TdsParserHelperClasses.cs
- CellTreeNode.cs
- FormClosingEvent.cs
- ExpressionCopier.cs
- DataDocumentXPathNavigator.cs
- LoginStatusDesigner.cs
- FormatConvertedBitmap.cs
- StandardCommandToolStripMenuItem.cs
- ColumnHeaderConverter.cs
- DocumentPage.cs
- CaseInsensitiveComparer.cs
- MarkupExtensionParser.cs
- SortQueryOperator.cs
- SqlCharStream.cs
- Crc32Helper.cs
- SafeRightsManagementPubHandle.cs
- HttpDebugHandler.cs
- ColorBlend.cs
- CompositionTarget.cs
- TypeReference.cs
- ComponentGuaranteesAttribute.cs
- FileInfo.cs
- GeometryModel3D.cs
- unsafeIndexingFilterStream.cs
- ConfigXmlSignificantWhitespace.cs
- SqlXml.cs
- MatrixTransform.cs
- WebPartChrome.cs
- EntityClientCacheKey.cs
- EntityConnectionStringBuilder.cs
- ObjectDataSourceMethodEventArgs.cs
- SmtpCommands.cs
- TypeDescriptorFilterService.cs
- ProjectionPath.cs
- MenuBase.cs