本文整理汇总了C#中Type.GetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetMethod方法的具体用法?C# Type.GetMethod怎么用?C# Type.GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.GetMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClientReflectionHelper
static ClientReflectionHelper ()
{
SystemAssembly = typeof (Uri).Assembly;
web_header_collection = SystemAssembly.GetType ("System.Net.WebHeaderCollection");
headers_all_keys = web_header_collection.GetProperty ("AllKeys").GetGetMethod ();
headers_get = web_header_collection.GetMethod ("Get", new Type [] { typeof (string) });
headers_set = web_header_collection.GetMethod ("Set", new Type [] { typeof (string), typeof (string) });
Type network_credential = SystemAssembly.GetType ("System.Net.NetworkCredential");
network_credential_ctor = network_credential.GetConstructor (new Type [] { typeof (string), typeof (string), typeof (string) });
}
示例2: Reports_RMLauncher
static Reports_RMLauncher()
{
_sendEmailMaint = System.Web.Compilation.BuildManager.GetType(_SENDEMAILMAINT_TYPE, false);
_sendEmailMethod = null;
MemberInfo[] search = null;
if (_sendEmailMaint != null)
{
_sendEmailMethod = _sendEmailMaint.GetMethod(_SENDEMAIL_METHOD, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public);
search = _sendEmailMaint.GetMember(_SENDEMAILPARAMS_TYPE);
}
Type sendEmailParams = search != null && search.Length > 0 && search[0] is Type ? (Type)search[0] : null;
if (sendEmailParams != null)
{
_sendEmailParamsCtor = sendEmailParams.GetConstructor(new Type[0]);
_fromMethod = sendEmailParams.GetProperty("From");
_toMethod = sendEmailParams.GetProperty("To");
_ccMethod = sendEmailParams.GetProperty("Cc");
_bccMethod = sendEmailParams.GetProperty("Bcc");
_subjectMethod = sendEmailParams.GetProperty("Subject");
_bodyMethod = sendEmailParams.GetProperty("Body");
_activitySourceMethod = sendEmailParams.GetProperty("Source");
_parentSourceMethod = sendEmailParams.GetProperty("ParentSource");
_templateIDMethod = sendEmailParams.GetProperty("TemplateID");
_attachmentsMethod = sendEmailParams.GetProperty("Attachments");
}
_canSendEmail = _sendEmailParamsCtor != null && _sendEmailMaint != null && _sendEmailMethod != null &&
_fromMethod != null && _toMethod != null && _ccMethod != null && _bccMethod != null &&
_subjectMethod != null && _bodyMethod != null &&
_activitySourceMethod != null && _parentSourceMethod != null && _templateIDMethod != null && _attachmentsMethod != null;
}
示例3: GetValue
public object GetValue (string key, Type type)
{
if (key == null)
throw new ArgumentNullException ("key");
if (type == null)
throw new ArgumentNullException ("type");
string value = appSettings [key];
if (value == null)
throw new InvalidOperationException ("'" + key + "' could not be found.");
if (type == typeof (string))
return value;
MethodInfo parse = type.GetMethod ("Parse", new Type [] {typeof (string)});
if (parse == null)
throw new InvalidOperationException ("Type " + type + " does not have a Parse method");
object result = null;
try {
result = parse.Invoke (null, new object [] {value});
} catch (Exception e) {
throw new InvalidOperationException ("Parse error.", e);
}
return result;
}
示例4: Pages_ReportLauncher
static Pages_ReportLauncher()
{
_sendEmailMaint = System.Web.Compilation.BuildManager.GetType(_SENDEMAILMAINT_TYPE, false);
_sendEmailMethod = null;
MemberInfo[] search = null;
if (_sendEmailMaint != null)
{
_sendEmailMethod = _sendEmailMaint.GetMethod(_SENDEMAIL_METHOD, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public);
search = _sendEmailMaint.GetMember(_SENDEMAILPARAMS_TYPE);
}
Type sendEmailParams = search != null && search.Length > 0 && search[0] is Type ? (Type)search[0] : null;
if (sendEmailParams != null)
{
_sendEmailParamsCtor = sendEmailParams.GetConstructor(new Type[0]);
_fromMethod = sendEmailParams.GetProperty("From");
_toMethod = sendEmailParams.GetProperty("To");
_ccMethod = sendEmailParams.GetProperty("Cc");
_bccMethod = sendEmailParams.GetProperty("Bcc");
_subjectMethod = sendEmailParams.GetProperty("Subject");
_bodyMethod = sendEmailParams.GetProperty("Body");
_activitySourceMethod = sendEmailParams.GetProperty("Source");
_parentSourceMethod = sendEmailParams.GetProperty("ParentSource");
_templateIDMethod = sendEmailParams.GetProperty("TemplateID");
_attachmentsMethod = sendEmailParams.GetProperty("Attachments");
}
_canSendEmail = _sendEmailParamsCtor != null && _sendEmailMaint != null && _sendEmailMethod != null &&
_fromMethod != null && _toMethod != null && _ccMethod != null && _bccMethod != null &&
_subjectMethod != null && _bodyMethod != null &&
_activitySourceMethod != null && _parentSourceMethod != null && _templateIDMethod != null && _attachmentsMethod != null && !PXSiteMap.IsPortal;
Type reportFunctionsType = System.Web.Compilation.BuildManager.GetType(_REPORTFUNCTIONS_TYPE, false);
if (reportFunctionsType != null)
ExpressionContext.RegisterExternalObject("Payments", Activator.CreateInstance(reportFunctionsType));
}
示例5: MethodDetails
public MethodDetails(string _str_methodString, object[] _parameters, object _instance)
{
// for: Gets the type from the method string
for (int i = 0; i < _str_methodString.Length; i++)
{
if (_str_methodString[i] == '.')
{
char[] c = new char[i];
_str_methodString.CopyTo(0, c, 0, i);
methodType = Type.GetType(new string(c));
char[] d = new char[_str_methodString.Length - i];
_str_methodString.CopyTo(i + 1, d, 0, _str_methodString.Length - i - 1);
methodName = methodType.GetMethod(new string(d));
parameters = _parameters;
instance = _instance;
return;
}
}
methodType = null;
methodName = null;
parameters = null;
instance = null;
Debug.LogWarning("MethodDetails.MethodDetails(): Cannot get method type. methodType = " + _str_methodString + "(Possibly missing a '.'?)");
}
示例6: RelationsInspectorLink
// ctor. retrieves types, properties and methods
static RelationsInspectorLink()
{
windowType = GetTypeInAssembly( riWindowTypeName, riAssemblyName );
if ( windowType == null )
{
return; // this happens when RI is not installed. no need for an error msg here.
}
api1Property = windowType.GetProperty( api1PropertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty );
if ( api1Property == null )
{
Debug.LogError( "Failed to retrieve API1 property of type " + windowType );
return;
}
api1Type = GetTypeInAssembly( riAPI1TypeName, riAssemblyName );
if ( api1Type == null )
{
Debug.LogError( "Failed to retrieve API1 type" );
return;
}
api1ResetTargetsMethod = api1Type.GetMethod( api1ResetTargetsMethodName, api1ResetTargetsArguments );
if ( api1ResetTargetsMethod == null )
{
Debug.LogError( "Failed to retrieve API method ResetTargets(object[],Type,bool)" );
return;
}
RIisAvailable = true;
}
示例7: InitType
public static void InitType() {
if (realType == null) {
Assembly assembly = Assembly.GetAssembly(typeof(Editor));
realType = assembly.GetType("UnityEditor.AvatarPreview");
method_ctor = realType.GetConstructor(new Type[] { typeof(Animator), typeof(Motion)});
property_OnAvatarChangeFunc = realType.GetProperty("OnAvatarChangeFunc");
property_IKOnFeet = realType.GetProperty("IKOnFeet");
property_Animator = realType.GetProperty("Animator");
method_DoPreviewSettings = realType.GetMethod("DoPreviewSettings");
method_OnDestroy = realType.GetMethod("OnDestroy");
method_DoAvatarPreview = realType.GetMethod("DoAvatarPreview", new Type[] {typeof(Rect), typeof(GUIStyle)});
method_ResetPreviewInstance = realType.GetMethod("ResetPreviewInstance");
// method_CalculatePreviewGameObject = realType.GetMethod("CalculatePreviewGameObject", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
field_timeControl = realType.GetField("timeControl");
}
}
示例8: OnEnable
//Type handleUtilityType;
//Type[] types = { };
void OnEnable() {
selfScript = (ItemConnectionPoint)target;
//handleUtilityType = Type.GetType("HandleUtility, Assembly_CSharp-Editor", false, false);
Type[] editorTypes = typeof(Editor).Assembly.GetTypes();
type_HandleUtility = editorTypes.FirstOrDefault<Type>(x => x.Name == "HandleUtility");
meth_IntersectRayMesh = type_HandleUtility.GetMethod("IntersectRayMesh", (BindingFlags.Static | BindingFlags.NonPublic));
}
示例9: GameBehaviourMethods
public GameBehaviourMethods( Type type )
{
onGameStartMethod = type.GetMethod("OnGameStart");
onGamePauseMethod = type.GetMethod("OnGamePause");
onGameOverMethod = type.GetMethod("OnGameOver");
onGameClearMethod = type.GetMethod("OnGameClear");
onGameResetMethod = type.GetMethod("OnGameReset");
onGameResumeMethod = type.GetMethod("OnGameResume");
postAwakeMethod = type.GetMethod("PostAwake");
onPostDestroyMethod = type.GetMethod("OnPostDestroy");
}
示例10: DynamicInstructionN
public DynamicInstructionN(Type delegateType, CallSite site)
{
var methodInfo = delegateType.GetMethod("Invoke");
var parameters = methodInfo.GetParameters();
_target = CallInstruction.Create(methodInfo, parameters);
_site = site;
_argumentCount = parameters.Length - 1;
_targetDelegate = site.GetType().GetField("Target").GetValue(site);
}
示例11: Solution
static Solution()
{
s_SolutionParser = Type.GetType("Microsoft.Build.Construction.SolutionParser, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", false, false);
if (s_SolutionParser != null)
{
s_SolutionParser_solutionReader = s_SolutionParser.GetProperty("SolutionReader", BindingFlags.NonPublic | BindingFlags.Instance);
s_SolutionParser_projects = s_SolutionParser.GetProperty("Projects", BindingFlags.NonPublic | BindingFlags.Instance);
s_SolutionParser_parseSolution = s_SolutionParser.GetMethod("ParseSolution", BindingFlags.NonPublic | BindingFlags.Instance);
}
}
示例12: Create
static XunitTestCase Create(Type typeUnderTest, string methodName, params object[] arguments)
{
var methodUnderTest = typeUnderTest.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
var assembly = Reflector.Wrap(typeUnderTest.Assembly);
var type = Reflector.Wrap(typeUnderTest);
var method = Reflector.Wrap(methodUnderTest);
var fact = Reflector.Wrap(CustomAttributeData.GetCustomAttributes(methodUnderTest)
.Single(cad => cad.AttributeType == typeof(FactAttribute)));
return new XunitTestCase(assembly, type, method, fact, arguments.Length == 0 ? null : arguments);
}
示例13: RunTests
static void RunTests(int series, Type type)
{
const string Prefix = "Test";
MethodInfo createObjectMethod = type.GetMethod ("CreateObject");
foreach (MethodInfo mi in type.GetMethods ()) {
string name = mi.Name;
if (!name.StartsWith (Prefix))
continue;
int id = Convert.ToInt32 (name.Substring (Prefix.Length));
int res = test_method_thunk (series + id, mi.MethodHandle.Value, createObjectMethod.MethodHandle.Value);
if (res != 0) {
Console.WriteLine ("{0} returned {1}", mi, res);
Environment.Exit ((id << 3) + res);
}
}
}
示例14: CreateMetabaseSettings
static MetabaseSettingsIis CreateMetabaseSettings(Type type)
{
object instance = null;
MethodInfo method = type.GetMethod(CreateMetabaseSettingsIis7MethodName, BindingFlags.NonPublic | BindingFlags.Static);
try
{
new PermissionSet(PermissionState.Unrestricted).Assert();
instance = method.Invoke(null, null);
}
finally
{
PermissionSet.RevertAssert();
}
if (!(instance is MetabaseSettingsIis))
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Hosting_BadMetabaseSettingsIis7Type(type.AssemblyQualifiedName)));
}
return (MetabaseSettingsIis)instance;
}
示例15: GetFilters_ReturnsEmptyCollections_ForActionsWithQueryableAttributeApplied
public void GetFilters_ReturnsEmptyCollections_ForActionsWithQueryableAttributeApplied(
string actionName,
Type controllerType)
{
// Arrange
HttpConfiguration config = new HttpConfiguration();
string controllerName = controllerType.Name.Replace("Controller","");
HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(
config,
controllerName,
controllerType);
HttpActionDescriptor actionDescriptor = new ReflectedHttpActionDescriptor(
controllerDescriptor,
controllerType.GetMethod(actionName));
// Act
FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute(), skipQueryableAttribute: true)
.GetFilters(config, actionDescriptor).ToArray();
// Assert
Assert.Empty(filters);
}