Exemple #1
0
        private static Value GetTag(CallScope args)
        {
            Item  item = ScopeExtensions.FindScope <Item>(args);
            Value val  = null;

            if (args.Size == 1)
            {
                if (args[0].Type == ValueTypeEnum.String)
                {
                    val = item.GetTag(args.Get <string>(0));
                }
                else if (args[0].Type == ValueTypeEnum.Mask)
                {
                    val = item.GetTag(args.Get <Mask>(0));
                }
                else
                {
                    throw new RuntimeError(String.Format(RuntimeError.ErrorMessageExpectedStringOrMaskForArgument1ButReceivedSmth, args[0].ToString()));
                }
            }
            else if (args.Size == 2)
            {
                if (args[0].Type == ValueTypeEnum.Mask && args[1].Type == ValueTypeEnum.Mask)
                {
                    val = item.GetTag(args.Get <Mask>(0), args.Get <Mask>(1));
                }
                else
                {
                    throw new RuntimeError(String.Format(RuntimeError.ErrorMessageExpectedMasksForArguments1and2ButReceivedSmthAndSmth, args[0].ToString(), args[1].ToString()));
                }
            }
            else if (args.Size == 0)
            {
                throw new RuntimeError(RuntimeError.ErrorMessageTooFewArgumentsToFunction);
            }
            else
            {
                throw new RuntimeError(RuntimeError.ErrorMessageTooManyArgumentsToFunction);
            }

            return(Value.IsNullOrEmptyOrFalse(val) ? Value.Empty : val);
        }
Exemple #2
0
 private static Value GetWrapper(CallScope scope, Func <Xact, Value> func)
 {
     return(func(ScopeExtensions.FindScope <Xact>(scope)));
 }