Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / Markup / ArrayExtension.cs / 1 / ArrayExtension.cs
/****************************************************************************\ * * File: ArrayExtension.cs * * Class for Xaml markup extension for Arrays * * Copyright (C) 2004 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Windows; using System.Collections; using System.ComponentModel; namespace System.Windows.Markup { ////// Class for Xaml markup extension for Arrays. /// [ContentProperty("Items")] [MarkupExtensionReturnType(typeof(Array))] public class ArrayExtension : MarkupExtension, IAddChild { ////// Constructor that takes no parameters. This creates an empty array. /// public ArrayExtension() { } ////// Constructor that takes one parameter. This initializes the type of the array. /// public ArrayExtension( Type arrayType) { if (arrayType == null) { throw new ArgumentNullException("arrayType"); } _arrayType = arrayType; } ////// Constructor for writing /// /// The array to write public ArrayExtension(Array elements) { _arrayList.AddRange(elements); _arrayType = elements.GetType().GetElementType(); } ////// Called to Add an object as a new array item. This will append the object to the end /// of the array. /// /// /// Object to add to the end of the array. /// public void AddChild(Object value) { _arrayList.Add(value); } ////// Called to Add a text as a new array item. This will append the object to the end /// of the array. /// /// /// Text to Add to the end of the array /// public void AddText(string text) { AddChild(text); } ////// Get and set the type of array to be created when calling ProvideValue /// [ConstructorArgument("type")] public Type Type { get { return _arrayType; } set { _arrayType = value; } } ////// An IList accessor to the contents of the array /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public IList Items { get { return _arrayList; } } ////// Return an array that is sized to the number of objects added to the ArrayExtension. /// /// Object that can provide services for the markup extension. ////// The Array containing all the objects added to this extension. /// public override object ProvideValue(IServiceProvider serviceProvider) { if (_arrayType == null) { throw new InvalidOperationException(SR.Get(SRID.MarkupExtensionArrayType)); } object retArray = null; try { retArray = _arrayList.ToArray(_arrayType); } catch (System.InvalidCastException) { // If an element was added to the ArrayExtension that does not agree with the // ArrayType, then an InvalidCastException will occur. Generate a more // meaningful error for this case. throw new InvalidOperationException(SR.Get(SRID.MarkupExtensionArrayBadType, _arrayType.Name)); } return retArray; } private ArrayList _arrayList = new ArrayList(); private Type _arrayType; } } // 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
- DataTableNewRowEvent.cs
- DispatcherHooks.cs
- PointHitTestParameters.cs
- ZipIOLocalFileDataDescriptor.cs
- PageAsyncTask.cs
- XmlEventCache.cs
- SiteMapProvider.cs
- Listbox.cs
- Properties.cs
- followingsibling.cs
- XmlDataDocument.cs
- InputScope.cs
- Crypto.cs
- AppDomainResourcePerfCounters.cs
- XmlHierarchyData.cs
- OutputCacheProfileCollection.cs
- CollectionsUtil.cs
- SqlMethodCallConverter.cs
- MimeFormatter.cs
- StorageEndPropertyMapping.cs
- EncodingTable.cs
- DbXmlEnabledProviderManifest.cs
- TextEditorParagraphs.cs
- SAPIEngineTypes.cs
- HttpRequestCacheValidator.cs
- DataGridViewDataConnection.cs
- BinaryObjectReader.cs
- NamespaceImport.cs
- BulletChrome.cs
- EntityDataSourceColumn.cs
- PlainXmlSerializer.cs
- XmlSerializerFactory.cs
- FileStream.cs
- WebException.cs
- ListViewItemMouseHoverEvent.cs
- Soap.cs
- AmbientLight.cs
- IsolatedStorageFileStream.cs
- ComponentCollection.cs
- IdentityNotMappedException.cs
- CodeGen.cs
- IgnoreFileBuildProvider.cs
- InstanceDataCollection.cs
- DeviceContext2.cs
- VectorValueSerializer.cs
- CalendarTable.cs
- AnimationException.cs
- RelatedCurrencyManager.cs
- ErrorRuntimeConfig.cs
- BStrWrapper.cs
- PixelFormat.cs
- _FtpDataStream.cs
- EventProviderWriter.cs
- ScrollItemPattern.cs
- QilStrConcatenator.cs
- RSAPKCS1SignatureFormatter.cs
- NativeMethods.cs
- IPEndPoint.cs
- BitmapEffectGroup.cs
- PageThemeCodeDomTreeGenerator.cs
- CreatingCookieEventArgs.cs
- StorageScalarPropertyMapping.cs
- HelpKeywordAttribute.cs
- EmptyStringExpandableObjectConverter.cs
- TableCell.cs
- XmlSchemaAnnotation.cs
- DecimalStorage.cs
- PointF.cs
- SystemTcpStatistics.cs
- SymmetricAlgorithm.cs
- DesignUtil.cs
- InvokeCompletedEventArgs.cs
- _ListenerAsyncResult.cs
- Vector3DKeyFrameCollection.cs
- Unit.cs
- StrongNameMembershipCondition.cs
- ContainerUIElement3D.cs
- SystemIPInterfaceProperties.cs
- ModuleElement.cs
- XmlWhitespace.cs
- _emptywebproxy.cs
- Comparer.cs
- SQLUtility.cs
- BlobPersonalizationState.cs
- ImageField.cs
- _NetworkingPerfCounters.cs
- COM2ColorConverter.cs
- DatePicker.cs
- Style.cs
- EndPoint.cs
- SqlError.cs
- ComEventsInfo.cs
- Multiply.cs
- Visual3D.cs
- DotExpr.cs
- SecurityTokenProvider.cs
- ComboBox.cs
- AppSettingsReader.cs
- AttributeConverter.cs
- QilParameter.cs