mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
53 lines
2.2 KiB
C#
53 lines
2.2 KiB
C#
//------------------------------------------------------------------------------
|
||
// <copyright file="SystemWebProxy.cs" company="Microsoft">
|
||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||
// </copyright>
|
||
//------------------------------------------------------------------------------
|
||
|
||
namespace System.Web.Util {
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Diagnostics;
|
||
using System.Reflection;
|
||
using System.Web.Security;
|
||
using System.Security.Permissions;
|
||
|
||
// Because this assembly ships in the client SKU, whereas System.Web.dll ships in the Extended SKU, we need to
|
||
// proxy any usage of System.Web.dll. This allows us to fail gracefully if the Extended SKU is not present.
|
||
// Users can avoid this failure by overridding all virtual members on both of these types which will prevent
|
||
// this class, and hence, System.Web.dll, from ever being called.
|
||
internal static class SystemWebProxy {
|
||
|
||
public static readonly IMembershipAdapter Membership = GetMembershipAdapter();
|
||
|
||
private static IMembershipAdapter GetMembershipAdapter() {
|
||
IMembershipAdapter membership = CreateSystemWebMembershipAdapter();
|
||
if (membership == null) {
|
||
membership = new DefaultMembershipAdapter();
|
||
}
|
||
|
||
return membership;
|
||
}
|
||
|
||
private static IMembershipAdapter CreateSystemWebMembershipAdapter() {
|
||
Type type = Type.GetType("System.Web.Security.MembershipAdapter, " + AssemblyRef.SystemWeb, throwOnError:false);
|
||
if (type != null) {
|
||
// Running on Extended SKU
|
||
|
||
return (IMembershipAdapter)DangerousCreateInstance(type);
|
||
}
|
||
|
||
// Running on Client SKU
|
||
return null;
|
||
}
|
||
|
||
// Partially trusted callers might not have permissions to create an instance of
|
||
// System.Web’s MembershipAdapter type (it’s an internal type), so give them access.
|
||
[ReflectionPermission(SecurityAction.Assert, Flags=ReflectionPermissionFlag.MemberAccess)]
|
||
private static object DangerousCreateInstance(Type type) {
|
||
|
||
return Activator.CreateInstance(type);
|
||
}
|
||
}
|
||
}
|