Code:
/ 4.0 / 4.0 / 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. 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextDecoration.cs
- ByteAnimationUsingKeyFrames.cs
- XamlPointCollectionSerializer.cs
- CodeSnippetExpression.cs
- ImageInfo.cs
- PartBasedPackageProperties.cs
- HtmlInputPassword.cs
- CodeDefaultValueExpression.cs
- RootBrowserWindow.cs
- BaseTemplateCodeDomTreeGenerator.cs
- panel.cs
- Msec.cs
- TdsParameterSetter.cs
- PropertyTab.cs
- CodeAccessSecurityEngine.cs
- AvTraceDetails.cs
- PointLightBase.cs
- _ListenerResponseStream.cs
- WebScriptEndpointElement.cs
- OleDbDataReader.cs
- AssociatedControlConverter.cs
- LayoutTableCell.cs
- DBCommand.cs
- ConfigurationManagerHelperFactory.cs
- SafeFileMapViewHandle.cs
- Msec.cs
- Directory.cs
- WsatExtendedInformation.cs
- MasterPageCodeDomTreeGenerator.cs
- AttributeInfo.cs
- TreeNodeSelectionProcessor.cs
- ContextMenu.cs
- SqlGatherConsumedAliases.cs
- DecimalConstantAttribute.cs
- UnhandledExceptionEventArgs.cs
- CollectionViewSource.cs
- XmlSchemaType.cs
- SafeRegistryHandle.cs
- ReaderWriterLock.cs
- ColorContext.cs
- EntityCollection.cs
- XmlToDatasetMap.cs
- HotCommands.cs
- PageEventArgs.cs
- GPRECTF.cs
- CompilerScope.Storage.cs
- XmlDataSourceNodeDescriptor.cs
- RemotingConfiguration.cs
- PrincipalPermission.cs
- RSACryptoServiceProvider.cs
- WebHttpSecurityElement.cs
- XmlSchemaValidator.cs
- AlignmentYValidation.cs
- SemanticResultKey.cs
- EDesignUtil.cs
- RadioButtonBaseAdapter.cs
- Visitors.cs
- TreeViewEvent.cs
- ReachFixedDocumentSerializerAsync.cs
- PropertyDescriptors.cs
- SqlUserDefinedAggregateAttribute.cs
- FtpRequestCacheValidator.cs
- pingexception.cs
- LayoutUtils.cs
- SqlDataSourceConfigureSortForm.cs
- UrlParameterReader.cs
- PipelineModuleStepContainer.cs
- WSTrustDec2005.cs
- ObjectKeyFrameCollection.cs
- PermissionSetTriple.cs
- X509ThumbprintKeyIdentifierClause.cs
- SafeThreadHandle.cs
- PartialList.cs
- Context.cs
- AtlasWeb.Designer.cs
- DomainUpDown.cs
- SchemaTableColumn.cs
- DesignerVerbCollection.cs
- DesigntimeLicenseContextSerializer.cs
- ReturnEventArgs.cs
- ClipboardProcessor.cs
- BuiltInExpr.cs
- RelationshipManager.cs
- DocumentAutomationPeer.cs
- StateFinalizationActivity.cs
- ProxySimple.cs
- OutputCacheModule.cs
- XmlElementAttribute.cs
- TreeViewItemAutomationPeer.cs
- KeyConverter.cs
- SmtpDigestAuthenticationModule.cs
- GenericXmlSecurityToken.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- GeneralTransformCollection.cs
- AuthenticationServiceManager.cs
- WrapPanel.cs
- InputLanguage.cs
- StoreAnnotationsMap.cs
- WhitespaceRule.cs
- ConfigurationValidatorBase.cs