本文整理汇总了C#中Rock.Model.Attribute.CopyPropertiesFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Attribute.CopyPropertiesFrom方法的具体用法?C# Attribute.CopyPropertiesFrom怎么用?C# Attribute.CopyPropertiesFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.Attribute
的用法示例。
在下文中一共展示了Attribute.CopyPropertiesFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveAttributeEdits
/// <summary>
/// Saves any attribute edits made using an Attribute Editor control
/// </summary>
/// <param name="edtAttribute">The edt attribute.</param>
/// <param name="entityTypeId">The entity type identifier.</param>
/// <param name="entityTypeQualifierColumn">The entity type qualifier column.</param>
/// <param name="entityTypeQualifierValue">The entity type qualifier value.</param>
/// <param name="rockContext">The rock context.</param>
/// <returns></returns>
/// <remarks>
/// If a rockContext value is included, this method will save any previous changes made to the context
/// </remarks>
public static Rock.Model.Attribute SaveAttributeEdits( AttributeEditor edtAttribute, int? entityTypeId, string entityTypeQualifierColumn, string entityTypeQualifierValue, RockContext rockContext = null )
{
// Create and update a new attribute object with new values
rockContext = rockContext ?? new RockContext();
var internalAttributeService = new AttributeService( rockContext );
Rock.Model.Attribute attribute = null;
var newAttribute = new Rock.Model.Attribute();
if ( edtAttribute.AttributeId.HasValue )
{
attribute = internalAttributeService.Get( edtAttribute.AttributeId.Value );
}
if ( attribute != null )
{
newAttribute.CopyPropertiesFrom( attribute );
}
else
{
newAttribute.Order = internalAttributeService.Queryable().Max( a => a.Order ) + 1;
}
edtAttribute.GetAttributeProperties( newAttribute );
return SaveAttributeEdits( newAttribute, entityTypeId, entityTypeQualifierColumn, entityTypeQualifierValue, rockContext );
}