public PropertyTypeRegistration(string propName, RepositoryDataType dataType)
		{
			//-- Use when a property is generic: ContentHandler does not contain this property but ContentTypeDefinition contains it.
			Name = propName;
			DataType = dataType;
			IsDeclared = true;
		}
Example #2
0
 private static DataType ConvertDataType(RepositoryDataType source)
 {
     if (source == RepositoryDataType.NotDefined)
     {
         throw new ArgumentOutOfRangeException("source", "Source DataType cannot be NotDefined");
     }
     return((DataType)source);
 }
Example #3
0
        internal static RepositoryDataType[] GetDataTypes(string fieldShortName)
        {
            List <DataSlotInfo> slots = DataSlots[FieldShortNamesFullNames[fieldShortName]];

            RepositoryDataType[] result = new RepositoryDataType[slots.Count];
            for (int i = 0; i < slots.Count; i++)
            {
                result[i] = slots[i].DataType;
            }
            return(result);
        }
        private static void CheckDataType(string propName, RepositoryDataType dataType, string nodeTypeName, SchemaEditor editor)
        {
            var propType = editor.PropertyTypes[propName];

            if (propType == null)
            {
                return;
            }
            if (dataType == (RepositoryDataType)propType.DataType)
            {
                return;
            }

            // "DataType collision in two properties. NodeType = '{0}', PropertyType = '{1}', original DataType = {2}, passed DataType = {3}.";
            throw new RegistrationException(String.Format(SR.Exceptions.Registration.Msg_DataTypeCollisionInTwoProperties_4,
                                                          nodeTypeName, propName, propType.DataType, dataType));
        }
Example #5
0
		internal static string EncodeBinding(RepositoryDataType slotType, int slotNumber)
		{
			return String.Concat("#", slotType, "_", slotNumber);
		}
		public RepositoryPropertyAttribute(string propertyName, RepositoryDataType dataType)
		{
			_propertyName = propertyName;
			_dataType = dataType;
		}
		public RepositoryPropertyAttribute(RepositoryDataType dataType) : this(null, dataType) { }
Example #8
0
        private void SetFieldSlots()
        {
            //  Field slot indices and readonly.
            foreach (FieldSetting fieldSetting in this.FieldSettings)
            {
                if (fieldSetting.DataTypes.Length == 0)
                {
                    continue;
                }
                Type[][] slots = fieldSetting.HandlerSlots;
                for (int i = 0; i < fieldSetting.Bindings.Count; i++)
                {
                    string propName     = fieldSetting.Bindings[i];
                    Type   propertyType = null;
                    bool   readOnly     = false;

                    // generic property
                    RepositoryDataType dataType = fieldSetting.DataTypes[i];
                    switch (dataType)
                    {
                    case RepositoryDataType.String:
                    case RepositoryDataType.Text:
                        propertyType = typeof(string);
                        break;

                    case RepositoryDataType.Int:
                        propertyType = typeof(Int32);
                        break;

                    case RepositoryDataType.Currency:
                        propertyType = typeof(decimal);
                        break;

                    case RepositoryDataType.DateTime:
                        propertyType = typeof(DateTime);
                        break;

                    case RepositoryDataType.Binary:
                        propertyType = typeof(BinaryData);
                        break;

                    case RepositoryDataType.Reference:
                        propertyType = typeof(NodeList <Node>);
                        break;

                    default:
                        throw new ContentRegistrationException(String.Concat("Unknown datatype: ", dataType), this.Name, fieldSetting.Name);
                    }

                    for (int j = 0; j < slots[i].Length; j++)
                    {
                        if (slots[i][j].IsAssignableFrom(propertyType))
                        {
                            fieldSetting.HandlerSlotIndices[i] = j;
                            fieldSetting.PropertyIsReadOnly    = readOnly;
                            break;
                        }
                    }
                }
                fieldSetting.Initialize();
            }
        }
Example #9
0
        protected virtual void SetFieldSlots()
        {
            //-- Field slot indices and readonly.
            foreach (FieldSetting fieldSetting in this.FieldSettings)
            {
                if (fieldSetting.DataTypes.Length == 0)
                {
                    continue;
                }
                Type[][] slots = fieldSetting.HandlerSlots;
                for (int i = 0; i < fieldSetting.Bindings.Count; i++)
                {
                    string propName     = fieldSetting.Bindings[i];
                    Type   propertyType = null;
                    bool   readOnly     = false;

                    //-- generic property
                    RepositoryDataType dataType = fieldSetting.DataTypes[i];
                    switch (dataType)
                    {
                    case RepositoryDataType.String:
                    case RepositoryDataType.Text:
                        propertyType = typeof(string);
                        break;

                    case RepositoryDataType.Int:
                        propertyType = typeof(Int32);
                        break;

                    case RepositoryDataType.Currency:
                        propertyType = typeof(decimal);
                        break;

                    case RepositoryDataType.DateTime:
                        propertyType = typeof(DateTime);
                        break;

                    case RepositoryDataType.Binary:
                        propertyType = typeof(BinaryData);
                        break;

                    case RepositoryDataType.Reference:
                        propertyType = typeof(NodeList <Node>);
                        break;

                    default:
                        throw new ContentRegistrationException(String.Concat("Unknown datatype: ", dataType), this.Name, fieldSetting.Name);
                    }

                    for (int j = 0; j < slots[i].Length; j++)
                    {
                        ////-- for your information:
                        //typeof(Node).IsAssignableFrom(typeof(User)) ==> true
                        //typeof(User).IsAssignableFrom(typeof(Node)) ==> false
                        //-- this is the bad code:
                        //if (propertyType.IsAssignableFrom(slots[i][j]))
                        //-- this is the good:
                        try
                        {
                            var a = fieldSetting.Name[0] == '#';
                            var b = fieldSetting.DataTypes.Length == 0;
                            var x = fieldSetting.HandlerSlotIndices[i];
                        }
                        catch
                        {
                            throw;
                        }
                        if (slots[i][j].IsAssignableFrom(propertyType))
                        {
                            fieldSetting.HandlerSlotIndices[i] = j;
                            fieldSetting.PropertyIsReadOnly    = readOnly;
                            break;
                        }
                    }
                }
                fieldSetting.Initialize();
            }
        }
Example #10
0
		public DataSlotAttribute(int slotIndex, RepositoryDataType dataType, params Type[] acceptedTypes)
		{
			_slotIndex = slotIndex;
			_dataType = dataType;
			_acceptedTypes = acceptedTypes;
		}
Example #11
0
 public DataSlotInfo(int slotIndex, RepositoryDataType dataType, Type[] acceptedTypes)
 {
     SlotIndex     = slotIndex;
     DataType      = dataType;
     AcceptedTypes = acceptedTypes;
 }
Example #12
0
 public RepositoryPropertyAttribute(string propertyName, RepositoryDataType dataType)
 {
     _propertyName = propertyName;
     _dataType     = dataType;
 }
Example #13
0
 public RepositoryPropertyAttribute(RepositoryDataType dataType) : this(null, dataType)
 {
 }
Example #14
0
		private static void CheckDataType(string propName, RepositoryDataType dataType, string nodeTypeName, SchemaEditor editor)
		{
			var propType = editor.PropertyTypes[propName];

			if (propType == null)
				return;
			if (dataType == (RepositoryDataType)propType.DataType)
				return;

			//"DataType collision in two properties. NodeType = '{0}', PropertyType = '{1}', original DataType = {2}, passed DataType = {3}.";
			throw new RegistrationException(String.Format(SR.Exceptions.Registration.Msg_DataTypeCollisionInTwoProperties_4,
				nodeTypeName, propName, propType.DataType, dataType));
		}
Example #15
0
        private void SetFieldSlots(Type handlerType)
        {
            //-- Field slot indices and readonly.
            if (handlerType == null)
            {
                throw new ContentRegistrationException(String.Concat("Unknown ContentHandler: '", this.HandlerName, "'. ContentType: ", this.Name));
            }
            foreach (FieldSetting fieldSetting in this.FieldSettings)
            {
                if (fieldSetting.DataTypes.Length == 0)
                {
                    continue;
                }
                Type[][] slots = fieldSetting.HandlerSlots;
                for (int i = 0; i < fieldSetting.Bindings.Count; i++)
                {
                    string       propName = fieldSetting.Bindings[i];
                    PropertyInfo propInfo = null;
                    propInfo = handlerType.GetProperty(propName);
                    Type propertyType = null;
                    bool readOnly     = false;
                    if (propInfo != null)
                    {
                        //-- code property
                        propertyType = propInfo.PropertyType;
                        readOnly     = readOnly || !ContentTypeManager.PropertyHasPublicSetter(propInfo);
                    }
                    else
                    {
                        //-- generic property
                        if (handlerType != typeof(GenericContent) &&
                            !handlerType.IsSubclassOf(typeof(GenericContent)))
                        {
                            throw new ContentRegistrationException(String.Concat("Unknown property: ", propName), this.Name, fieldSetting.Name);
                        }
                        RepositoryDataType dataType = fieldSetting.DataTypes[i];
                        switch (dataType)
                        {
                        case RepositoryDataType.String:
                        case RepositoryDataType.Text:
                            propertyType = typeof(string);
                            break;

                        case RepositoryDataType.Int:
                            propertyType = typeof(Int32);
                            break;

                        case RepositoryDataType.Currency:
                            propertyType = typeof(decimal);
                            break;

                        case RepositoryDataType.DateTime:
                            propertyType = typeof(DateTime);
                            break;

                        case RepositoryDataType.Binary:
                            propertyType = typeof(BinaryData);
                            break;

                        case RepositoryDataType.Reference:
                            propertyType = typeof(NodeList <Node>);
                            break;

                        default:
                            throw new ContentRegistrationException(String.Concat("Unknown datatype: ", dataType), this.Name, fieldSetting.Name);
                        }
                    }
                    for (int j = 0; j < slots[i].Length; j++)
                    {
                        ////-- for your information:
                        //typeof(Node).IsAssignableFrom(typeof(User)) ==> true
                        //typeof(User).IsAssignableFrom(typeof(Node)) ==> false
                        //-- this is the bad code:
                        //if (propertyType.IsAssignableFrom(slots[i][j]))
                        //-- this is the good:
                        if (slots[i][j].IsAssignableFrom(propertyType))
                        {
                            fieldSetting.HandlerSlotIndices[i] = j;
                            fieldSetting.PropertyIsReadOnly    = readOnly;
                            break;
                        }
                    }
                }
                fieldSetting.Initialize();
            }
        }
Example #16
0
		private static DataType ConvertDataType(RepositoryDataType source)
		{
			if (source == RepositoryDataType.NotDefined)
				throw new ArgumentOutOfRangeException("source", "Source DataType cannot be NotDefined");
			return (DataType)source;
		}
Example #17
0
 public DataSlotAttribute(int slotIndex, RepositoryDataType dataType, params Type[] acceptedTypes)
 {
     _slotIndex     = slotIndex;
     _dataType      = dataType;
     _acceptedTypes = acceptedTypes;
 }
Example #18
0
 internal static string EncodeBinding(RepositoryDataType slotType, int slotNumber)
 {
     return(String.Concat("#", slotType, "_", slotNumber));
 }
Example #19
0
		internal static RepositoryDataType[] GetDataTypes(string fieldShortName)
		{
			List<DataSlotInfo> slots = DataSlots[FieldShortNamesFullNames[fieldShortName]];
			RepositoryDataType[] result = new RepositoryDataType[slots.Count];
			for (int i = 0; i < slots.Count; i++)
				result[i] = slots[i].DataType;
			return result;
		}