public static DynamicProperty ToDynamicProperty(this platformDto.DynamicObjectProperty propertyDto)
        {
            var result = new DynamicProperty();

            result.Id           = propertyDto.Id;
            result.IsArray      = propertyDto.IsArray ?? false;
            result.IsDictionary = propertyDto.IsDictionary ?? false;
            result.IsRequired   = propertyDto.IsRequired ?? false;
            result.Name         = propertyDto.Name;
            result.ValueType    = propertyDto.ValueType;

            if (propertyDto.DisplayNames != null)
            {
                result.DisplayNames = propertyDto.DisplayNames.Select(x => new LocalizedString(new Language(x.Locale), x.Name)).ToList();
            }

            if (propertyDto.Values != null)
            {
                if (result.IsDictionary)
                {
                    var dictValues = propertyDto.Values
                                     .Where(x => x.Value != null)
                                     .Select(x => x.Value)
                                     .Cast <JObject>()
                                     .Select(x => x.ToObject <platformDto.DynamicPropertyDictionaryItem>())
                                     .ToArray();

                    result.DictionaryValues = dictValues.Select(x => x.ToDictItem()).ToList();
                }
                else
                {
                    result.Values = propertyDto.Values
                                    .Where(x => x.Value != null)
                                    .Select(x => x.ToLocalizedString())
                                    .ToList();
                }
            }

            return(result);
        }
        public static platformDto.DynamicObjectProperty ToDynamicPropertyDto(this DynamicProperty dynamicProperty)
        {
            var result = new platformDto.DynamicObjectProperty();

            result.Id           = dynamicProperty.Id;
            result.IsArray      = dynamicProperty.IsArray;
            result.IsDictionary = dynamicProperty.IsDictionary;
            result.IsRequired   = dynamicProperty.IsRequired;
            result.Name         = dynamicProperty.Name;
            result.ValueType    = dynamicProperty.ValueType;

            if (dynamicProperty.Values != null)
            {
                result.Values = dynamicProperty.Values.Select(v => v.ToPropertyValueDto()).ToList();
            }
            else if (dynamicProperty.DictionaryValues != null)
            {
                result.Values = dynamicProperty.DictionaryValues.Select(x => x.ToPropertyValueDto()).ToList();
            }

            return(result);
        }