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
- RTLAwareMessageBox.cs
- CryptoApi.cs
- EntitySqlException.cs
- HttpInputStream.cs
- IERequestCache.cs
- EntityDataSourceSelectedEventArgs.cs
- Misc.cs
- HtmlWindow.cs
- DomNameTable.cs
- DecimalAnimation.cs
- Graph.cs
- WindowPatternIdentifiers.cs
- WebPartUserCapability.cs
- IERequestCache.cs
- SpecularMaterial.cs
- BinaryFormatterWriter.cs
- DataGridViewCellLinkedList.cs
- FixedDSBuilder.cs
- ThreadSafeList.cs
- PropertyTabChangedEvent.cs
- CompilerScopeManager.cs
- MgmtConfigurationRecord.cs
- PointConverter.cs
- FixedFlowMap.cs
- UIElement.cs
- BitmapFrameEncode.cs
- DataConnectionHelper.cs
- HtmlSelect.cs
- BeginEvent.cs
- nulltextcontainer.cs
- UshortList2.cs
- JsonCollectionDataContract.cs
- QilStrConcatenator.cs
- PagedDataSource.cs
- FormsAuthenticationTicket.cs
- AddInAttribute.cs
- SHA256Managed.cs
- SqlPersonalizationProvider.cs
- GenericsInstances.cs
- AsymmetricKeyExchangeFormatter.cs
- CaseKeyBox.ViewModel.cs
- WebPartUtil.cs
- Wildcard.cs
- GlyphElement.cs
- HtmlInputText.cs
- ListViewDeletedEventArgs.cs
- SoapEnumAttribute.cs
- MetadataCache.cs
- Propagator.ExtentPlaceholderCreator.cs
- FragmentQueryProcessor.cs
- DefaultValueAttribute.cs
- UserControl.cs
- EventLogPermission.cs
- SplashScreen.cs
- XmlDataImplementation.cs
- SmiEventSink_DeferedProcessing.cs
- ObjectManager.cs
- InvalidPropValue.cs
- UidManager.cs
- XPathNodeList.cs
- InternalBufferOverflowException.cs
- Content.cs
- Pkcs9Attribute.cs
- SqlFactory.cs
- FacetEnabledSchemaElement.cs
- ValidationError.cs
- DescriptionAttribute.cs
- CodeAttributeArgumentCollection.cs
- HtmlWindowCollection.cs
- CommonProperties.cs
- MiniModule.cs
- HelpProvider.cs
- HelloOperationCD1AsyncResult.cs
- DifferencingCollection.cs
- RestHandler.cs
- invalidudtexception.cs
- EmptyEnumerable.cs
- ReadOnlyCollectionBase.cs
- WindowHideOrCloseTracker.cs
- RenderTargetBitmap.cs
- FixedSOMGroup.cs
- DesignerTextBoxAdapter.cs
- RenamedEventArgs.cs
- CompiledXpathExpr.cs
- X500Name.cs
- Calendar.cs
- RequestNavigateEventArgs.cs
- OracleParameter.cs
- ControlOperationBehavior.cs
- MediaTimeline.cs
- Choices.cs
- ToolStripSeparator.cs
- UnsupportedPolicyOptionsException.cs
- CacheChildrenQuery.cs
- NodeInfo.cs
- ComplexType.cs
- CompilerParameters.cs
- COAUTHIDENTITY.cs
- Paragraph.cs
- RemotingConfiguration.cs