1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Microsoft Public License. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Microsoft Public License, please send an email to
8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Microsoft Public License.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
15 using System; using Microsoft;
18 #if !SILVERLIGHT // ComObject
20 using System.Diagnostics;
21 using System.Runtime.InteropServices.ComTypes;
23 using System.Globalization;
24 using Marshal = System.Runtime.InteropServices.Marshal;
27 namespace System.Dynamic {
29 namespace Microsoft.Scripting {
32 internal sealed class ComMethodDesc {
33 private readonly int _memid; // this is the member id extracted from FUNCDESC.memid
34 private readonly string _name;
35 internal readonly INVOKEKIND InvokeKind;
36 private readonly int _paramCnt;
38 private ComMethodDesc(int dispId) {
42 internal ComMethodDesc(string name, int dispId)
44 // no ITypeInfo constructor
48 internal ComMethodDesc(string name, int dispId, INVOKEKIND invkind)
49 : this(name, dispId) {
53 internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
54 : this(funcDesc.memid) {
56 InvokeKind = funcDesc.invkind;
59 string[] rgNames = new string[1 + funcDesc.cParams];
60 typeInfo.GetNames(_memid, rgNames, rgNames.Length, out cNames);
61 if (IsPropertyPut && rgNames[rgNames.Length - 1] == null) {
62 rgNames[rgNames.Length - 1] = "value";
65 Debug.Assert(cNames == rgNames.Length);
68 _paramCnt = funcDesc.cParams;
73 Debug.Assert(_name != null);
79 get { return _memid; }
82 public bool IsPropertyGet {
84 return (InvokeKind & INVOKEKIND.INVOKE_PROPERTYGET) != 0;
88 public bool IsDataMember {
91 if (!IsPropertyGet || DispId == ComDispIds.DISPID_NEWENUM) {
95 //must have no parameters
96 return _paramCnt == 0;
100 public bool IsPropertyPut {
102 return (InvokeKind & (INVOKEKIND.INVOKE_PROPERTYPUT | INVOKEKIND.INVOKE_PROPERTYPUTREF)) != 0;
106 public bool IsPropertyPutRef {
108 return (InvokeKind & INVOKEKIND.INVOKE_PROPERTYPUTREF) != 0;
112 internal int ParamCount {