e79aa3c0ed
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
// <copyright file="SRef.cs" company="Microsoft">
|
|
// Copyright (c) 2009 Microsoft Corporation. All rights reserved.
|
|
// </copyright>
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Reflection;
|
|
using System.Security;
|
|
using System.Security.Permissions;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace System.Runtime.Caching {
|
|
internal class SRef {
|
|
private static Type s_type = Type.GetType("System.SizedReference", true, false);
|
|
private Object _sizedRef;
|
|
|
|
internal SRef(Object target) {
|
|
_sizedRef = Activator.CreateInstance(s_type,
|
|
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance,
|
|
null,
|
|
new object[] { target },
|
|
null);
|
|
}
|
|
|
|
internal long ApproximateSize {
|
|
[SecuritySafeCritical]
|
|
[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;
|
|
}
|
|
}
|
|
|
|
//
|
|
[SuppressMessage("Microsoft.Security", "CA2106:SecureAsserts", Justification = "Grandfathered suppression from original caching code checkin")]
|
|
[SecuritySafeCritical]
|
|
[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);
|
|
}
|
|
}
|
|
}
|