WriteSetOrAppendMembersToXml method

void WriteSetOrAppendMembersToXml(
  1. EwsServiceXmlWriter writer,
  2. List<GroupMember> members,
  3. bool setMode
)
Generate XML to delete individual members. Xml writer. Members to delete. Generate XML to Set or Append members. When members are set, the existing PDL member collection is cleared. On append members are added to the PDL existing members collection. Xml writer. Members to set or append. True - set members, false - append members.

Implementation

//        /* private */ void WriteDeleteMembersToXml(EwsServiceXmlWriter writer, List<GroupMember> members)
//        {
//            if (members.length != 0)
//            {
//                GroupMemberPropertyDefinition memberPropDef = new GroupMemberPropertyDefinition();
//
//                for (GroupMember member in members)
//                {
//                    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.DeleteItemField);
//
//                    memberPropDef.Key = member.Key;
//                    memberPropDef.WriteToXml(writer);
//
//                    writer.WriteEndElement();   // DeleteItemField
//                }
//            }
//        }

/// <summary>
/// Generate XML to Set or Append members.
/// When members are set, the existing PDL member collection is cleared.
/// On append members are added to the PDL existing members collection.
/// </summary>
/// <param name="writer">Xml writer.</param>
/// <param name="members">Members to set or append.</param>
/// <param name="setMode">True - set members, false - append members.</param>
/* private */
void WriteSetOrAppendMembersToXml(
    EwsServiceXmlWriter writer, List<GroupMember> members, bool setMode) {
  if (members.length != 0) {
    writer.WriteStartElement(
        XmlNamespace.Types,
        setMode
            ? XmlElementNames.SetItemField
            : XmlElementNames.AppendToItemField);

    ContactGroupSchema.Members.WriteToXml(writer);

    writer.WriteStartElement(
        XmlNamespace.Types, XmlElementNames.DistributionList);
    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Members);

    for (GroupMember member in members) {
      member.WriteToXml(writer, XmlElementNames.Member);
    }

    writer.WriteEndElement(); // Members
    writer.WriteEndElement(); // Group
    writer.WriteEndElement(); // setMode ? SetItemField : AppendItemField
  }
}