Beispiel #1
0
        public bool TryParse(GameCache cache, List <string> args, out IBounds result, out string error)
        {
            result = null;
            error  = null;

            var argType  = GetType().GenericTypeArguments[0];
            var argCount = SetFieldCommand.RangeArgCount(argType);

            if (argCount * 2 != args.Count)
            {
                error = $"{args.Count} arguments supplied; should be {argCount * 2}";
                return(false);
            }

            var min = SetFieldCommand.ParseArgs(cache, argType, null, args.Take(argCount).ToList());
            var max = SetFieldCommand.ParseArgs(cache, argType, null, args.Skip(argCount).Take(argCount).ToList());

            if (min.Equals(false) || max.Equals(false))
            {
                error = $"Invalid value parsed.";
                return(false);
            }

            result = Activator.CreateInstance(this.GetType(), new object[] { min, max }) as IBounds;
            return(true);
        }
Beispiel #2
0
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;
            var argType  = this.GetType().GenericTypeArguments[0];
            var argCount = SetFieldCommand.RangeArgCount(argType);

            if (argCount * 2 != args.Count)
            {
                error = $"{args.Count} arguments supplied; should be {argCount * 2}";
                return(false);
            }

            var min = SetFieldCommand.ParseArgs(cacheContext, argType, null, args.Take(argCount).ToList());

            if (min.Equals(false))
            {
                error = $"{min} (min) is `false`";
                return(false);
            }

            var max = SetFieldCommand.ParseArgs(cacheContext, argType, null, args.Skip(argCount).Take(argCount).ToList());

            if (max.Equals(false))
            {
                error = $"{max} (max) is `false`";
                return(false);
            }

            result = Activator.CreateInstance(this.GetType(), new object[] { min, max }) as IBlamType;
            error  = null;
            return(true);
        }
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;

            if (args.Count != 2)
            {
                error = $"{args.Count} arguments supplied; should be 2";
                return(false);
            }
            else
            {
                var cacheAddressType = SetFieldCommand.ParseArgs(cacheContext, typeof(CacheResourceAddressType), null, args.Take(1).ToList());
                if (!(cacheAddressType is CacheResourceAddressType))
                {
                    error = $"Failed to parse `{args[0]}` as `CacheAddressType`";
                    return(false);
                }
                else if (!int.TryParse(args[1], out int offset))
                {
                    error = $"Failed to parse `{args[1]}` as `int` (offset).";
                    return(false);
                }
                else
                {
                    result = new CacheResourceAddress((cacheAddressType as CacheResourceAddressType?).Value, offset);
                    error  = null;
                    return(true);
                }
            }
        }