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; }
private static DataType ConvertDataType(RepositoryDataType source) { if (source == RepositoryDataType.NotDefined) { throw new ArgumentOutOfRangeException("source", "Source DataType cannot be NotDefined"); } return((DataType)source); }
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)); }
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) { }
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(); } }
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(); } }
public DataSlotAttribute(int slotIndex, RepositoryDataType dataType, params Type[] acceptedTypes) { _slotIndex = slotIndex; _dataType = dataType; _acceptedTypes = acceptedTypes; }
public DataSlotInfo(int slotIndex, RepositoryDataType dataType, Type[] acceptedTypes) { SlotIndex = slotIndex; DataType = dataType; AcceptedTypes = acceptedTypes; }
public RepositoryPropertyAttribute(string propertyName, RepositoryDataType dataType) { _propertyName = propertyName; _dataType = dataType; }
public RepositoryPropertyAttribute(RepositoryDataType dataType) : this(null, dataType) { }
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)); }
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(); } }
private static DataType ConvertDataType(RepositoryDataType source) { if (source == RepositoryDataType.NotDefined) throw new ArgumentOutOfRangeException("source", "Source DataType cannot be NotDefined"); return (DataType)source; }
public DataSlotAttribute(int slotIndex, RepositoryDataType dataType, params Type[] acceptedTypes) { _slotIndex = slotIndex; _dataType = dataType; _acceptedTypes = acceptedTypes; }
internal static string EncodeBinding(RepositoryDataType slotType, int slotNumber) { return(String.Concat("#", slotType, "_", slotNumber)); }
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; }