internal ExpressionInfo GetCustomProperty(CustomPropertyDefinitionCollection properties, string name, ExpressionInfo defaultValue) { // get property CustomPropertyDefinition property = properties[name]; // if property is not set then return default value return(property == null ? defaultValue : property.Value); }
private void InitializeCustomProperty(string propertyName, string defaultValue = "") { var customProp = ReportItem.CustomProperties[propertyName]; if (customProp != null) { return; } customProp = new CustomPropertyDefinition(propertyName, defaultValue); ReportItem.CustomProperties.Add(customProp); }
internal void SetCustomProperty(CustomPropertyDefinitionCollection properties, string name, ExpressionInfo value, ExpressionInfo defaultValue) { // Fire component changing if (ComponentChangeService != null) { ComponentChangeService.OnComponentChanging(ReportItem, null); } // get property CustomPropertyDefinition property = properties[name]; bool isDefaultValue = defaultValue == value; if (isDefaultValue) { // reset the property value if (property != null) { properties.Remove(property); } } else { // set property value if (property == null) { properties.Add(new CustomPropertyDefinition(name, value)); } else { property.Value = value; } } // Fire component changed if (ComponentChangeService != null) { ComponentChangeService.OnComponentChanged(ReportItem, null, null, null); } }
private void FillEntityProperties(PropertyDefinition rp, XmlNode propertiesNode) { XmlElement propertyElement = null; if (rp is ScalarPropertyDefinition) { propertyElement = CreateElement("Property"); } else if (rp is EntityPropertyDefinition) { propertyElement = CreateElement("EntityProperty"); } else if (rp is CustomPropertyDefinition) { propertyElement = CreateElement("CustomProperty"); } else { throw new NotSupportedException(rp.GetType().ToString()); } if (rp.PropertyAccessLevel == AccessLevel.Private && rp.Interfaces.Any()) { string[] ss = rp.Name.Split(':'); if (ss.Length > 1) { propertyElement.SetAttribute("name", ss[1]); } else { propertyElement.SetAttribute("name", rp.Name); } } else { propertyElement.SetAttribute("name", rp.Name); } if (rp.Attributes != Field2DbRelations.None) { propertyElement.SetAttribute("attributes", rp.Attributes.ToString().Replace(",", "")); } if (rp.SourceFragment != null) { propertyElement.SetAttribute("table", rp.SourceFragment.Identifier); } if (rp.PropertyType != null) { if (rp is ScalarPropertyDefinition || rp is CustomPropertyDefinition) { propertyElement.SetAttribute("type", rp.PropertyType.Identifier); } else if (rp is EntityPropertyDefinition) { propertyElement.SetAttribute("referencedEntity", rp.PropertyType.Entity.Identifier); } else { throw new NotSupportedException(rp.GetType().ToString()); } } if (!string.IsNullOrEmpty(rp.Description)) { propertyElement.SetAttribute("description", rp.Description); } if (rp.FieldAccessLevel != AccessLevel.Private && !(rp is CustomPropertyDefinition)) { propertyElement.SetAttribute("classfieldAccessLevel", rp.FieldAccessLevel.ToString()); } if (rp.PropertyAccessLevel != AccessLevel.Public) { propertyElement.SetAttribute("propertyAccessLevel", rp.PropertyAccessLevel.ToString()); } if (rp.PropertyAlias != rp.Name) { propertyElement.SetAttribute("propertyAlias", rp.PropertyAlias); } if (rp.Disabled) { propertyElement.SetAttribute("disabled", XmlConvert.ToString(true)); } if (rp.Obsolete != ObsoleteType.None) { propertyElement.SetAttribute("obsolete", rp.Obsolete.ToString()); } if (!string.IsNullOrEmpty(rp.ObsoleteDescripton)) { propertyElement.SetAttribute("obsoleteDescription", rp.ObsoleteDescripton); } if (rp.EnablePropertyChanged && !(rp is CustomPropertyDefinition)) { propertyElement.SetAttribute("enablePropertyChanged", XmlConvert.ToString(rp.EnablePropertyChanged)); } if (rp.Action != MergeAction.Merge) { propertyElement.SetAttribute("action", rp.Action.ToString()); } if (!string.IsNullOrEmpty(rp.DefferedLoadGroup) && !(rp is CustomPropertyDefinition)) { propertyElement.SetAttribute("defferedLoadGroup", rp.DefferedLoadGroup); } if (!rp.GenerateAttribute && !(rp is CustomPropertyDefinition)) { propertyElement.SetAttribute("generateAttribute", XmlConvert.ToString(rp.GenerateAttribute)); } if (!string.IsNullOrEmpty(rp.AvailableFrom) && !(rp is CustomPropertyDefinition)) { propertyElement.SetAttribute("availableFrom", rp.AvailableFrom); } if (!string.IsNullOrEmpty(rp.AvailableTo) && !(rp is CustomPropertyDefinition)) { propertyElement.SetAttribute("availableTo", rp.AvailableTo); } if (!string.IsNullOrEmpty(rp.Feature)) { propertyElement.SetAttribute("feature", rp.Feature); } if (rp.Interfaces.Any()) { var implElement = CreateElement("implement"); propertyElement.AppendChild(implElement); foreach (var interfaceId in rp.Interfaces) { var intElement = CreateElement("interface"); implElement.AppendChild(intElement); intElement.SetAttribute("ref", interfaceId.Ref); if (!string.IsNullOrEmpty(interfaceId.Prop)) { intElement.SetAttribute("property", interfaceId.Prop); } } } if (rp is ScalarPropertyDefinition) { ScalarPropertyDefinition property = rp as ScalarPropertyDefinition; if (!string.IsNullOrEmpty(property.SourceFieldAlias)) { propertyElement.SetAttribute("fieldAlias", property.SourceFieldAlias); } if (property.SourceField != null) { propertyElement.SetAttribute("fieldName", property.SourceFieldExpression); if (!string.IsNullOrEmpty(property.SourceType)) { propertyElement.SetAttribute("fieldTypeName", property.SourceType); } if (property.SourceTypeSize.HasValue) { propertyElement.SetAttribute("fieldTypeSize", XmlConvert.ToString(property.SourceTypeSize.Value)); } if (!property.IsNullable) { propertyElement.SetAttribute("fieldNullable", XmlConvert.ToString(property.IsNullable)); } if (!string.IsNullOrEmpty(property.SourceField.DefaultValue)) { propertyElement.SetAttribute("fieldDefault", property.SourceField.DefaultValue); } } } else if (rp is EntityPropertyDefinition) { EntityPropertyDefinition property = rp as EntityPropertyDefinition; foreach (EntityPropertyDefinition.SourceField field in property.SourceFields) { XmlElement fields = CreateElement("field"); fields.SetAttribute("relatedProperty", field.PropertyAlias); if (!string.IsNullOrEmpty(field.SourceFieldExpression)) { fields.SetAttribute("fieldName", field.SourceFieldExpression); } if (!string.IsNullOrEmpty(field.SourceType)) { fields.SetAttribute("fieldTypeName", field.SourceType); } if (field.SourceTypeSize.HasValue) { fields.SetAttribute("fieldTypeSize", XmlConvert.ToString(field.SourceTypeSize.Value)); } if (!field.IsNullable) { fields.SetAttribute("fieldNullable", XmlConvert.ToString(field.IsNullable)); } if (!string.IsNullOrEmpty(field.SourceFieldAlias)) { fields.SetAttribute("fieldAlias", field.SourceFieldAlias); } if (!string.IsNullOrEmpty(field.DefaultValue)) { fields.SetAttribute("fieldDefault", field.DefaultValue); } propertyElement.AppendChild(fields); } } else if (rp is CustomPropertyDefinition) { CustomPropertyDefinition property = rp as CustomPropertyDefinition; XmlElement get = CreateElement("Get"); FillBody(get, property.GetBody); propertyElement.AppendChild(get); if (property.SetBody != null) { XmlElement set = CreateElement("Set"); FillBody(set, property.SetBody); propertyElement.AppendChild(set); } } else { throw new NotSupportedException(rp.GetType().ToString()); } if (rp.Extensions.Count > 0) { foreach (var extension in rp.Extensions) { FillExtension(propertyElement, extension); } } propertiesNode.AppendChild(propertyElement); }