private bool IsConstructorVisible(ConstructorInfo constructor) { return(constructor.IsPublic || constructor.IsFamily || constructor.IsFamilyOrAssembly || (constructor.IsAssembly && InternalsUtil.IsInternalToDynamicProxy(constructor.DeclaringType.GetTypeInfo().Assembly))); }
private bool IsConstructorVisible(IConstructorInfo constructor) { return(constructor.IsPublic || constructor.IsFamily || constructor.IsFamilyOrAssembly #if !Silverlight || (constructor.IsAssembly && InternalsUtil.IsInternalToDynamicProxy(constructor.DeclaringType.Assembly()))); #else ; #endif }
private MethodAttributes ObtainAttributes() { var methodInfo = Method; var attributes = MethodAttributes.Virtual; if (methodInfo.IsFinal || Method.DeclaringType.IsInterface) { attributes |= MethodAttributes.NewSlot; } if (methodInfo.IsPublic) { attributes |= MethodAttributes.Public; } if (methodInfo.IsHideBySig) { attributes |= MethodAttributes.HideBySig; } if (InternalsUtil.IsInternal(methodInfo) && InternalsUtil.IsInternalToDynamicProxy(methodInfo.DeclaringType.Assembly)) { attributes |= MethodAttributes.Assembly; } if (methodInfo.IsFamilyAndAssembly) { attributes |= MethodAttributes.FamANDAssem; } else if (methodInfo.IsFamilyOrAssembly) { attributes |= MethodAttributes.FamORAssem; } else if (methodInfo.IsFamily) { attributes |= MethodAttributes.Family; } if (Standalone == false) { attributes |= MethodAttributes.SpecialName; } return(attributes); }
/// <summary> /// Validates that the target type to proxy is visible and not generic. /// </summary> /// <param name="target"> /// The interface type to proxy. /// </param> private static void AssertValidType(Type target) { // This is copied from the DefaultProxyBuilder because we need to // validate types but the validation logic is not accessible. bool isTargetNested = target.IsNested; bool isNestedAndInternal = isTargetNested && (target.IsNestedAssembly || target.IsNestedFamORAssem); bool isInternalNotNested = target.IsVisible == false && isTargetNested == false; bool internalAndVisibleToDynProxy = (isInternalNotNested || isNestedAndInternal) && InternalsUtil.IsInternalToDynamicProxy(target.Assembly); var isAccessible = target.IsPublic || target.IsNestedPublic || internalAndVisibleToDynProxy; if (!isAccessible) { throw new GeneratorException(String.Format(CultureInfo.CurrentUICulture, Resources.DynamicProxy_InterfaceTypeToProxyNotPublic, target.FullName)); } if (target.IsGenericTypeDefinition) { throw new GeneratorException(String.Format(CultureInfo.CurrentUICulture, Resources.DynamicProxy_InterfaceTypeToProxyIsGeneric, target.FullName)); } }