本文整理汇总了C#中Reflector.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Reflector.GetType方法的具体用法?C# Reflector.GetType怎么用?C# Reflector.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reflector
的用法示例。
在下文中一共展示了Reflector.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDialog
public bool ShowDialog(IntPtr hWndOwner)
{
bool flag = false;
if (Environment.OSVersion.Version.Major >= 6)
{
var r = new Reflector("System.Windows.Forms");
uint num = 0;
Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
object dialog = r.Call(ofd, "CreateVistaDialog");
r.Call(ofd, "OnBeforeVistaDialog", dialog);
uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions");
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
r.CallAs(typeIFileDialog, dialog, "SetOptions", options);
object pfde = r.New("FileDialog.VistaDialogEvents", ofd);
object[] parameters = new object[] { pfde, num };
r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
num = (uint)parameters[1];
try
{
int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
flag = 0 == num2;
}
finally
{
r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
GC.KeepAlive(pfde);
}
}
else
{
using (var fbd = new FolderBrowserDialog())
{
fbd.Description = this.Title;
fbd.SelectedPath = this.InitialDirectory;
fbd.ShowNewFolderButton = false;
if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) return false;
ofd.FileName = fbd.SelectedPath;
flag = true;
}
}
return flag;
}
示例2: ShowDialog
private bool ShowDialog(IntPtr hWndOwner)
{
bool flag;
if (Environment.OSVersion.Version.Major >= 6)
{
var r = new Reflector("System.Windows.Forms");
uint num = 0;
var typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
var dialog = Reflector.Call(_ofd, "CreateVistaDialog");
Reflector.Call(_ofd, "OnBeforeVistaDialog", dialog);
var options = (uint)Reflector.CallAs(typeof(FileDialog), _ofd, "GetOptions");
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
Reflector.CallAs(typeIFileDialog, dialog, "SetOptions", options);
var pfde = r.New("FileDialog.VistaDialogEvents", _ofd);
var parameters = new[] { pfde, num };
Reflector.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
num = (uint)parameters[1];
try
{
var num2 = (int)Reflector.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
flag = 0 == num2;
}
finally
{
Reflector.CallAs(typeIFileDialog, dialog, "Unadvise", num);
GC.KeepAlive(pfde);
}
}
else
{
var fbd = new FolderBrowserDialog {
Description = Title,
SelectedPath = InitialDirectory
};
if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK)
return false;
_ofd.FileName = fbd.SelectedPath;
return true;
}
return flag;
}
示例3: ShowDialog
public bool ShowDialog(IntPtr hWndOwner)
{
if ((Environment.OSVersion.Version.Major >= 6) && !this.UseOldDialog)
{
Reflector reflector = new Reflector("System.Windows.Forms");
uint num = 0;
Type type = reflector.GetType("FileDialogNative.IFileDialog");
object obj2 = reflector.Call(this.ofd, "CreateVistaDialog", new object[0]);
reflector.Call(this.ofd, "OnBeforeVistaDialog", new object[] {obj2});
uint num2 = (uint) reflector.CallAs(typeof (FileDialog), this.ofd, "GetOptions", new object[0]);
num2 |= (uint) reflector.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
reflector.CallAs(type, obj2, "SetOptions", new object[] {num2});
object obj3 = reflector.New("FileDialog.VistaDialogEvents", new object[] {this.ofd});
object[] parameters = new object[] {obj3, num};
reflector.CallAs2(type, obj2, "Advise", parameters);
num = (uint) parameters[1];
try
{
int num3 = (int) reflector.CallAs(type, obj2, "Show", new object[] {hWndOwner});
return (0 == num3);
}
finally
{
reflector.CallAs(type, obj2, "Unadvise", new object[] {num});
GC.KeepAlive(obj3);
}
}
FolderBrowserDialogEx ex = new FolderBrowserDialogEx();
ex.Description = this.Title;
ex.SelectedPath = this.InitialDirectory;
ex.ShowNewFolderButton = true;
ex.ShowEditBox = true;
ex.ShowFullPathInEditBox = true;
if (ex.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK)
{
return false;
}
this.ofd.FileName = ex.SelectedPath;
return true;
}
示例4: ShowDialog
/// <summary>
/// Shows the dialog
/// </summary>
/// <param name="hWndOwner">Handle of the control to be parent</param>
/// <returns>True if the user presses OK else false</returns>
public bool ShowDialog(IntPtr hWndOwner)
{
bool flag = false;
if (PlatformHelper.GetPlatform() == Platform.OsX ||
PlatformHelper.GetPlatform() == Platform.Linux ||
Environment.OSVersion.Version.Major < 6)
{
flag = FallBackToFolderBrowserDialog(hWndOwner);
}
else
{
var r = new Reflector("System.Windows.Forms");
uint num = 0;
Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
if (typeIFileDialog == null)
flag = FallBackToFolderBrowserDialog(hWndOwner);
else
{
object dialog = r.Call(ofd, "CreateVistaDialog");
r.Call(ofd, "OnBeforeVistaDialog", dialog);
uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions");
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
r.CallAs(typeIFileDialog, dialog, "SetOptions", options);
object pfde = r.New("FileDialog.VistaDialogEvents", ofd);
object[] parameters = new object[] { pfde, num };
r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
num = (uint)parameters[1];
try
{
int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
flag = 0 == num2;
}
finally
{
r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
GC.KeepAlive(pfde);
}
}
}
return flag;
}
示例5: ShowDialog
/// <summary>
/// Shows the dialog
/// </summary>
/// <returns>True if the user presses OK else false</returns>
public DialogResult ShowDialog(IntPtr hWndOwner)
{
bool flag;
if (Environment.OSVersion.Version.Major >= 6) // if current OS is windows and version Vista or higher - then use extended dialogs
{
var r = new Reflector("System.Windows.Forms");
uint num = 0;
var typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
var dialog = r.Call(ofd, "CreateVistaDialog");
r.Call(ofd, "OnBeforeVistaDialog", dialog);
var options = (uint)r.CallAs(typeof(FileDialog), ofd, "GetOptions");
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
r.CallAs(typeIFileDialog, dialog, "SetOptions", options);
var pfde = r.New("FileDialog.VistaDialogEvents", ofd);
var parameters = new[] { pfde, num };
r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
num = (uint)parameters[1];
try
{
var num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
flag = 0 == num2;
}
finally
{
r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
GC.KeepAlive(pfde);
}
}
else // in another case - use standart dialog
{
using (var fbd = new FolderBrowserDialog { Description = Title, SelectedPath = InitialDirectory, ShowNewFolderButton = false, RootFolder = RootFolder })
{
if (fbd.ShowDialog() != DialogResult.OK)
return DialogResult.Cancel;
ofd.FileName = fbd.SelectedPath;
flag = true;
}
}
return flag ? DialogResult.OK : DialogResult.Cancel;
}
示例6: ShowDialog
/// <summary>
/// Shows the dialog
/// </summary>
/// <param name="hWndOwner">Handle of the control to be parent</param>
/// <returns>True if the user presses OK else false</returns>
public bool ShowDialog(IntPtr hWndOwner)
{
bool flag;
// TODO: Find way to use Microsoft.Win32
Reflector r = new Reflector("System.Windows.Forms");
uint num = 0;
Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
object dialog = r.Call(ofd, "CreateVistaDialog");
r.Call(ofd, "OnBeforeVistaDialog", dialog);
uint options = (uint)r.CallAs(typeof(FileDialog), ofd, "GetOptions");
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
r.CallAs(typeIFileDialog, dialog, "SetOptions", options);
object pfde = r.New("FileDialog.VistaDialogEvents", ofd);
object[] parameters = new object[] { pfde, num };
r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
num = (uint)parameters[1];
try
{
int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
flag = 0 == num2;
}
finally
{
r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
GC.KeepAlive(pfde);
}
return flag;
}