示例#1
0
        public string GetEncryptedString(MapConfigEntry entry)
        {
            Type t = entry.Default.GetType();

            if (!(t == typeof(string) || t == typeof(String)))
            {
                throw new Exception("GetEncryptedString only works on string entries.");
            }

            string result = string.Empty;

            try
            {
                result = StringCrypt.DecryptString((string)GetValue(entry), _cryptPass);
                if (result != string.Empty)
                {
                    if (result.StartsWith(_cryptCheck))
                    {
                        result = result.Replace(_cryptCheck, string.Empty);
                    }
                    else
                    {
                        result = string.Empty;
                    }
                }
            }
            catch
            {
                result = string.Empty;
            }

            return(result);
        }
示例#2
0
        public string GetEncryptedString(MapConfigEntry entry)
        {
            Type t = entry.Default.GetType();
            if (!(t == typeof(string) || t == typeof(String)))
                throw new Exception("GetEncryptedString only works on string entries.");

            string result = string.Empty;
            try
            {
                result = StringCrypt.DecryptString((string)GetValue(entry), _cryptPass);
                if (result != string.Empty)
                {
                    if (result.StartsWith(_cryptCheck))
                        result = result.Replace(_cryptCheck, string.Empty);
                    else
                        result = string.Empty;
                }
            }
            catch
            {
                result = string.Empty;
            }

            return result;
        }
示例#3
0
        public object GetValue(MapConfigEntry entry)
        {
            Type t = entry.Default.GetType();

            if (t == typeof(string) || t == typeof(String))
            {
                return(GetValue(entry.Key, (string)entry.Default));
            }
            else if (t == typeof(int))
            {
                return(GetValue(entry.Key, (int)entry.Default));
            }
            else if (t == typeof(double))
            {
                return(GetValue(entry.Key, (double)entry.Default));
            }
            else if (t == typeof(bool) || t == typeof(Boolean))
            {
                return(GetValue(entry.Key, (bool)entry.Default));
            }
            else if (t == typeof(Dictionary <int, string>))
            {
                return(GetValue(entry.Key, ((Dictionary <int, string>)entry.Default)));
            }
            else
            {
                return(GetValue(entry.Key, (string)entry.Default.ToString())); //On their own to parse it
            }
            throw new Exception("Default Type must be string, int, double, bool or Dictionary<int,string>");
        }
示例#4
0
        public void SetValue(MapConfigEntry entry, object value)
        {
            Type t     = value.GetType();
            Type dType = entry.Default.GetType();

            if (t != dType && !(t.IsGenericType && t.GetGenericTypeDefinition() == dType.GetGenericTypeDefinition()))
            {
                throw new Exception("Value type does not equal default value type.");
            }

            if (t == typeof(string) || t == typeof(String))
            {
                SetValue(entry.Key, (string)value);
            }
            else if (t == typeof(int))
            {
                SetValue(entry.Key, (int)value);
            }
            else if (t == typeof(double))
            {
                SetValue(entry.Key, (double)value);
            }
            else if (t == typeof(bool) || t == typeof(Boolean))
            {
                SetValue(entry.Key, (bool)value);
            }
            else if (t == typeof(Dictionary <int, string>))
            {
                SetValue(entry.Key, (Dictionary <int, string>)value);
            }
            else
            {
                SetValue(entry.Key, value.ToString());
            }
        }
示例#5
0
        public void SetEncryptedString(MapConfigEntry entry, string value)
        {
            Type t = entry.Default.GetType();

            if (!(t == typeof(string) || t == typeof(String)))
            {
                throw new Exception("SetEncryptedString only works on string entries.");
            }

            SetValue(entry, StringCrypt.EncryptString(_cryptCheck + value, _cryptPass));
        }
示例#6
0
        public void SetValue(MapConfigEntry entry, object value)
        {
            Type t = value.GetType();
            Type dType = entry.Default.GetType();
            if (t != dType && !(t.IsGenericType && t.GetGenericTypeDefinition() == dType.GetGenericTypeDefinition()))
                throw new Exception("Value type does not equal default value type.");

            if (t == typeof(string) || t == typeof(String)) SetValue(entry.Key, (string)value);
            else if (t == typeof(int)) SetValue(entry.Key, (int)value);
            else if (t == typeof(double)) SetValue(entry.Key, (double)value);
            else if (t == typeof(bool) || t == typeof(Boolean)) SetValue(entry.Key, (bool)value);
            else if (t == typeof(Dictionary<int,string>)) SetValue(entry.Key, (Dictionary<int,string>)value);
            else SetValue(entry.Key, value.ToString());
        }
示例#7
0
        public void SetEncryptedString(MapConfigEntry entry, string value)
        {
            Type t = entry.Default.GetType();
            if (!(t == typeof(string) || t == typeof(String)))
                throw new Exception("SetEncryptedString only works on string entries.");

            SetValue(entry, StringCrypt.EncryptString(_cryptCheck + value, _cryptPass));
        }
示例#8
0
        public object GetValue(MapConfigEntry entry)
        {
            Type t = entry.Default.GetType();

            if (t == typeof(string) || t == typeof(String)) return GetValue(entry.Key, (string)entry.Default);
            else if (t == typeof(int)) return GetValue(entry.Key, (int)entry.Default);
            else if (t == typeof(double)) return GetValue(entry.Key, (double)entry.Default);
            else if (t == typeof(bool) || t == typeof(Boolean)) return GetValue(entry.Key, (bool)entry.Default);
            else if (t == typeof(Dictionary<int, string>))
                return GetValue(entry.Key, ((Dictionary<int, string>) entry.Default));
            else return GetValue(entry.Key, (string)entry.Default.ToString()); //On their own to parse it

            throw new Exception("Default Type must be string, int, double, bool or Dictionary<int,string>");
        }
示例#9
0
文件: Config.cs 项目: TingPing/elpis
 public HotkeyConfig GetKeyObject(MapConfigEntry entry)
 {
     return new HotkeyConfig((string)_c.GetValue(entry), (HotkeyConfig)entry.Default);
 }