Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / security / system / security / authentication / ExtendedProtection / ServiceNameCollection.cs / 1 / ServiceNameCollection.cs
using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Collections; using System.Diagnostics; namespace System.Security.Authentication.ExtendedProtection { // derived from ReadOnlyCollectionBase because it needs to be back ported to .Net 1.x 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.InvariantCultureIgnoreCase) == 0) { found = true; break; } } return found; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Collections; using System.Diagnostics; namespace System.Security.Authentication.ExtendedProtection { // derived from ReadOnlyCollectionBase because it needs to be back ported to .Net 1.x 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.InvariantCultureIgnoreCase) == 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
- PathFigureCollection.cs
- TableAdapterManagerMethodGenerator.cs
- FontFamilyConverter.cs
- HealthMonitoringSection.cs
- formatter.cs
- DefaultPrintController.cs
- Normalizer.cs
- DoubleStorage.cs
- ToolBarOverflowPanel.cs
- Attributes.cs
- CalendarButtonAutomationPeer.cs
- SettingsProperty.cs
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- SqlCacheDependencyDatabaseCollection.cs
- PropertyValueUIItem.cs
- TypeConverter.cs
- SecurityCredentialsManager.cs
- SqlCharStream.cs
- ScrollItemProviderWrapper.cs
- iisPickupDirectory.cs
- TextServicesCompartmentEventSink.cs
- SafeBitVector32.cs
- WebPartDeleteVerb.cs
- HostedHttpRequestAsyncResult.cs
- TypedElement.cs
- TypeDescriptor.cs
- infer.cs
- LogExtent.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- ByteAnimationUsingKeyFrames.cs
- NativeMethods.cs
- CodeArrayIndexerExpression.cs
- ResXResourceReader.cs
- GenerateDerivedKeyRequest.cs
- SignatureGenerator.cs
- InfoCardProofToken.cs
- CategoryAttribute.cs
- GridViewItemAutomationPeer.cs
- CollectionChangeEventArgs.cs
- WindowsListViewSubItem.cs
- RuntimeHandles.cs
- _AuthenticationState.cs
- ActivityValidator.cs
- TransactionTraceIdentifier.cs
- TdsRecordBufferSetter.cs
- EntityDataSourceWizardForm.cs
- MimePart.cs
- DrawItemEvent.cs
- StringFunctions.cs
- TargetException.cs
- SystemWebExtensionsSectionGroup.cs
- Rfc2898DeriveBytes.cs
- HttpRequestBase.cs
- ModelVisual3D.cs
- List.cs
- ISAPIRuntime.cs
- RectangleGeometry.cs
- ManagementEventWatcher.cs
- Parser.cs
- VersionUtil.cs
- ScriptControlManager.cs
- NavigationExpr.cs
- SafeNativeMethods.cs
- DataPagerFieldCommandEventArgs.cs
- DispatcherExceptionEventArgs.cs
- InvalidDataException.cs
- GridSplitterAutomationPeer.cs
- WebOperationContext.cs
- BitmapEffectCollection.cs
- RectAnimationBase.cs
- Label.cs
- AuthenticationManager.cs
- FunctionDescription.cs
- CryptoApi.cs
- FixUpCollection.cs
- StandardCommandToolStripMenuItem.cs
- SingleAnimation.cs
- ApplicationFileParser.cs
- ADMembershipUser.cs
- SimplePropertyEntry.cs
- BuildManagerHost.cs
- Error.cs
- LeaseManager.cs
- ActiveXSite.cs
- SupportsEventValidationAttribute.cs
- SweepDirectionValidation.cs
- SafeNativeMemoryHandle.cs
- ClientOptions.cs
- updatecommandorderer.cs
- RtfControls.cs
- Line.cs
- StringPropertyBuilder.cs
- CalendarSelectionChangedEventArgs.cs
- XmlSchemaObject.cs
- FlowDocumentReader.cs
- XmlAttribute.cs
- TagNameToTypeMapper.cs
- CatalogZoneBase.cs
- UInt32Storage.cs
- MasterPageBuildProvider.cs