public AcceptTyperActionsAttribute(params TyperAction[] actions) { foreach (var action in actions) { Actions |= action; } }
public static object InvokeActionMethod(this ITyperRef objRef, TyperAction action, params object[] objects) { var method = objRef.GetActionMethod(action); if (method == null) { return(null); } return(method.Invoke(objRef, objects)); }
public static bool AcceptTyperAction(this Type type, TyperAction action) { var attribute = type.GetCustomAttribute <AcceptTyperActionsAttribute>(false); if (attribute == null && action == TyperAction.None) { return(true); } return(attribute != null && attribute.Actions.HasFlag(action)); }
public Type GetRefTyper(string key, string typerName = null, TyperAction action = TyperAction.None) { typerName = typerName?.ToLower() ?? CurrentTyperName; if (typerName == null) { return(null); } var typer = GetTyper(typerName); return(GetRefTyper(key, typer, action)); }
public static MethodInfo GetActionMethod(this Type refType, TyperAction action) { var methods = refType.GetMethods(); foreach (var method in methods) { var attribute = method.GetCustomAttribute <AcceptTyperActionsAttribute>(false); if (attribute == null) { continue; } if (attribute.Actions.HasFlag(action)) { return(method); } } return(null); }
public AcceptTyperActionsAttribute(bool none = false) { if (none) { Actions |= TyperAction.None; } else { foreach (var action in Enum.GetValues(typeof(TyperAction))) { if (action.Equals(TyperAction.None)) { continue; } Actions |= (TyperAction)action; } } }
public Type GetRefTyper(string key, Type typer = null, TyperAction action = TyperAction.None) { typer = typer ?? CurrentTyper; if (typer == null) { return(null); } SetCurrentTyper(typer); var listTypeName = CurrentTyperName + action.ToString(); if (TyperConfigurarion.ListedRefTypers[key].ContainsKey(listTypeName)) { return(TyperConfigurarion.ListedRefTypers[key].GetValueOrDefault(listTypeName)); } var refTyper = GetRefTypers(key).FindRefTypers(typer, action); TyperConfigurarion.ListedRefTypers[key].Add(listTypeName, refTyper); return(refTyper); }
public static object InoveActionMethod(Type refType, TyperAction action, params object[] objects) { return(refType.InvokeActionMethod(action, objects)); }
public static MethodInfo GetActionMethod(Type refType, TyperAction action) { return(refType.GetActionMethod(action)); }
public Type GetRefTyper(string key, TyperAction action = TyperAction.None) { return(GetRefTyper(key, CurrentTyper, action)); }
//public static Type GetRefTyper(this ITyperEntity entity, string key, TyperAction action = TyperAction.None) //{ // return Typer.GetRefTyper(key, entity.GetType(), action); //} //public static Object GetRefObj(this ITyperEntity domainObj, string key, TyperAction action = TyperAction.None) //{ // var refType = domainObj.GetRefTyper(key, action); // if (refType == null) // return null; // return refType.CreateInstance(); //} public static MethodInfo GetActionMethod(this ITyperRef objRef, TyperAction action) { return(objRef.GetType().GetActionMethod(action)); }
public static Type FindRefTypers(this IEnumerable <Type> types, Type domainType, TyperAction action = TyperAction.None) { var likeTypes = types .Where(t => t.GetCustomAttribute <TyperReferenceAttribute>() != null); foreach (var type in likeTypes) { if (!type.HasTyper(domainType)) { continue; } if (action == TyperAction.None || type.AcceptTyperAction(action)) { return(type); } } return(null); }
public static object InvokeActionMethod(this Type refType, TyperAction action, params object[] @params) { var objRef = refType.CreateInstance() as ITyperRef; return(objRef.InvokeActionMethod(action, @params)); }