private Func <object> CreateTransparentProxyGetter(Export export) { return(() => { var exportedValue = export.Value; if (exportedValue == null) { return null; } var typeName = export.GetExportTypeName(); if (string.IsNullOrEmpty(typeName)) { return exportedValue; } var type = exportedValue.GetType(); var contractType = type.GetInterfaces().FirstOrDefault(interfaceType => interfaceType.FullName == typeName); if (contractType == null || !contractType.IsInterface) { return exportedValue; } var interceptors = Aspects.Where(aspect => aspect.Pointcut(export)).Select(aspect => aspect.AopFilter); if (!interceptors.Any()) { return exportedValue; } var proxy = new RealProxyWrapper(contractType, exportedValue); return proxy.GetTransparentProxy(); }); }
public override MarshalByRefObject CreateInstance(Type serverType) { MarshalByRefObject obj = base.CreateInstance(serverType); var proxy = new RealProxyWrapper(serverType, obj); return((MarshalByRefObject)proxy.GetTransparentProxy()); }