public void BindingTest(NativeBindingType bindingType) { var factory = BindingFactory.GetFactoryForBindingType(bindingType); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var binding = factory.CreateBinding <ITestBindingWindows>(); Assert.NotEqual(IntPtr.Zero, binding.GetStdHandle(-11)); ref var _ = ref binding.GetCommandLineWRef; }
/// <summary> /// Get a factory that can create bindings of the specified type. /// </summary> /// <param name="bindingType">The desired strategy for creating bindings.</param> /// <returns>A binding factory that can create bindings using the desired strategy.</returns> public static BindingFactory GetFactoryForBindingType(NativeBindingType bindingType) { switch (bindingType) { case NativeBindingType.Static: return(new StaticBindingFactory()); case NativeBindingType.Indirect: return(new IndirectBindingFactory()); default: throw new ArgumentOutOfRangeException(); } }