//internal for testing
        internal static dynamic EstablishModel(IDictionary <string, object> args, ModelIsArgumentAttribute attr = null)
        {
            dynamic currentModel = null;

            if (args.Count > 1)
            {
                if (attr != null)
                {
                    if (attr.ParameterName != null)
                    {
                        currentModel = args.Where(p => p.Key == attr.ParameterName).Select(d => d.Value).FirstOrDefault();
                    }
                    else
                    {
                        currentModel = args.Values.Skip(attr.Position).Take(1).FirstOrDefault();
                    }
                }
            }

            if (currentModel == null)
            {
                //we setup the first param as the model
                currentModel = args.Values.FirstOrDefault();
            }

            //if model is a value type ignore
            if (currentModel != null)
            {
                var tp = (Type)currentModel.GetType();

                if (!tp.IsUserDefinedClass())
                {
                    currentModel = null;
#if DEBUG
                    Debug.WriteLine("Action argument which is not an object is ignored by SmartController");
#endif
                }
            }

            return(currentModel);
        }
        //internal for testing
        internal static dynamic EstablishModel(IDictionary<string, object> args, ModelIsArgumentAttribute attr = null)
        {
            dynamic currentModel = null;
            if (args.Count > 1)
            {
                if (attr != null)
                {
                    if (attr.ParameterName != null)
                    {
                        currentModel = args.Where(p => p.Key == attr.ParameterName).Select(d => d.Value).FirstOrDefault();
                    }
                    else
                    {
                        currentModel = args.Values.Skip(attr.Position).Take(1).FirstOrDefault();
                    }
                }
            }

            if (currentModel == null)
            {
                //we setup the first param as the model
                currentModel = args.Values.FirstOrDefault();
            }

            //if model is a value type ignore
            if (currentModel != null)
            {

                var tp = (Type)currentModel.GetType();
                
                if (!tp.IsUserDefinedClass())
                {
                    currentModel = null;
#if DEBUG
                    Debug.WriteLine("Action argument which is not an object is ignored by SmartController");
#endif
                }

            }

            return currentModel;
        }