Ejemplo n.º 1
0
        public object ExecuteFunction(string funcname, object[] args, InputContext context)
        {
            switch (funcname)
            {
            case "f:substring":
                if (args.Length > 2)
                {
                    return(Substring(ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsInt(args[1]), ExCasts.GetObjectAsInt(args[2])));
                }
                return(Substring(ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsInt(args[1])));

            case "f:length":
                return(Length(ExCasts.GetObjectAsString(args[0])));

            case "f:comma":
                return(Comma(ExCasts.UnwrapStringArray(args)));

            case "f:commaand":
                return(CommaAnd(ExCasts.UnwrapStringArray(args)));

            case "f:replace":
                return(Replace(ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsString(args[1]), ExCasts.GetObjectAsString(args[2])));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }
Ejemplo n.º 2
0
 public string SubstringRuntime(object[] args)
 {
     if (args.Length > 2)
     {
         return(Substring(
                    ExCasts.GetObjectAsString(args[0]),
                    ExCasts.GetObjectAsInt(args[1]),
                    ExCasts.GetObjectAsInt(args[2])));
     }
     return(Substring(
                ExCasts.GetObjectAsString(args[0]),
                ExCasts.GetObjectAsInt(args[1])));
 }
Ejemplo n.º 3
0
 public object[] SubsetRuntime(object[] args)
 {
     if (args.Length > 2)
     {
         return(Subset(
                    (object[])args[0],
                    ExCasts.GetObjectAsInt(args[1]),
                    ExCasts.GetObjectAsInt(args[2])));
     }
     return(Subset(
                (object[])args[0],
                ExCasts.GetObjectAsInt(args[1])));
 }
Ejemplo n.º 4
0
        public object ExecuteFunction(string funcname, object[] args, InputContext context)
        {
            switch (funcname)
            {
            case "f:random":
                return(RandomDouble(ExCasts.GetObjectAsDouble(args[0]), ExCasts.GetObjectAsDouble(args[1]), context.Random));

            case "f:randomint":
                return(RandomInt(ExCasts.GetObjectAsInt(args[0]), ExCasts.GetObjectAsInt(args[1]), context.Random));

            case "f:roll":
                return(Roll(ExCasts.GetObjectAsInt(args[0]), ExCasts.GetObjectAsInt(args[1]), context.Random));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }
Ejemplo n.º 5
0
        public object ExecuteFunction(string funcname, object[] args, InputContext context)
        {
            switch (funcname)
            {
            case "f:subset":
                if (args.Length > 2)
                {
                    return(Subset(
                               ExCasts.InspectObjectForObjectArray(args[0]),
                               ExCasts.GetObjectAsInt(args[1]),
                               ExCasts.GetObjectAsInt(args[2])));
                }
                return(Subset(
                           ExCasts.InspectObjectForObjectArray(args[0]),
                           ExCasts.GetObjectAsInt(args[1])));

            case "f:length":
                return(Length(args));

            case "f:append":
                return(Append(
                           ExCasts.InspectObjectForObjectArray(args[0]),
                           ExCasts.UnwrapAtRuntime(args[1])
                           ));

            case "f:insert":
                return(Insert(
                           ExCasts.InspectObjectForObjectArray(args[0]),
                           ExCasts.UnwrapAtRuntime(args[1]),
                           ExCasts.GetObjectAsInt(args[2])
                           ));

            case "f:remove":
                return(Remove(
                           ExCasts.InspectObjectForObjectArray(args[0]),
                           ExCasts.GetObjectAsInt(args[1])
                           ));

            default:
                throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'");
            }
        }