openDecal/Managed/Decal.Adapter/Decal.Adapter.NetParser/MessageWrapper.cs
erik d1442e3747 Initial commit: Complete open-source Decal rebuild
All 5 phases of the open-source Decal rebuild:

Phase 1: 14 decompiled .NET projects (Interop.*, Adapter, FileService, DecalUtil)
Phase 2: 10 native DLLs rewritten as C# COM servers with matching GUIDs
  - DecalDat, DHS, SpellFilter, DecalInput, DecalNet, DecalFilters
  - Decal.Core, DecalControls, DecalRender, D3DService
Phase 3: C++ shims for Inject.DLL (D3D9 hooking) and LauncherHook.DLL
Phase 4: DenAgent WinForms tray application
Phase 5: WiX installer and build script

25 C# projects building with 0 errors.
Native C++ projects require VS 2022 + Windows SDK (x86).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:27:56 +01:00

77 lines
1.7 KiB
C#

using System.Runtime.InteropServices;
using Decal.Interop.Net;
namespace Decal.Adapter.NetParser;
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(IMessage2))]
[ProgId("DecalAdapter.MessageWrapper")]
[Guid("76142307-98E3-494d-8320-3C801010221D")]
public class MessageWrapper : IMessage2, IMessage
{
private Message msg;
internal Message Wrapped => msg;
public MessageRoot Begin => new MessageRootWrapper(this);
public int Count => msg.Count;
public byte[] RawData => msg.RawData;
public int Type => msg.Type;
// IMessage/IMessage2 properties - parameterless accessors for the COM interface
object IMessage.Value => get_Value(0);
IMessageMember IMessage.Struct => get_Struct(0);
byte[] IMessage.RawValue => get_RawValue(0);
string IMessage.FieldName => get_FieldName(0);
object IMessage2.Value => get_Value(0);
IMessageMember IMessage2.Struct => get_Struct(0);
byte[] IMessage2.RawValue => get_RawValue(0);
string IMessage2.FieldName => get_FieldName(0);
public MessageWrapper()
{
}
internal MessageWrapper(Message msg)
{
this.msg = msg;
if (!this.msg.mStruct.mParsed)
{
this.msg.mStruct.Parse();
}
}
public string get_FieldName(int Index)
{
return msg.Name(Index);
}
public byte[] get_RawValue(object vElement)
{
return msg.RawValue(msg.mStruct.ObjectToIndex(vElement));
}
public IMessageMember get_Struct(object vElement)
{
int num = msg.mStruct.ObjectToIndex(vElement);
if (num < 0)
{
throw new COMHResultException((HResults)1);
}
return new MessageMemberWrapper(msg.Struct(num), this);
}
public object get_Value(object vElement)
{
int num = msg.mStruct.ObjectToIndex(vElement);
if (num >= 0)
{
return msg.Value<object>(num);
}
return null;
}
}