예제 #1
0
파일: Bounds.cs 프로젝트: Pedro413/TagTool
        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);
        }
예제 #2
0
파일: Bounds.cs 프로젝트: jaron780/TagTool
        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);
        }