Exemplo n.º 1
0
        internal override IList <KeyValuePair <string, object> > GetMembers(IEnumerable <string> names)
        {
            if (names == null)
            {
                names = GetMemberNames(true);
            }

            Type comType = RuntimeCallableWrapper.GetType();

            var members = new List <KeyValuePair <string, object> >();

            foreach (string name in names)
            {
                if (name == null)
                {
                    continue;
                }

                ComMethodDesc method;
                if (ComTypeDesc.TryGetFunc(name, out method) && method.IsDataMember)
                {
                    try
                    {
                        object value = comType.InvokeMember(
                            method.Name,
                            BindingFlags.GetProperty,
                            null,
                            RuntimeCallableWrapper,
                            Utils.EmptyArray <object>(),
                            CultureInfo.InvariantCulture
                            );
                        members.Add(new KeyValuePair <string, object>(method.Name, value));

                        // evaluation failed for some reason. pass exception out
                    }
                    catch (Exception ex)
                    {
                        members.Add(new KeyValuePair <string, object>(method.Name, ex));
                    }
                }
            }

            return(members.ToArray());
        }
Exemplo n.º 2
0
 internal bool TryGetMemberMethod(string name, out ComMethodDesc method)
 {
     EnsureScanDefinedMethods();
     return(_comTypeDesc.TryGetFunc(name, out method));
 }