Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Permissions / StrongNamePublicKeyBlob.cs / 1305376 / StrongNamePublicKeyBlob.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // StrongNamePublicKeyBlob.cs // //[....] // namespace System.Security.Permissions { using System; using System.Security.Util; using System.Diagnostics.Contracts; [System.Runtime.InteropServices.ComVisible(true)] [Serializable] sealed public class StrongNamePublicKeyBlob { internal byte[] PublicKey; internal StrongNamePublicKeyBlob() { } public StrongNamePublicKeyBlob( byte[] publicKey ) { if (publicKey == null) throw new ArgumentNullException( "PublicKey" ); Contract.EndContractBlock(); this.PublicKey = new byte[publicKey.Length]; Array.Copy( publicKey, 0, this.PublicKey, 0, publicKey.Length ); } internal StrongNamePublicKeyBlob( String publicKey ) { this.PublicKey = Hex.DecodeHexString( publicKey ); } private static bool CompareArrays( byte[] first, byte[] second ) { if (first.Length != second.Length) { return false; } int count = first.Length; for (int i = 0; i < count; ++i) { if (first[i] != second[i]) return false; } return true; } internal bool Equals( StrongNamePublicKeyBlob blob ) { if (blob == null) return false; else return CompareArrays( this.PublicKey, blob.PublicKey ); } public override bool Equals( Object obj ) { if (obj == null || !(obj is StrongNamePublicKeyBlob)) return false; return this.Equals( (StrongNamePublicKeyBlob)obj ); } static private int GetByteArrayHashCode( byte[] baData ) { if (baData == null) return 0; int accumulator = 0; for (int i = 0; i < baData.Length; ++i) { accumulator = (accumulator << 8) ^ (int)baData[i] ^ (accumulator >> 24); } return accumulator; } public override int GetHashCode() { return GetByteArrayHashCode( PublicKey ); } public override String ToString() { return Hex.EncodeHexString( PublicKey ); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // StrongNamePublicKeyBlob.cs // //[....] // namespace System.Security.Permissions { using System; using System.Security.Util; using System.Diagnostics.Contracts; [System.Runtime.InteropServices.ComVisible(true)] [Serializable] sealed public class StrongNamePublicKeyBlob { internal byte[] PublicKey; internal StrongNamePublicKeyBlob() { } public StrongNamePublicKeyBlob( byte[] publicKey ) { if (publicKey == null) throw new ArgumentNullException( "PublicKey" ); Contract.EndContractBlock(); this.PublicKey = new byte[publicKey.Length]; Array.Copy( publicKey, 0, this.PublicKey, 0, publicKey.Length ); } internal StrongNamePublicKeyBlob( String publicKey ) { this.PublicKey = Hex.DecodeHexString( publicKey ); } private static bool CompareArrays( byte[] first, byte[] second ) { if (first.Length != second.Length) { return false; } int count = first.Length; for (int i = 0; i < count; ++i) { if (first[i] != second[i]) return false; } return true; } internal bool Equals( StrongNamePublicKeyBlob blob ) { if (blob == null) return false; else return CompareArrays( this.PublicKey, blob.PublicKey ); } public override bool Equals( Object obj ) { if (obj == null || !(obj is StrongNamePublicKeyBlob)) return false; return this.Equals( (StrongNamePublicKeyBlob)obj ); } static private int GetByteArrayHashCode( byte[] baData ) { if (baData == null) return 0; int accumulator = 0; for (int i = 0; i < baData.Length; ++i) { accumulator = (accumulator << 8) ^ (int)baData[i] ^ (accumulator >> 24); } return accumulator; } public override int GetHashCode() { return GetByteArrayHashCode( PublicKey ); } public override String ToString() { return Hex.EncodeHexString( PublicKey ); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SparseMemoryStream.cs
- HttpRequestCacheValidator.cs
- SecureUICommand.cs
- XsdDataContractImporter.cs
- MarkedHighlightComponent.cs
- ECDsaCng.cs
- ToolCreatedEventArgs.cs
- DataExpression.cs
- SpellerHighlightLayer.cs
- UrlMappingCollection.cs
- ContentElement.cs
- CodeSubDirectory.cs
- ParallelTimeline.cs
- AttributeQuery.cs
- DataServiceQueryOfT.cs
- IEnumerable.cs
- DataGridViewToolTip.cs
- xmlglyphRunInfo.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- X500Name.cs
- EventBuilder.cs
- COM2PictureConverter.cs
- ReadOnlyDataSourceView.cs
- NonClientArea.cs
- PartialCachingControl.cs
- SqlDataSourceSelectingEventArgs.cs
- SiteOfOriginPart.cs
- XsltLibrary.cs
- NamespaceEmitter.cs
- IItemContainerGenerator.cs
- SafeBitVector32.cs
- WindowInteropHelper.cs
- RowToFieldTransformer.cs
- Certificate.cs
- Package.cs
- TextClipboardData.cs
- DataGridPagerStyle.cs
- InvalidProgramException.cs
- StoragePropertyMapping.cs
- DuplexChannelBinder.cs
- AutomationPatternInfo.cs
- XmlILIndex.cs
- _NativeSSPI.cs
- Relationship.cs
- DataObjectFieldAttribute.cs
- ConfigXmlCDataSection.cs
- XmlSerializer.cs
- CommentEmitter.cs
- EntityViewGenerationConstants.cs
- InfoCardArgumentException.cs
- ThrowOnMultipleAssignment.cs
- MemberPathMap.cs
- TypeName.cs
- path.cs
- XmlSerializableReader.cs
- ContextQuery.cs
- XmlAttributeOverrides.cs
- MailHeaderInfo.cs
- DateTimeConverter.cs
- MessagePartSpecification.cs
- LabelEditEvent.cs
- InputBuffer.cs
- ForEachAction.cs
- Utils.cs
- TypeSystemProvider.cs
- X509AsymmetricSecurityKey.cs
- ServiceObjectContainer.cs
- HeaderedItemsControl.cs
- ZipIOLocalFileBlock.cs
- PtsCache.cs
- TrackPoint.cs
- DockEditor.cs
- oledbconnectionstring.cs
- TimeSpanConverter.cs
- SafePointer.cs
- TextBox.cs
- CaseStatement.cs
- StylusOverProperty.cs
- ObjectDataSourceFilteringEventArgs.cs
- RuntimeIdentifierPropertyAttribute.cs
- SerTrace.cs
- NavigatorInput.cs
- Wizard.cs
- NumberEdit.cs
- StrokeCollectionDefaultValueFactory.cs
- ConstNode.cs
- BufferModeSettings.cs
- SessionEndingEventArgs.cs
- MimeXmlImporter.cs
- DeviceContext2.cs
- DragDropManager.cs
- RsaSecurityTokenParameters.cs
- AssemblyResourceLoader.cs
- StylusOverProperty.cs
- SystemIPv6InterfaceProperties.cs
- LexicalChunk.cs
- WebPartMenuStyle.cs
- ImageClickEventArgs.cs
- RuleInfoComparer.cs
- MatrixTransform3D.cs