SRef.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Cache / SRef.cs / 1305376 / SRef.cs

                            using System; 
using System.Globalization;
using System.Reflection;
using System.Security.Permissions;
using System.Web; 

namespace System.Web.Caching { 
    internal class SRef { 
        private static Type s_type = Type.GetType("System.SizedReference", true, false);
        private Object _sizedRef; 

        internal SRef(Object target) {
            _sizedRef = HttpRuntime.CreateNonPublicInstance(s_type, new object[] {target});
        } 

        internal long ApproximateSize { 
            [PermissionSet(SecurityAction.Assert, Unrestricted=true)] 
            get {
                object o = s_type.InvokeMember("ApproximateSize", 
                                               BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty,
                                               null, // binder
                                               _sizedRef, // target
                                               null, // args 
                                               CultureInfo.InvariantCulture);
                return (long) o; 
            } 
        }
 
        [PermissionSet(SecurityAction.Assert, Unrestricted=true)]
        internal void Dispose() {
            s_type.InvokeMember("Dispose",
                                BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, 
                                null, // binder
                                _sizedRef, // target 
                                null, // args 
                                CultureInfo.InvariantCulture);
        } 
    }
}

// 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
This book is available now!
Buy at Amazon US or
Buy at Amazon UK