private void ParseFieldElements(XPathNavigator fieldsElement, IXmlNamespaceResolver nsres) { foreach (XPathNavigator fieldElement in fieldsElement.SelectChildren(XPathNodeType.Element)) { FieldDescriptor fieldDescriptor = FieldDescriptor.Parse(fieldElement, nsres, this); CheckFieldValidation(fieldDescriptor, this.Name); int fieldIndex = GetFieldSettingIndexByName(fieldDescriptor.FieldName); FieldSetting fieldSetting = fieldIndex < 0 ? null : this.FieldSettings[fieldIndex]; if (fieldSetting == null) { //==== if there is not...: create and inherit fieldSetting = FieldSetting.Create(fieldDescriptor); this.FieldSettings.Add(fieldSetting); //-- inherit new fieldType foreach (ContentType child in this.ChildTypes) { child.InheritField(fieldSetting); } } else { //==== if there is ... if (fieldSetting.Owner == this) { string fieldSettingTypeName = fieldDescriptor.FieldSettingTypeName; if (String.IsNullOrEmpty(fieldSettingTypeName)) { fieldSettingTypeName = FieldManager.GetDefaultFieldSettingTypeName(fieldDescriptor.FieldTypeName); } if (fieldSettingTypeName == fieldSetting.GetType().FullName) { fieldSetting.Modify(fieldDescriptor); } else { ChangeFieldSetting(fieldSetting, fieldDescriptor); } } else { //==== if inherited: break inheritance //-- create new FieldSetting newFieldSetting = FieldSetting.Create(fieldDescriptor); newFieldSetting.ParentFieldSetting = fieldSetting; this.FieldSettings[fieldIndex] = newFieldSetting; //-- inherit foreach (ContentType child in this.ChildTypes) { child.InheritField(newFieldSetting); } } } } }
public static string GetDefaultFieldSettingTypeName(Type fieldType) { return(FieldManager.GetDefaultFieldSettingTypeName(fieldType.FullName)); }