Esempio n. 1
0
            /// <summary>
            /// Execute a single test iteration.
            /// </summary>
            /// <param name="watch">The stopwatch timing the iteration.</param>
            /// <returns>A value indicating whether or not the test is valid.</returns>
            public bool Execute(Stopwatch watch)
            {
                JsonBuilder writer = JsonDna.PerpareWriter();

                JsonDna.RecursiveObject(writer, 3, 3);
                return(JsonDna.ConfirmWriter(writer, Constants.ComplexJson, watch));
            }
Esempio n. 2
0
        /// <summary>
        /// Recursively build a complex object.
        /// </summary>
        /// <param name="writer">The writer to use.</param>
        /// <param name="width">The length of the recursive array.</param>
        /// <param name="depth">The depth of the recursive object.</param>
        private static void RecursiveObject(JsonBuilder writer, int width, int depth)
        {
            writer.OpenObject();
            writer.OpenProperty(Constants.LogicalProperty);
            writer.WriteValue(Constants.LogicalValue);
            writer.CloseToken();
            writer.OpenProperty(Constants.IntegralProperty);
            writer.WriteValue(Constants.IntegralValue);
            writer.CloseToken();
            writer.OpenProperty(Constants.FloatProperty);
            writer.WriteValue(Constants.FloatValue);
            writer.CloseToken();
            writer.OpenProperty(Constants.TextProperty);
            writer.WriteValue(Constants.TextValue);
            writer.CloseToken();
            if (depth > 0)
            {
                writer.OpenProperty(Constants.ArrayProperty);
                writer.OpenArray();
                for (int i = 0; i < width; i++)
                {
                    int shallow = depth - 1;
                    JsonDna.RecursiveObject(writer, width, shallow);
                }

                writer.CloseToken();
                writer.CloseToken();
            }

            writer.CloseToken();
        }