public new static SafeArrayMarshalDescriptor FromReader(IBinaryStreamReader reader) { var descriptor = new SafeArrayMarshalDescriptor(); if (reader.CanRead((sizeof(byte)))) { descriptor.ElementType = (VariantType)reader.ReadByte(); } return(descriptor); }
public static new SafeArrayMarshalDescriptor FromReader(IBinaryStreamReader reader) { var descriptor = new SafeArrayMarshalDescriptor() { StartOffset = reader.Position, }; if (reader.CanRead((sizeof (byte)))) descriptor.ElementType = (VariantType)reader.ReadByte(); return descriptor; }
public bool Equals(SafeArrayMarshalDescriptor x, SafeArrayMarshalDescriptor y) { if (x == null && y == null) { return(true); } if (x == null || y == null) { return(false); } return(x.ElementType == y.ElementType); }
public void CreateSafeArrayMarshalDescriptor() { var assembly = Utilities.CreateTempNetAssembly(); var descriptor = new SafeArrayMarshalDescriptor() { ElementType = VariantType.UI4, }; var newDescriptor = BuildAppWithDescriptor(assembly, new SzArrayTypeSignature(assembly.NetDirectory.MetadataHeader.TypeSystem.Int32), descriptor, false); Assert.AreEqual(descriptor.ElementType, newDescriptor.ElementType); }
/// <summary> /// Reads a marshal descriptor signature from the provided input stream. /// </summary> /// <param name="parentModule">The module that defines the marshal descriptor</param> /// <param name="reader">The input stream.</param> /// <returns>The marshal descriptor.</returns> public static MarshalDescriptor FromReader(ModuleDefinition parentModule, IBinaryStreamReader reader) { var nativeType = (NativeType)reader.ReadByte(); MarshalDescriptor descriptor = nativeType switch { NativeType.SafeArray => SafeArrayMarshalDescriptor.FromReader(parentModule, reader), NativeType.FixedArray => FixedArrayMarshalDescriptor.FromReader(reader), NativeType.LPArray => LPArrayMarshalDescriptor.FromReader(reader), NativeType.CustomMarshaller => CustomMarshalDescriptor.FromReader(parentModule, reader), NativeType.FixedSysString => FixedSysStringMarshalDescriptor.FromReader(reader), NativeType.Interface => ComInterfaceMarshalDescriptor.FromReader(nativeType, reader), NativeType.IDispatch => ComInterfaceMarshalDescriptor.FromReader(nativeType, reader), NativeType.IUnknown => ComInterfaceMarshalDescriptor.FromReader(nativeType, reader), _ => new SimpleMarshalDescriptor(nativeType) }; descriptor.ExtraData = reader.ReadToEnd(); return(descriptor); }
public static MarshalDescriptor FromReader(IBinaryStreamReader reader) { var type = (NativeType)reader.ReadByte(); switch (type) { case NativeType.Array: return(ArrayMarshalDescriptor.FromReader(reader)); case NativeType.FixedArray: return(FixedArrayMarshalDescriptor.FromReader(reader)); case NativeType.SafeArray: return(SafeArrayMarshalDescriptor.FromReader(reader)); case NativeType.CustomMarshaler: return(CustomMarshalDescriptor.FromReader(reader)); default: return(new SimpleMarshalDescriptor(type)); } }