Example #1
0
 /// <summary>
 /// Reads a custom attribute
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="stream">A stream positioned at the the first byte of the CA blob</param>
 /// <param name="ctor">Custom attribute constructor</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="CustomAttribute"/> instance</returns>
 public static CustomAttribute Read(ModuleDef module, IBinaryReader stream, ICustomAttributeType ctor, GenericParamContext gpContext)
 {
     using (var reader = new CustomAttributeReader(module, stream, gpContext)) {
         try {
             if (stream == null || ctor == null)
             {
                 return(reader.CreateRaw(ctor));
             }
             return(reader.Read(ctor));
         }
         catch (CABlobParserException) {
             return(reader.CreateRaw(ctor));
         }
         catch (IOException) {
             return(reader.CreateRaw(ctor));
         }
     }
 }
Example #2
0
 /// <summary>
 /// Reads a custom attribute
 /// </summary>
 /// <param name="readerModule">Reader module</param>
 /// <param name="ctor">Custom attribute constructor</param>
 /// <param name="offset">Offset of custom attribute in the #Blob stream</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="CustomAttribute"/> instance</returns>
 public static CustomAttribute Read(ModuleDefMD readerModule, ICustomAttributeType ctor, uint offset, GenericParamContext gpContext)
 {
     using (var reader = new CustomAttributeReader(readerModule, offset, gpContext)) {
         try {
             if (ctor == null)
             {
                 return(reader.CreateRaw(ctor));
             }
             return(reader.Read(ctor));
         }
         catch (CABlobParserException) {
             return(reader.CreateRaw(ctor));
         }
         catch (IOException) {
             return(reader.CreateRaw(ctor));
         }
     }
 }
Example #3
0
		/// <summary>
		/// Reads a custom attribute
		/// </summary>
		/// <param name="module">Owner module</param>
		/// <param name="stream">A stream positioned at the the first byte of the CA blob</param>
		/// <param name="ctor">Custom attribute constructor</param>
		/// <param name="gpContext">Generic parameter context</param>
		/// <returns>A new <see cref="CustomAttribute"/> instance</returns>
		public static CustomAttribute Read(ModuleDef module, IBinaryReader stream, ICustomAttributeType ctor, GenericParamContext gpContext) {
			using (var reader = new CustomAttributeReader(module, stream, gpContext)) {
				try {
					if (stream == null || ctor == null)
						return reader.CreateRaw(ctor);
					return reader.Read(ctor);
				}
				catch (CABlobParserException) {
					return reader.CreateRaw(ctor);
				}
				catch (IOException) {
					return reader.CreateRaw(ctor);
				}
			}
		}
Example #4
0
		/// <summary>
		/// Reads a custom attribute
		/// </summary>
		/// <param name="readerModule">Reader module</param>
		/// <param name="ctor">Custom attribute constructor</param>
		/// <param name="offset">Offset of custom attribute in the #Blob stream</param>
		/// <param name="gpContext">Generic parameter context</param>
		/// <returns>A new <see cref="CustomAttribute"/> instance</returns>
		public static CustomAttribute Read(ModuleDefMD readerModule, ICustomAttributeType ctor, uint offset, GenericParamContext gpContext) {
			using (var reader = new CustomAttributeReader(readerModule, offset, gpContext)) {
				try {
					if (ctor == null)
						return reader.CreateRaw(ctor);
					return reader.Read(ctor);
				}
				catch (CABlobParserException) {
					return reader.CreateRaw(ctor);
				}
				catch (IOException) {
					return reader.CreateRaw(ctor);
				}
			}
		}