protected override object GetValue(PropertyBag propertyValues) { if (propertyValues != null) { JArray array = JArray.Parse(propertyValues.Object.ToString()); if (array != null) { return array; } else { if (propertyValues.Object is IEnumerable && !(propertyValues.Object is string)) { var items = ((IEnumerable)propertyValues.Object).Cast<object>(); return new JArray(items.Select(item => this.ItemType.GetValue(PropertyBag.Create(item)))); } } return new JArray(this.ItemType.GetValue(propertyValues)); } else { return null; } }
protected override object GetValue(PropertyBag propertyValues) { if (propertyValues != null) { return propertyValues.Object; } else { return null; } }
protected override object GetValue(PropertyBag propertyValues) { // in this case, the value is just the entire property object. if (propertyValues != null) { return propertyValues.Object; } else { return null; } }
private static JProperty GetJProperty(KeyValuePair<string, DataType> sourceProperty, PropertyBag propertyValues) { string propertyName = sourceProperty.Key; if (propertyValues.ContainsKey(propertyName)) { var propertyValue = sourceProperty.Value.GetValue(propertyValues.GetBag(propertyName)); if (propertyValue != null) { if (!(propertyValue is JToken)) { propertyValue = new JValue(propertyValue); } return new JProperty(propertyName, propertyValue); } } return null; }
protected override object GetValue(PropertyBag propertyValues) { throw new InvalidOperationException("Cannot serialize value from an unresolved type reference"); }
protected abstract object GetValue(PropertyBag propertyValues);
protected override object GetValue(PropertyBag propertyValues) { return new JObject(this.properties.Select(p => GetJProperty(p, propertyValues)).Where(p => p != null)); }