I have an Archetype fieldset with a property on it that is a nuPicker. I can't seem to get a Picker instance from the value of that property. Consider this code:
var one = model.GetValue<Picker>("newWindow");
var two = model.GetValue<string>("newWindow");
If it helps, here is the context in which I am trying to get the value:
using Archetype.Models;
using Newtonsoft.Json;
using nuPickers;
using Rhythm.Extensions.Helpers;
using System;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using Types;
using Umbraco.Core;
public class LinkConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context,
Type sourceType)
{
return true;
}
public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
{
if (value is string)
{
value = JsonConvert.DeserializeObject<ArchetypeModel>(value as string);
}
var model = (value as ArchetypeModel).FirstOrDefault();
var alias = model.Alias;
if ("contentLink".InvariantEquals(alias))
{
var strNodeId = model.GetValue<string>("linkPage");
if(!string.IsNullOrWhiteSpace(strNodeId))
{
var nodeId = int.Parse(strNodeId);
var helper = ContentHelper.GetHelper();
var node = helper.TypedContent(nodeId);
if (node != null)
{
var suffix = model.GetValue<string>("linkSuffix");
var url = node.Url + suffix;
// null
var one = model.GetValue<Picker>("newWindow");
// [{"key":"True","label":"Open in New Window"}]
var two = model.GetValue<string>("newWindow");
return new Link()
{
Label = model.GetValue<string>("linkLabel"),
NewWindow = false,//TODO: Hardcoded until I can resolve a bug.
Title = model.GetValue<string>("linkTitle"),
Url = url
};
}
}
}
//TODO: Other link types.
return null;
}
}
Getting Value of nuPicker on Archetype Property
I have an Archetype fieldset with a property on it that is a nuPicker. I can't seem to get a
Picker
instance from the value of that property. Consider this code:The value of
one
is null and the value oftwo
is:The type of
model
isArchetypeFieldsetModel
. It seems as if the property value converter isn't working for some reason. I could manually deserialize the value, but this comment leads me to believe the code I am attempting to use should work: https://our.umbraco.org/projects/backoffice-extensions/archetype/sound-off/54224-Using-nuPickers-in-Archetype#comment-195142If it helps, here is the context in which I am trying to get the value:
is working on a reply...