private void CreateObject(ClassDataContract classContract)
            {
                _objectType = classContract.UnderlyingType;
                Type type = classContract.ObjectType;

                _objectLocal = _ilg.DeclareLocal(type, "objectDeserialized");

                if (classContract.UnderlyingType == Globals.TypeOfDBNull)
                {
                    _ilg.LoadMember(Globals.TypeOfDBNull.GetField("Value"));
                    _ilg.Stloc(_objectLocal);
                }
                else if (classContract.IsNonAttributedType)
                {
                    if (type.IsValueType)
                    {
                        _ilg.Ldloca(_objectLocal);
                        _ilg.InitObj(type);
                    }
                    else
                    {
                        _ilg.New(classContract.GetNonAttributedTypeConstructor());
                        _ilg.Stloc(_objectLocal);
                    }
                }
                else
                {
                    _ilg.Call(null, JsonFormatGeneratorStatics.GetUninitializedObjectMethod, classContract.TypeForInitialization);
                    _ilg.ConvertValue(Globals.TypeOfObject, type);
                    _ilg.Stloc(_objectLocal);
                }
            }
        void CreateObject(ClassDataContract classContract)
        {
            Type type = objectType = classContract.UnderlyingType;

            if (type.IsValueType && !classContract.IsNonAttributedType)
            {
                type = Globals.TypeOfValueType;
            }

            if (classContract.UnderlyingType == Globals.TypeOfDBNull)
            {
                objectLocal = DBNull.Value;
            }
            else if (classContract.IsNonAttributedType)
            {
                if (type.IsValueType)
                {
                    objectLocal = FormatterServices.GetUninitializedObject(type);
                }
                else
                {
                    objectLocal = classContract.GetNonAttributedTypeConstructor().Invoke(new object [0]);
                }
            }
            else
            {
                objectLocal = CodeInterpreter.ConvertValue(XmlFormatReaderGenerator.UnsafeGetUninitializedObject(DataContract.GetIdForInitialization(classContract)), Globals.TypeOfObject, type);
            }
        }
 private void CreateObject(ClassDataContract classContract)
 {
     Type typeOfValueType = this.objectType = classContract.UnderlyingType;
     if (typeOfValueType.IsValueType && !classContract.IsNonAttributedType)
     {
         typeOfValueType = Globals.TypeOfValueType;
     }
     this.objectLocal = this.ilg.DeclareLocal(typeOfValueType, "objectDeserialized");
     if (classContract.UnderlyingType == Globals.TypeOfDBNull)
     {
         this.ilg.LoadMember(Globals.TypeOfDBNull.GetField("Value"));
         this.ilg.Stloc(this.objectLocal);
     }
     else if (classContract.IsNonAttributedType)
     {
         if (typeOfValueType.IsValueType)
         {
             this.ilg.Ldloca(this.objectLocal);
             this.ilg.InitObj(typeOfValueType);
         }
         else
         {
             this.ilg.New(classContract.GetNonAttributedTypeConstructor());
             this.ilg.Stloc(this.objectLocal);
         }
     }
     else
     {
         this.ilg.Call(null, XmlFormatGeneratorStatics.GetUninitializedObjectMethod, DataContract.GetIdForInitialization(classContract));
         this.ilg.ConvertValue(Globals.TypeOfObject, typeOfValueType);
         this.ilg.Stloc(this.objectLocal);
     }
 }
Example #4
0
            private void CreateObject(ClassDataContract classContract)
            {
                Type typeOfValueType = this.objectType = classContract.UnderlyingType;

                if (typeOfValueType.IsValueType && !classContract.IsNonAttributedType)
                {
                    typeOfValueType = Globals.TypeOfValueType;
                }
                this.objectLocal = this.ilg.DeclareLocal(typeOfValueType, "objectDeserialized");
                if (classContract.UnderlyingType == Globals.TypeOfDBNull)
                {
                    this.ilg.LoadMember(Globals.TypeOfDBNull.GetField("Value"));
                    this.ilg.Stloc(this.objectLocal);
                }
                else if (classContract.IsNonAttributedType)
                {
                    if (typeOfValueType.IsValueType)
                    {
                        this.ilg.Ldloca(this.objectLocal);
                        this.ilg.InitObj(typeOfValueType);
                    }
                    else
                    {
                        this.ilg.New(classContract.GetNonAttributedTypeConstructor());
                        this.ilg.Stloc(this.objectLocal);
                    }
                }
                else
                {
                    this.ilg.Call(null, XmlFormatGeneratorStatics.GetUninitializedObjectMethod, DataContract.GetIdForInitialization(classContract));
                    this.ilg.ConvertValue(Globals.TypeOfObject, typeOfValueType);
                    this.ilg.Stloc(this.objectLocal);
                }
            }
            private void CreateObject(ClassDataContract classContract)
            {
                _objectType = classContract.UnderlyingType;
                Type type = classContract.ObjectType;

                _objectLocal = _ilg.DeclareLocal(type, "objectDeserialized");

                if (classContract.UnderlyingType == Globals.TypeOfDBNull)
                {
                    _ilg.LoadMember(Globals.TypeOfDBNull.GetField("Value"));
                    _ilg.Stloc(_objectLocal);
                }
                else if (classContract.IsNonAttributedType)
                {
                    if (type.GetTypeInfo().IsValueType)
                    {
                        _ilg.Ldloca(_objectLocal);
                        _ilg.InitObj(type);
                    }
                    else
                    {
                        _ilg.New(classContract.GetNonAttributedTypeConstructor());
                        _ilg.Stloc(_objectLocal);
                    }
                }
                else
                {
                    _ilg.Call(null, JsonFormatGeneratorStatics.GetUninitializedObjectMethod, classContract.TypeForInitialization);
                    _ilg.ConvertValue(Globals.TypeOfObject, type);
                    _ilg.Stloc(_objectLocal);
                }
            }
		void CreateObject (ClassDataContract classContract)
		{
			Type type = objectType = classContract.UnderlyingType;
			if (type.IsValueType && !classContract.IsNonAttributedType)
				type = Globals.TypeOfValueType;

			if (classContract.UnderlyingType == Globals.TypeOfDBNull)
				objectLocal = DBNull.Value;
			else if (classContract.IsNonAttributedType) {
				if (type.IsValueType)
					objectLocal = FormatterServices.GetUninitializedObject (type);
				else
					objectLocal = classContract.GetNonAttributedTypeConstructor ().Invoke (new object [0]);
			}
			else
				objectLocal = CodeInterpreter.ConvertValue (XmlFormatReaderGenerator.UnsafeGetUninitializedObject (DataContract.GetIdForInitialization (classContract)), Globals.TypeOfObject, type);
		}