示例#1
0
        private static object Decode(Type type, string raw, GameStruct instance)
        {
            var parser      = new LLParser(instance.GetParserSense(), raw);
            var description = GeometryDashApi.GetStructMemberCache(type);

            Span <char> next     = null;
            var         position = -1;

            while ((next = parser.Next()) != null)
            {
                position++;
                var value = next.ToString();
                if (!description.Members.TryGetValue(position, out var member))
                {
                    throw new Exception($"Can't find member for position: {position}");
                }

                if (member.ArraySeparatorAttribute != null)
                {
                    member.SetValue(instance, ArrayParser.Decode(member.MemberType, member.ArraySeparatorAttribute.Separator, value));
                    continue;
                }

                member.SetValue(instance, GeometryDashApi.GetStringParser(member.MemberType)(value));
            }

            return(instance);
        }
        public ServerResponse(HttpStatusCode statusCode, string body)
        {
            HttpStatusCode = statusCode;
            raw            = body;
            var match = StatusCodeMatcher.Match(body);

            if (match.Success)
            {
                GeometryDashStatusCode = int.Parse(match.Value);
            }
            else
            {
                value = (T)GeometryDashApi.GetStringParser(typeof(T))(body);
            }
        }
示例#3
0
        public static object Decode(Type type, string separator, string raw)
        {
            var instance = Activator.CreateInstance(type);
            var argument = type.GetGenericArguments()[0];
            var parser   = new LLParser(separator, raw);

            Span <char> next = null;
            var         add  = type.GetMethod("Add");

            while ((next = parser.Next()) != null)
            {
                add !.Invoke(instance, new object[] { GeometryDashApi.GetStringParser(argument)(next.ToString()) });
            }
            return(instance);
        }
示例#4
0
 public static void Invoke()
 {
     GeometryDashApi.RegisterBlockType(typeof(MyShakeTrigger), true);
     var levels = new LocalLevels();
     var level  = new Level(levels.GetLevel("Temp"));
 }