public void SetIgnoredFields(string placeholderName, IEnumerable <string> fields) { var schemaManager = new WordPropertySchemaManager(_model); var schema = schemaManager.GetSchema(); var propertyType = schema?.GetPropertyType("IgnoredListFields"); if (propertyType != null) { var property = _model.GetProperty(propertyType) ?? _model.AddProperty(propertyType, null); if (property is IPropertyArray propertyArray) { var list = new List <string>(); var existing = propertyArray.Value? .Where(x => !string.IsNullOrWhiteSpace(x) && !x.StartsWith($"{placeholderName}#")) .ToArray(); if (existing?.Any() ?? false) { list.AddRange(existing); } if (fields?.Any() ?? false) { list.AddRange(fields.Select(x => $"{placeholderName}#{x}")); } propertyArray.Value = list; } } }
public IEnumerable <string> GetPlaceholdersWithIgnoredFields() { IEnumerable <string> result = null; var schemaManager = new WordPropertySchemaManager(_model); var schema = schemaManager.GetSchema(); var propertyType = schema?.GetPropertyType("IgnoredListFields"); if (propertyType != null) { var property = _model.GetProperty(propertyType) as IPropertyArray; result = property?.Value?.Select(x => x.Split('#').FirstOrDefault()) .Distinct().Where(x => !string.IsNullOrWhiteSpace(x)); } return(result); }
public IEnumerable <string> GetIgnoredFields(string placeholderName) { IEnumerable <string> result = null; var schemaManager = new WordPropertySchemaManager(_model); var schema = schemaManager.GetSchema(); var propertyType = schema?.GetPropertyType("IgnoredListFields"); if (propertyType != null) { var property = _model.GetProperty(propertyType) as IPropertyArray; var values = property?.Value?.Where(x => x.StartsWith($"{placeholderName}#")).ToArray(); if (values?.Any() ?? false) { result = values.Select(x => x.Replace($"{placeholderName}#", "")); } } return(result); }