Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        private static FieldCreationOptions FieldMultilineTextOptionsToCreation(string title, FieldMultilineTextOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Note);

            creationOptions.ImportFromCommonFieldOptions(title, options);

            if (options.NumberOfLines.HasValue)
            {
                creationOptions.SetAttribute("NumLines", options.NumberOfLines.ToString());
            }

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

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

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

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

            return(creationOptions);
        }
Esempio n. 3
0
        private static FieldCreationOptions FieldLookupOptionsToCreation(string title, FieldLookupOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Lookup);

            creationOptions.ImportFromCommonFieldOptions(title, options);
            creationOptions.SetAttribute("ShowField", options.LookupFieldName);
            creationOptions.SetAttribute("List", options.LookupListId.ToString());
            return(creationOptions);
        }
Esempio n. 4
0
        private static FieldCreationOptions FieldDateTimeOptionsToCreation(string title, FieldDateTimeOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.DateTime);

            creationOptions.ImportFromCommonFieldOptions(title, options);
            creationOptions.SetAttribute("Format", options.DisplayFormat.ToString());
            creationOptions.SetAttribute("FriendlyDisplayFormat", options.FriendlyDisplayFormat.ToString());
            creationOptions.SetAttribute("CalType", ((int)options.DateTimeCalendarType).ToString());
            return(creationOptions);
        }
Esempio n. 5
0
        private static FieldCreationOptions FieldUserOptionsToCreation(string title, FieldUserOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.User);

            creationOptions.ImportFromCommonFieldOptions(title, options);
            creationOptions.SetAttribute("UserSelectionMode", ((int)options.SelectionMode).ToString());
            creationOptions.SetAttribute("UserSelectionScope", "0");
            //creationOptions.SetAttribute("IsModern", "TRUE");
            //creationOptions.SetAttribute("Dropdown", "TRUE");
            return(creationOptions);
        }
Esempio n. 6
0
        private static FieldCreationOptions FieldCurrencyOptionsToCreation(string title, FieldCurrencyOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Currency);

            creationOptions.ImportFromCommonFieldOptions(title, options);
            if (options.Decimals.HasValue)
            {
                creationOptions.SetAttribute("Decimals", options.Decimals.ToString().ToUpper());
            }
            if (options.CurrencyLocaleId.HasValue)
            {
                creationOptions.SetAttribute("LCID", options.CurrencyLocaleId.ToString().ToUpper());
            }
            return(creationOptions);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        private static FieldCreationOptions FieldUrlOptionsToCreation(string title, FieldUrlOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.URL);

            creationOptions.ImportFromCommonFieldOptions(title, options);
            creationOptions.SetAttribute("Format", options.DisplayFormat.ToString());
            return(creationOptions);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        private static FieldCreationOptions FieldTextOptionsToCreation(string title, FieldTextOptions options)
        {
            FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Text);

            creationOptions.ImportFromCommonFieldOptions(title, options);

            if (options != null && options.MaxLength.HasValue)
            {
                creationOptions.SetAttribute("MaxLength", options.MaxLength.ToString());
            }

            return(creationOptions);
        }