Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / Switch.cs / 1305376 / Switch.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Statements { using System; using System.Activities; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq.Expressions; using System.Windows.Markup; using System.Runtime; [ContentProperty("Cases")] public sealed class Switch: NativeActivity { IDictionary cases; public Switch() { } public Switch(Expression > expression) : this() { if (expression == null) { throw FxTrace.Exception.ArgumentNull("expression"); } this.Expression = new InArgument (expression); } public Switch(Activity expression) : this() { if (expression == null) { throw FxTrace.Exception.ArgumentNull("expression"); } this.Expression = new InArgument (expression); } public Switch(InArgument expression) : this() { if (expression == null) { throw FxTrace.Exception.ArgumentNull("expression"); } this.Expression = expression; } [RequiredArgument] [DefaultValue(null)] public InArgument Expression { get; set; } public IDictionary Cases { get { if (this.cases == null) { this.cases = new CasesDictionary (); } return this.cases; } } [DefaultValue(null)] public Activity Default { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument expressionArgument = new RuntimeArgument("Expression", typeof(T), ArgumentDirection.In, true); metadata.Bind(Expression, expressionArgument); metadata.SetArgumentsCollection(new Collection { expressionArgument }); Collection children = new Collection (); foreach (Activity child in Cases.Values) { children.Add(child); } if (Default != null) { children.Add(Default); } metadata.SetChildrenCollection(children); } protected override void Execute(NativeActivityContext context) { T result = Expression.Get(context); Activity selection = null; if (!Cases.TryGetValue(result, out selection)) { if (this.Default != null) { selection = this.Default; } else { if (TD.SwitchCaseNotFoundIsEnabled()) { TD.SwitchCaseNotFound(this.DisplayName); } } } if (selection != null) { context.ScheduleActivity(selection); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientEventManager.cs
- EntityDataSourceWizardForm.cs
- HitTestWithGeometryDrawingContextWalker.cs
- DocumentViewer.cs
- BindingCompleteEventArgs.cs
- SessionSwitchEventArgs.cs
- ToolStripControlHost.cs
- WebServiceReceiveDesigner.cs
- sqlser.cs
- XmlTextEncoder.cs
- RecognitionResult.cs
- Enum.cs
- CheckBoxPopupAdapter.cs
- ConstructorBuilder.cs
- OleDbPropertySetGuid.cs
- JsonDeserializer.cs
- MenuItemStyleCollection.cs
- TypedReference.cs
- SqlDataSourceFilteringEventArgs.cs
- ServerIdentity.cs
- HorizontalAlignConverter.cs
- ContainerUtilities.cs
- LocalizationParserHooks.cs
- DiscreteKeyFrames.cs
- DrawingCollection.cs
- arc.cs
- SchemaType.cs
- NumericPagerField.cs
- SimpleTableProvider.cs
- PagesChangedEventArgs.cs
- ArcSegment.cs
- ITreeGenerator.cs
- XslVisitor.cs
- HtmlImage.cs
- ActivityTypeResolver.xaml.cs
- _NestedMultipleAsyncResult.cs
- IndexerNameAttribute.cs
- Propagator.JoinPropagator.cs
- LinkedList.cs
- StateRuntime.cs
- EntityProviderFactory.cs
- SystemMulticastIPAddressInformation.cs
- CryptoConfig.cs
- SessionState.cs
- DataGridPageChangedEventArgs.cs
- HtmlTableCellCollection.cs
- FontInfo.cs
- BrowsableAttribute.cs
- LinearKeyFrames.cs
- ContentOperations.cs
- ToolStripTextBox.cs
- WebContext.cs
- ElementMarkupObject.cs
- GACMembershipCondition.cs
- DoubleLinkListEnumerator.cs
- Claim.cs
- ComplexPropertyEntry.cs
- CaseStatementSlot.cs
- FramingFormat.cs
- StorageComplexTypeMapping.cs
- BigInt.cs
- JournalEntryStack.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- AdPostCacheSubstitution.cs
- CqlErrorHelper.cs
- DataBoundControlAdapter.cs
- FixedNode.cs
- XmlWhitespace.cs
- FontStyles.cs
- PathGeometry.cs
- AssemblyCollection.cs
- CodeTypeOfExpression.cs
- securitycriticaldataClass.cs
- UriSection.cs
- XmlRawWriter.cs
- FixedHighlight.cs
- DocumentPaginator.cs
- QilTypeChecker.cs
- ExpandSegmentCollection.cs
- ZoneButton.cs
- InfoCardMasterKey.cs
- ServicesSection.cs
- TimersDescriptionAttribute.cs
- SmtpNetworkElement.cs
- AppDomainProtocolHandler.cs
- AppSettingsExpressionBuilder.cs
- HttpApplication.cs
- ImmComposition.cs
- smtpconnection.cs
- AuthStoreRoleProvider.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- AlphabeticalEnumConverter.cs
- LostFocusEventManager.cs
- NamespaceList.cs
- ActivityIdHeader.cs
- WebRequestModulesSection.cs
- InvalidProgramException.cs
- MergablePropertyAttribute.cs
- HttpCookiesSection.cs
- HttpUnhandledOperationInvoker.cs