Changeset 13 for Common/Registry.cs


Ignore:
Timestamp:
Feb 8, 2021, 4:23:17 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Fixes to existing classes.
  • Added: File type association method.
  • Added: RecentFiles and Table classes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/Registry.cs

    r9 r13  
    1 using System;
     1using System;
    22using System.Collections.Generic;
    33using System.Linq;
     
    3535        }
    3636
     37        public static long GetValueLong(this RegistryKey regKey, string name, long defaultValue)
     38        {
     39            object value = regKey.GetValue(name, defaultValue);
     40            if (value is long) return (long)value;
     41            else return defaultValue;
     42        }
     43
    3744        public static float GetValueFloat(this RegistryKey regKey, string name, float defaultValue)
    3845        {
    3946            object value = regKey.GetValue(name, defaultValue.ToString());
    40             float num;
    41             if (float.TryParse((string)value, out num))
     47            if (float.TryParse((string) value, out float num))
     48            {
    4249                return num;
     50            }
    4351            else return defaultValue;
    4452        }
     
    6068        }
    6169
     70        public static void SetValueLong(this RegistryKey regKey, string name, long value)
     71        {
     72            regKey.SetValue(name, value);
     73        }
     74
    6275        public static void SetValueFloat(this RegistryKey regKey, string name, float value)
    6376        {
Note: See TracChangeset for help on using the changeset viewer.