protected override void HandlePropertyNotLastPropertyAndNotReferenceProperty( IBusinessObjectClass businessObjectClass, IBusinessObjectProperty property) { throw new ParseException( string.Format( "Each property in a property path except the last one must be a reference property. Property '{0}' is of type '{1}'.", property.Identifier, property.GetType().Name)); }
private Replacer.ReplaceInfo[] GetPropertyInfos(IBusinessObjectClass businessObjectClass, IBusinessObjectProperty[] properties) { Replacer.ReplaceInfo[] propertyInfos = new Replacer.ReplaceInfo[properties.Length]; for (int index = 0; index < properties.Length; index++) { IBusinessObjectProperty property = properties[index]; bool found = false; foreach (Configuration.ControlInfo controlMapping in _configuration.ControlMappings) { if (HasInterface(property.GetType(), controlMapping.propertyType) && property.IsList == controlMapping.isList) { ApplicationConfiguration.ReplaceInfo[] additionalReplaceInfos = new ApplicationConfiguration.ReplaceInfo[] { new ApplicationConfiguration.ReplaceInfo(Placeholder.ToString(DefinedPlaceholder.DOMAIN_PROPERTYNAME), property.Identifier) }; string additionalAttributes = Replacer.Replace(additionalReplaceInfos, controlMapping.additionalAttributes); string additionalElements = Replacer.Replace(additionalReplaceInfos, controlMapping.additionalElements); propertyInfos[index].replaceInfos = new string[] { Placeholder.ToString(DefinedPlaceholder.DOMAIN_PROPERTYNAME), property.Identifier, Placeholder.ToString(DefinedPlaceholder.CONTROLTYPE), controlMapping.controlName, Placeholder.ToString(DefinedPlaceholder.ADDITIONALATTRIBUTES), additionalAttributes, Placeholder.ToString(DefinedPlaceholder.ADDITIONALELEMENTS), additionalElements }; found = true; break; } } if (!found) { propertyInfos[index].replaceInfos = null; _warnings.AddWarning(WarningCode.MissingControlMapping, businessObjectClass.Identifier + "." + property.Identifier + " (" + property.GetType().ToString() + ")"); } } return(propertyInfos); }
private void CheckPropertyBase(IBusinessObjectProperty expectedProperty, IBusinessObjectProperty actualProperty) { ArgumentUtility.CheckNotNull("expectedProperty", expectedProperty); Assert.That(actualProperty, Is.Not.Null); Assert.That(actualProperty.GetType(), Is.SameAs(expectedProperty.GetType()), "BusinessObjectPropertyType"); Assert.That(expectedProperty.PropertyType, Is.EqualTo(actualProperty.PropertyType), "PropertyType"); Assert.That(expectedProperty.IsList, Is.EqualTo(actualProperty.IsList), "IsList"); if (expectedProperty.IsList) { Assert.That(expectedProperty.ListInfo.ItemType, Is.EqualTo(actualProperty.ListInfo.ItemType), "ListInfo.ItemType"); } Assert.That(expectedProperty.IsRequired, Is.EqualTo(actualProperty.IsRequired), "IsRequired"); Assert.That(((PropertyBase)actualProperty).ReflectedClass, Is.Not.Null); if (typeof(IBusinessObjectStringProperty).IsAssignableFrom(actualProperty.GetType())) { CheckStringProperty((IBusinessObjectStringProperty)actualProperty, expectedProperty); } }
/// <summary>Tests whether the <paramref name="property"/>'s type is part of the <paramref name="supportedPropertyInterfaces"/> array.</summary> /// <param name="property">The <see cref="IBusinessObjectProperty"/> to be tested. Must not be <see langword="null"/>.</param> /// <param name="supportedPropertyInterfaces"> /// The list of interfaces to test the <paramref name="property"/> against. Use <see langword="null"/> if no restrictions are made. Items must /// not be <see langword="null"/>. /// </param> /// <returns> /// <see langword="true"/> if the <paramref name="property"/>'s type is found in the <paramref name="supportedPropertyInterfaces"/> array. /// </returns> public bool IsPropertyInterfaceSupported(IBusinessObjectProperty property, Type[] supportedPropertyInterfaces) { ArgumentUtility.CheckNotNull("property", property); if (supportedPropertyInterfaces == null) { return(true); } ArgumentUtility.CheckNotNullOrItemsNull("supportedPropertyInterfaces", supportedPropertyInterfaces); bool isSupportedPropertyInterface = false; for (int i = 0; i < supportedPropertyInterfaces.Length; i++) { Type supportedInterface = supportedPropertyInterfaces[i]; if (supportedInterface.IsAssignableFrom(property.GetType())) { isSupportedPropertyInterface = true; break; } } return(isSupportedPropertyInterface); }
/// <summary> /// Evaluates the type of <paramref name="property"/> and returns the appropriate <see cref="BocDateTimeValueType"/>. /// </summary> /// <param name="property"> The <see cref="IBusinessObjectProperty"/> to be evaluated. </param> /// <returns> The matching <see cref="BocDateTimeValueType"/></returns> private BocDateTimeValueType GetBocDateTimeValueType(IBusinessObjectProperty property) { if (property == null) { return(BocDateTimeValueType.Undefined); } IBusinessObjectDateTimeProperty dateTimeProperty = property as IBusinessObjectDateTimeProperty; if (dateTimeProperty == null) { throw new NotSupportedException("BocDateTimeValue does not support property type " + property.GetType()); } if (dateTimeProperty.Type == DateTimeType.Date) { return(BocDateTimeValueType.Date); } else { return(BocDateTimeValueType.DateTime); } }
/// <summary> Returns the proper <see cref="BocTextValueType"/> for the passed <see cref="IBusinessObjectProperty"/>. </summary> /// <param name="property"> The <see cref="IBusinessObjectProperty"/> to analyze. </param> /// <exception cref="NotSupportedException"> The specialized type of the <paremref name="property"/> is not supported. </exception> private BocTextValueType GetBocTextValueType(IBusinessObjectProperty property) { if (property is IBusinessObjectStringProperty) { return(BocTextValueType.String); } else if (property is IBusinessObjectNumericProperty) { IBusinessObjectNumericProperty numericProperty = (IBusinessObjectNumericProperty)property; if (numericProperty.Type == typeof(byte)) { return(BocTextValueType.Byte); } else if (numericProperty.Type == typeof(decimal)) { return(BocTextValueType.Decimal); } else if (numericProperty.Type == typeof(double)) { return(BocTextValueType.Double); } else if (numericProperty.Type == typeof(short)) { return(BocTextValueType.Int16); } else if (numericProperty.Type == typeof(int)) { return(BocTextValueType.Int32); } else if (numericProperty.Type == typeof(long)) { return(BocTextValueType.Int64); } else if (numericProperty.Type == typeof(float)) { return(BocTextValueType.Single); } else { throw new NotSupportedException("BocTextValue does not support property type " + property.GetType()); } } else if (property is IBusinessObjectDateTimeProperty) { IBusinessObjectDateTimeProperty dateTimeProperty = (IBusinessObjectDateTimeProperty)property; if (dateTimeProperty.Type == DateTimeType.Date) { return(BocTextValueType.Date); } else { return(BocTextValueType.DateTime); } } else { throw new NotSupportedException("BocTextValue does not support property type " + property.GetType()); } }