Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / security / system / security / authentication / ExtendedProtection / ServiceNameCollection.cs / 1305376 / ServiceNameCollection.cs
using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; namespace System.Security.Authentication.ExtendedProtection { // derived from ReadOnlyCollectionBase because it needs to be back ported to .Net 1.x [SuppressMessage("Microsoft.Design","CA1058:TypesShouldNotExtendCertainBaseTypes", Justification="changing this would be a breaking change; this code has already shipped")] [Serializable] public class ServiceNameCollection : ReadOnlyCollectionBase { public ServiceNameCollection(ICollection items) { if (items == null) { throw new ArgumentNullException("items"); } InnerList.AddRange(items); } public ServiceNameCollection Merge(string serviceName) { ArrayList newServiceNames = new ArrayList(); // be compatible with .Net 1.x; no generics newServiceNames.AddRange(this.InnerList); AddIfNew(newServiceNames, serviceName); ServiceNameCollection newCollection = new ServiceNameCollection(newServiceNames); return newCollection; } public ServiceNameCollection Merge(IEnumerable serviceNames) { ArrayList newServiceNames = new ArrayList(); // be compatible with .Net 1.x; no generics newServiceNames.AddRange(this.InnerList); // we have a pretty bad performance here: O(n^2), but since service name lists should // be small (<<50) and Merge() should not be called frequently, this shouldn't be an issue foreach (object item in serviceNames) { AddIfNew(newServiceNames, item as string); } ServiceNameCollection newCollection = new ServiceNameCollection(newServiceNames); return newCollection; } private void AddIfNew(ArrayList newServiceNames, string serviceName) { if (String.IsNullOrEmpty(serviceName)) { throw new ArgumentException(SR.GetString(SR.security_ServiceNameCollection_EmptyServiceName)); } if (!Contains(serviceName, newServiceNames)) { newServiceNames.Add(serviceName); } } private bool Contains(string searchServiceName, ICollection serviceNames) { Debug.Assert(serviceNames != null); Debug.Assert(!String.IsNullOrEmpty(searchServiceName)); bool found = false; foreach (string serviceName in serviceNames) { if (String.Compare(serviceName, searchServiceName, StringComparison.OrdinalIgnoreCase) == 0) { found = true; break; } } return found; } } } // 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
- PersonalizationAdministration.cs
- EntryPointNotFoundException.cs
- DataSvcMapFileSerializer.cs
- PermissionSetEnumerator.cs
- MemoryStream.cs
- BuildResultCache.cs
- Multiply.cs
- StagingAreaInputItem.cs
- PropertyMapper.cs
- EdmValidator.cs
- SqlConnectionHelper.cs
- SelectionProcessor.cs
- StorageBasedPackageProperties.cs
- DbReferenceCollection.cs
- StrokeNodeData.cs
- CompositeDuplexElement.cs
- OrCondition.cs
- TargetException.cs
- WebPartZone.cs
- ObjectConverter.cs
- _ConnectOverlappedAsyncResult.cs
- IOException.cs
- RequestChannel.cs
- TableAutomationPeer.cs
- NativeMethods.cs
- CryptoKeySecurity.cs
- ContractHandle.cs
- FtpWebResponse.cs
- DesignerCommandAdapter.cs
- CommandDevice.cs
- QueryResponse.cs
- RelatedImageListAttribute.cs
- ReturnType.cs
- _AutoWebProxyScriptHelper.cs
- ContextCorrelationInitializer.cs
- __Filters.cs
- HistoryEventArgs.cs
- XsdValidatingReader.cs
- HtmlTitle.cs
- DbConnectionPool.cs
- EntryWrittenEventArgs.cs
- DelegatedStream.cs
- StringFormat.cs
- QueryableFilterRepeater.cs
- TextRangeEditTables.cs
- TextViewSelectionProcessor.cs
- PackagePart.cs
- DependencyPropertyConverter.cs
- ProxySimple.cs
- DataKeyCollection.cs
- TypeConverterHelper.cs
- RegistryExceptionHelper.cs
- SqlFunctionAttribute.cs
- DataGridViewRowStateChangedEventArgs.cs
- SqlConnectionManager.cs
- Utils.cs
- HeaderedContentControl.cs
- NavigationCommands.cs
- AliasExpr.cs
- DeadCharTextComposition.cs
- CorePropertiesFilter.cs
- SafeSecurityHandles.cs
- StructuralObject.cs
- PreApplicationStartMethodAttribute.cs
- FontFamily.cs
- SQLInt16.cs
- TripleDESCryptoServiceProvider.cs
- Schedule.cs
- FlowDocument.cs
- DataServiceContext.cs
- MultiPropertyDescriptorGridEntry.cs
- updateconfighost.cs
- SiteMapDesignerDataSourceView.cs
- AutoGeneratedField.cs
- XmlSchemaValidator.cs
- XmlAttributeAttribute.cs
- UrlAuthorizationModule.cs
- NamespaceExpr.cs
- FilterQuery.cs
- PropertyTabAttribute.cs
- TextPatternIdentifiers.cs
- CodePropertyReferenceExpression.cs
- MethodCallTranslator.cs
- FormViewDeleteEventArgs.cs
- SystemPens.cs
- Misc.cs
- MetadataCache.cs
- Attributes.cs
- LogLogRecordEnumerator.cs
- httpapplicationstate.cs
- MachineKeySection.cs
- FlagsAttribute.cs
- GlyphingCache.cs
- Action.cs
- UserControlDesigner.cs
- BitmapEffectDrawingContextWalker.cs
- ActivityCodeGenerator.cs
- ApplicationSettingsBase.cs
- XmlEncoding.cs
- EndPoint.cs