// <auto-generated/>

#nullable disable

using System;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using Sample.Models;

namespace Sample
{
    public partial class DynamicModel
    {
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
        private bool PropagateGet(global::System.ReadOnlySpan<byte> jsonPath, out global::System.ClientModel.Primitives.JsonPatch.EncodedValue value)
        {
            global::System.ReadOnlySpan<byte> local = jsonPath.SliceToStartOfPropertyName();
            value = default;

            if (local.StartsWith("p1"u8))
            {
                int propertyLength = "p1"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                string key = currentSlice.GetFirstPropertyName(out int i);
                if (!P1.TryGetValue(key, out global::Sample.Models.DynamicDictionary item))
                {
                    return false;
                }
                return item.Patch.TryGetEncodedValue([.. "$"u8, .. currentSlice.GetRemainder(i)], out value);
            }
            if (local.StartsWith("p2"u8))
            {
                int propertyLength = "p2"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                return P2[index].Patch.TryGetEncodedValue([.. "$"u8, .. currentSlice.Slice(bytesConsumed)], out value);
            }
            if (local.StartsWith("p3"u8))
            {
                int propertyLength = "p3"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                return P3[index].Patch.TryGetEncodedValue([.. "$"u8, .. currentSlice.Slice(bytesConsumed)], out value);
            }
            if (local.StartsWith("p4"u8))
            {
                int propertyLength = "p4"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                currentSlice = currentSlice.Slice(bytesConsumed);
                if (!currentSlice.TryGetIndex(out int index0, out int bytesConsumed0))
                {
                    return false;
                }
                return P4[index][index0].Patch.TryGetEncodedValue([.. "$"u8, .. currentSlice.Slice(bytesConsumed0)], out value);
            }
            if (local.StartsWith("p5"u8))
            {
                int propertyLength = "p5"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                currentSlice = currentSlice.Slice(bytesConsumed);
                if (!currentSlice.TryGetIndex(out int index0, out int bytesConsumed0))
                {
                    return false;
                }
                currentSlice = currentSlice.Slice(bytesConsumed0);
                if (!currentSlice.TryGetIndex(out int index1, out int bytesConsumed1))
                {
                    return false;
                }
                return P5[index][index0][index1].Patch.TryGetEncodedValue([.. "$"u8, .. currentSlice.Slice(bytesConsumed1)], out value);
            }
            if (local.StartsWith("p6"u8))
            {
                int propertyLength = "p6"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                string key = currentSlice.GetFirstPropertyName(out int i);
                if (!P6.TryGetValue(key, out global::System.Collections.Generic.IList<global::Sample.Models.DynamicDictionary> item))
                {
                    return false;
                }
                currentSlice = currentSlice.GetRemainder(i);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                return item[index].Patch.TryGetEncodedValue([.. "$"u8, .. currentSlice.Slice(bytesConsumed)], out value);
            }
            return false;
        }
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.

#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
        private bool PropagateSet(global::System.ReadOnlySpan<byte> jsonPath, global::System.ClientModel.Primitives.JsonPatch.EncodedValue value)
        {
            global::System.ReadOnlySpan<byte> local = jsonPath.SliceToStartOfPropertyName();

            if (local.StartsWith("p1"u8))
            {
                int propertyLength = "p1"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                string key = currentSlice.GetFirstPropertyName(out int i);
                if (!P1.TryGetValue(key, out global::Sample.Models.DynamicDictionary item))
                {
                    return false;
                }
                item.Patch.Set([.. "$"u8, .. currentSlice.GetRemainder(i)], value);
                return true;
            }
            if (local.StartsWith("p2"u8))
            {
                int propertyLength = "p2"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                P2[index].Patch.Set([.. "$"u8, .. currentSlice.Slice(bytesConsumed)], value);
                return true;
            }
            if (local.StartsWith("p3"u8))
            {
                int propertyLength = "p3"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                P3[index].Patch.Set([.. "$"u8, .. currentSlice.Slice(bytesConsumed)], value);
                return true;
            }
            if (local.StartsWith("p4"u8))
            {
                int propertyLength = "p4"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                currentSlice = currentSlice.Slice(bytesConsumed);
                if (!currentSlice.TryGetIndex(out int index0, out int bytesConsumed0))
                {
                    return false;
                }
                P4[index][index0].Patch.Set([.. "$"u8, .. currentSlice.Slice(bytesConsumed0)], value);
                return true;
            }
            if (local.StartsWith("p5"u8))
            {
                int propertyLength = "p5"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                currentSlice = currentSlice.Slice(bytesConsumed);
                if (!currentSlice.TryGetIndex(out int index0, out int bytesConsumed0))
                {
                    return false;
                }
                currentSlice = currentSlice.Slice(bytesConsumed0);
                if (!currentSlice.TryGetIndex(out int index1, out int bytesConsumed1))
                {
                    return false;
                }
                P5[index][index0][index1].Patch.Set([.. "$"u8, .. currentSlice.Slice(bytesConsumed1)], value);
                return true;
            }
            if (local.StartsWith("p6"u8))
            {
                int propertyLength = "p6"u8.Length;
                global::System.ReadOnlySpan<byte> currentSlice = local.Slice(propertyLength);
                string key = currentSlice.GetFirstPropertyName(out int i);
                if (!P6.TryGetValue(key, out global::System.Collections.Generic.IList<global::Sample.Models.DynamicDictionary> item))
                {
                    return false;
                }
                currentSlice = currentSlice.GetRemainder(i);
                if (!currentSlice.TryGetIndex(out int index, out int bytesConsumed))
                {
                    return false;
                }
                item[index].Patch.Set([.. "$"u8, .. currentSlice.Slice(bytesConsumed)], value);
                return true;
            }
            return false;
        }
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
    }
}
