public MainForm() { InitializeComponent(); registry = new InterceptorRegistry(); filtersController = new FilterController(registry); InitFilters(); controller = new MediaController(Handle, panelVideo, filtersController); controller.FormatChanged += (s, e) => statusCurrentFormat.Text = e.Data; controller.VideoWindowSizeChanged += (s, e) => statusVideoWindowSize.Text = e.Data; controller.FpsChanged += (s, e) => { var action = new Action(() => statusFPS.Text = e.Data()); if (InvokeRequired) { Invoke(action); } else { action(); } }; Resize += FormResize; }
public MainForm() { InitializeComponent(); registry = new InterceptorRegistry(); filtersController = new FilterController(registry); InitFilters(); controller = new MediaController(Handle, panelVideo, filtersController); controller.FormatChanged += (s, e) => statusCurrentFormat.Text = e.Data; controller.VideoWindowSizeChanged += (s, e) => statusVideoWindowSize.Text = e.Data; controller.FpsChanged += (s, e) => { var action = new Action(() => statusFPS.Text = e.Data()); if (InvokeRequired) { Invoke(action); } else { action(); } }; Resize += FormResize; }
/// <summary> /// Generates interceptable proxy class. /// </summary> /// <param name="context">The <see cref="CodeGenerationContext"/> representing code generation based execution context.</param> /// <returns>The generated interceptable proxy class</returns> public Type GenerateInterceptableProxyClass(CodeGenerationContext context) { _interfaceOrBaseType = context.InterfaceOrBaseType; _targetType = context.TargetType; _interceptors = context.Interceptors; var assemblyName = new AssemblyName($"AssemblyFor{_interfaceOrBaseType.Name}{GenerateSurfix()}"); var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); _moduleBuilder = assemblyBuilder.DefineDynamicModule($"{assemblyName}.dll"); if (_interfaceOrBaseType.IsInterface) { _typeBuilder = _moduleBuilder.DefineType($"{_interfaceOrBaseType.Name}{GenerateSurfix()}", TypeAttributes.Public, typeof(object), new Type[] { _interfaceOrBaseType }); _targetField = _typeBuilder.DefineField("_target", _interfaceOrBaseType, FieldAttributes.Private); } else { _typeBuilder = _moduleBuilder.DefineType($"{_interfaceOrBaseType.Name}{GenerateSurfix()}", TypeAttributes.Public, _interfaceOrBaseType); } if (_interfaceOrBaseType.IsGenericType) { var interfaceParameters = ((TypeInfo)_interfaceOrBaseType).GenericTypeParameters; var parameterNames = interfaceParameters.Select(it => it.Name).ToArray(); var proxyParameters = _typeBuilder.DefineGenericParameters(parameterNames); for (int index = 0; index < interfaceParameters.Length; index++) { var parameter = proxyParameters[index]; parameter.SetGenericParameterAttributes(interfaceParameters[index].GenericParameterAttributes); var constraints = new List <Type>(); foreach (Type constraint in interfaceParameters[index].GetGenericParameterConstraints()) { if (constraint.IsClass) { parameter.SetBaseTypeConstraint(constraint); } else { constraints.Add(constraint); } } if (constraints.Count > 0) { parameter.SetInterfaceConstraints(constraints.ToArray()); } } } _interceptorsField = _typeBuilder.DefineField("_interceptors", typeof(IInterceptorRegistry), FieldAttributes.Private); if (_interfaceOrBaseType.IsInterface) { GenerateForInterface(); } else { GenerateForVirtualMethods(); } return(_typeBuilder.CreateTypeInfo()); }
public PluginManager(IUIHost host, IInterceptorRegistry registry) { this.host = host; this.registry = registry; }
/// <summary> /// Create a new <see cref="CodeGenerationContext"/>. /// </summary> /// <param name="interface">Implemented interface or base type of generated interceptable proxy class.</param> /// <param name="interceptors">Interceptor registration specific to implementation type.</param> /// <param name="targetType">Interface implementation type.</param> public CodeGenerationContext(Type @interface, Type targetType, IInterceptorRegistry interceptors) { InterfaceOrBaseType = @interface ?? throw new ArgumentNullException(nameof(@interface)); Interceptors = interceptors ?? throw new ArgumentNullException(nameof(interceptors)); TargetType = targetType ?? throw new ArgumentNullException(nameof(targetType)); }
/// <summary> /// Create a new <see cref="CodeGenerationContext"/>. /// </summary> /// <param name="baseType">Implemented interface or base type of generated interceptable proxy class.</param> /// <param name="interceptors">Interceptor registration specific to implementation type.</param> public CodeGenerationContext(Type baseType, IInterceptorRegistry interceptors) { InterfaceOrBaseType = baseType ?? throw new ArgumentNullException(nameof(baseType)); Interceptors = interceptors ?? throw new ArgumentNullException(nameof(interceptors)); }
public FilterController(IInterceptorRegistry registry) { this.registry = registry; }
public FilterController(IInterceptorRegistry registry) { this.registry = registry; }
public PluginManager(IUIHost host, IInterceptorRegistry registry) { this.host = host; this.registry = registry; }