/// <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 or <c>null</c> if one of the /// args is <c>null</c> or if we failed to parse the CA blob</returns> public static CustomAttribute Read(ModuleDef module, IBinaryReader stream, ICustomAttributeType ctor, GenericParamContext gpContext) { if (stream == null || ctor == null) { return(null); } try { using (var reader = new CustomAttributeReader(module, stream, gpContext)) return(reader.Read(ctor)); } catch (CABlobParserException) { return(null); } catch (IOException) { return(null); } }
/// <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> /// <returns>A new <see cref="CustomAttribute"/> instance or <c>null</c> if one of the /// args is <c>null</c> or if we failed to parse the CA blob</returns> public static CustomAttribute Read(ModuleDef module, IImageStream stream, ICustomAttributeType ctor) { if (stream == null || ctor == null) { return(null); } try { using (var reader = new CustomAttributeReader(module, stream, ctor)) return(reader.Read()); } catch (CABlobParserException) { return(null); } catch (IOException) { return(null); } }
/// <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)); } } }
/// <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> /// <returns>A new <see cref="CustomAttribute"/> instance</returns> public static CustomAttribute Read(ModuleDefMD readerModule, ICustomAttributeType ctor, uint offset) { if (ctor == null) { return(CreateEmpty(ctor)); } using (var reader = new CustomAttributeReader(readerModule, ctor, offset)) { try { return(reader.Read()); } catch (CABlobParserException) { return(new CustomAttribute(ctor, reader.GetRawBlob())); } catch (IOException) { return(new CustomAttribute(ctor, reader.GetRawBlob())); } } }
/// <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> /// <returns>A new <see cref="CustomAttribute"/> instance</returns> public static CustomAttribute Read(ModuleDefMD readerModule, ICustomAttributeType ctor, uint offset) { if (ctor == null) return CreateEmpty(ctor); using (var reader = new CustomAttributeReader(readerModule, offset)) { try { return reader.Read(ctor); } catch (CABlobParserException) { return new CustomAttribute(ctor, reader.GetRawBlob()); } catch (IOException) { return new CustomAttribute(ctor, reader.GetRawBlob()); } } }
/// <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> /// <returns>A new <see cref="CustomAttribute"/> instance or <c>null</c> if one of the /// args is <c>null</c> or if we failed to parse the CA blob</returns> public static CustomAttribute Read(ModuleDef module, IBinaryReader stream, ICustomAttributeType ctor) { if (stream == null || ctor == null) return null; try { using (var reader = new CustomAttributeReader(module, stream)) return reader.Read(ctor); } catch (CABlobParserException) { return null; } catch (IOException) { return null; } }
/// <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); } } }
/// <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); } } }