private void EnsureUpdateIsGranted <T>(object newVal, T existingObj, string existingPropertyName, bool isReadonly)
        {
            var oldValue = Reflective.GetValue <object>(existingObj, existingPropertyName);

            // if it's an enum, cast it to ints int representation
            if (oldValue?.GetType().IsEnum ?? false)
            {
                oldValue = (int)Enum.Parse(oldValue.GetType(), oldValue.ToString());
            }

            if (!Equals(newVal, oldValue) && isReadonly)
            {
                throw new ForbiddenException($"Update on field {existingPropertyName} is not allowed, but server received updated values");
            }
        }
Exemplo n.º 2
0
        public static T GetServerSettings <T>() where T : SettingsEntry
        {
            var relativePath = Reflective.GetValue <string>(typeof(T), "RelativePath");

            return(GetServerSettings <T>(relativePath));
        }