More actions
Nguyenduyan (talk | contribs) Created page with "{{CGscriptClass_Template |Name=GroupBuilderRuleCollection |Description=Represents a level of group builder rules. |Methods= {{CGscriptMethods_Template|ReturnType=Empty|Name=Ad..." |
Nguyenduyan (talk | contribs) No edit summary |
||
Line 21: | Line 21: | ||
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | ||
}} | }} | ||
=== <span style="color:#DF8621">'''Examples'''</span> === | |||
'''Example: Add new rules''' | |||
<source lang="javascript"> | |||
//Create a new group | |||
string groupName = "Test Group Builder: GroupBuilderRuleCollection"; | |||
number groupTemplateResourceId=2066; | |||
number parentResourceId = 11088827; | |||
array group = Group_new(groupName, groupTemplateResourceId, parentResourceId); | |||
Group_save(group); | |||
number groupRId = group[GROUP_RESOURCE_ID ]; | |||
//Create rule for the group | |||
GroupBuilderRoot root = new GroupBuilderRoot (groupRId); | |||
GroupBuilderRule rule1 = new GroupBuilderRule (root); | |||
GroupBuilderRule rule2 = new GroupBuilderRule (root); | |||
GroupBuilderRule rule3 = new GroupBuilderRule (root); | |||
GroupBuilderRuleCollection ruleColection = root.RootRules; | |||
ruleColection.Add(rule1); | |||
ruleColection.Add(rule2); | |||
ruleColection.Add(rule3); | |||
root.Save(); | |||
</source> | |||
<br/> | |||
'''Example: Remove rule''' | |||
<source lang="javascript"> | |||
GroupBuilderRoot root = new GroupBuilderRoot (15560827); | |||
GroupBuilderRuleCollection ruleColection = root.RootRules; | |||
print(ruleColection.Count);//3 | |||
GroupBuilderRule rule2 = ruleColection[1]; | |||
ruleColection.Remove(rule2); | |||
print(ruleColection.Count);//2 | |||
root.Save(); | |||
</source> |
Revision as of 03:54, 19 April 2017
GroupBuilderRuleCollection
Represents a level of group builder rules.
Methods
- Empty Add(GroupBuilderRule rule "Rule to add") - Add a new rule
- GroupBuilderRule this[] { get; }(int index "Index") - Get rule at index
- bool Remove(GroupBuilderRule rule "Rule to remove") - Remove rule. Return true if removed
- Empty this[] { set; }(int index "Index", GroupBuilderRule value "Value to set") - Set rule at index
- string ToString() - The string representation of the object.
Properties
- int Count { get; } - Number of rules at this level
- string ObjectTypeName { get; } - The name of the type of object.
- TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Example: Add new rules
//Create a new group
string groupName = "Test Group Builder: GroupBuilderRuleCollection";
number groupTemplateResourceId=2066;
number parentResourceId = 11088827;
array group = Group_new(groupName, groupTemplateResourceId, parentResourceId);
Group_save(group);
number groupRId = group[GROUP_RESOURCE_ID ];
//Create rule for the group
GroupBuilderRoot root = new GroupBuilderRoot (groupRId);
GroupBuilderRule rule1 = new GroupBuilderRule (root);
GroupBuilderRule rule2 = new GroupBuilderRule (root);
GroupBuilderRule rule3 = new GroupBuilderRule (root);
GroupBuilderRuleCollection ruleColection = root.RootRules;
ruleColection.Add(rule1);
ruleColection.Add(rule2);
ruleColection.Add(rule3);
root.Save();
Example: Remove rule
GroupBuilderRoot root = new GroupBuilderRoot (15560827);
GroupBuilderRuleCollection ruleColection = root.RootRules;
print(ruleColection.Count);//3
GroupBuilderRule rule2 = ruleColection[1];
ruleColection.Remove(rule2);
print(ruleColection.Count);//2
root.Save();