Пример #1
0
        public ElementInstance(ILinkElement instance)
        {
            this.instance = instance;
            invoker = CreateInvoker(instance);

            // You would do it smarter
            IsBefore = instance.GetType().BaseType.Name.StartsWith("Before");
            IsAfter = instance.GetType().BaseType.Name.StartsWith("After");

            if (IsAfter || IsBefore)
                return;

            IsSurround = true;
        }
Пример #2
0
        static IStepInvoker CreateInvoker(ILinkElement step)
        {
            var behaviorInterface = step.GetType().GetInterfaces().First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ILinkElement <,>));
            var invokerType       = typeof(StepInvoker <,>).MakeGenericType(behaviorInterface.GetGenericArguments());

            return((IStepInvoker)Activator.CreateInstance(invokerType));
        }
Пример #3
0
        public ElementInstance(ILinkElement instance)
        {
            this.instance = instance;
            invoker       = CreateInvoker(instance);

            // You would do it smarter
            IsBefore = instance.GetType().BaseType.Name.StartsWith("Before");
            IsAfter  = instance.GetType().BaseType.Name.StartsWith("After");

            if (IsAfter || IsBefore)
            {
                return;
            }

            IsSurround = true;
        }
Пример #4
0
 static IElementInvoker CreateInvoker(ILinkElement step)
 {
     var behaviorInterface = step.GetType().GetInterfaces().First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ILinkElement<,>));
     var invokerType = typeof(ElementInvoker<,>).MakeGenericType(behaviorInterface.GetGenericArguments());
     return (IElementInvoker)Activator.CreateInstance(invokerType);
 }