Last active
October 12, 2016 13:27
-
-
Save 5up3rman/a58547639624255da3fd2de1c96ae389 to your computer and use it in GitHub Desktop.
Rule Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HideFields<T> : RuleAction<T> where T : ContentEditorRuleContext | |
{ | |
public string FieldName { get; set; } | |
public override void Apply(T ruleContext) | |
{ | |
var mappedItem = | |
MappedItemExtensions.GetItem(ruleContext.MappedItems, MappedItemType.Field, FieldName) ?? | |
new MappedItem(); | |
mappedItem.Type = MappedItemType.Field; | |
mappedItem.OriginalName = FieldName; | |
mappedItem.Hide = true; | |
// Add Item to RuleContext | |
ruleContext.MappedItems.AddOrReplaceItem(mappedItem); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SetFieldNames<T> : RuleAction<T> where T : ContentEditorRuleContext | |
{ | |
public string FieldName { get; set; } | |
public string NewTitle { get; set; } | |
public override void Apply(T ruleContext) | |
{ | |
var mappedItem = | |
MappedItemExtensions.GetMappedItem(ruleContext.MappedItems, MappedItemType.Field, FieldName) ?? | |
new MappedItem(); | |
mappedItem.Type = MappedItemType.Field; | |
mappedItem.OriginalName = FieldName; | |
mappedItem.NewTitle = NewTitle; | |
// Add Item to RuleContext | |
ruleContext.MappedItems.AddOrReplaceItem(mappedItem); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SetShortDescription<T> : RuleAction<T> where T : ContentEditorRuleContext | |
{ | |
public string FieldName { get; set; } | |
public string Text { get; set; } | |
public override void Apply(T ruleContext) | |
{ | |
var mappedItem = | |
MappedItemExtensions.GetMappedItem(ruleContext.MappedItems, MappedItemType.Field, FieldName) ?? | |
new MappedItem(); | |
mappedItem.Type = MappedItemType.Field; | |
mappedItem.OriginalTitle = FieldName; | |
mappedItem.ShortDescription = Text; | |
// Add Item to RuleContext | |
ruleContext.MappedItems.AddOrReplaceItem(mappedItem); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment