private ListCreationInformation BuildListCreationInformation(ClientContext context, Type entityType) { ListCreationInformation listCreationInfo = new ListCreationInformation { Title = EntityHelper.GetInternalNameFromEntityType(entityType), TemplateType = EntityHelper.GetListTemplateType(entityType), Description = EntityHelper.GetDescriptionFromEntityType(entityType), }; int?documentTemplateType = GetTableDocumentTemplateType(entityType); if (documentTemplateType.HasValue) { listCreationInfo.DocumentTemplateType = documentTemplateType.Value; } QuickLaunchOptions?quickLaunchOption = GetQuickLaunchOption(entityType); if (quickLaunchOption.HasValue) { listCreationInfo.QuickLaunchOption = quickLaunchOption.Value; } string url = GetTableUrl(entityType); if (url != null) { listCreationInfo.Url = url; } return(listCreationInfo); }
private string GetFieldCreationXml(PropertyInfo property, Dictionary <string, Guid> lookupTableIds) { Type propertyType = property.PropertyType; string internalName = EntityHelper.GetInternalNameFromProperty(property); string displayName = EntityHelper.GetDisplayNameFromProperty(property); string description = EntityHelper.GetDescriptionFromEntityType(propertyType); bool isRequired = PropertyIsRequired(property); bool isUnique = IsTrue(propertyType.GetCustomAttribute <UniqueAttribute>()?.IsUnique); string fieldTypeName = EntityHelper.GetFieldType(property); bool isMulti = IsMulti(propertyType); if (fieldTypeName == nameof(FieldType.Lookup)) { EntityHelper.RemoveLookupIdFromFieldName(isMulti, ref internalName, ref displayName); } GetFieldCreationAdditionalXmlForFieldType(fieldTypeName, property, lookupTableIds, out string fieldAttributes, out string fieldAdditional); string fieldTypeString = fieldTypeName.ToString(); if (fieldAttributes == null) { fieldAttributes = string.Empty; } if (fieldAttributes == null) { fieldAdditional = string.Empty; } if (isMulti) { if (fieldTypeName == nameof(FieldType.Choice)) { fieldTypeString = "Multi" + fieldTypeString; } else { fieldAttributes += " Mult='TRUE'"; fieldTypeString += "Multi"; } } var indexAttribute = property.GetCustomAttribute <IndexAttribute>(); if (indexAttribute != null) { fieldAttributes += " Indexed='TRUE'"; } string csomCreateCaml = $"<Field Type='{fieldTypeString}' Name='{internalName}' DisplayName='{displayName}' StaticName='{internalName}'"; if (isRequired) { csomCreateCaml += " Required='TRUE'"; } if (isUnique) { csomCreateCaml += " EnforceUniqueValues='TRUE'"; } csomCreateCaml += $" {fieldAttributes}"; if (string.IsNullOrWhiteSpace(fieldAdditional)) { csomCreateCaml += "/>"; } else { csomCreateCaml += ">"; csomCreateCaml += fieldAdditional; csomCreateCaml += "</Field>"; } return(csomCreateCaml); }