public static ContentElementViewModel CreateContentElement(this AddonElementData data, object model = null) { if (data.Type.IsSubclassOf(typeof(ContentElementAddon))) { return(ContentElementAddon.CreateFromModel(data.Type, model)); } if (!(data.Attribute is ContentAddonElementAttribute a) || a.ViewModelType == null) { return(null); } if (model is null) { return((ContentElementViewModel)Activator.CreateInstance(a.ViewModelType)); } return((ContentElementViewModel)Activator.CreateInstance(a.ViewModelType, model)); }
internal ContentElementAddonModel(ContentElementAddon typeProvider) { _typeProvider = typeProvider; }