简体   繁体   中英

.NET Standard 2.0 - Windows Registry - works on Mac OS X - Unity

I have my project (originally developed on Unity - Windows) on API Compatibility Level set to .NET Standard 2.0, and in my project I have an external.dll class library compiled also as .NET Standard 2.0 in which is used Microsoft.Win32. I am saving some data to the Windows Registry.

Now I am adapting the project to work on Mac too, and I found that my external.dll with the Registry thing is working with no error on my Mac also.

I've been trying to find where could that data be stored, as Mac's OS X doesn't have a Windows like Registry?

Why and how is this working?

The code is used as a.dll plugin in Unity.

using Microsoft.Win32;

...

    private RegistryKey key;

    public StorageImpl()
    {
        key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath, true);

        if (key == null)
        {
            key = Registry.CurrentUser.CreateSubKey(RegistryKeyPath);
        }
    }

    public DateTime? StartDate
    {
        get
        {
            object value = key.GetValue(RegistryStartDate);
            return value != null ? DateTime.FromBinary((long)value) : (DateTime?)null;
        }

        set
        {
            if (value != null)
            {
                key.SetValue(RegistryStartDate, value.Value.ToBinary(), RegistryValueKind.QWord);
            }
            else
            {
                key.DeleteValue(RegistryStartDate);
            }

            key.Flush();
        }
    }

I found where the data is being saved: /Users/user/.mono/registry/CurrentUser/software/nameOfSoftware/values.xml

I had to search manually listing all folder content using terminal: ls -a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM