protected void AddField([CanBeNull] XmlNode node) { if (node?.Attributes?["name"] == null) { return; } var field = new SolrSchemaField(); SetProperties(node, field); _solrSchemaFields.Add(field); }
private void SetProperties([NotNull] XmlNode node, [NotNull] SolrSchemaField field) { if (node.Attributes?["type"] == null) { return; } field.Name = GetStringParameter(node, "name"); foreach (XmlAttribute attr in node.Attributes) { // skip all attributes from other namespaces, such as Sitecore's patch:source="..." if (attr.Name == "name" || attr.Name.Contains(":")) { continue; } field.Properties.Add(attr.Name, attr.Value); } }
/// <summary> /// Returns remove commands for all existing fields, equal to the default /// Sitecore implementation /// </summary> /// <returns></returns> public IEnumerable <XElement> GetRemoveAllFields() { foreach (var solrCopyField in _solrSchema.SolrCopyFields) { var d = new SolrSchemaCopyField { Source = solrCopyField.Source, Destination = solrCopyField.Destination }; yield return(d.SerializeDeleteCommand(_solrSchema)); } foreach (var solrDynamicField in _solrSchema.SolrDynamicFields .Where(s => _solrSolrSchemaConfiguration.DynamicFields.All(f => f.Name != s.Name))) { var d = new SolrSchemaDynamicField(solrDynamicField.Name); yield return(d.SerializeDeleteCommand(_solrSchema)); } foreach (var solrField in _solrSchema.SolrFields .Where(s => _solrSolrSchemaConfiguration.Fields.All(f => f.Name != s.Name))) { var d = new SolrSchemaField(solrField.Name); yield return(d.SerializeDeleteCommand(_solrSchema)); } }