System.Text.ASCIIEncoding.GetDecoder C# (CSharp) Method

GetDecoder() public method

public GetDecoder ( ) : System.Text.Decoder
return System.Text.Decoder
        public override System.Text.Decoder GetDecoder()
        {
            throw null;
        }

Usage Example

示例#1
0
    private void GetPrefKeysWindows()
    {
        var charEncoding = new System.Text.ASCIIEncoding();
        var decoder      = charEncoding.GetDecoder();
        // Unity stores prefs in the registry on Windows.

        string regKey = @"Software\" + PlayerSettings.companyName + @"\" + PlayerSettings.productName;

        Debug.Log(regKey);


        RegistryKey key = Registry.CurrentUser.OpenSubKey(regKey);

        foreach (string subkeyName in key.GetValueNames())
        {
            string keyName = subkeyName.Substring(0, subkeyName.LastIndexOf("_"));
            var    val     = key.GetValue(subkeyName);
            string sval    = val.ToString();

            if (!PlayerPrefs.HasKey(keyName))
            {
                Debug.LogWarning(keyName + " " + PlayerPrefs.HasKey(keyName));
            }
            else
            {
                Debug.Log(keyName + " " + PlayerPrefs.HasKey(keyName));
            }

            if (!PlayerPrefs.HasKey(keyName))
            {
                continue;
            }

            // getting the type of the key is not supported in Mono with registry yet :(
            // Have to infer type and guess...
            int    testInt    = -1;
            string newType    = "";
            bool   couldBeInt = int.TryParse(sval, out testInt);

            if (!float.IsNaN(PlayerPrefs.GetFloat(keyName, float.NaN)))
            {
                val     = PlayerPrefs.GetFloat(keyName).ToString();
                newType = "real";
            }
            else if (couldBeInt && (PlayerPrefs.GetInt(keyName, testInt - 10) == testInt))
            {
                newType = "integer";
            }
            else
            {
                newType = "string";
                sval    = System.Text.Encoding.Default.GetString((Byte[])val);
            }

            PlayerPrefStore pref = new PlayerPrefStore(keyName, newType, sval);
            playerPrefs.Add(pref);
        }
    }
All Usage Examples Of System.Text.ASCIIEncoding::GetDecoder