示例#1
0
		private FieldSetting CreateNewFieldType(FieldDescriptor fieldInfo, Dictionary<string, List<string>> newBindings, ContentListType listType, SlotTable slotTable, SchemaEditor editor)
		{
			List<string> bindList = new List<string>();
			foreach (RepositoryDataType slotType in FieldManager.GetDataTypes(fieldInfo.FieldTypeShortName))
			{
				if (slotType == RepositoryDataType.NotDefined)
					continue;
				int slotNumber = slotTable.ReserveSlot((DataType)slotType);
				string binding = EncodeBinding(slotType, slotNumber);
				bindList.Add(binding);

				PropertyType pt = editor.PropertyTypes[binding];
				if (pt == null)
					pt = editor.CreateContentListPropertyType((DataType)slotType, slotNumber);
				editor.AddPropertyTypeToPropertySet(pt, listType);
			}
			newBindings.Add(fieldInfo.FieldName, bindList);

			return FieldSetting.Create(fieldInfo, bindList);
		}
示例#2
0
        internal static FieldDescriptor Parse(XPathNavigator fieldElement, IXmlNamespaceResolver nsres, ContentType contentType)
        {
            FieldDescriptor fdesc = new FieldDescriptor();

            fdesc.Owner = contentType;
            var fieldName = fieldElement.GetAttribute("name", String.Empty);

            fdesc.FieldName          = fieldName;
            fdesc.FieldTypeShortName = fieldElement.GetAttribute("type", String.Empty);
            fdesc.FieldTypeName      = fieldElement.GetAttribute("handler", String.Empty);
            fdesc.IsContentListField = fdesc.FieldName[0] == '#';
            if (String.IsNullOrEmpty(fdesc.FieldTypeShortName))
            {
                fdesc.FieldTypeShortName = FieldManager.GetShortName(fdesc.FieldTypeName);
            }

            if (fdesc.FieldTypeName.Length == 0)
            {
                if (fdesc.FieldTypeShortName.Length == 0)
                {
                    throw new ContentRegistrationException("Field element's 'handler' attribute is required if 'type' attribute is not given.", contentType.Name, fdesc.FieldName);
                }
                fdesc.FieldTypeName = FieldManager.GetFieldHandlerName(fdesc.FieldTypeShortName);
            }

            fdesc.Bindings = new List <string>();

            foreach (XPathNavigator subElement in fieldElement.SelectChildren(XPathNodeType.Element))
            {
                switch (subElement.LocalName)
                {
                case "DisplayName":
                    fdesc.DisplayName = subElement.Value;
                    break;

                case "Description":
                    fdesc.Description = subElement.Value;
                    break;

                case "Icon":
                    fdesc.Icon = subElement.Value;
                    break;

                case "Bind":
                    var propertyName = subElement.GetAttribute("property", String.Empty);
                    fdesc.Bindings.Add(propertyName);
                    fdesc.IsRerouted |= propertyName != fdesc.FieldName;
                    break;

                case "Indexing":
                    foreach (XPathNavigator indexingSubElement in subElement.SelectChildren(XPathNodeType.Element))
                    {
                        switch (indexingSubElement.LocalName)
                        {
                        case "Mode": fdesc.IndexingMode = indexingSubElement.Value; break;

                        case "Store": fdesc.IndexStoringMode = indexingSubElement.Value; break;

                        case "TermVector": fdesc.IndexingTermVector = indexingSubElement.Value; break;

                        case "Analyzer": fdesc.Analyzer = ParseAnalyzer(indexingSubElement.Value, contentType.Name, fieldName); break;

                        case "IndexHandler": fdesc.IndexHandlerTypeName = indexingSubElement.Value; break;
                        }
                    }
                    break;

                case "Configuration":
                    fdesc.ConfigurationElement = subElement;
                    fdesc.FieldSettingTypeName = subElement.GetAttribute("handler", String.Empty);
                    break;

                case "AppInfo":
                    fdesc.AppInfo = subElement;
                    break;

                default:
                    throw new NotSupportedException(String.Concat("Unknown element in Field: ", subElement.LocalName));
                }
            }

            // Default binding;
            RepositoryDataType[] dataTypes = FieldManager.GetDataTypes(fdesc.FieldTypeShortName);
            fdesc.DataTypes = dataTypes;
            if (fdesc.IsContentListField)
            {
                foreach (var d in dataTypes)
                {
                    fdesc.Bindings.Add(null);
                }
            }
            else
            {
                if (dataTypes.Length > 1 && fdesc.Bindings.Count != dataTypes.Length)
                {
                    throw new ContentRegistrationException("Missing excplicit 'Binding' elements", contentType.Name, fdesc.FieldName);
                }
                if (dataTypes.Length == 1 && fdesc.Bindings.Count == 0)
                {
                    fdesc.Bindings.Add(fdesc.FieldName);
                }
            }

            fdesc.XmlNamespaceResolver = nsres;

            return(fdesc);
        }
示例#3
0
		private void ChangeFieldSetting(FieldSetting oldSetting, FieldDescriptor fieldDescriptor)
		{
			FieldSetting newSetting = FieldSetting.Create(fieldDescriptor);

			int index = this.GetFieldSettingIndexByName(newSetting.Name);
			this.FieldSettings[index] = newSetting;

			newSetting.ParentFieldSetting = oldSetting.ParentFieldSetting;

			ChangeParentFieldSettingRecursive(oldSetting, newSetting);
		}
示例#4
0
        //---------------------------------------------------------------------- Other validation

        private static void CheckFieldValidation(FieldDescriptor fieldDesc, string contentTypeName)
        {
            if (fieldDesc.Analyzer != null)
            {
                var analyzerType = TypeHandler.GetType(fieldDesc.Analyzer);
                if (analyzerType == null)
                    throw new RegistrationException(String.Concat("Unknown analyzer: ", fieldDesc.Analyzer, ". Field: ", fieldDesc.FieldName, ", ContentType: ", contentTypeName));
            }
        }
示例#5
0
		internal static FieldDescriptor Parse(XPathNavigator fieldElement, IXmlNamespaceResolver nsres, ContentType contentType)
		{
			FieldDescriptor fdesc = new FieldDescriptor();
			fdesc.Owner = contentType;
            var fieldName = fieldElement.GetAttribute("name", String.Empty);
            fdesc.FieldName = fieldName;
			fdesc.FieldTypeShortName = fieldElement.GetAttribute("type", String.Empty);
			fdesc.FieldTypeName = fieldElement.GetAttribute("handler", String.Empty);
            fdesc.IsContentListField = fdesc.FieldName[0] == '#';
            if (String.IsNullOrEmpty(fdesc.FieldTypeShortName))
                fdesc.FieldTypeShortName = FieldManager.GetShortName(fdesc.FieldTypeName);

			if (fdesc.FieldTypeName.Length == 0)
			{
				if (fdesc.FieldTypeShortName.Length == 0)
					throw new ContentRegistrationException("Field element's 'handler' attribute is required if 'type' attribute is not given.", contentType.Name, fdesc.FieldName);
				fdesc.FieldTypeName = FieldManager.GetFieldHandlerName(fdesc.FieldTypeShortName);
			}

			fdesc.Bindings = new List<string>();

			foreach (XPathNavigator subElement in fieldElement.SelectChildren(XPathNodeType.Element))
			{
				switch (subElement.LocalName)
				{
                    case "DisplayName":
                        fdesc.DisplayName = subElement.Value;
						break;
					case "Description":
						fdesc.Description = subElement.Value;
						break;
					case "Icon":
						fdesc.Icon = subElement.Value;
						break;
					case "Bind":
						fdesc.Bindings.Add(subElement.GetAttribute("property", String.Empty));
						break;
                    case "Indexing":
                        foreach (XPathNavigator indexingSubElement in subElement.SelectChildren(XPathNodeType.Element))
                        {
                            switch (indexingSubElement.LocalName)
                            {
                                case "Mode": fdesc.IndexingMode = indexingSubElement.Value; break;
                                case "Store": fdesc.IndexStoringMode = indexingSubElement.Value; break;
                                case "TermVector": fdesc.IndexingTermVector = indexingSubElement.Value; break;
                                case "Analyzer": fdesc.Analyzer = indexingSubElement.Value; break;
                                case "IndexHandler": fdesc.IndexHandlerTypeName = indexingSubElement.Value; break;
                            }
                        }
                        break;
					case "Configuration":
						fdesc.ConfigurationElement = subElement;
						fdesc.FieldSettingTypeName = subElement.GetAttribute("handler", String.Empty);
						break;
					case "AppInfo":
                        fdesc.AppInfo = subElement;
						break;
					default:
						throw new NotSupportedException(String.Concat("Unknown element in Field: ", subElement.LocalName));
				}
			}

			//-- Default binding;
			RepositoryDataType[] dataTypes = FieldManager.GetDataTypes(fdesc.FieldTypeShortName);
			fdesc.DataTypes = dataTypes;
            if (fdesc.IsContentListField)
            {
                foreach(var d in dataTypes)
                    fdesc.Bindings.Add(null);
            }
            else
            {
                if (dataTypes.Length > 1 && fdesc.Bindings.Count != dataTypes.Length)
                    throw new ContentRegistrationException("Missing excplicit 'Binding' elements", contentType.Name, fdesc.FieldName);
                if (dataTypes.Length == 1 && fdesc.Bindings.Count == 0)
                    fdesc.Bindings.Add(fdesc.FieldName);
            }

			fdesc.XmlNamespaceResolver = nsres;

			return fdesc;
		}