本文整理汇总了C#中Rock.Model.AttributeService.GetSystemSetting方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeService.GetSystemSetting方法的具体用法?C# AttributeService.GetSystemSetting怎么用?C# AttributeService.GetSystemSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.AttributeService
的用法示例。
在下文中一共展示了AttributeService.GetSystemSetting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetValue
/// <summary>
/// Sets the value.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetValue( string key, string value )
{
var rockContext = new Rock.Data.RockContext();
var attributeService = new AttributeService( rockContext );
var attribute = attributeService.GetSystemSetting( key );
if ( attribute == null )
{
attribute = new Rock.Model.Attribute();
attribute.FieldTypeId = FieldTypeCache.Read( new Guid( SystemGuid.FieldType.TEXT ) ).Id;
attribute.EntityTypeQualifierColumn = Rock.Model.Attribute.SYSTEM_SETTING_QUALIFIER;
attribute.EntityTypeQualifierValue = string.Empty;
attribute.Key = key;
attribute.Name = key.SplitCase();
attribute.DefaultValue = value;
attributeService.Add( attribute );
}
else
{
attribute.DefaultValue = value;
}
rockContext.SaveChanges();
AttributeCache.Flush( attribute.Id );
var settings = SystemSettings.Read();
var attributeCache = settings.Attributes.FirstOrDefault( a => a.Key.Equals( key, StringComparison.OrdinalIgnoreCase ) );
if ( attributeCache != null )
{
attributeCache.DefaultValue = value;
}
else
{
settings.Attributes.Add( AttributeCache.Read( attribute.Id ) );
}
}