Here are the examples of the csharp api System.Type.GetMethod(string, System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
890 Examples
19
View Source File : CommonExpressionMeta.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
public static Expression Call_WriteFixUInt32WithRefPos(Expression value, Expression refb)
{
return Expression.Call(Par_Writer, typeof(BssomWriter).GetMethod(nameof(BssomWriter.WriteFixUInt32WithRefPos), instanceAndInternalFlag, null, new Type[] { value.Type, typeof(long) }, null), value, refb);
}
19
View Source File : CommonExpressionMeta.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
public static Expression Call_Reader_ReadRaw64Ref(Expression remaining)
{
return Expression.Call(Par_Reader, typeof(BssomReader).GetMethod(nameof(BssomReader.ReadRaw64), instanceAndInternalFlag, null, new Type[] { typeof(int).MakeByRefType() }, null), remaining);
}
19
View Source File : CommonExpressionMeta.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
public static Expression Call_WriteDateTime(Expression value)
{
return Expression.Call(Par_Writer, typeof(BssomWriter).GetMethod(nameof(BssomWriter.Write), instanceAndInternalFlag, null, new Type[] { typeof(DateTime), typeof(bool), typeof(bool) }, null), value, Field_SerializeOption_IsUseStandardDateTime, Expression.Constant(true));
}
19
View Source File : CommonExpressionMeta.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
public static Expression Call_Read(string typeName)
{
return Expression.Call(Par_Reader, typeof(BssomReader).GetMethod("Read" + typeName, instanceAndInternalFlag, null, new Type[0], null));
}
19
View Source File : CommonExpressionMeta.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
public static Expression Call_Write(Expression value)
{
return Expression.Call(Par_Writer, typeof(BssomWriter).GetMethod(nameof(BssomWriter.Write), instanceAndInternalFlag, null, new Type[] { value.Type }, null), value);
}
19
View Source File : Helpers.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
internal static MethodInfo GetInstanceMethod(Type declaringType, string name, Type[] types)
{
if(types == null) types = EmptyTypes;
#if PORTABLE || COREFX
MethodInfo method = declaringType.GetMethod(name, types);
if (method != null && method.IsStatic) method = null;
return method;
#else
return declaringType.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, types, null);
#endif
}
19
View Source File : QuaternionBinder.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public override void RegisterCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
{
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
MethodBase method;
Type[] args;
Type type = typeof(Quaternion);
args = new Type[] { typeof(float), typeof(float), typeof(float), typeof(float) };
method = type.GetConstructor(flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, NewQuaternion);
args = new Type[] { typeof(Quaternion), typeof(Quaternion) };
method = type.GetMethod("op_Multiply", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Multiply);
args = new Type[] { typeof(Quaternion), typeof(Vector3) };
method = type.GetMethod("op_Multiply", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Multiply2);
args = new Type[] { typeof(Quaternion), typeof(Quaternion) };
method = type.GetMethod("op_Equality", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Equality);
args = new Type[] { typeof(Quaternion), typeof(Quaternion) };
method = type.GetMethod("op_Inequality", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Inequality);
args = new Type[] { typeof(Quaternion), typeof(Quaternion) };
method = type.GetMethod("Dot", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Dot);
args = new Type[] { typeof(Quaternion), typeof(Quaternion) };
method = type.GetMethod("Angle", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Angle);
args = new Type[] { typeof(Vector3) };
method = type.GetMethod("Euler", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Euler);
args = new Type[] { typeof(float), typeof(float), typeof(float) };
method = type.GetMethod("Euler", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Quaternion_Euler2);
args = new Type[] { };
method = type.GetMethod("get_eulerAngles", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_EulerAngle);
args = new Type[] { };
method = type.GetMethod("get_idenreplacedy", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Idenreplacedy);
}
19
View Source File : Vector2Binder.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public override void RegisterCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
{
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
MethodBase method;
Type[] args;
Type type = typeof(Vector2);
args = new Type[] { typeof(float), typeof(float) };
method = type.GetConstructor(flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, NewVector2);
args = new Type[] { typeof(Vector2), typeof(Vector2) };
method = type.GetMethod("op_Addition", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Add);
args = new Type[] { typeof(Vector2), typeof(Vector2) };
method = type.GetMethod("op_Subtraction", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Subtraction);
args = new Type[] { typeof(Vector2), typeof(float) };
method = type.GetMethod("op_Multiply", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Multiply);
args = new Type[] { typeof(float), typeof(Vector2) };
method = type.GetMethod("op_Multiply", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Multiply2);
args = new Type[] { typeof(Vector2), typeof(float) };
method = type.GetMethod("op_Division", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Division);
args = new Type[] { typeof(Vector2) };
method = type.GetMethod("op_UnaryNegation", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Negate);
args = new Type[] { typeof(Vector2), typeof(Vector2) };
method = type.GetMethod("op_Equality", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Equality);
args = new Type[] { typeof(Vector2), typeof(Vector2) };
method = type.GetMethod("op_Inequality", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Inequality);
args = new Type[] { typeof(Vector2) };
method = type.GetMethod("op_Implicit", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Implicit);
args = new Type[] { typeof(Vector3) };
method = type.GetMethod("op_Implicit", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Implicit2);
args = new Type[] { typeof(Vector2), typeof(Vector2) };
method = type.GetMethod("Dot", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Dot);
args = new Type[] { typeof(Vector2), typeof(Vector2) };
method = type.GetMethod("Distance", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector2_Distance);
args = new Type[] { };
method = type.GetMethod("get_magnitude", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Magnitude);
args = new Type[] { };
method = type.GetMethod("get_sqrMagnitude", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_SqrMagnitude);
args = new Type[] { };
method = type.GetMethod("get_normalized", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Normalized);
args = new Type[] { };
method = type.GetMethod("get_one", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_One);
args = new Type[] { };
method = type.GetMethod("get_zero", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Zero);
}
19
View Source File : Vector3Binder.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public override void RegisterCLRRedirection(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
{
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
MethodBase method;
Type[] args;
Type type = typeof(Vector3);
args = new Type[] { typeof(float), typeof(float), typeof(float) };
method = type.GetConstructor(flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, NewVector3);
args = new Type[] { typeof(float), typeof(float) };
method = type.GetConstructor(flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, NewVector3_2);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("op_Addition", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Add);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("op_Subtraction", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Subtraction);
args = new Type[] { typeof(Vector3), typeof(float) };
method = type.GetMethod("op_Multiply", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Multiply);
args = new Type[] { typeof(float), typeof(Vector3) };
method = type.GetMethod("op_Multiply", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Multiply2);
args = new Type[] { typeof(Vector3), typeof(float) };
method = type.GetMethod("op_Division", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Division);
args = new Type[] { typeof(Vector3) };
method = type.GetMethod("op_UnaryNegation", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Negate);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("op_Equality", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Equality);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("op_Inequality", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Inequality);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("Dot", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Dot);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("Cross", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Cross);
args = new Type[] { typeof(Vector3), typeof(Vector3) };
method = type.GetMethod("Distance", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Vector3_Distance);
args = new Type[] { };
method = type.GetMethod("get_magnitude", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Magnitude);
args = new Type[] { };
method = type.GetMethod("get_sqrMagnitude", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_SqrMagnitude);
args = new Type[] { };
method = type.GetMethod("get_normalized", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Normalized);
args = new Type[] { };
method = type.GetMethod("get_one", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_One);
args = new Type[] { };
method = type.GetMethod("get_zero", flag, null, args, null);
appdomain.RegisterCLRMethodRedirection(method, Get_Zero);
}
19
View Source File : ParseableSerializer.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static ParseableSerializer TryCreate(Type type, TypeModel model)
{
if (type == null) throw new ArgumentNullException("type");
#if WINRT || PORTABLE || COREFX || PROFILE259
MethodInfo method = null;
#if WINRT || COREFX || PROFILE259
foreach (MethodInfo tmp in type.GetTypeInfo().GetDeclaredMethods("Parse"))
#else
foreach (MethodInfo tmp in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly))
#endif
{
ParameterInfo[] p;
if (tmp.Name == "Parse" && tmp.IsPublic && tmp.IsStatic && tmp.DeclaringType == type && (p = tmp.GetParameters()) != null && p.Length == 1 && p[0].ParameterType == typeof(string))
{
method = tmp;
break;
}
}
#else
MethodInfo method = type.GetMethod("Parse",
BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly,
null, new Type[] { model.MapType(typeof(string)) }, null);
#endif
if (method != null && method.ReturnType == type)
{
if (Helpers.IsValueType(type))
{
MethodInfo toString = GetCustomToString(type);
if (toString == null || toString.ReturnType != model.MapType(typeof(string))) return null; // need custom ToString, fools
}
return new ParseableSerializer(method);
}
return null;
}
19
View Source File : Helpers.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
internal static MethodInfo GetStaticMethod(Type declaringType, string name, Type[] parameterTypes)
{
#if PORTABLE
foreach (MethodInfo method in declaringType.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
{
if (method.Name == name && IsMatch(method.GetParameters(), parameterTypes)) return method;
}
return null;
#else
return declaringType.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameterTypes, null);
#endif
}
19
View Source File : Object.Extension.cs
License : MIT License
Project Creator : 7Bytes-Studio
License : MIT License
Project Creator : 7Bytes-Studio
public static object To(this object value,Type tp)
{
if (value == null) return null;
if (tp.IsGenericType)
{
tp = tp.GetGenericArguments()[0];
}
if (tp.Name.ToLower() == "string")
{
return value;
}
var TryParse = tp.GetMethod("TryParse", BindingFlags.Public | BindingFlags.Static, Type.DefaultBinder,
new Type[] { typeof(string), tp.MakeByRefType() },
new ParameterModifier[] { new ParameterModifier(2) });
var parameters = new object[] { value, Activator.CreateInstance(tp) };
bool success = (bool)TryParse.Invoke(null, parameters);
if (success)
{
return parameters[1];
}
return null;
}
19
View Source File : Object.Extension.cs
License : MIT License
Project Creator : 7Bytes-Studio
License : MIT License
Project Creator : 7Bytes-Studio
public static T To<T>(this object value)
{
if (value == null) return default(T);
Type tp = typeof(T);
if (tp.IsGenericType)
{
tp = tp.GetGenericArguments()[0];
}
if (tp.Name.ToLower() == "string")
{
return (T)value;
}
var TryParse = tp.GetMethod("TryParse", BindingFlags.Public | BindingFlags.Static, Type.DefaultBinder,
new Type[] { typeof(string), tp.MakeByRefType() },
new ParameterModifier[] { new ParameterModifier(2) });
var parameters = new object[] { value, Activator.CreateInstance(tp) };
bool success = (bool)TryParse.Invoke(null, parameters);
if (success)
{
return (T)parameters[1];
}
return default(T);
}
19
View Source File : Object.Extension.cs
License : MIT License
Project Creator : 7Bytes-Studio
License : MIT License
Project Creator : 7Bytes-Studio
public static object Invoke(this object instance,string methodName,Type[] argTypes,object[] args)
{
if (null == instance) return null;
var type = instance.GetType();
var key = type.FullName + methodName;
var bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
if (!s_MethodInfoDic.ContainsKey(key))
{
s_MethodInfoDic.Add(key, type.GetMethod(methodName, bindingFlags, Type.DefaultBinder, argTypes, new ParameterModifier[] { new ParameterModifier(argTypes.Length) }));
}
return s_MethodInfoDic[key].Invoke(instance, args);
}
19
View Source File : TypeUtil.cs
License : MIT License
Project Creator : Abc-Arbitrage
License : MIT License
Project Creator : Abc-Arbitrage
private static Func<IntPtr, Type>? BuildGetTypeFromHandleFunc()
{
var method = typeof(Type).GetMethod("GetTypeFromHandleUnsafe", BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(IntPtr) }, null);
if (method == null)
return null;
var param = Parameter(typeof(IntPtr));
return Lambda<Func<IntPtr, Type>>(
Call(method, param),
param
).Compile();
}
19
View Source File : LogEventTests.Append.cs
License : MIT License
Project Creator : Abc-Arbitrage
License : MIT License
Project Creator : Abc-Arbitrage
[TestCase(typeof(bool))]
[TestCase(typeof(byte))]
[TestCase(typeof(char))]
[TestCase(typeof(short))]
[TestCase(typeof(int))]
[TestCase(typeof(long))]
[TestCase(typeof(float))]
[TestCase(typeof(double))]
[TestCase(typeof(decimal))]
[TestCase(typeof(Guid))]
[TestCase(typeof(DateTime))]
[TestCase(typeof(TimeSpan))]
public void should_append_nullable(Type type)
{
typeof(LogEventTests).GetMethod(nameof(should_append_nullable), BindingFlags.Instance | BindingFlags.NonPublic, null, Type.EmptyTypes, null)
.MakeGenericMethod(type)
.Invoke(this, new object[0]);
}
19
View Source File : LogEventTests.AppendWithFormat.cs
License : MIT License
Project Creator : Abc-Arbitrage
License : MIT License
Project Creator : Abc-Arbitrage
[TestCase(typeof(byte), "X4")]
[TestCase(typeof(short), "X4")]
[TestCase(typeof(int), "X")]
[TestCase(typeof(long), "X")]
[TestCase(typeof(float), "E")]
[TestCase(typeof(double), "P3")]
[TestCase(typeof(decimal), "E04")]
[TestCase(typeof(Guid), "X")]
[TestCase(typeof(DateTime), "yyyy-MM-dd")]
[TestCase(typeof(TimeSpan), "g")]
public void should_append_nullable_with_format(Type type, string format)
{
typeof(LogEventTests).GetMethod(nameof(should_append_nullable_with_format), BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(string) }, null)
.MakeGenericMethod(type)
.Invoke(this, new object[] { format });
}
19
View Source File : FdbTuplePackers.cs
License : MIT License
Project Creator : abdullin
License : MIT License
Project Creator : abdullin
private static Delegate GetSerializerFor([NotNull] Type type)
{
if (type == null) throw new ArgumentNullException("type");
if (type == typeof(object))
{ // return a generic serializer that will inspect the runtime type of the object
return new Encoder<object>(FdbTuplePackers.SerializeObjectTo);
}
var typeArgs = new[] { typeof(TupleWriter).MakeByRefType(), type };
var method = typeof(FdbTuplePackers).GetMethod("SerializeTo", BindingFlags.Static | BindingFlags.Public, null, typeArgs, null);
if (method != null)
{ // we have a direct serializer
return method.CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
}
// maybe if it is a tuple ?
if (typeof(IFdbTuple).IsreplacedignableFrom(type))
{
method = typeof(FdbTuplePackers).GetMethod("SerializeTupleTo", BindingFlags.Static | BindingFlags.Public);
if (method != null)
{
return method.MakeGenericMethod(type).CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
}
}
if (typeof(ITupleFormattable).IsreplacedignableFrom(type))
{
method = typeof(FdbTuplePackers).GetMethod("SerializeFormattableTo", BindingFlags.Static | BindingFlags.Public);
if (method != null)
{
return method.CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
}
}
if (typeof(IFdbKey).IsreplacedignableFrom(type))
{
method = typeof(FdbTuplePackers).GetMethod("SerializeFdbKeyTo", BindingFlags.Static | BindingFlags.Public);
if (method != null)
{
return method.CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
}
}
var nullableType = Nullable.GetUnderlyingType(type);
if (nullableType != null)
{ // nullable types can reuse the underlying type serializer
method = typeof(FdbTuplePackers).GetMethod("SerializeNullableTo", BindingFlags.Static | BindingFlags.Public);
if (method != null)
{
return method.MakeGenericMethod(nullableType).CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
}
}
// TODO: look for a static SerializeTo(BWB, T) method on the type itself ?
// no luck..
return null;
}
19
View Source File : TypeHelpers.cs
License : MIT License
Project Creator : adrianoc
License : MIT License
Project Creator : adrianoc
public static MethodBase ResolveMethod(string replacedemblyName, string declaringTypeName, string methodName, BindingFlags bindingFlags, string typeArgumentList, params string[] paramTypes)
{
var containingreplacedembly = replacedembly.Load(new replacedemblyName(replacedemblyName));
var declaringType = containingreplacedembly.GetType(declaringTypeName);
if (declaringType.IsGenericType)
{
var typeArguments = typeArgumentList.Split(',');
declaringType = declaringType.MakeGenericType(typeArguments.Select(Type.GetType).ToArray());
}
if (methodName == ".ctor")
{
var resolvedCtor = declaringType.GetConstructor(
bindingFlags,
null,
paramTypes.Select(Type.GetType).ToArray(),
null);
if (resolvedCtor == null)
{
throw new InvalidOperationException($"Failed to resolve ctor [{replacedemblyName}] {declaringType}({string.Join(',', paramTypes)})");
}
return resolvedCtor;
}
var resolvedMethod = declaringType.GetMethod(methodName,
bindingFlags,
null,
paramTypes.Select(Type.GetType).ToArray(),
null);
if (resolvedMethod == null)
{
throw new InvalidOperationException($"Failed to resolve method [{replacedemblyName}] {declaringType}.{methodName}({string.Join(',', paramTypes)})");
}
return resolvedMethod;
}
19
View Source File : ReflectionExtend.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static bool HaseMethod(this Type type, string fun)
{
if (type == null
|| fun == null)
return false;
return type.GetMethod(fun, BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Public, Type.DefaultBinder, Type.EmptyTypes, null) != null;
}
19
View Source File : ProceduralWorldsGUI.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public Gradient GradientField(GUIContent content, Gradient gradient)
{
if (content != null && content.text != null)
EditorGUILayout.PrefixLabel(content);
if (gradientField == null)
{
gradientField = typeof(EditorGUILayout).GetMethod(
"GradientField",
BindingFlags.NonPublic | BindingFlags.Static,
null,
new Type[] { typeof(string), typeof(Gradient), typeof(GUILayoutOption[]) },
null
);
}
gradient = (Gradient)gradientField.Invoke(null, new object[] {"", gradient, null});
return gradient;
}
19
View Source File : SamplerSettingsPopup.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
protected override void GUIStart()
{
gradientField = typeof(EditorGUILayout).GetMethod(
"GradientField",
BindingFlags.NonPublic | BindingFlags.Static,
null,
new Type[] { typeof(string), typeof(Gradient), typeof(GUILayoutOption[]) },
null
);
}
19
View Source File : CustomShaderInspector.cs
License : MIT License
Project Creator : alexismorin
License : MIT License
Project Creator : alexismorin
public static Gradient GradientField( Gradient value, params GUILayoutOption[] options )
{
#if UNITY_2018_3_OR_NEWER
return EditorGUILayout.GradientField( value, options );
#else
MethodInfo method = EditorGUILayoutEx.Type.GetMethod( "GradientField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof( Gradient ), typeof( GUILayoutOption[] ) }, null );
return (Gradient)method.Invoke( Type, new object[]{ value, options} );
#endif
}
19
View Source File : CustomShaderInspector.cs
License : MIT License
Project Creator : alexismorin
License : MIT License
Project Creator : alexismorin
public static Gradient GradientField( string label, Gradient value, params GUILayoutOption[] options )
{
#if UNITY_2018_3_OR_NEWER
return EditorGUILayout.GradientField( label, value, options );
#else
MethodInfo method = EditorGUILayoutEx.Type.GetMethod( "GradientField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof( string ), typeof( Gradient ), typeof( GUILayoutOption[] ) }, null );
return (Gradient)method.Invoke( Type, new object[] { label, value, options } );
#endif
}
19
View Source File : AnkhErrorHandler.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
public void Invoke(Exception ex, ExceptionInfo info)
{
try
{
// BH: Uses reflection to find the best match based on the exception??
Type t = typeof(HandlerDelegator);
MethodInfo method = t.GetMethod("DoHandle", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { ex.GetType(), typeof(ExceptionInfo) }, null);
if (method != null)
method.Invoke(this, new object[] { ex, info });
else
DoHandle(ex, info);
}
catch (Exception x)
{
Debug.WriteLine(x);
}
}
19
View Source File : DiscoveryClientListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(DiscoveryClientListener));
return hasDerivedMethod;
}
19
View Source File : FloatArrayListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(FloatArrayListener));
return hasDerivedMethod;
}
19
View Source File : IntArrayListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(IntArrayListener));
return hasDerivedMethod;
}
19
View Source File : LogWriter.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(LogWriter));
return hasDerivedMethod;
}
19
View Source File : NetworkConnectionListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(NetworkConnectionListener));
return hasDerivedMethod;
}
19
View Source File : SessionManagerListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(SessionManagerListener));
return hasDerivedMethod;
}
19
View Source File : ObjectElementListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(ObjectElementListener));
return hasDerivedMethod;
}
19
View Source File : RoomManagerListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(RoomManagerListener));
return hasDerivedMethod;
}
19
View Source File : UserPresenceManagerListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(UserPresenceManagerListener));
return hasDerivedMethod;
}
19
View Source File : PairingListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(PairingListener));
return hasDerivedMethod;
}
19
View Source File : PairMaker.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(PairMaker));
return hasDerivedMethod;
}
19
View Source File : SessionListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(SessionListener));
return hasDerivedMethod;
}
19
View Source File : StringArrayListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(StringArrayListener));
return hasDerivedMethod;
}
19
View Source File : SyncListener.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
private bool SwigDerivedClreplacedHasMethod(string methodName, global::System.Type[] methodTypes) {
global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclreplacedOf(typeof(SyncListener));
return hasDerivedMethod;
}
19
View Source File : TypeExtensions.cs
License : MIT License
Project Creator : anet-team
License : MIT License
Project Creator : anet-team
public static MethodInfo GetPublicInstanceMethod(this Type type, string name, Type[] types)
{
#if NETSTANDARD1_3 || NETCOREAPP1_0
var method = type.GetMethod(name, types);
return (method?.IsPublic == true && !method.IsStatic) ? method : null;
#else
return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public, null, types, null);
#endif
}
19
View Source File : ParseableSerializer.cs
License : MIT License
Project Creator : AnotherEnd15
License : MIT License
Project Creator : AnotherEnd15
public static ParseableSerializer TryCreate(Type type, TypeModel model)
{
if (type == null) throw new ArgumentNullException("type");
#if PORTABLE || COREFX || PROFILE259
MethodInfo method = null;
#if COREFX || PROFILE259
foreach (MethodInfo tmp in type.GetTypeInfo().GetDeclaredMethods("Parse"))
#else
foreach (MethodInfo tmp in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly))
#endif
{
ParameterInfo[] p;
if (tmp.Name == "Parse" && tmp.IsPublic && tmp.IsStatic && tmp.DeclaringType == type && (p = tmp.GetParameters()) != null && p.Length == 1 && p[0].ParameterType == typeof(string))
{
method = tmp;
break;
}
}
#else
MethodInfo method = type.GetMethod("Parse",
BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly,
null, new Type[] { model.MapType(typeof(string)) }, null);
#endif
if (method != null && method.ReturnType == type)
{
if (Helpers.IsValueType(type))
{
MethodInfo toString = GetCustomToString(type);
if (toString == null || toString.ReturnType != model.MapType(typeof(string))) return null; // need custom ToString, fools
}
return new ParseableSerializer(method);
}
return null;
}
19
View Source File : Helpers.cs
License : MIT License
Project Creator : AnotherEnd15
License : MIT License
Project Creator : AnotherEnd15
internal static MethodInfo GetInstanceMethod(Type declaringType, string name, Type[] types)
{
if (types == null) types = EmptyTypes;
#if PORTABLE || COREFX
MethodInfo method = declaringType.GetMethod(name, types);
if (method != null && method.IsStatic) method = null;
return method;
#else
return declaringType.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, types, null);
#endif
}
19
View Source File : Utils.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static object InvokeMethod(object target, string name, params object[] args)
{
#if NETSTANDARD1_3
return target.GetType().GetTypeInfo().GetDeclaredMethod(name).Invoke(target, args);
#else
return target.GetType().GetMethod(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, GetTypesArray(args), null).Invoke(target, args);
#endif
}
19
View Source File : Utils.cs
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static object InvokeMethod(Type target, string name, params object[] args)
{
#if NETSTANDARD1_3
return target.GetTypeInfo().GetDeclaredMethod(name).Invoke(null, args);
#else
return target.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, GetTypesArray(args), null).Invoke(null, args);
#endif
}
19
View Source File : Utility.cs
License : MIT License
Project Creator : aprilyush
License : MIT License
Project Creator : aprilyush
public static object GetMethodResult(object container, string methodName, out bool exist)
{
exist = false;
Type type = (container is Type ? (Type)container : container.GetType());
MethodInfo method = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.Instance |
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.IgnoreCase,
null, Type.EmptyTypes, new ParameterModifier[0]);
object result = null;
if (method != null)
{
exist = true;
return method.Invoke(method.IsStatic ? null : container, null);
}
return result;
}
19
View Source File : FunctionTag.cs
License : MIT License
Project Creator : aprilyush
License : MIT License
Project Creator : aprilyush
private object GetFunctionResult()
{
//计算表达式的值
object value = null;
List<object> funcParams = new List<object>();
List<Type> funcParamsTypes = new List<Type>();
foreach (IExpression exp in this.FunctionArgs)
{
object expValue = exp.GetValue();
funcParams.Add(expValue);
funcParamsTypes.Add(expValue == null ? typeof(object) : expValue.GetType());
}
string invokeMethod = this.Method.GetTextValue();
if (this.Type == null)
{
//调用自定义函数
UserDefinedFunction func;
if (this.OwnerTemplate.UserDefinedFunctions.TryGetValue(invokeMethod, out func))
{
value = func(funcParams.ToArray());
}
}
else
{
//如果类型定义的是变量表达式则获取表达式的值,否则建立类型
object container = this.Type.Value is VariableExpression ? this.Type.Value.GetValue() : Utility.CreateType(this.Type.Value.GetValue().ToString());
if (container != null)
{
System.Type type = container is System.Type ? (System.Type)container : container.GetType();
BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.IgnoreCase;
if (!(container is System.Type)) flags |= BindingFlags.Instance;
MethodInfo method = type.GetMethod(invokeMethod, flags, null, funcParamsTypes.ToArray(), null);
if (method == null)
{
//获取所有同名的方法
MemberInfo[] methods = type.GetMember(invokeMethod, flags | BindingFlags.InvokeMethod);
foreach (MethodInfo m in methods)
{
ParameterInfo[] parameters = m.GetParameters();
if (parameters.Length == 1
&& parameters[0].ParameterType.IsArray
&& parameters[0].ParameterType.FullName == "System.Object[]")
{
//如果函数只有一个参数,并且是Object数组参数
try
{
value = m.Invoke(container is System.Type ? null : container, new object[] { funcParams.ToArray() });
//不出错.则退出查找
break;
}
catch (TargetInvocationException e)
{
throw new Exception(string.Format("在执行标签“{0}”的方法时出错", this.ToString()), e);
}
catch { }
}
else if (parameters.Length == funcParams.Count)
{
//尝试转换类型
List<object> paramValues = new List<object>();
for (var i = 0; i < parameters.Length; i++)
{
object v = funcParams[i];
if (parameters[i].ParameterType != funcParamsTypes[i] && v != null)
{
v = Utility.ConvertTo(funcParams[i].ToString(), parameters[i].ParameterType);
if (v == null) break; //转换失败则尝试下一个方法
paramValues.Add(v);
}
else
{
paramValues.Add(v);
}
}
if (paramValues.Count == parameters.Length)
{
try
{
value = m.Invoke(container is System.Type ? null : container, paramValues.ToArray());
//不出错.则退出查找
break;
}
catch (TargetInvocationException e)
{
throw new Exception(string.Format("在执行标签“{0}”的方法时出错", this.ToString()), e);
}
catch { }
}
paramValues.Clear();
}
}
}
else
{
//执行方法
try
{
value = method.Invoke(container is System.Type ? null : container, funcParams.ToArray());
}
catch (TargetInvocationException e)
{
throw new Exception(string.Format("在执行标签“{0}”的方法时出错", this.ToString()), e);
}
catch
{
value = null;
}
}
}
}
return value;
}
19
View Source File : Utility.cs
License : MIT License
Project Creator : aprilyush
License : MIT License
Project Creator : aprilyush
public static object GetPropertyValue(object container, string propName, out bool exist)
{
exist = false;
object value = null;
if (container == null)
{
throw new ArgumentNullException("container");
}
if (string.IsNullOrEmpty(propName))
{
throw new ArgumentNullException("propName");
}
if (Utility.IsInteger(propName))
{
#region 索引值部分
//属性名只为数字.则取数组索引
int index = Utility.ConverToInt32(propName);
if (container is IList)
{
IList iList = (IList)container;
if (iList.Count > index)
{
exist = true;
value = iList[index];
}
}
else if (container is ICollection)
{
ICollection ic = (ICollection)container;
if (ic.Count > index)
{
exist = true;
IEnumerator ie = ic.GetEnumerator();
int i = 0;
while (i++ <= index) { ie.MoveNext(); }
value = ie.Current;
}
}
else
{
//判断是否含有索引属性
PropertyInfo item = container.GetType().GetProperty("Item", new Type[] { typeof(int) });
if (item != null)
{
try
{
value = item.GetValue(container, new object[] { index });
exist = true;
}
catch
{
exist = false;
}
}
}
#endregion
}
else
{
#region 字段/属性/键值
//容器是类型.则查找静态属性或字段
Type type = container is Type ? (Type)container : container.GetType();
BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.IgnoreCase;
if (!(container is Type)) flags |= BindingFlags.Instance;
//查找字段
FieldInfo field = type.GetField(propName, flags);
if (field != null)
{
exist = true;
value = field.GetValue(container);
}
else
{
//查找属性
PropertyInfo property = type.GetProperty(propName, flags, null, null, Type.EmptyTypes, new ParameterModifier[0]);
if (property != null)
{
exist = true;
value = property.GetValue(container, null);
}
else if (container is ICustomTypeDescriptor)
{
//已实现ICustomTypeDescriptor接口
ICustomTypeDescriptor ictd = (ICustomTypeDescriptor)container;
PropertyDescriptor descriptor = ictd.GetProperties().Find(propName, true);
if (descriptor != null)
{
exist = true;
value = descriptor.GetValue(container);
}
}
else if (container is IDictionary)
{
//是IDictionary集合
IDictionary idic = (IDictionary)container;
if (idic.Contains(propName))
{
exist = true;
value = idic[propName];
}
}
else if (container is NameObjectCollectionBase)
{
//是NameObjectCollectionBase派生对象
NameObjectCollectionBase nob = (NameObjectCollectionBase)container;
//调用私有方法
MethodInfo method = nob.GetType().GetMethod("BaseGet", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string) }, new ParameterModifier[] { new ParameterModifier(1) });
if (method != null)
{
value = method.Invoke(container, new object[] { propName });
exist = value != null;
}
}
else
{
//判断是否含有索引属性
PropertyInfo item = type.GetProperty("Item", new Type[] { typeof(string) });
if (item != null)
{
try
{
value = item.GetValue(container, new object[] { propName });
exist = true;
}
catch
{
exist = false;
}
}
}
}
#endregion
}
return value;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : askguanyu
License : MIT License
Project Creator : askguanyu
private static void Main(string[] args)
{
//// args[0] = AddInDomain replacedembly path
//// args[1] = GUID
//// args[2] = PID
//// args[3] = AddInDomainSetup file
//// args[4] = Redirect output or not
if (args.Length < 4)
{
ProgramInternalLogger.Log(true, new ArgumentNullException("args"));
Console.WriteLine(@"
args[0] = AddInDomain replacedembly path
args[1] = GUID
args[2] = PID
args[3] = AddInDomainSetup file
args[4] = Redirect output or not");
return;
}
bool redirectOutput = false;
bool.TryParse(args[4], out redirectOutput);
try
{
ProgramInternalLogger.Log(redirectOutput, "AddInDomain is started");
ProgramInternalLogger.Log(redirectOutput, Environment.CommandLine);
Dictionary<replacedemblyName, string> resolveDict = new Dictionary<replacedemblyName, string>();
resolveDict.Add(new replacedemblyName("$[AddInreplacedemblyName]"), args[0]);
replacedemblyResolver resolver = new replacedemblyResolver(resolveDict);
resolver.Mount();
Type hostType = Type.GetType("$[AddInActivatorHostTypeName]");
if (hostType != null)
{
ProgramInternalLogger.Log(redirectOutput, "Succeeded: Type.GetType($[AddInActivatorHostTypeName])");
}
else
{
ProgramInternalLogger.Log(redirectOutput, string.Format("Could not load AddInActivatorHost type $[AddInActivatorHostTypeName] by using resolver with $[AddInreplacedemblyName] mapped to {0}", args[0]));
throw new TypeLoadException(string.Format("Could not load AddInActivatorHost type $[AddInActivatorHostTypeName] by using resolver with $[AddInreplacedemblyName] mapped to {0}", args[0]));
}
MethodInfo methodInfo = hostType.GetMethod("Run", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string[]) }, null);
if (methodInfo != null)
{
ProgramInternalLogger.Log(redirectOutput, "Succeeded: GetMethod on AddInActivatorHost");
}
else
{
ProgramInternalLogger.Log(redirectOutput, "'Run' method on AddInActivatorHost was not found.");
throw new Exception("'Run' method on AddInActivatorHost was not found.");
}
ProgramInternalLogger.Log(redirectOutput, "Begin Invoke AddInActivatorHost method.");
methodInfo.Invoke(null, new object[] { args });
}
catch (Exception e)
{
ProgramInternalLogger.Log(redirectOutput, string.Format("Summary: Failed to launch AddInActivatorHost:\r\n{0}", e.ToString()));
}
}
19
View Source File : Utils.cs
License : MIT License
Project Creator : aspnet
License : MIT License
Project Creator : aspnet
private static string ServerMapPath(string path)
{
if (s_hostingEnvironmentType == null)
return path;
MethodInfo mapPath = s_hostingEnvironmentType.GetMethod("MapPath", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, null);
if (mapPath == null)
return path;
return (string)mapPath.Invoke(null, new object[] { path });
}
19
View Source File : TypeExtensions.cs
License : MIT License
Project Creator : ay2015
License : MIT License
Project Creator : ay2015
public static MethodInfo GetPublicInstanceMethod(this Type type, string name, Type[] types)
{
return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public, null, types, null);
}
See More Examples