System.Runtime.Remoting.Identity.GetRandomBytes C# (CSharp) Méthode

GetRandomBytes() private static méthode

private static GetRandomBytes ( ) : Byte[]
Résultat Byte[]
        private static Byte[] GetRandomBytes()
        {
            // PERF? In a situation where objects need URIs at a very fast
            // rate, we will end up creating too many of these tiny byte-arrays
            // causing pressure on GC!
            // One option would be to have a buff in the managed thread class
            // and use that to get a chunk of random bytes consuming 
            // 18 bytes at a time. 
            // This would avoid the need to have a lock across threads.
            Byte[] randomBytes = new byte[18];
            s_rng.GetBytes(randomBytes);
            return randomBytes;
        }

Usage Example

Exemple #1
0
 // Token: 0x06005448 RID: 21576 RVA: 0x0012A910 File Offset: 0x00128B10
 internal void SetOrCreateURI(string uri, bool bIdCtor)
 {
     if (!bIdCtor && this._ObjURI != null)
     {
         throw new RemotingException(Environment.GetResourceString("Remoting_SetObjectUriForMarshal__UriExists"));
     }
     if (uri == null)
     {
         string text = Convert.ToBase64String(Identity.GetRandomBytes());
         this._ObjURI = string.Concat(new string[]
         {
             Identity.IDGuidString,
             text.Replace('/', '_'),
             "_",
             Identity.GetNextSeqNum().ToString(CultureInfo.InvariantCulture.NumberFormat),
             ".rem"
         }).ToLower(CultureInfo.InvariantCulture);
         return;
     }
     if (this is ServerIdentity)
     {
         this._ObjURI = Identity.IDGuidString + uri;
         return;
     }
     this._ObjURI = uri;
 }
All Usage Examples Of System.Runtime.Remoting.Identity::GetRandomBytes