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
- HtmlInputReset.cs
- CurrentChangingEventArgs.cs
- OdbcDataReader.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- WebHeaderCollection.cs
- NamespaceInfo.cs
- TransactionScope.cs
- XmlComplianceUtil.cs
- SoapInteropTypes.cs
- ReflectionPermission.cs
- WebBaseEventKeyComparer.cs
- RegistrySecurity.cs
- CmsInterop.cs
- Focus.cs
- GlyphRunDrawing.cs
- PropertyGridEditorPart.cs
- XmlUtil.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- Win32.cs
- CustomValidator.cs
- InitializeCorrelation.cs
- BatchParser.cs
- MarkupExtensionSerializer.cs
- localization.cs
- baseaxisquery.cs
- CodeMethodMap.cs
- ConstrainedGroup.cs
- ReadOnlyHierarchicalDataSource.cs
- RC2.cs
- StringInfo.cs
- FormDocumentDesigner.cs
- WmlTextBoxAdapter.cs
- UserPersonalizationStateInfo.cs
- HttpHandlersSection.cs
- TripleDES.cs
- NaturalLanguageHyphenator.cs
- HtmlTextViewAdapter.cs
- FixedPage.cs
- DateTimeConstantAttribute.cs
- ImageCodecInfo.cs
- ObjectDataSourceEventArgs.cs
- SortFieldComparer.cs
- DataPagerCommandEventArgs.cs
- AnnotationComponentManager.cs
- AdapterDictionary.cs
- Span.cs
- MetadataProperty.cs
- ScrollEventArgs.cs
- ObjectContext.cs
- ConsoleCancelEventArgs.cs
- PropertyMetadata.cs
- MenuEventArgs.cs
- SingleKeyFrameCollection.cs
- RuleSetDialog.Designer.cs
- CheckBoxFlatAdapter.cs
- MatrixKeyFrameCollection.cs
- CharacterMetricsDictionary.cs
- XmlSchemaAttribute.cs
- Dump.cs
- DataGridViewRowEventArgs.cs
- TargetException.cs
- ApplicationActivator.cs
- ItemContainerProviderWrapper.cs
- TextAutomationPeer.cs
- TitleStyle.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- StopStoryboard.cs
- SqlComparer.cs
- ContentElement.cs
- WinOEToolBoxItem.cs
- _DomainName.cs
- AssertValidation.cs
- PropertyIDSet.cs
- GridViewEditEventArgs.cs
- TreeIterators.cs
- GcHandle.cs
- RemotingServices.cs
- FileStream.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- GcHandle.cs
- precedingsibling.cs
- ListViewGroupConverter.cs
- PreviewKeyDownEventArgs.cs
- WebReferencesBuildProvider.cs
- RuntimeConfig.cs
- CleanUpVirtualizedItemEventArgs.cs
- util.cs
- ResourceExpressionBuilder.cs
- DebugInfo.cs
- EdmRelationshipRoleAttribute.cs
- HttpServerUtilityWrapper.cs
- SystemIPGlobalStatistics.cs
- ASCIIEncoding.cs
- EnumerableCollectionView.cs
- ContextProperty.cs
- ViewStateException.cs
- ResourceIDHelper.cs
- XamlSerializerUtil.cs
- QuaternionConverter.cs