Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Expressions / ArrayItemReference.cs / 1305376 / ArrayItemReference.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities.Expressions
{
using System.Activities.Statements;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.Serialization;
public sealed class ArrayItemReference : CodeActivity>
{
public ArrayItemReference()
: base()
{
}
[RequiredArgument]
[DefaultValue(null)]
public InArgument Array
{
get;
set;
}
[RequiredArgument]
[DefaultValue(null)]
public InArgument Index
{
get;
set;
}
protected override void CacheMetadata(CodeActivityMetadata metadata)
{
RuntimeArgument arrayArgument = new RuntimeArgument("Array", typeof(TItem[]), ArgumentDirection.In, true);
metadata.Bind(this.Array, arrayArgument);
RuntimeArgument indexArgument = new RuntimeArgument("Index", typeof(int), ArgumentDirection.In, true);
metadata.Bind(this.Index, indexArgument);
RuntimeArgument resultArgument = new RuntimeArgument("Result", typeof(Location), ArgumentDirection.Out);
metadata.Bind(this.Result, resultArgument);
metadata.SetArgumentsCollection(
new Collection
{
arrayArgument,
indexArgument,
resultArgument
});
}
protected override Location Execute(CodeActivityContext context)
{
TItem[] items = this.Array.Get(context);
if (items == null)
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.MemberCannotBeNull("Array", this.GetType().Name, this.DisplayName)));
}
int itemIndex = this.Index.Get(context);
return new ArrayLocation(items, itemIndex);
}
[DataContract]
class ArrayLocation : Location
{
[DataMember]
TItem[] array;
[DataMember(EmitDefaultValue = false)]
int index;
public ArrayLocation(TItem[] array, int index)
: base()
{
this.array = array;
this.index = index;
}
public override TItem Value
{
get
{
return this.array[this.index];
}
set
{
this.array[this.index] = value;
}
}
}
}
}
// 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
- DataProviderNameConverter.cs
- ListBindingConverter.cs
- TraceContext.cs
- _HelperAsyncResults.cs
- EntityDataSourceStatementEditorForm.cs
- HostedHttpRequestAsyncResult.cs
- ToolStripSystemRenderer.cs
- ColorTranslator.cs
- FixedHyperLink.cs
- DoubleAnimation.cs
- AdPostCacheSubstitution.cs
- WebBrowserNavigatingEventHandler.cs
- TransformerConfigurationWizardBase.cs
- UnsafeNativeMethodsTablet.cs
- DetailsViewUpdateEventArgs.cs
- HandlerBase.cs
- ReferenceAssemblyAttribute.cs
- WebPartMovingEventArgs.cs
- EncryptionUtility.cs
- OptionalColumn.cs
- _UriSyntax.cs
- UserMapPath.cs
- XPathSelfQuery.cs
- SqlBuffer.cs
- SqlSelectStatement.cs
- SurrogateSelector.cs
- GradientStop.cs
- ObjectAnimationUsingKeyFrames.cs
- MaterialGroup.cs
- DataConnectionHelper.cs
- ResourceDefaultValueAttribute.cs
- PathFigure.cs
- UpdatePanelTriggerCollection.cs
- XmlLinkedNode.cs
- StructuredTypeEmitter.cs
- ClientScriptManagerWrapper.cs
- ContainerSelectorGlyph.cs
- SecurityUniqueId.cs
- TextPenaltyModule.cs
- TextEditorTables.cs
- MemoryPressure.cs
- GlyphInfoList.cs
- XPathNode.cs
- SafeNativeMethods.cs
- IgnoreSectionHandler.cs
- Configuration.cs
- SafeCoTaskMem.cs
- ErrorWrapper.cs
- InheritanceAttribute.cs
- RankException.cs
- DesignerHierarchicalDataSourceView.cs
- CalendarDateRange.cs
- DataBoundControlAdapter.cs
- ReadWriteSpinLock.cs
- X509CertificateStore.cs
- SQLInt16.cs
- StylusPlugin.cs
- ConnectionPoint.cs
- Base64Decoder.cs
- X509Certificate2Collection.cs
- CodeGen.cs
- RubberbandSelector.cs
- WebDisplayNameAttribute.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- EntityDataSourceWrapper.cs
- OdbcTransaction.cs
- DbMetaDataFactory.cs
- IntegrationExceptionEventArgs.cs
- XamlStream.cs
- MessageHeader.cs
- PathSegment.cs
- IntPtr.cs
- DecoderReplacementFallback.cs
- AuthenticationConfig.cs
- Brushes.cs
- TextServicesPropertyRanges.cs
- PageClientProxyGenerator.cs
- QueryCacheEntry.cs
- XmlDataLoader.cs
- UpdatePanelControlTrigger.cs
- FileLogRecordEnumerator.cs
- UpdatePanelTrigger.cs
- UInt32Storage.cs
- ConfigXmlElement.cs
- LocalizableResourceBuilder.cs
- ObjectTypeMapping.cs
- ComplexLine.cs
- PrintControllerWithStatusDialog.cs
- ToolStripGripRenderEventArgs.cs
- NavigationPropertyEmitter.cs
- PopupRootAutomationPeer.cs
- AsyncStreamReader.cs
- Formatter.cs
- Visual3D.cs
- DockPattern.cs
- Html32TextWriter.cs
- FileLogRecord.cs
- BaseTemplateParser.cs
- WebPartConnectionsCancelVerb.cs
- CurrentChangingEventArgs.cs