public static void SetTokenFromPropertyEditor(string value) { var datatype = dts.GetDataTypeDefinitionByPropertyEditorAlias("NW.PieMan").First(); var settings = dts.GetPreValuesByDataTypeId(datatype.Id).ToList(); var o = JsonConvert.DeserializeObject<ConfigSettings>(settings.First()); o.refresh_token = value; var prevalue = new PreValue(JsonConvert.SerializeObject(o)); var dict = new Dictionary<string, Umbraco.Core.Models.PreValue>(); dict.Add("settings", prevalue); dict.Add("account", new PreValue(settings[1])); dict.Add("profile", new PreValue(settings[2])); dts.SaveDataTypeAndPreValues(datatype, dict); }
public ActionResult Install() { var dataTypeService = ApplicationContext.Current.Services.DataTypeService; var dataType = dataTypeService.GetDataTypeDefinitionById(Constants.System.DefaultContentListViewDataTypeId); var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(dataType.Id); var dict = preVals.FormatAsDictionary(); if (!dict.ContainsKey("pageSize")) dict["pageSize"] = new PreValue("10"); dict["pageSize"].Value = "200"; dataTypeService.SavePreValues(dataType, dict); var contentTypeService = ApplicationContext.Current.Services.ContentTypeService; var contentType = new ContentType(-1) { Alias = _contentAlias, Name = "LoadTest Content", Description = "Content for LoadTest", Icon = "icon-document" }; var def = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(_textboxDefinitionId); contentType.AddPropertyType(new PropertyType(def) { Name = "Origin", Alias = "origin", Description = "The origin of the content.", }); contentTypeService.Save(contentType); var containerTemplate = ImportTemplate(ApplicationContext.Current.Services, "~/Views/LoadTestContainer.cshtml", "LoadTestContainer", "LoadTestContainer", _containerTemplateText); var containerType = new ContentType(-1) { Alias = _containerAlias, Name = "LoadTest Container", Description = "Container for LoadTest content", Icon = "icon-document", AllowedAsRoot = true, IsContainer = true }; containerType.AllowedContentTypes = containerType.AllowedContentTypes.Union(new[] { new ContentTypeSort(new Lazy<int>(() => contentType.Id), 0, contentType.Alias), }); containerType.AllowedTemplates = containerType.AllowedTemplates.Union(new[] { containerTemplate }); containerType.SetDefaultTemplate(containerTemplate); contentTypeService.Save(containerType); var contentService = ApplicationContext.Current.Services.ContentService; var content = contentService.CreateContent("LoadTestContainer", -1, _containerAlias); contentService.SaveAndPublishWithStatus(content); return ContentHtml("Installed."); }
/// <summary> /// Specifies a string prevalue to apply to a data type /// </summary> /// <param name="alias"> The alias of the prevalue</param> /// <param name="value"> The value of the prevalue</param> public PreValueAttribute(string alias, string value) { Alias = alias; PreValue = new PreValue(value); }
/// <summary> /// Specifies a string prevalue to apply to a data type /// </summary> /// <param name="alias"> The alias of the prevalue</param> /// <param name="value"> The value of the prevalue</param> /// <param name="id"> The id of the prevalue</param> /// <param name="sortOrder"> The sort order of the prevalue</param> public PreValueAttribute(string alias, string value, int sortOrder, int id = 0) { Alias = alias; PreValue = new PreValue(id, value, sortOrder); }