forked from ClearFoundry/ClearScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatchMember.cs
More file actions
92 lines (76 loc) · 2.62 KB
/
DispatchMember.cs
File metadata and controls
92 lines (76 loc) · 2.62 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
namespace Microsoft.ClearScript.Util.COM
{
internal sealed class DispatchMember
{
public string Name { get; private set; }
public int DispID { get; private set; }
public DispatchFlags DispatchFlags { get; private set; }
private DispatchMember(string name, int dispid)
{
Name = name;
DispID = dispid;
}
public DispatchMember(string name, int dispid, INVOKEKIND invokeKind)
: this(name, dispid)
{
if (invokeKind.HasFlag(INVOKEKIND.INVOKE_FUNC))
{
DispatchFlags |= DispatchFlags.Method;
}
if (invokeKind.HasFlag(INVOKEKIND.INVOKE_PROPERTYGET))
{
DispatchFlags |= DispatchFlags.PropertyGet;
}
if (invokeKind.HasFlag(INVOKEKIND.INVOKE_PROPERTYPUT))
{
DispatchFlags |= DispatchFlags.PropertyPut;
}
if (invokeKind.HasFlag(INVOKEKIND.INVOKE_PROPERTYPUTREF))
{
DispatchFlags |= DispatchFlags.PropertyPutRef;
}
}
public DispatchMember(string name, int dispid, DispatchPropFlags flags)
: this(name, dispid)
{
if (flags.HasFlag(DispatchPropFlags.CanCall))
{
DispatchFlags |= DispatchFlags.Method;
}
if (flags.HasFlag(DispatchPropFlags.CanGet))
{
DispatchFlags |= DispatchFlags.PropertyGet;
}
if (flags.HasFlag(DispatchPropFlags.CanPut))
{
DispatchFlags |= DispatchFlags.PropertyPut;
}
if (flags.HasFlag(DispatchPropFlags.CanPutRef))
{
DispatchFlags |= DispatchFlags.PropertyPutRef;
}
}
public static DispatchMember Merge(int dispid, IEnumerable<DispatchMember> group)
{
var members = group.ToArray();
if (members.Length < 1)
{
return null;
}
var result = new DispatchMember(members[0].Name, dispid);
foreach (var member in members)
{
Debug.Assert(member.Name == result.Name);
Debug.Assert(member.DispID == result.DispID);
result.DispatchFlags |= member.DispatchFlags;
}
return result;
}
}
}