コード例 #1
0
        private IReadOnlyList <DispatchMember> GetMembers()
        {
            if (members == null)
            {
                members = dispatch.GetMembers().ToArray();
            }

            return(members);
        }
コード例 #2
0
        private static int GetDispIDForName(this IDispatch dispatch, string name)
        {
            var dispids = new int[1];
            var names   = new[] { name };

            if (HResult.Succeeded(dispatch.GetIDsOfNames(ref iid, names, 1, 0, dispids)))
            {
                return(dispids[0]);
            }

            if (name.IsDispIDName(out dispids[0]))
            {
                return(dispids[0]);
            }

            var member = dispatch.GetMembers().FirstOrDefault(testMember => testMember.Name == name);

            if (member == null)
            {
                throw new MissingMemberException(MiscHelpers.FormatInvariant("The object has no property named '{0}'", name));
            }

            return(member.DispID);
        }
コード例 #3
0
 public static IEnumerable <string> GetPropertyNames(this IDispatch dispatch)
 {
     return(dispatch.GetMembers().Select(member => member.Name));
 }
コード例 #4
0
 private IReadOnlyList <DispatchMember> GetMembers()
 {
     return(members ?? (members = dispatch.GetMembers().ToArray()));
 }