예제 #1
0
        /// <summary>
        /// Initializes a new instance of the KeyColumnConverter class.
        /// </summary>
        public KeyColumnConverter()
        {
            const string MakeKeyMethodName = "MakeKey";

            Type[] arguments = new[] { typeof(JET_SESID), typeof(JET_TABLEID), typeof(TColumn), typeof(MakeKeyGrbit) };

            // Look for a private method in this class that takes the appropriate arguments,
            // otherwise a method on the Api class.
            MethodInfo method = typeof(KeyColumnConverter <TColumn>).GetMethod(
                MakeKeyMethodName,
                BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.ExactBinding,
                null,
                arguments,
                null) ?? typeof(Api).GetMethod(
                MakeKeyMethodName,
                BindingFlags.Static | BindingFlags.Public | BindingFlags.ExactBinding,
                null,
                arguments,
                null);

            if (null != method)
            {
                this.keyMaker = (MakeKeyDelegate)Delegate.CreateDelegate(typeof(MakeKeyDelegate), method);
                RuntimeHelpers.PrepareDelegate(this.keyMaker);
            }
            else
            {
                throw new ArgumentOutOfRangeException("type", typeof(TColumn), "Not supported for MakeKey");
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the KeyColumnConverter class.
        /// </summary>
        /// <param name="type">The type to convert to/from.</param>
        public KeyColumnConverter(Type type) : base(type)
        {
            if (!MakeKeyDelegates.ContainsKey(type))
            {
                throw new ArgumentOutOfRangeException("type", type, "Not supported for MakeKey");
            }

            this.makeKey = MakeKeyDelegates[type];
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the KeyColumnConverter class.
        /// </summary>
        /// <param name="type">The type to convert to/from.</param>
        public KeyColumnConverter(Type type) : base(type)
        {
            if (!MakeKeyDelegates.ContainsKey(type))
            {
                throw new ArgumentOutOfRangeException("type", type, "Not supported for MakeKey");
            }

            this.makeKey = MakeKeyDelegates[type];
        }