Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / Configuration / DeclaredTypeElementCollection.cs / 1 / DeclaredTypeElementCollection.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime.Serialization.Configuration { using System; using System.Configuration; using System.Globalization; [ConfigurationCollection(typeof(DeclaredTypeElement))] public sealed class DeclaredTypeElementCollection : ConfigurationElementCollection { public DeclaredTypeElementCollection() { } public DeclaredTypeElement this[int index] { get { DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(index); return retval; } set { // Only validate input if config is not Read-Only, otherwise // let BaseAdd throw appropriate exception if (!this.IsReadOnly()) { if (value == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); } if (BaseGet(index) != null) { BaseRemoveAt(index); } } BaseAdd(index, value); } } public new DeclaredTypeElement this[string typeName] { get { if (String.IsNullOrEmpty(typeName)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName"); } DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(typeName); return retval; } set { // Only validate input if config is not Read-Only, otherwise // let Add throw appropriate exception if (!this.IsReadOnly()) { if (String.IsNullOrEmpty(typeName)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName"); } if (value == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); } if (BaseGet(typeName) != null) { BaseRemove(typeName); } else { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new IndexOutOfRangeException(SR.GetString(SR.ConfigIndexOutOfRange, typeName))); } } Add(value); } } public void Add(DeclaredTypeElement element) { // Only validate input if config is not Read-Only, otherwise // let BaseAdd throw appropriate exception if (!this.IsReadOnly()) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } } BaseAdd(element); } public void Clear() { BaseClear(); } public bool Contains(string typeName) { if (String.IsNullOrEmpty(typeName)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName"); } return this.BaseGet(typeName) != null; } protected override ConfigurationElement CreateNewElement() { DeclaredTypeElement retval = new DeclaredTypeElement(); return retval; } protected override Object GetElementKey(ConfigurationElement element) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } return ((DeclaredTypeElement)element).Type; } public int IndexOf(DeclaredTypeElement element) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } return BaseIndexOf(element); } public void Remove(DeclaredTypeElement element) { // Only validate input if config is not Read-Only, otherwise // let BaseRemove throw appropriate exception if (!this.IsReadOnly()) { if (element == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element"); } } BaseRemove(this.GetElementKey(element)); } public void Remove(string typeName) { // Only validate input if config is not Read-Only, otherwise // let BaseRemove throw appropriate exception if (!this.IsReadOnly()) { if (String.IsNullOrEmpty(typeName)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName"); } } BaseRemove(typeName); } public void RemoveAt(int index) { BaseRemoveAt(index); } } } // 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
- TypeTypeConverter.cs
- StreamedFramingRequestChannel.cs
- PatternMatcher.cs
- ProtocolViolationException.cs
- HostProtectionException.cs
- PopupRootAutomationPeer.cs
- ParagraphResult.cs
- TCPClient.cs
- CommunicationObjectFaultedException.cs
- Tokenizer.cs
- TreeIterator.cs
- EditorBrowsableAttribute.cs
- TextReturnReader.cs
- Compiler.cs
- HandleCollector.cs
- SHA384.cs
- XmlTextReaderImpl.cs
- ClrPerspective.cs
- InternalMappingException.cs
- DialogResultConverter.cs
- OperationInfoBase.cs
- TextComposition.cs
- PrimitiveXmlSerializers.cs
- InteropAutomationProvider.cs
- CodeMemberEvent.cs
- HotCommands.cs
- CardSpaceShim.cs
- GridViewItemAutomationPeer.cs
- CellQuery.cs
- ResolveNameEventArgs.cs
- TextCompositionManager.cs
- adornercollection.cs
- WebPartConnectionsCancelEventArgs.cs
- BindingListCollectionView.cs
- DataGridViewCellStateChangedEventArgs.cs
- DragEventArgs.cs
- UIInitializationException.cs
- VirtualizingPanel.cs
- _ShellExpression.cs
- ConcurrentBag.cs
- StateDesignerConnector.cs
- ExeConfigurationFileMap.cs
- TypeResolvingOptionsAttribute.cs
- UIElement3DAutomationPeer.cs
- MetadataCache.cs
- CharStorage.cs
- WebPartMinimizeVerb.cs
- TokenBasedSet.cs
- DrawListViewColumnHeaderEventArgs.cs
- BinaryUtilClasses.cs
- Int32RectConverter.cs
- StandardOleMarshalObject.cs
- MenuItem.cs
- SafeNativeMethods.cs
- Conditional.cs
- ConfigXmlAttribute.cs
- ObjectResult.cs
- MarkupCompilePass2.cs
- Object.cs
- SizeValueSerializer.cs
- DeploymentSection.cs
- SQlBooleanStorage.cs
- MultipartIdentifier.cs
- ContextBase.cs
- MaskedTextProvider.cs
- WebPartConnection.cs
- TypedElement.cs
- TreeChangeInfo.cs
- ToggleButtonAutomationPeer.cs
- ConnectionStringSettingsCollection.cs
- RankException.cs
- ResourceWriter.cs
- AbstractExpressions.cs
- ProfileEventArgs.cs
- TableNameAttribute.cs
- ParseHttpDate.cs
- ExtensionSimplifierMarkupObject.cs
- WorkBatch.cs
- EndpointInfoCollection.cs
- FixedDocumentSequencePaginator.cs
- ToolStripGrip.cs
- XmlNodeChangedEventArgs.cs
- ZoomPercentageConverter.cs
- ApplicationManager.cs
- SynthesizerStateChangedEventArgs.cs
- CollectionViewGroupInternal.cs
- InstanceValue.cs
- X500Name.cs
- SourceFileBuildProvider.cs
- SkipStoryboardToFill.cs
- CultureMapper.cs
- CultureSpecificStringDictionary.cs
- ConfigurationSectionGroupCollection.cs
- ToolStripDropDown.cs
- DetailsViewCommandEventArgs.cs
- LinkedResource.cs
- StyleTypedPropertyAttribute.cs
- RequestCacheEntry.cs
- ScrollBar.cs
- ReliableSessionBindingElement.cs