예제 #1
0
        /// <summary>
        /// <para>
        /// Use reflect to invoke method.
        /// </para>
        /// </summary>
        /// <param name="service">
        /// <see cref="HermesAuthorizationService"/> object.
        /// </param>
        /// <param name="methodName">
        /// method name.
        /// </param>
        public static void Invoke(HermesAuthorizationService service,
                                  string methodName)
        {
            MethodInfo info =
                service.GetType().GetMethod(methodName,
                                            BindingFlags.Instance | BindingFlags.NonPublic);

            info.Invoke(service, new object[] { });
        }
예제 #2
0
        /// <summary>
        /// <para>
        /// Use reflect to get the value of service.
        /// </para>
        /// </summary>
        /// <typeparam name="T">
        /// Field type.
        /// </typeparam>
        /// <param name="service">
        /// <see cref="HermesAuthorizationService"/> object.
        /// </param>
        /// <param name="fieldName">
        /// field name.
        /// </param>
        /// <returns>The field value in service.</returns>
        public static T GetField <T>(HermesAuthorizationService service,
                                     string fieldName)
        {
            FieldInfo info =
                service.GetType().GetField(fieldName,
                                           BindingFlags.NonPublic | BindingFlags.Instance);

            return((T)info.GetValue(service));
        }