Пример #1
0
        public async Task <IField> AddCalculatedAsync(string title, FieldCalculatedOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(await AddFieldAsync(FieldCalculatedOptionsToCreation(title, options)).ConfigureAwait(false));
        }
Пример #2
0
        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);
        }
Пример #3
0
 public IField AddCalculated(string title, FieldCalculatedOptions options)
 {
     return(AddCalculatedAsync(title, options).GetAwaiter().GetResult());
 }
Пример #4
0
 public IField AddCalculatedBatch(Batch batch, string title, FieldCalculatedOptions options)
 {
     return(AddCalculatedBatchAsync(batch, title, options).GetAwaiter().GetResult());
 }
Пример #5
0
 public async Task <IField> AddCalculatedBatchAsync(string title, FieldCalculatedOptions options)
 {
     return(await AddCalculatedBatchAsync(PnPContext.CurrentBatch, title, options).ConfigureAwait(false));
 }