private string GetFieldCreator(ClientContext ctx, string title, AppManifestBase manifest) { OnVerboseNotify("Getting field creator for " + title); var builder = new FieldCreatorBuilder(); builder.VerboseNotify += builder_Notify; if (manifest == null) { return(builder.GetFieldCreator(ctx, title)); } builder.GetFieldCreator(ctx, title, manifest); return(string.Empty); }
private void GetFieldDifferences(WebCreator webDefinition) { OnVerboseNotify("Processing fields"); webDefinition.AppManifest.Fields = new Dictionary <string, string>(); _sourceContext.Web.EnsureProperty(w => w.Fields.Include(f => f.InternalName, f => f.Sealed, f => f.FieldTypeKind, f => f.Hidden, f => f.Title)); _baseContext.Web.EnsureProperty(w => w.Fields.Include(f => f.InternalName)); var fieldCreatorBuilder = new FieldCreatorBuilder(); fieldCreatorBuilder.VerboseNotify += (sender, args) => OnVerboseNotify(args.Message); var fieldsToAdd = _sourceContext.Web.Fields.Where( f => _baseContext.Web.Fields.FirstOrDefault(bf => bf.InternalName == f.InternalName) == null); foreach (var field in fieldsToAdd) { if (field.Sealed) { OnVerboseNotify( $"Sealed field {field.InternalName} found. Skipping. If this field is needed, add it explicitly. Note that if you install a sealed field, there is no way to uninstall it."); } else { Guid possibleTaxonomyField; //Somebody thought it would be a good idea to replace the first digit of the guid with a random character under certain circumstances //So replacing the first characte with a 0 will turn it back into a guid, if it is a guid var possibleTaxonomyFieldInternalName = $"0{field.InternalName.Substring(1)}"; if (field.FieldTypeKind == FieldType.Note && field.Hidden && Guid.TryParseExact(possibleTaxonomyFieldInternalName, "N", out possibleTaxonomyField) && field.Title.Contains("_")) { OnVerboseNotify( $"Skipping taxonomy note field {field.InternalName} found. Skipping. If this field is needed, add it explicitly."); } else { fieldCreatorBuilder.GetFieldCreator(_sourceContext, field.InternalName, webDefinition.AppManifest); } } } }