static public IsFingerEquivolentOperation CreateIsFingerEquivolentOperation(this Type item) { MethodInfoEX equals_ex_method = typeof(TypeExtensions_Finger_Create).GetStaticMethod <object, object>("EqualsEX"); return(item.CreateDynamicMethodDelegate <IsFingerEquivolentOperation>("IsFingerEquivolent_" + item.Name, delegate(MethodBase method) { ILBlock body = new ILBlock(); ILLocal obj1 = body.CreateNamedLocal(item, "obj1", method.GetTechnicalILParameter(0)); ILLocal obj2 = body.CreateNamedLocal(item, "obj2", method.GetTechnicalILParameter(1)); body.AddStatement(new ILIf( obj1.GetILIsNotNull()& obj2.GetILIsNotNull(), new ILBlock(delegate(ILBlock block) { foreach (FieldInfo field in item.GetAllInstanceFields()) { block.AddStatement(new ILIf( equals_ex_method.GetStaticILMethodInvokation( obj1.GetILField(field), obj2.GetILField(field) ).GetILIsFalse(), new ILReturn(false) )); } block.AddStatement(new ILReturn(true)); }) )); body.AddStatement(new ILReturn(false)); return body; })); }
static public bool InspectAdd(this IEnumerable item, object value) { if (item != null) { MethodInfoEX method = item.GetType().GetFilteredInstanceMethods( Filterer_MethodInfo.IsNamed("Add"), Filterer_MethodInfo.HasOneEffectiveParameter() ).GetFirst(); if (method != null) { if (value == null) { value = method.GetEffectiveParameterType(0).GetDefaultValue(); } method.Invoke(item, new object[] { value }); return(true); } return(item.InspectInsert( item.InspectCount(), value )); } return(false); }
private PropInfoEX HydrateAsMethodPair(HuskReader reader) { MethodInfoEX set_method = MethodInfoEXHusker.INSTANCE.Hydrate(reader); MethodInfoEX get_method = MethodInfoEXHusker.INSTANCE.Hydrate(reader); return(new PropInfoEX_MethodPair(set_method, get_method)); }
static public Function_MethodInfo New(string name, PathResolver path_resolver, IEnumerable <Type> parameter_types) { MethodInfoEX method = path_resolver.GetOutputType().GetInstanceMethod(name, parameter_types); if (method != null) { return(new Function_MethodInfo(method)); } return(null); }
static public Function_MethodInfo New(Type type, string name, IEnumerable <Type> parameter_types) { MethodInfoEX method = type.GetInstanceMethod(name, parameter_types); if (method != null) { return(new Function_MethodInfo(method)); } return(null); }
public Function_MethodInfo(MethodInfoEX m) : base( m.IfNotNull(z => z.DeclaringType), m.IfNotNull(z => z.ReturnType), m.IfNotNull(z => z.GetEffectiveParameters().Convert(p => KeyValuePair.New(p.Name, p.ParameterType))) ) { name = m.IfNotNull(z => z.Name); invoker = m.IfNotNull(z => z.GetBasicMethodInvoker()); method = m; }
static public bool InspectRemoveAt(this IEnumerable item, int index) { if (item != null) { MethodInfoEX method = item.GetType().GetFilteredInstanceMethods( Filterer_MethodInfo.IsNamed("RemoveAt"), Filterer_MethodInfo.CanEffectiveParametersHold <int>() ).GetFirst(); if (method != null) { method.Invoke(item, new object[] { index }); return(true); } } return(false); }
static public bool InspectRemove(this IEnumerable item, object value) { if (item != null) { MethodInfoEX method = item.GetType().GetFilteredInstanceMethods( Filterer_MethodInfo.IsNamed("Remove"), Filterer_MethodInfo.HasOneEffectiveParameter() ).GetFirst(); if (method != null) { method.Invoke(item, new object[] { value }); return(true); } } return(false); }
static public bool InspectInsert(this IEnumerable item, int index, object value) { if (item != null) { MethodInfoEX method = item.GetType().GetFilteredInstanceMethods( Filterer_MethodInfo.IsNamed("Insert"), Filterer_MethodInfo.CanNthEffectiveParameterHold(0, typeof(int)), Filterer_MethodInfo.HasTwoEffectiveParameters() ).GetFirst(); if (method != null) { if (value == null) { value = method.GetEffectiveParameterType(1).GetDefaultValue(); } method.Invoke(item, new object[] { index, value }); return(true); } } return(false); }
static public FingerPrintOperation CreateFingerPrintOperation(this Type item) { MethodInfoEX get_hash_code_ex_method = typeof(TypeExtensions_Finger_Create).GetStaticMethod <object>("GetHashCodeEX"); return(item.CreateDynamicMethodDelegate <FingerPrintOperation>("FingerPrint_" + item.Name, delegate(MethodBase method){ ILBlock body = new ILBlock(); ILLocal obj = body.CreateNamedLocal(item, "this", method.GetTechnicalILParameter(0)); ILLocal hash = body.CreateNamedLocal(typeof(int), "hash", 17); foreach (FieldInfo field in item.GetAllInstanceFields()) { body.AddStatement( new ILAssign( hash, hash * 23 + get_hash_code_ex_method.GetStaticILMethodInvokation(obj.GetILField(field)) ) ); } body.AddStatement(new ILReturn(hash)); return body; })); }
static public Variable CreateVariable(this MethodInfoEX item) { return(new Variable_Prop(item.CreatePropInfo())); }
static public Function CreateFunction(this MethodInfoEX item) { return(new Function_MethodInfo(item)); }
static public Action CreateAction(this MethodInfoEX item, params object[] arguments) { return(item.CreateAction((IEnumerable <object>)arguments)); }
static public Action CreateAction(this MethodInfoEX item, IEnumerable <object> arguments) { return(item.CreateFunction().CreateAction(arguments)); }