Beispiel #1
0
        public DefaultAspectContext(IServiceProvider provider, TargetDescriptor target, ProxyDescriptor proxy, ParameterCollection parameters, ReturnParameterDescriptor returnParameter)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (proxy == null)
            {
                throw new ArgumentNullException(nameof(proxy));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (returnParameter == null)
            {
                throw new ArgumentNullException(nameof(returnParameter));
            }

            serviceProvider = provider;
            Target          = target;
            Proxy           = proxy;
            Parameters      = parameters;
            ReturnParameter = returnParameter;
        }
 public GameTarget(TargetDescriptor descriptor, TargetContext context)
     : base(descriptor, context)
 {
     this.LaunchModule = typeof(DemoApp);
     this.Type         = TargetType.Game;
     this.LinkType     = TargetLinkType.Modular;
 }
    /*
     * Invoked by a game object to mark itself as target.
     * By doing this, as soon as it satisfies the "show target tracker" condition,
     * the tracker is displayed in the UI canvas.
     * The simplest way to have objects invoking this method is be assigning the
     * "UITargetTrackerTarget" behaviour, ie. adding the script as component.
     */
    public void RegisterAsTarget(UITargetTrackerTarget target)
    {
        TargetDescriptor td = new TargetDescriptor();

        td.target  = target;
        td.tracker = null;         // tracker gets assigned when conditions are met, see UpdateTargetStates()

        targetObjectRegistry.Add(td);
    }
        public void Test_Property()
        {
            object impInstance = new DescriptorWithParameter();

            TargetDescriptor descriptor = new TargetDescriptor(impInstance, DescriptorWithParameter.Method, typeof(DescriptorWithParameter), DescriptorWithParameter.Method, typeof(DescriptorWithParameter));

            Assert.Equal(descriptor.ImplementationInstance, impInstance);
            Assert.Equal(descriptor.ServiceMethod, DescriptorWithParameter.Method);
            Assert.Equal(descriptor.ServiceType, typeof(DescriptorWithParameter));
            Assert.Equal(descriptor.ImplementationMethod, DescriptorWithParameter.Method);
            Assert.Equal(descriptor.ImplementationType, typeof(DescriptorWithParameter));
        }
        public void Invoke_Test(object value)
        {
            object impInstance = new DescriptorWithParameter();

            TargetDescriptor descriptor = new TargetDescriptor(impInstance, DescriptorWithParameter.Method, typeof(DescriptorWithParameter), DescriptorWithParameter.InvokeMethod, typeof(DescriptorWithParameter));

            var parameters = new ParameterCollection(new object[] { value }, DescriptorWithParameter.InvokeMethod.GetParameters());

            var result = descriptor.Invoke(parameters);

            Assert.Equal(result, value);
        }