/// <summary>
        /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridControlValue"/>.
        /// </summary>
        /// <param name="control">The parent control.</param>
        /// <param name="token">The instance of <see cref="JToken"/> representing the control value.</param>
        /// <param name="value">The converted value.</param>
        public virtual bool ConvertControlValue(GridControl control, JToken token, out IGridControlValue value)
        {
            value = null;

            switch (control.Editor.Alias)
            {
            case "media":
                value = GridControlMediaValue.Parse(control, token as JObject);
                break;

            case "embed":
                value = GridControlEmbedValue.Parse(control, token);
                break;

            case "rte":
                value = GridControlRichTextValue.Parse(control, token);
                break;

            case "macro":
                value = GridControlMacroValue.Parse(control, token as JObject);
                break;

            case "headline":
            case "quote":
                value = GridControlTextValue.Parse(control, token);
                break;
            }

            return(value != null);
        }
Exemple #2
0
        /// <summary>
        /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridControlValue"/>.
        /// </summary>
        /// <param name="control">The parent control.</param>
        /// <param name="token">The instance of <see cref="JToken"/> representing the control value.</param>
        /// <param name="value">The converted value.</param>
        public override bool ConvertControlValue(GridControl control, JToken token, out IGridControlValue value)
        {
            value = null;

            if (IsEmbedEditor(control.Editor))
            {
                value = new GridControlEmbedValue(control, token);
            }
            else if (IsMacroEditor(control.Editor))
            {
                value = new GridControlMacroValue(control, token as JObject);
            }
            else if (IsMediaEditor(control.Editor))
            {
                value = ParseGridControlMediaValue(control, token as JObject);
            }
            else if (IsRichTextEditor(control.Editor))
            {
                value = new GridControlRichTextValue(control, token);
            }
            else if (IsTextStringEditor(control.Editor))
            {
                value = new GridControlTextValue(control, token);
            }

            return(value != null);
        }
Exemple #3
0
        /// <summary>
        /// Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="value">The value.</param>
        /// <param name="serializer">The calling serializer.</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            GridControlTextValue text = value as GridControlTextValue;

            if (text != null)
            {
                writer.WriteValue(text.Value);
                return;
            }
            serializer.Serialize(writer, value);
        }
        /// <summary>
        /// Converts the specified <paramref name="token"/> into an instance of <see cref="IGridControlValue"/>.
        /// </summary>
        /// <param name="control">The parent control.</param>
        /// <param name="token">The instance of <see cref="JToken"/> representing the control value.</param>
        /// <param name="value">The converted value.</param>
        public bool ConvertControlValue(GridControl control, JToken token, out IGridControlValue value)
        {
            value = null;

            switch (control.Editor.Alias)
            {
            case "media_wide":
            case "media_wide_cropped":
                value = GridControlMediaValue.Parse(control, token as JObject);
                break;

            case "banner_headline":
            case "banner_tagline":
            case "headline_centered":
            case "abstract":
            case "paragraph":
            case "quote_D":
            case "code":
                value = GridControlTextValue.Parse(control, token);
                break;
            }

            return(value != null);
        }