/// <summary> /// Reads the old (.NET 1.x) DeclSecurity blob format /// </summary> /// <returns></returns> private ThreadSafe.IList <SecurityAttribute> ReadXmlFormat() { var xml = Encoding.Unicode.GetString(reader.ReadAllBytes()); var sa = SecurityAttribute.CreateFromXml(module, xml); return(ThreadSafeListCreator.Create <SecurityAttribute>(sa)); }
/// <summary> /// Gets the binary custom attribute data that was used to create this instance. /// </summary> /// <returns>Blob of this custom attribute</returns> public byte[] GetBlob() { if (rawData != null) { return(rawData); } if (blob != null) { return(blob); } #if THREAD_SAFE if (blobReader != null) { lock (this) { #endif if (blobReader != null) { blob = blobReader.ReadAllBytes(); blobReader.Dispose(); blobReader = null; return(blob); } #if THREAD_SAFE } } #endif if (blob != null) { return(blob); } return(blob = new byte[0]); }
static IBinaryReader CloneBlobReader(IBinaryReader reader) { if (reader == null) { return(null); } var imgStream = reader as IImageStream; if (imgStream != null) { return(imgStream.Clone()); } return(MemoryImageStream.Create(reader.ReadAllBytes())); }
/// <summary> /// Gets the binary custom attribute data that was used to create this instance. /// </summary> /// <returns>Blob of this custom attribute</returns> public byte[] GetBlob() { if (rawData != null) { return(rawData); } if (blobReader != null) { #if THREAD_SAFE lock (this) #endif return(blobReader.ReadAllBytes()); } return(new byte[0]); }
byte[] GetRawBlob() { return(reader.ReadAllBytes()); }
MarshalType Read() { MarshalType returnValue; try { var nativeType = (NativeType)reader.ReadByte(); NativeType nt; int size; switch (nativeType) { case NativeType.FixedSysString: size = CanRead() ? (int)reader.ReadCompressedUInt32() : -1; returnValue = new FixedSysStringMarshalType(size); break; case NativeType.SafeArray: var vt = CanRead() ? (VariantType)reader.ReadCompressedUInt32() : VariantType.NotInitialized; var udtName = CanRead() ? ReadUTF8String() : null; var udtRef = (object)udtName == null ? null : TypeNameParser.ParseReflection(module, UTF8String.ToSystemStringOrEmpty(udtName), null, gpContext); returnValue = new SafeArrayMarshalType(vt, udtRef); break; case NativeType.FixedArray: size = CanRead() ? (int)reader.ReadCompressedUInt32() : -1; nt = CanRead() ? (NativeType)reader.ReadCompressedUInt32() : NativeType.NotInitialized; returnValue = new FixedArrayMarshalType(size, nt); break; case NativeType.Array: nt = CanRead() ? (NativeType)reader.ReadCompressedUInt32() : NativeType.NotInitialized; int paramNum = CanRead() ? (int)reader.ReadCompressedUInt32() : -1; size = CanRead() ? (int)reader.ReadCompressedUInt32() : -1; int flags = CanRead() ? (int)reader.ReadCompressedUInt32() : -1; returnValue = new ArrayMarshalType(nt, paramNum, size, flags); break; case NativeType.CustomMarshaler: var guid = ReadUTF8String(); var nativeTypeName = ReadUTF8String(); var custMarshalerName = ReadUTF8String(); var cmRef = TypeNameParser.ParseReflection(module, UTF8String.ToSystemStringOrEmpty(custMarshalerName), new CAAssemblyRefFinder(module), gpContext); var cookie = ReadUTF8String(); returnValue = new CustomMarshalType(guid, nativeTypeName, cmRef, cookie); break; case NativeType.IUnknown: case NativeType.IDispatch: case NativeType.IntF: int iidParamIndex = CanRead() ? (int)reader.ReadCompressedUInt32() : -1; return(new InterfaceMarshalType(nativeType, iidParamIndex)); default: returnValue = new MarshalType(nativeType); break; } } catch { returnValue = new RawMarshalType(reader.ReadAllBytes()); } return(returnValue); }
static IBinaryReader CloneBlobReader(IBinaryReader reader) { if (reader == null) return null; var imgStream = reader as IImageStream; if (imgStream != null) return imgStream.Clone(); return MemoryImageStream.Create(reader.ReadAllBytes()); }