IsCallable() static private méthode

static private IsCallable ( object obj ) : bool
obj object
Résultat bool
Exemple #1
0
        /// <summary>
        /// Returns the value as a callable (if it is callable, else returns Callable.Nil).
        /// </summary>
        public Callable ToCallable()
        {
            if (!Callable.IsCallable(RefVal))
            {
                return(Callable.Nil);
            }

            return(new Callable()
            {
                Val = RefVal
            });
        }
Exemple #2
0
        /// <summary>
        /// Attempts to cast to a Table or UserData type,
        /// returning <c>null</c> on failure.
        /// </summary>
        public T As <T>()
            where T : class
        {
            var val = RefVal;

            if (val == NumTypeTag ||
                val == TrueTag || val == FalseTag ||
                val is byte[] ||
                Callable.IsCallable(val))
            {
                return(null);
            }

            var asWrapper = val as UserDataWrapper;

            if (asWrapper != null)
            {
                val = asWrapper.Value;
            }

            return(val as T);
        }
Exemple #3
0
        /// <summary>
        /// Gets the value as userdata (if it is userdata, else returns nil).
        /// Note that builtin types don't count as userdata.
        /// </summary>
        public object ToUserData()
        {
            if (RefVal == null || RefVal == TrueTag ||
                RefVal == FalseTag || RefVal == NumTypeTag)
            {
                return(null);
            }

            if (RefVal is byte[] || RefVal is Table ||
                Callable.IsCallable(RefVal))
            {
                return(null);
            }

            var asWrapper = RefVal as UserDataWrapper;

            if (asWrapper != null)
            {
                return(asWrapper.Value);
            }

            return(RefVal);
        }