public XofFileSaveData AddData(Guid template, string name, Guid?id, byte[] data)
        {
            GCHandle idHandle = default;

            try
            {
                if (id.HasValue)
                {
                    idHandle = GCHandle.Alloc(id.Value, GCHandleType.Pinned);
                }

                IXofFileSaveData dataObject = _saveData.AddDataObject(
                    ref template,
                    string.IsNullOrEmpty(name) ? null : name,
                    id.HasValue ? idHandle.AddrOfPinnedObject() : IntPtr.Zero,
                    data == null || data.Length == 0 ? IntPtr.Zero : new IntPtr(data.Length),
                    data == null || data.Length == 0 ? IntPtr.Zero : Marshal.UnsafeAddrOfPinnedArrayElement(data, 0));

                return(new XofFileSaveData(dataObject));
            }
            finally
            {
                if (idHandle.IsAllocated)
                {
                    idHandle.Free();
                }
            }
        }
 internal XofFileSaveData(IXofFileSaveData saveData)
 {
     _saveData = saveData;
 }