Beispiel #1
0
        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;
            }
Beispiel #2
0
        /// <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();
            }
        }