Пример #1
0
        public override int FindMethod(string name)
        {
            int dispId;

            if (!_dispIdCache.TryGetValue(name, out dispId))
            {
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    if (_dispatchedType != null)
                    {
                        var memberInfo = _dispatchedType.GetMember(name);
                        if (memberInfo.Length == 0 || !(memberInfo[0].MemberType == MemberTypes.Method || memberInfo[0].MemberType == MemberTypes.Property))
                        {
                            throw RuntimeException.MethodNotFoundException(name);
                        }
                        else
                        {
                            _membersCache.Add(dispId, memberInfo[0]);
                            _dispIdCache.Add(name, dispId);
                        }
                    }
                    else
                    {
                        _dispIdCache.Add(name, dispId);
                    }
                }
                else
                {
                    throw RuntimeException.MethodNotFoundException(name);
                }
            }

            return(dispId);
        }
        private bool TryFindProperty(string name, out RcwPropertyMetadata md)
        {
            if (_props.Names.TryGetValue(name, out md))
            {
                return(true);
            }

            if (DispatchUtility.TryGetDispId(Instance, name, out var dispId))
            {
                md = new RcwPropertyMetadata(name, dispId);
                _props.Add(md);
                return(true);
            }

            return(false);
        }
        private bool TryFindMethod(string name, out RcwMethodMetadata md)
        {
            if (_methods.Names.TryGetValue(name, out md))
            {
                return(true);
            }

            if (DispatchUtility.TryGetDispId(Instance, name, out var dispId))
            {
                md = new RcwMethodMetadata(name, dispId, null);
                _methods.Add(md);
                return(true);
            }

            return(false);
        }
Пример #4
0
        public override int FindMethod(string name)
        {
            int dispId;

            if (!_dispIdCache.TryGetValue(name, out dispId))
            {
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    _dispIdCache.Add(name, dispId);
                }
                else
                {
                    throw RuntimeException.MethodNotFoundException(name);
                }
            }

            return(dispId);
        }
Пример #5
0
        public int FindMemberIndex(string name)
        {
            int knownDiIndex;

            if (!_dispIdIndexes.TryGetValue(name, out knownDiIndex))
            {
                int dispId;
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    knownDiIndex = _dispIds.Count;
                    _dispIds.Add(dispId);
                    _dispIdIndexes.Add(name, knownDiIndex);
                }
                else
                {
                    knownDiIndex = -1;
                }
            }

            return(knownDiIndex);
        }