Esempio n. 1
0
 public AcceptTyperActionsAttribute(params TyperAction[] actions)
 {
     foreach (var action in actions)
     {
         Actions |= action;
     }
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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;
                }
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public static object InoveActionMethod(Type refType, TyperAction action, params object[] objects)
 {
     return(refType.InvokeActionMethod(action, objects));
 }
Esempio n. 9
0
 public static MethodInfo GetActionMethod(Type refType, TyperAction action)
 {
     return(refType.GetActionMethod(action));
 }
Esempio n. 10
0
 public Type GetRefTyper(string key, TyperAction action = TyperAction.None)
 {
     return(GetRefTyper(key, CurrentTyper, action));
 }
Esempio n. 11
0
        //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));
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        public static object InvokeActionMethod(this Type refType, TyperAction action, params object[] @params)
        {
            var objRef = refType.CreateInstance() as ITyperRef;

            return(objRef.InvokeActionMethod(action, @params));
        }