public FieldValueAccessor(FieldInfo fieldInfo) { this.field = new SafeField(fieldInfo); this.isWriteable = !(fieldInfo.IsInitOnly || fieldInfo.IsLiteral); this.targetType = fieldInfo.FieldType; this.contextType = fieldInfo.DeclaringType; }
/// <summary> /// For webapplications always /// <ul> /// <li>convert IResources using the current context.</li> /// <li>use "web" as default resource protocol</li> /// <li>use <see cref="HybridContextStorage"/> as default threading storage</li> /// </ul> /// </summary> static WebSupportModule() { s_log = LogManager.GetLogger(typeof(WebSupportModule)); #if NET_2_0 // required to enable accessing HttpContext.Request during IHttpModule.Init() in integrated mode ContextHideRequestResponse = null; try { fiHideRequestResponse = typeof(HttpContext).GetField("HideRequestResponse", BindingFlags.Instance | BindingFlags.NonPublic); // fiHideRequestResponse.SetValue(HttpContext.Current, false); ContextHideRequestResponse = (fiHideRequestResponse != null)?new SafeField(fiHideRequestResponse):null; } catch (SecurityException sec) { s_log.Warn(string.Format("failed reflecting field HttpContext.HideRequestResponse due to security restrictions {0}", sec)); } #endif // register additional resource handler ResourceHandlerRegistry.RegisterResourceHandler(WebUtils.DEFAULT_RESOURCE_PROTOCOL, typeof(WebResource)); // replace default IResource converter TypeConverterRegistry.RegisterConverter(typeof(IResource), new ResourceConverter( new ConfigurableResourceLoader(WebUtils.DEFAULT_RESOURCE_PROTOCOL))); // default to hybrid thread storage implementation LogicalThreadContext.SetStorage(new HybridContextStorage()); s_log.Debug("Set default resource protocol to 'web' and installed HttpContext-aware HybridContextStorage"); }
static ControlAccessor() { SafeField fldControls = null; MethodInfo fnClear = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnClear = GetMethod("Clear"); fldControls = new SafeField(typeof(ControlCollection).GetField("_controls", BindingFlags.Instance | BindingFlags.NonPublic)); }); s_miClear = fnClear; ControlsArrayField = fldControls; CreateControlCollectionDelegate fnBaseCreateControlCollection = null; AddedControlDelegate fnBaseAddedControl = null; RemovedControlDelegate fnBaseRemovedControl = null; VoidMethodDelegate fnBaseClearNamingContainer = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnBaseCreateControlCollection = (CreateControlCollectionDelegate)Delegate.CreateDelegate(typeof(CreateControlCollectionDelegate), GetMethod("CreateControlCollection")); fnBaseAddedControl = (AddedControlDelegate)Delegate.CreateDelegate(typeof(AddedControlDelegate), GetMethod("AddedControl")); fnBaseRemovedControl = (RemovedControlDelegate)Delegate.CreateDelegate(typeof(RemovedControlDelegate), GetMethod("RemovedControl")); fnBaseClearNamingContainer = (VoidMethodDelegate)Delegate.CreateDelegate(typeof(VoidMethodDelegate), GetMethod("ClearNamingContainer")); }); BaseCreateControlCollection = fnBaseCreateControlCollection; BaseAddedControl = fnBaseAddedControl; BaseRemovedControl = fnBaseRemovedControl; BaseClearNamingContainer = fnBaseClearNamingContainer; }
static NamingContainerSupportsWebDependencyInjectionOwnerProxy() { SafeField fld = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fld = new SafeField(typeof(Control).GetField("_occasionalFields", BindingFlags.Instance | BindingFlags.NonPublic)); }); refOccasionalFields = fld; }
static ControlCollectionAccessor() { IDynamicField owner = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { #if MONO_2_0 owner = new SafeField(typeof(ControlCollection).GetField("owner", BindingFlags.Instance | BindingFlags.NonPublic)); #else owner = new SafeField(typeof(ControlCollection).GetField("_owner", BindingFlags.Instance | BindingFlags.NonPublic)); #endif }); _owner = owner; }
public ElementVanillaStat(SafeField <EquipmentStats, float[]> info, DamageType.Types type, String id, int place, VanillaStat.Type stattype) : base(id, place, stattype) { this.info = info; this.type = type; }
public BasicVanillaStat(SafeField <EquipmentStats, float> info, String id, int place, VanillaStat.Type stattype) : base(id, place, stattype) { this.info = info; }