Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PluginModule"/> class.
        /// </summary>
        /// <param name="fileName">The file name of the DLL to load.</param>
        /// <param name="entryPoint">The name of the entry point in the DLL.</param>
        /// <exception cref="System.EntryPointNotFoundException">The entry point specified by <paramref name="entryPoint"/> was not found in <paramref name="fileName"/>.</exception>
        /// <exception cref="System.IO.FileNotFoundException">The file specified by <paramref name="fileName"/> cannot be found.</exception>
        public PluginModule(string fileName, string entryPoint)
        {
            disposed = false;
            handle   = UnsafeNativeMethods.LoadLibraryExW(fileName, IntPtr.Zero, 0U);
            if (!handle.IsInvalid)
            {
                IntPtr address = UnsafeNativeMethods.GetProcAddress(handle, entryPoint);

                if (address != IntPtr.Zero)
                {
                    this.entryPoint = (PluginEntryPoint)Marshal.GetDelegateForFunctionPointer(address, typeof(PluginEntryPoint));
                    this.fileName   = fileName;
                }
                else
                {
                    handle.Dispose();
                    handle = null;

                    throw new EntryPointNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.PluginEntryPointNotFound, entryPoint, fileName));
                }
            }
            else
            {
                int hr = Marshal.GetHRForLastWin32Error();
                Marshal.ThrowExceptionForHR(hr);
            }
        }
Exemplo n.º 2
0
        public static void OpenRider(string file, int line, string sln = null)
        {
            if (sln == null || !File.Exists(sln))
            {
                var dir = new DirectoryInfo(Application.dataPath).Parent;
                var prj = dir.Name;
                sln = dir + "/" + prj + ".sln";
            }

            PluginEntryPoint.CallRider(string.Format("{0}{1}{0} --line {2} {0}{3}{0}", "\"", sln, line, Path.GetFullPath(file)));
        }