Ejemplo n.º 1
0
        public async Task <IField> AddChoiceMultiAsync(string title, FieldChoiceMultiOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(await AddFieldAsync(FieldChoiceMultiOptionsToCreation(title, options)).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        private static FieldCreationOptions FieldChoiceMultiOptionsToCreation(string title, FieldChoiceMultiOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.MultiChoice);

            creationOptions.ImportFromCommonFieldOptions(title, options);
            if (options.FillInChoice.HasValue)
            {
                creationOptions.SetAttribute("FillInChoice", options.FillInChoice.Value.ToString().ToUpper());
            }

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(options.DefaultChoice))
            {
                sb.AppendLine($"<Default>{CsomHelper.XmlString(options.DefaultChoice)}</Default>");
            }

            sb.AppendLine("<CHOICES>");

            foreach (var choice in options.Choices)
            {
                sb.AppendLine($"<CHOICE>{CsomHelper.XmlString(choice)}</CHOICE>");
            }
            sb.AppendLine("</CHOICES>");

            creationOptions.SetChildXmlNode("ChoiceXml", sb.ToString());

            return(creationOptions);
        }
Ejemplo n.º 3
0
 public IField AddChoiceMulti(string title, FieldChoiceMultiOptions options)
 {
     return(AddChoiceMultiAsync(title, options).GetAwaiter().GetResult());
 }
Ejemplo n.º 4
0
 public IField AddChoiceMultiBatch(Batch batch, string title, FieldChoiceMultiOptions options)
 {
     return(AddChoiceMultiBatchAsync(batch, title, options).GetAwaiter().GetResult());
 }
Ejemplo n.º 5
0
 public async Task <IField> AddChoiceMultiBatchAsync(string title, FieldChoiceMultiOptions options)
 {
     return(await AddChoiceMultiBatchAsync(PnPContext.CurrentBatch, title, options).ConfigureAwait(false));
 }