Example #1
0
        /// <summary>
        /// 从列表中查找入口并返回非托管方法委托
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private T GetDelegate <T>(string name) where T : class
        {
            string entryName = _entryList.FirstOrDefault(p => p.StartsWith(name));

            if (!string.IsNullOrEmpty(entryName))
            {
                return(_wrapper.GetUnmanagedFunction <T>(entryName));
            }
            throw new Exception(string.Format("Failed to get entry point for \"{0}\"", name));
        }
Example #2
0
        /// <summary>
        /// 从列表中查找入口并返回非托管方法委托(注意接口前缀不能相同,否则可能找到错误的入口)
        /// </summary>
        /// <param name="name">方法委托</param>
        /// <returns></returns>
        private T GetDelegate <T>(string name) where T : class
        {
            var entries = _entryList.Where(p => p.StartsWith(string.Format("?{0}@", name)));
            int count   = entries.Count();

            if (count > 1)
            {
                throw new Exception(string.Format("More than one entries found with the name: \"{0}\"", name));
            }
            if (count == 0)
            {
                throw new Exception(string.Format("Failed to get entry point for \"{0}\"", name));
            }
            string entryName = entries.FirstOrDefault();

            return(_wrapper.GetUnmanagedFunction <T>(entryName));
        }