//------------------------------------------------------------------------------
// <auto-generated>
//     このコードはツールによって生成されました。
//     ランタイム バージョン:4.0.30319.42000
//
//     このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
//     コードが再生成されるときに損失したりします。
// </auto-generated>
//------------------------------------------------------------------------------

namespace Sandbox.Shared.GeneratedSerializers {
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("MsgPack.Serialization.CodeDomSerializers.CodeDomSerializerBuilder", "0.9.0.0")]
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public class PersonSerializer : MsgPack.Serialization.MessagePackSerializer<Person> {
        
        private MsgPack.Serialization.MessagePackSerializer<int> _serializer0;
        
        private MsgPack.Serialization.MessagePackSerializer<string> _serializer1;
        
        private MsgPack.Serialization.MessagePackSerializer<Sex> _serializer2;
        
        private System.Collections.Generic.IList<System.Action<MsgPack.Packer, Person>> _packOperationList;
        
        private System.Collections.Generic.IDictionary<string, System.Action<MsgPack.Packer, Person>> _packOperationTable;
        
        private System.Collections.Generic.IDictionary<string, System.Func<Person, bool>> _nullCheckersTable;
        
        private System.Action<Person, int> this_SetUnpackedValueOfAgeDelegate;
        
        private System.Func<MsgPack.Unpacker, System.Type, string, int> MsgPack_Serialization_UnpackHelpers_UnpackInt32ValueDelegate;
        
        private System.Action<Person, string> this_SetUnpackedValueOfFirstNameDelegate;
        
        private System.Func<MsgPack.Unpacker, System.Type, string, string> MsgPack_Serialization_UnpackHelpers_UnpackStringValueDelegate;
        
        private System.Action<Person, string> this_SetUnpackedValueOfLastNameDelegate;
        
        private System.Action<Person, Sex> this_SetUnpackedValueOfSexDelegate;
        
        private System.Collections.Generic.IList<string> _memberNames;
        
        private System.Collections.Generic.IList<System.Action<MsgPack.Unpacker, Person, int, int>> _unpackOperationList;
        
        private System.Collections.Generic.IDictionary<string, System.Action<MsgPack.Unpacker, Person, int, int>> _unpackOperationTable;
        
        public PersonSerializer(MsgPack.Serialization.SerializationContext context) : 
                base(context, (MsgPack.Serialization.SerializerCapabilities.PackTo | MsgPack.Serialization.SerializerCapabilities.UnpackFrom)) {
            MsgPack.Serialization.PolymorphismSchema schema0 = default(MsgPack.Serialization.PolymorphismSchema);
            schema0 = null;
            this._serializer0 = context.GetSerializer<int>(schema0);
            MsgPack.Serialization.PolymorphismSchema schema1 = default(MsgPack.Serialization.PolymorphismSchema);
            schema1 = null;
            this._serializer1 = context.GetSerializer<string>(schema1);
            this._serializer2 = context.GetSerializer<Sex>(MsgPack.Serialization.EnumMessagePackSerializerHelpers.DetermineEnumSerializationMethod(context, typeof(Sex), MsgPack.Serialization.EnumMemberSerializationMethod.Default));
            System.Action<MsgPack.Packer, Person>[] packOperationList = default(System.Action<MsgPack.Packer, Person>[]);
            packOperationList = new System.Action<MsgPack.Packer, Person>[4];
            packOperationList[0] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfAge);
            packOperationList[1] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfFirstName);
            packOperationList[2] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfLastName);
            packOperationList[3] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfSex);
            this._packOperationList = packOperationList;
            System.Collections.Generic.Dictionary<string, System.Action<MsgPack.Packer, Person>> packOperationTable = default(System.Collections.Generic.Dictionary<string, System.Action<MsgPack.Packer, Person>>);
            packOperationTable = new System.Collections.Generic.Dictionary<string, System.Action<MsgPack.Packer, Person>>(4);
            packOperationTable["Age"] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfAge);
            packOperationTable["FirstName"] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfFirstName);
            packOperationTable["LastName"] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfLastName);
            packOperationTable["Sex"] = new System.Action<MsgPack.Packer, Person>(this.PackValueOfSex);
            this._packOperationTable = packOperationTable;
            System.Collections.Generic.Dictionary<string, System.Func<Person, bool>> nullCheckerTable = default(System.Collections.Generic.Dictionary<string, System.Func<Person, bool>>);
            nullCheckerTable = new System.Collections.Generic.Dictionary<string, System.Func<Person, bool>>(2);
            nullCheckerTable["FirstName"] = new System.Func<Person, bool>(this.IsFirstNameNull);
            nullCheckerTable["LastName"] = new System.Func<Person, bool>(this.IsLastNameNull);
            this._nullCheckersTable = nullCheckerTable;
            System.Action<MsgPack.Unpacker, Person, int, int>[] unpackOperationList = default(System.Action<MsgPack.Unpacker, Person, int, int>[]);
            unpackOperationList = new System.Action<MsgPack.Unpacker, Person, int, int>[4];
            unpackOperationList[0] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfAge);
            unpackOperationList[1] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfFirstName);
            unpackOperationList[2] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfLastName);
            unpackOperationList[3] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfSex);
            this._unpackOperationList = unpackOperationList;
            System.Collections.Generic.Dictionary<string, System.Action<MsgPack.Unpacker, Person, int, int>> unpackOperationTable = default(System.Collections.Generic.Dictionary<string, System.Action<MsgPack.Unpacker, Person, int, int>>);
            unpackOperationTable = new System.Collections.Generic.Dictionary<string, System.Action<MsgPack.Unpacker, Person, int, int>>(4);
            unpackOperationTable["Age"] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfAge);
            unpackOperationTable["FirstName"] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfFirstName);
            unpackOperationTable["LastName"] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfLastName);
            unpackOperationTable["Sex"] = new System.Action<MsgPack.Unpacker, Person, int, int>(this.UnpackValueOfSex);
            this._unpackOperationTable = unpackOperationTable;
            this._memberNames = new string[] {
                    "Age",
                    "FirstName",
                    "LastName",
                    "Sex"};
            this.this_SetUnpackedValueOfAgeDelegate = new System.Action<Person, int>(this.SetUnpackedValueOfAge);
            this.MsgPack_Serialization_UnpackHelpers_UnpackInt32ValueDelegate = new System.Func<MsgPack.Unpacker, System.Type, string, int>(MsgPack.Serialization.UnpackHelpers.UnpackInt32Value);
            this.this_SetUnpackedValueOfFirstNameDelegate = new System.Action<Person, string>(this.SetUnpackedValueOfFirstName);
            this.MsgPack_Serialization_UnpackHelpers_UnpackStringValueDelegate = new System.Func<MsgPack.Unpacker, System.Type, string, string>(MsgPack.Serialization.UnpackHelpers.UnpackStringValue);
            this.this_SetUnpackedValueOfLastNameDelegate = new System.Action<Person, string>(this.SetUnpackedValueOfLastName);
            this.this_SetUnpackedValueOfSexDelegate = new System.Action<Person, Sex>(this.SetUnpackedValueOfSex);
        }
        
        private void PackValueOfAge(MsgPack.Packer packer, Person objectTree) {
            this._serializer0.PackTo(packer, objectTree.Age);
        }
        
        private void PackValueOfFirstName(MsgPack.Packer packer, Person objectTree) {
            this._serializer1.PackTo(packer, objectTree.FirstName);
        }
        
        private bool IsFirstNameNull(Person objectTree) {
            return (objectTree.FirstName == null);
        }
        
        private void PackValueOfLastName(MsgPack.Packer packer, Person objectTree) {
            this._serializer1.PackTo(packer, objectTree.LastName);
        }
        
        private bool IsLastNameNull(Person objectTree) {
            return (objectTree.LastName == null);
        }
        
        private void PackValueOfSex(MsgPack.Packer packer, Person objectTree) {
            this._serializer2.PackTo(packer, objectTree.Sex);
        }
        
        protected override void PackToCore(MsgPack.Packer packer, Person objectTree) {
            MsgPack.Serialization.PackToArrayParameters<Person> packHelperParameters = default(MsgPack.Serialization.PackToArrayParameters<Person>);
            packHelperParameters.Packer = packer;
            packHelperParameters.Target = objectTree;
            packHelperParameters.Operations = this._packOperationList;
            MsgPack.Serialization.PackToMapParameters<Person> packHelperParameters0 = default(MsgPack.Serialization.PackToMapParameters<Person>);
            packHelperParameters0.Packer = packer;
            packHelperParameters0.Target = objectTree;
            packHelperParameters0.Operations = this._packOperationTable;
            packHelperParameters0.SerializationContext = this.OwnerContext;
            packHelperParameters0.NullCheckers = this._nullCheckersTable;
            if ((this.OwnerContext.SerializationMethod == MsgPack.Serialization.SerializationMethod.Array)) {
                MsgPack.Serialization.PackHelpers.PackToArray(ref packHelperParameters);
            }
            else {
                MsgPack.Serialization.PackHelpers.PackToMap(ref packHelperParameters0);
            }
        }
        
        private void SetUnpackedValueOfAge(Person unpackingContext, int unpackedValue) {
            unpackingContext.Age = unpackedValue;
        }
        
        private void UnpackValueOfAge(MsgPack.Unpacker unpacker, Person unpackingContext, int indexOfItem, int itemsCount) {
            MsgPack.Serialization.UnpackValueTypeValueParameters<Person, int> unpackHelperParameters = default(MsgPack.Serialization.UnpackValueTypeValueParameters<Person, int>);
            unpackHelperParameters.Unpacker = unpacker;
            unpackHelperParameters.UnpackingContext = unpackingContext;
            unpackHelperParameters.Serializer = this._serializer0;
            unpackHelperParameters.ItemsCount = itemsCount;
            unpackHelperParameters.Unpacked = indexOfItem;
            unpackHelperParameters.TargetObjectType = typeof(int);
            unpackHelperParameters.MemberName = "Age";
            unpackHelperParameters.DirectRead = this.MsgPack_Serialization_UnpackHelpers_UnpackInt32ValueDelegate;
            unpackHelperParameters.Setter = this.this_SetUnpackedValueOfAgeDelegate;
            MsgPack.Serialization.UnpackHelpers.UnpackValueTypeValue(ref unpackHelperParameters);
        }
        
        private void SetUnpackedValueOfFirstName(Person unpackingContext, string unpackedValue) {
            unpackingContext.FirstName = unpackedValue;
        }
        
        private void UnpackValueOfFirstName(MsgPack.Unpacker unpacker, Person unpackingContext, int indexOfItem, int itemsCount) {
            MsgPack.Serialization.UnpackReferenceTypeValueParameters<Person, string> unpackHelperParameters0 = default(MsgPack.Serialization.UnpackReferenceTypeValueParameters<Person, string>);
            unpackHelperParameters0.Unpacker = unpacker;
            unpackHelperParameters0.UnpackingContext = unpackingContext;
            unpackHelperParameters0.Serializer = this._serializer1;
            unpackHelperParameters0.ItemsCount = itemsCount;
            unpackHelperParameters0.Unpacked = indexOfItem;
            unpackHelperParameters0.TargetObjectType = typeof(string);
            unpackHelperParameters0.MemberName = "FirstName";
            unpackHelperParameters0.NilImplication = MsgPack.Serialization.NilImplication.MemberDefault;
            unpackHelperParameters0.DirectRead = this.MsgPack_Serialization_UnpackHelpers_UnpackStringValueDelegate;
            unpackHelperParameters0.Setter = this.this_SetUnpackedValueOfFirstNameDelegate;
            MsgPack.Serialization.UnpackHelpers.UnpackReferenceTypeValue(ref unpackHelperParameters0);
        }
        
        private void SetUnpackedValueOfLastName(Person unpackingContext, string unpackedValue) {
            unpackingContext.LastName = unpackedValue;
        }
        
        private void UnpackValueOfLastName(MsgPack.Unpacker unpacker, Person unpackingContext, int indexOfItem, int itemsCount) {
            MsgPack.Serialization.UnpackReferenceTypeValueParameters<Person, string> unpackHelperParameters1 = default(MsgPack.Serialization.UnpackReferenceTypeValueParameters<Person, string>);
            unpackHelperParameters1.Unpacker = unpacker;
            unpackHelperParameters1.UnpackingContext = unpackingContext;
            unpackHelperParameters1.Serializer = this._serializer1;
            unpackHelperParameters1.ItemsCount = itemsCount;
            unpackHelperParameters1.Unpacked = indexOfItem;
            unpackHelperParameters1.TargetObjectType = typeof(string);
            unpackHelperParameters1.MemberName = "LastName";
            unpackHelperParameters1.NilImplication = MsgPack.Serialization.NilImplication.MemberDefault;
            unpackHelperParameters1.DirectRead = this.MsgPack_Serialization_UnpackHelpers_UnpackStringValueDelegate;
            unpackHelperParameters1.Setter = this.this_SetUnpackedValueOfLastNameDelegate;
            MsgPack.Serialization.UnpackHelpers.UnpackReferenceTypeValue(ref unpackHelperParameters1);
        }
        
        private void SetUnpackedValueOfSex(Person unpackingContext, Sex unpackedValue) {
            unpackingContext.Sex = unpackedValue;
        }
        
        private void UnpackValueOfSex(MsgPack.Unpacker unpacker, Person unpackingContext, int indexOfItem, int itemsCount) {
            MsgPack.Serialization.UnpackValueTypeValueParameters<Person, Sex> unpackHelperParameters2 = default(MsgPack.Serialization.UnpackValueTypeValueParameters<Person, Sex>);
            unpackHelperParameters2.Unpacker = unpacker;
            unpackHelperParameters2.UnpackingContext = unpackingContext;
            unpackHelperParameters2.Serializer = this._serializer2;
            unpackHelperParameters2.ItemsCount = itemsCount;
            unpackHelperParameters2.Unpacked = indexOfItem;
            unpackHelperParameters2.TargetObjectType = typeof(Sex);
            unpackHelperParameters2.MemberName = "Sex";
            unpackHelperParameters2.DirectRead = null;
            unpackHelperParameters2.Setter = this.this_SetUnpackedValueOfSexDelegate;
            MsgPack.Serialization.UnpackHelpers.UnpackValueTypeValue(ref unpackHelperParameters2);
        }
        
        protected override Person UnpackFromCore(MsgPack.Unpacker unpacker) {
            Person result = default(Person);
            result = new Person();
            if (unpacker.IsArrayHeader) {
                return MsgPack.Serialization.UnpackHelpers.UnpackFromArray(unpacker, result, MsgPack.Serialization.UnpackHelpers.GetIdentity<Person>(), this._memberNames, this._unpackOperationList);
            }
            else {
                return MsgPack.Serialization.UnpackHelpers.UnpackFromMap(unpacker, result, MsgPack.Serialization.UnpackHelpers.GetIdentity<Person>(), this._unpackOperationTable);
            }
        }
    }
}
