/// <summary>
/// Create sample RuleData array to modify the rules associated with a folder.
/// </summary>
/// <returns>Return RuleData array to be used in RopModifyRules request.</returns>
protected RuleData[] CreateSampleRuleDataArrayForAdd()
{
int propertyValuesCount = 4;
PropertyValue[] propertyValues = new PropertyValue[propertyValuesCount];
for (int i = 0; i < propertyValuesCount; i++)
{
propertyValues[i] = new PropertyValue();
}
// As specified in section 2.2.1.3.2 in [MS-OXORULE],
// when adding a PRULE, the client MUST NOT
// pass in PidTagRuleId, it MUST pass in PidTagRuleCondition,
// PidTagRuleActions and PidTagRuleProvider.
TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue();
PropertyTag tempPropertyTag = new PropertyTag
{
PropertyId = 0x6676, PropertyType = 0003
};
taggedPropertyValue.PropertyTag = tempPropertyTag;
byte[] value3 = { 0x00, 0x00, 0x00, 0x0a };
taggedPropertyValue.Value = value3;
propertyValues[3].Value = taggedPropertyValue.Serialize();
// PidTagRuleCondition
taggedPropertyValue = new TaggedPropertyValue();
tempPropertyTag.PropertyId = 0x6679;
tempPropertyTag.PropertyType = 0x00fd;
taggedPropertyValue.PropertyTag = tempPropertyTag;
byte[] value =
{
0x03, 0x01, 0x00, 0x01, 0x00, 0x1f, 0x00, 0x37, 0x00, 0x1f, 0x00,
0x37, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6a, 0x00, 0x65,
0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, 0x58, 0x00, 0x00, 0x00
};
taggedPropertyValue.Value = value;
propertyValues[1].Value = taggedPropertyValue.Serialize();
// PidTagRuleAction
taggedPropertyValue = new TaggedPropertyValue();
tempPropertyTag.PropertyId = 0x6680;
tempPropertyTag.PropertyType = 0x00fe;
taggedPropertyValue.PropertyTag = tempPropertyTag;
byte[] value1 = { 0x01, 0x00, 0x09, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
taggedPropertyValue.Value = value1;
propertyValues[2].Value = taggedPropertyValue.Serialize();
// PidTagRuleProvider
taggedPropertyValue = new TaggedPropertyValue();
tempPropertyTag.PropertyId = 0x6681;
tempPropertyTag.PropertyType = 0x001f;
taggedPropertyValue.PropertyTag = tempPropertyTag;
byte[] value2 = Encoding.Unicode.GetBytes("RuleOrganizer\0");
taggedPropertyValue.Value = value2;
propertyValues[0].Value = taggedPropertyValue.Serialize();
RuleData sampleRuleData = new RuleData
{
RuleDataFlags = 0x01,
PropertyValueCount = (ushort)propertyValues.Length,
PropertyValues = propertyValues
};
RuleData[] sampleRuleDataArray = new RuleData[1];
sampleRuleDataArray[0] = sampleRuleData;
return sampleRuleDataArray;
}