public MethodBindingToOneOfAlternativesLink(FuzzyMethodBinding binding, FuzzyType first, FuzzyType second) 
            : base(first, second)
        {
            _first = first;
            _second = second;
            _binding = binding;

            // first of all check whether _second is Arg or RetVal of one of the alts
            var secondPointHost = _binding.Alternatives.SingleOrDefault(alt => HostsSecondTypePoint(alt));

            // if it's not, then _second is the Target, i.e. we can take it from any alt we wish for now
            _alt = secondPointHost ?? _binding.Alternatives.First();
        }
Exemplo n.º 2
0
        private FuzzyMethod(FuzzyType target, IMethodInfo runtimeMethod)
        {
            _method = runtimeMethod;

            var genericArgs = new List<FuzzyType>();
            foreach (var genericArg in _method.GetMethodGenericArguments())
                genericArgs.Add(FuzzyType.FromRuntimeType(genericArg));
            GenericArguments = genericArgs.AsReadOnly();

            Target = target;
            ReturnValue = FuzzyType.FromRuntimeType(_method.ReturnType);
            Args = _method.GetParameters()
                .Select(param => FuzzyType.FromRuntimeType(param.ParameterType))
                .ToArray();

            // establishing links between typedef generic args and method's generic args
            // read more comments at FuzzyType.GetFieldOrProperty
            // see also comments to ReflectionHelper.GetGenericArgsMapping

            foreach (var pair in _method.GetGenericArgsMapping())
            {
                var typeDefArg = SelectGenericArg(pair.Value);
                var publicTypePointArgs = SelectGenericArg(pair.Key);
                publicTypePointArgs.IsIdenticalTo(typeDefArg);
            }

            // SomeMoreStuffInferred handlers for children just escalate the event
            // no need to process it since everything necessary is already done by links
            //
            // upd. currently noone cares about this event from this very class, 
            // but imo it's still important to comply to FuzzyMetadata contract

            Target.SomeMoreStuffInferred += (o, e) => FireSomeMoreStuffInferred();
            ReturnValue.SomeMoreStuffInferred += (o, e) => FireSomeMoreStuffInferred();
            Args.ForEach(arg => arg.SomeMoreStuffInferred += (o, e) => FireSomeMoreStuffInferred());

            // Register typepoints for debug -> 0 downtime in release, but immensely useful in debug mode
            var methodBinding = target.DebuggableParents.OfType<FuzzyMethodBinding>().SingleOrDefault();
            if (methodBinding != null)
            {
                this.RegDebuggableParent(methodBinding).SetDesc("alt");
                ReturnValue.RegDebuggableParent(this).SetDesc("ret");
                Args.ForEach((arg, i) => arg.RegDebuggableParent(this).SetDesc("arg" + i));
            }
        }
Exemplo n.º 3
0
 public bool SameType(FuzzyType t2)
 {
     return _runtimeType.SameType(t2.RuntimeType);
 }
Exemplo n.º 4
0
 public static FuzzyMethod FromRuntimeMethod(FuzzyType target, IMethodInfo runtimeMethod)
 {
     return new FuzzyMethod(target, runtimeMethod);
 }