Пример #1
0
        // Token: 0x060000CF RID: 207 RVA: 0x00006C8C File Offset: 0x00004E8C
        private void GenerateDynamic(Dictionary <Type, TypeData> map)
        {
            foreach (KeyValuePair <Type, TypeData> keyValuePair in map)
            {
                Type     key   = keyValuePair.Key;
                TypeData value = keyValuePair.Value;
                if (value.IsGenerated)
                {
                    value.WriterMethodInfo = Helpers.GenerateDynamicSerializerStub(key);
                    value.ReaderMethodInfo = Helpers.GenerateDynamicDeserializerStub(key);
                }
            }
            CodeGenContext codeGenContext = new CodeGenContext(map);

            foreach (KeyValuePair <Type, TypeData> keyValuePair2 in map)
            {
                Type     key2   = keyValuePair2.Key;
                TypeData value2 = keyValuePair2.Value;
                if (value2.IsGenerated)
                {
                    DynamicMethod dynamicMethod = (DynamicMethod)value2.WriterMethodInfo;
                    value2.TypeSerializer.GenerateWriterMethod(key2, codeGenContext, dynamicMethod.GetILGenerator());
                    DynamicMethod dynamicMethod2 = (DynamicMethod)value2.ReaderMethodInfo;
                    value2.TypeSerializer.GenerateReaderMethod(key2, codeGenContext, dynamicMethod2.GetILGenerator());
                }
            }
            DynamicMethod dynamicMethod3 = (DynamicMethod)codeGenContext.GetWriterMethodInfo(typeof(object));
            DynamicMethod dynamicMethod4 = (DynamicMethod)codeGenContext.GetReaderMethodInfo(typeof(object));

            this.m_serializerSwitch   = (Serializer.SerializerSwitch)dynamicMethod3.CreateDelegate(typeof(Serializer.SerializerSwitch));
            this.m_deserializerSwitch = (Serializer.DeserializerSwitch)dynamicMethod4.CreateDelegate(typeof(Serializer.DeserializerSwitch));
        }
Пример #2
0
        void GenerateDynamic(Dictionary <Type, TypeData> map)
        {
            /* generate stubs */
            foreach (var kvp in map)
            {
                var type = kvp.Key;
                var td   = kvp.Value;

                if (!td.IsGenerated)
                {
                    continue;
                }

                td.WriterMethodInfo = Helpers.GenerateDynamicSerializerStub(type);
                td.ReaderMethodInfo = Helpers.GenerateDynamicDeserializerStub(type);
            }

            var ctx = new CodeGenContext(map);

            /* generate bodies */

            foreach (var kvp in map)
            {
                var type = kvp.Key;
                var td   = kvp.Value;

                if (!td.IsGenerated)
                {
                    continue;
                }

                var writerDm = (DynamicMethod)td.WriterMethodInfo;
                td.TypeSerializer.GenerateWriterMethod(type, ctx, writerDm.GetILGenerator());

                var readerDm = (DynamicMethod)td.ReaderMethodInfo;
                td.TypeSerializer.GenerateReaderMethod(type, ctx, readerDm.GetILGenerator());
            }

            var writer = (DynamicMethod)ctx.GetWriterMethodInfo(typeof(object));
            var reader = (DynamicMethod)ctx.GetReaderMethodInfo(typeof(object));

            m_serializerSwitch   = (SerializerSwitch)writer.CreateDelegate(typeof(SerializerSwitch));
            m_deserializerSwitch = (DeserializerSwitch)reader.CreateDelegate(typeof(DeserializerSwitch));
        }
Пример #3
0
		void GenerateDynamic(Dictionary<Type, TypeData> map)
		{
			/* generate stubs */
			foreach (var kvp in map)
			{
				var type = kvp.Key;
				var td = kvp.Value;

				if (!td.IsGenerated)
					continue;

				td.WriterMethodInfo = Helpers.GenerateDynamicSerializerStub(type);
				td.ReaderMethodInfo = Helpers.GenerateDynamicDeserializerStub(type);
			}

			var ctx = new CodeGenContext(map);

			/* generate bodies */

			foreach (var kvp in map)
			{
				var type = kvp.Key;
				var td = kvp.Value;

				if (!td.IsGenerated)
					continue;

				var writerDm = (DynamicMethod)td.WriterMethodInfo;
				td.TypeSerializer.GenerateWriterMethod(type, ctx, writerDm.GetILGenerator());

				var readerDm = (DynamicMethod)td.ReaderMethodInfo;
				td.TypeSerializer.GenerateReaderMethod(type, ctx, readerDm.GetILGenerator());
			}

			var writer = (DynamicMethod)ctx.GetWriterMethodInfo(typeof(object));
			var reader = (DynamicMethod)ctx.GetReaderMethodInfo(typeof(object));

			m_serializerSwitch = (SerializerSwitch)writer.CreateDelegate(typeof(SerializerSwitch));
			m_deserializerSwitch = (DeserializerSwitch)reader.CreateDelegate(typeof(DeserializerSwitch));
		}