当前位置: 首页>>代码示例>>C#>>正文


C# ImmutableArray.DangerousGetUnderlyingArray方法代码示例

本文整理汇总了C#中ImmutableArray.DangerousGetUnderlyingArray方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.DangerousGetUnderlyingArray方法的具体用法?C# ImmutableArray.DangerousGetUnderlyingArray怎么用?C# ImmutableArray.DangerousGetUnderlyingArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImmutableArray的用法示例。


在下文中一共展示了ImmutableArray.DangerousGetUnderlyingArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PinnedMetadata

 public unsafe PinnedMetadata(ImmutableArray<byte> metadata)
 {
     _bytes = GCHandle.Alloc(metadata.DangerousGetUnderlyingArray(), GCHandleType.Pinned);
     this.Pointer = _bytes.AddrOfPinnedObject();
     this.Size = metadata.Length;
     this.Reader = new MetadataReader((byte*)this.Pointer, this.Size, MetadataReaderOptions.None, null);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:PinnedMetadata.cs

示例2: TryGetPublicKey

        /// <summary>
        /// Try to retrieve the public key from a crypto blob.
        /// </summary>
        /// <remarks>
        /// Can be either a PUBLICKEYBLOB or PRIVATEKEYBLOB. The BLOB must /// be unencrypted.
        /// </remarks>
        public unsafe static bool TryGetPublicKey(ImmutableArray<byte> blob, out ImmutableArray<byte> publicKey)
        {
            publicKey = ImmutableArray<byte>.Empty;

            // Is this already a strong name PublicKeyBlob?
            if (IsValidPublicKey(blob))
            {
                publicKey = blob;
                return true;
            }

            // Must be at least as large as header + RSA info
            if (blob.Length < sizeof(BlobHeader) + sizeof(RsaPubKey))
            {
                return false;
            }

            fixed (byte* backing = blob.DangerousGetUnderlyingArray())
            {
                var header = (BlobHeader*)backing;
                var rsa = (RsaPubKey*)(backing + sizeof(BlobHeader));

                // The RSA magic key must match the blob id
                if (header->Type == PrivateKeyBlobId &&
                    rsa->Magic == RSA2)
                {
                    return TryGetPublicKeyFromPrivateKeyBlob(backing, blob.Length, out publicKey);
                }
                else if (header->Type == PublicKeyBlobId &&
                    rsa->Magic == RSA1)
                {
                    return TryGetPublicKeyFromPublicKeyBlob(backing, blob.Length, out publicKey);
                }
            }

            return false;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:43,代码来源:CryptoBlobParser.cs

示例3: IsValidPublicKeyUnsafe

        private static unsafe bool IsValidPublicKeyUnsafe(ImmutableArray<byte> blob)
        {
            var blobArray = blob.DangerousGetUnderlyingArray();
            fixed (byte* blobPtr = blobArray)
            {
                var pkb = (SnPublicKeyBlob*)blobPtr;

                // The number of public key bytes must be the same as the size of the header plus the size of the public key data.
                if (blob.Length != s_publicKeyHeaderSize + pkb->PublicKeySize)
                {
                    return false;
                }

                // Check for the ECMA key, which does not obey the invariants checked below.
                if (ByteSequenceComparer.Equals(blob, s_ecmaKey))
                {
                    return true;
                }

                // The public key must be in the wincrypto PUBLICKEYBLOB format
                if (pkb->PublicKey[0] != PublicKeyBlobId)
                {
                    return false;
                }

                var signatureAlgorithmId = new AlgorithmId(pkb->SigAlgId);
                if (signatureAlgorithmId.IsSet && signatureAlgorithmId.Class != AlgorithmClass.Signature)
                {
                    return false;
                }

                var hashAlgorithmId = new AlgorithmId(pkb->HashAlgId);
                if (hashAlgorithmId.IsSet && (hashAlgorithmId.Class != AlgorithmClass.Hash || hashAlgorithmId.SubId < AlgorithmSubId.Sha1Hash))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:40,代码来源:CryptoBlobParser.cs

示例4: PinnedBlob

 public PinnedBlob(ImmutableArray<byte> blob)
     : this(blob.DangerousGetUnderlyingArray())
 {
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:PinnedBlob.cs


注:本文中的ImmutableArray.DangerousGetUnderlyingArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。