Пример #1
0
        public static BaseModule Build(BaseContainer modContainer, IModuleAttribute moduleBuilder)
        {
            if (modContainer == null)
            {
                throw new ArgumentNullException(nameof(modContainer));
            }
            if (moduleBuilder == null)
            {
                throw new ArgumentNullException(nameof(moduleBuilder));
            }

            try
            {
                return((BaseModule)InvokeBuildMethod(
                           moduleBuilder.GetType(),
                           moduleBuilder.ModifyAppliedType(modContainer.Member.MemberType),
                           nameof(IModuleAttribute.Build),
                           moduleBuilder,
                           modContainer));
            }
            catch (TargetInvocationException tie)
            {
                throw tie.InnerException;
            }
        }
Пример #2
0
        protected Module(BaseContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var actualMember = container.Member.GetMember;

            _setVal = MemberUtils.GetSetMethod(actualMember);
            _getVal = MemberUtils.GetGetMethod(actualMember);

            ModuleContainer = container;
        }
Пример #3
0
 private static object InvokeBuildMethod(Type onType, Type makeGeneric, string name, object instance, BaseContainer modContainer)
 => onType
 .GetMethod(name,
            BindingFlags.Public | BindingFlags.Instance,
            Type.DefaultBinder,
            new []
 {
     typeof(BaseContainer),
 },
            null)
 .MakeGenericMethod(makeGeneric)
 .Invoke(instance, new object[] { modContainer });