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); }
private static FieldCreationOptions FieldNumberOptionsToCreation(string title, FieldNumberOptions options) { FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Number); creationOptions.ImportFromCommonFieldOptions(title, options); if (options.DefaultValue.HasValue) { creationOptions.SetChildXmlNode("DefaultValue", $"<Default>{CsomHelper.XmlString(options.DefaultValue.Value.ToString())}</Default>"); } if (options.Decimals.HasValue) { creationOptions.SetAttribute("Decimals", options.Decimals.ToString()); } if (options.MinimumValue.HasValue) { creationOptions.SetAttribute("Min", options.MinimumValue.ToString()); } if (options.MaximumValue.HasValue) { creationOptions.SetAttribute("Max", options.MaximumValue.ToString()); } if (options.ShowAsPercentage.HasValue) { creationOptions.SetAttribute("Percentage", options.ShowAsPercentage.ToString().ToUpper()); } return(creationOptions); }
private static FieldCreationOptions FieldCalculatedOptionsToCreation(string title, FieldCalculatedOptions options) { FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Calculated); creationOptions.ImportFromCommonFieldOptions(title, options); creationOptions.SetChildXmlNode("Formula", $"<Formula>{CsomHelper.XmlString(options.Formula)}</Formula>"); if (options.DateFormat.HasValue) { creationOptions.SetAttribute("Format", options.DateFormat.ToString()); } creationOptions.SetAttribute("ResultType", options.OutputType.ToString()); if (options.ShowAsPercentage.HasValue) { creationOptions.SetAttribute("Percentage", options.ShowAsPercentage.ToString().ToUpper()); } return(creationOptions); }