コード例 #1
0
 internal JsonFormatClassWriterDelegate GenerateClassWriter(ClassDataContract classContract)
 {
     _ilg = new CodeGenerator();
     bool memberAccessFlag = classContract.RequiresMemberAccessForWrite(null, JsonGlobals.JsonSerializationPatterns);
     try
     {
         BeginMethod(_ilg, "Write" + DataContract.SanitizeTypeName(classContract.StableName.Name) + "ToJson", typeof(JsonFormatClassWriterDelegate), memberAccessFlag);
     }
     catch (SecurityException securityException)
     {
         if (memberAccessFlag)
         {
             classContract.RequiresMemberAccessForWrite(securityException, JsonGlobals.JsonSerializationPatterns);
         }
         else
         {
             throw;
         }
     }
     InitArgs(classContract.UnderlyingType);
     _memberNamesArg = _ilg.GetArg(4);
     WriteClass(classContract);
     return (JsonFormatClassWriterDelegate)_ilg.EndMethod();
 }
コード例 #2
0
 internal JsonFormatClassWriterDelegate GenerateClassWriter(ClassDataContract classContract)
 {
     ilg = new CodeGenerator();
     bool memberAccessFlag = classContract.RequiresMemberAccessForWrite(null);
     try
     {
         BeginMethod(ilg, "Write" + classContract.StableName.Name + "ToJson", typeof(JsonFormatClassWriterDelegate), memberAccessFlag);
     }
     catch (SecurityException securityException)
     {
         if (memberAccessFlag && securityException.PermissionType.Equals(typeof(ReflectionPermission)))
         {
             classContract.RequiresMemberAccessForWrite(securityException);
         }
         else
         {
             throw;
         }
     }
     InitArgs(classContract.UnderlyingType);
     memberNamesArg = ilg.GetArg(4);
     DemandSerializationFormatterPermission(classContract);
     DemandMemberAccessPermission(memberAccessFlag);
     if (classContract.IsReadOnlyContract)
     {
         ThrowIfCannotSerializeReadOnlyTypes(classContract);
     }
     WriteClass(classContract);
     return (JsonFormatClassWriterDelegate)ilg.EndMethod();
 }
コード例 #3
0
 CodeGenerator GenerateCollectionReaderHelper(CollectionDataContract collectionContract, bool isGetOnlyCollection)
 {
     ilg = new CodeGenerator();
     bool memberAccessFlag = collectionContract.RequiresMemberAccessForRead(null);
     try
     {
         if (isGetOnlyCollection)
         {
             BeginMethod(ilg, "Read" + collectionContract.StableName.Name + "FromJson" + "IsGetOnly", typeof(JsonFormatGetOnlyCollectionReaderDelegate), memberAccessFlag);
         }
         else
         {
             BeginMethod(ilg, "Read" + collectionContract.StableName.Name + "FromJson", typeof(JsonFormatCollectionReaderDelegate), memberAccessFlag);
         }
     }
     catch (SecurityException securityException)
     {
         if (memberAccessFlag && securityException.PermissionType.Equals(typeof(ReflectionPermission)))
         {
             collectionContract.RequiresMemberAccessForRead(securityException);
         }
         else
         {
             throw;
         }
     }
     InitArgs();
     DemandMemberAccessPermission(memberAccessFlag);
     collectionContractArg = ilg.GetArg(4);
     return ilg;
 }
コード例 #4
0
 private CodeGenerator GenerateCollectionReaderHelper(CollectionDataContract collectionContract, bool isGetOnlyCollection)
 {
     _ilg = new CodeGenerator();
     bool memberAccessFlag = collectionContract.RequiresMemberAccessForRead(null);
     try
     {
         if (isGetOnlyCollection)
         {
             BeginMethod(_ilg, "Read" + DataContract.SanitizeTypeName(collectionContract.StableName.Name) + "FromJson" + "IsGetOnly", typeof(JsonFormatGetOnlyCollectionReaderDelegate), memberAccessFlag);
         }
         else
         {
             BeginMethod(_ilg, "Read" + DataContract.SanitizeTypeName(collectionContract.StableName.Name) + "FromJson", typeof(JsonFormatCollectionReaderDelegate), memberAccessFlag);
         }
     }
     catch (SecurityException securityException)
     {
         if (memberAccessFlag)
         {
             collectionContract.RequiresMemberAccessForRead(securityException);
         }
         else
         {
             throw;
         }
     }
     InitArgs();
     _collectionContractArg = _ilg.GetArg(4);
     return _ilg;
 }