Пример #1
0
        private static void GenerateDefaultValues(Character character, Dictionary <int, FieldWithValue> fields,
                                                  FieldSaveStrategyBase strategy)
        {
            foreach (var field in fields.Values.Where(
                         f => !f.HasEditableValue && f.Field.CanHaveValue() &&
                         f.Field.IsAvailableForTarget(character)))
            {
                var newValue = strategy.GenerateDefaultValue(field);

                var normalizedValue = NormalizeValueBeforeAssign(field, newValue);

                strategy.AssignFieldValue(field, normalizedValue);
            }
        }
Пример #2
0
        private static void AssignValues(IReadOnlyDictionary <int, string> newFieldValue, Dictionary <int, FieldWithValue> fields,
                                         FieldSaveStrategyBase strategy)
        {
            foreach (var keyValuePair in newFieldValue)
            {
                var field = fields[keyValuePair.Key];

                strategy.EnsureEditAccess(field);

                var normalizedValue = NormalizeValueBeforeAssign(field, keyValuePair.Value);

                if (normalizedValue is null && field.Field.MandatoryStatus == MandatoryStatus.Required)
                {
                    throw new FieldRequiredException(field.Field.FieldName);
                }

                strategy.AssignFieldValue(field, normalizedValue);
            }
        }