File: DataExchangeServiceBinder.cs

package info (click to toggle)
mono 6.12.0.199%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,296,836 kB
  • sloc: cs: 11,181,803; xml: 2,850,076; ansic: 699,709; cpp: 123,344; perl: 59,361; javascript: 30,841; asm: 21,853; makefile: 20,405; sh: 15,009; python: 4,839; pascal: 925; sql: 859; sed: 16; php: 1
file content (117 lines) | stat: -rw-r--r-- 4,397 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using System.Workflow.ComponentModel;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using System.Security.Permissions;
using System.Globalization;


namespace System.Workflow.Activities
{
    internal sealed class ExternalDataExchangeBinder : Binder
    {
        Binder defltBinder;

        internal ExternalDataExchangeBinder()
        {
            defltBinder = Type.DefaultBinder;
        }

        public override MethodBase BindToMethod(BindingFlags bindingAttr,
                                                MethodBase[] match,
                                                ref object[] args,
                                                ParameterModifier[] modifiers,
                                                System.Globalization.CultureInfo culture,
                                                string[] names,
                                                out object state)
        {
            Object[] argsCopy = new Object[args.Length];
            args.CopyTo(argsCopy, 0);
            state = null;

            try
            {
                return defltBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);
            }
            catch (MissingMethodException) //5% case where when passed null for params.
            {

                if (match != null && match.Length != 0)
                {
                    for (int i = 0; i < match.Length; ++i)
                    {
                        ParameterInfo[] methodParams = match[i].GetParameters();

                        if (methodParams.Length == argsCopy.Length)
                        {
                            for (int j = 0; j < methodParams.Length; ++j)
                            {
                                if (!methodParams[j].ParameterType.IsInstanceOfType(argsCopy[j]))
                                {
                                    if (!(methodParams[j].ParameterType.IsArray && argsCopy[j] == null))
                                        break;
                                }

                                if (j + 1 == methodParams.Length)
                                    return match[i];
                            }
                        }
                    }
                }
            }

            return null;
        }

        public override FieldInfo BindToField(BindingFlags bindingAttr,
                                               FieldInfo[] match,
                                               object value,
                                               CultureInfo culture)
        {
            return defltBinder.BindToField(bindingAttr, match, value, culture);
        }

        public override MethodBase SelectMethod(BindingFlags bindingAttr,
                                                MethodBase[] match,
                                                Type[] types,
                                                ParameterModifier[] modifiers)
        {
            return defltBinder.SelectMethod(bindingAttr, match, types, modifiers);
        }

        public override PropertyInfo SelectProperty(BindingFlags bindingAttr,
                                                    PropertyInfo[] match,
                                                    Type returnType,
                                                    Type[] indexes,
                                                    ParameterModifier[] modifiers
        )
        {
            return defltBinder.SelectProperty(bindingAttr, match, returnType, indexes, modifiers);
        }

        public override object ChangeType(object value,
                                          Type type,
                                          CultureInfo culture
        )
        {
            return defltBinder.ChangeType(value, type, culture);
        }

        public override void ReorderArgumentArray(ref object[] args,
                                                  object state
        )
        {
            defltBinder.ReorderArgumentArray(ref args, state);
        }
    }
}