public bool TrySerialize(Type objectToSerializeType, object objectToSerialize, IXmlSerializer xmlSerializer, out XElement serializedObject) { if (objectToSerializeType == null) { throw new ArgumentNullException("objectToSerializeType"); } serializedObject = null; if (objectToSerializeType != typeof(DataFieldDescriptor)) { return(false); } if (objectToSerialize == null) { serializedObject = new XElement("DataFieldDescriptor"); } else { DataFieldDescriptor dataFieldDescriptor = (DataFieldDescriptor)objectToSerialize; serializedObject = dataFieldDescriptor.ToXml(); } return(true); }
public bool TryDeserialize(XElement serializedObject, IXmlSerializer xmlSerializer, out object deserializedObject) { if (serializedObject == null) { throw new ArgumentNullException("serializedObject"); } deserializedObject = null; if (serializedObject.Name.LocalName != "DataFieldDescriptor") { return(false); } if (!serializedObject.Elements().Any()) { deserializedObject = null; } else { deserializedObject = DataFieldDescriptor.FromXml(serializedObject); } return(true); }
private string GetBindingName(DataFieldDescriptor dataFieldDescriptor) { if (string.IsNullOrEmpty(_bindingNamesPrefix)) { return(dataFieldDescriptor.Name); } return(GetBindingName(_bindingNamesPrefix, dataFieldDescriptor.Name)); }
public static Type GetInstanceType(DataFieldDescriptor dataFieldDescriptor) { Type instanceType = dataFieldDescriptor.InstanceType; if (instanceType.IsGenericType && instanceType.GetGenericTypeDefinition() == typeof(Nullable<>)) { instanceType = instanceType.GetGenericArguments().First(); } return instanceType; }
/// <summary> /// Adds an interface the data type should inherit from /// </summary> /// <param name="interfaceType"></param> /// <param name="addInheritedFields"></param> internal void AddSuperInterface(Type interfaceType, bool addInheritedFields) { if (_superInterfaces.Contains(interfaceType) || interfaceType == typeof(IData)) { return; } _superInterfaces.Add(interfaceType); if (addInheritedFields) { foreach (PropertyInfo propertyInfo in interfaceType.GetProperties()) { if (propertyInfo.Name == nameof(IPageData.PageId) && interfaceType == typeof(IPageData)) { continue; } DataFieldDescriptor dataFieldDescriptor = ReflectionBasedDescriptorBuilder.BuildFieldDescriptor(propertyInfo, true); this.Fields.Add(dataFieldDescriptor); } } foreach (string propertyName in interfaceType.GetKeyPropertyNames()) { if (KeyPropertyNames.Contains(propertyName)) { continue; } PropertyInfo property = ReflectionBasedDescriptorBuilder.FindProperty(interfaceType, propertyName); if (DynamicTypeReflectionFacade.IsKeyField(property)) { this.KeyPropertyNames.Add(propertyName, false); } } foreach (var dataScopeIdentifier in DynamicTypeReflectionFacade.GetDataScopes(interfaceType)) { if (!this.DataScopes.Contains(dataScopeIdentifier)) { this.DataScopes.Add(dataScopeIdentifier); } } var superInterfaces = interfaceType.GetInterfaces().Where(t => typeof(IData).IsAssignableFrom(t)); foreach (Type superSuperInterfaceType in superInterfaces) { AddSuperInterface(superSuperInterfaceType, addInheritedFields); } }
public static WidgetFunctionProvider GetWidgetFunctionProvider(DataFieldDescriptor dataFieldDescriptor) { if ((dataFieldDescriptor.FormRenderingProfile != null) && (string.IsNullOrEmpty(dataFieldDescriptor.FormRenderingProfile.WidgetFunctionMarkup) == false)) { WidgetFunctionProvider widgetFunctionProvider = new WidgetFunctionProvider(XElement.Parse(dataFieldDescriptor.FormRenderingProfile.WidgetFunctionMarkup)); return widgetFunctionProvider; } else { return StandardWidgetFunctions.GetDefaultWidgetFunctionProviderByType(dataFieldDescriptor.InstanceType); } }
private Type GetFieldBindingType(DataFieldDescriptor fieldDescriptor) { var bindingType = fieldDescriptor.InstanceType; // Nullable<T> handling. Allowed types: Nullable<Guid>, Nullable<int>, Nullable<decimal> if (bindingType != typeof(Guid?) && bindingType != typeof(int?) && bindingType != typeof(decimal?) && bindingType.IsGenericType && bindingType.GetGenericTypeDefinition() == typeof(Nullable <>)) { return(bindingType.GetGenericArguments()[0]); } return(bindingType); }
private void ValidateFieldMembership(string dataFieldName) { DataFieldDescriptor dataFieldDescriptor = _validDataFieldDescriptions[dataFieldName]; if (dataFieldDescriptor == null) { throw new ArgumentException(string.Format("Unknown data field name '{0}'", dataFieldName)); } if (_allowNullableFields == false && dataFieldDescriptor.IsNullable) { throw new ArgumentException("Can not add nullable fields to this list"); } if (dataFieldDescriptor.StoreType.PhysicalStoreType == PhysicalStoreFieldType.LargeString && _allowLargeStringFields == false) { throw new ArgumentException("Can not add large string fields to this list"); } }
public static BaseValueProvider GetFallbackValueProvider(DataFieldDescriptor dataFieldDescriptor, bool isKeyProperty) { if (dataFieldDescriptor.DefaultValue != null) { return new ConstantValueProvider(dataFieldDescriptor.DefaultValue.Value); } Type instanceType = GetInstanceType(dataFieldDescriptor); if (instanceType == typeof(int)) { return new ConstantValueProvider(0); } else if (instanceType == typeof(decimal)) { return new ConstantValueProvider(0.0); } else if (instanceType == typeof(bool)) { return new ConstantValueProvider(false); } else if (instanceType == typeof(string)) { return new ConstantValueProvider(""); } else if (instanceType == typeof(Guid)) { if (isKeyProperty) { return new ConstantValueProvider(Guid.NewGuid()); } else { return new ConstantValueProvider(Guid.Empty); } } else if (instanceType == typeof(DateTime)) { return new ConstantValueProvider(DateTime.Now); } else { return new ConstantValueProvider(""); } }
/// <summary> /// Removes a super interface /// </summary> /// <param name="interfaceType">Type to remove</param> public void RemoveSuperInterface(Type interfaceType) { if (interfaceType == typeof(IData)) { return; } if (_superInterfaces.Contains(interfaceType)) { _superInterfaces.Remove(interfaceType); } foreach (PropertyInfo propertyInfo in interfaceType.GetProperties()) { DataFieldDescriptor dataFieldDescriptor = ReflectionBasedDescriptorBuilder.BuildFieldDescriptor(propertyInfo, true); if (this.Fields.Contains(dataFieldDescriptor)) { this.Fields.Remove(dataFieldDescriptor); } if (DynamicTypeReflectionFacade.IsKeyField(propertyInfo) && this.KeyPropertyNames.Contains(propertyInfo.Name)) { this.KeyPropertyNames.Remove(propertyInfo.Name); } } foreach (DataScopeIdentifier dataScopeIdentifier in DynamicTypeReflectionFacade.GetDataScopes(interfaceType)) { if (this.DataScopes.Contains(dataScopeIdentifier)) { this.DataScopes.Remove(dataScopeIdentifier); } } foreach (Type superSuperInterfaceType in interfaceType.GetInterfaces().Where(t => typeof(IData).IsAssignableFrom(t))) { RemoveSuperInterface(superSuperInterfaceType); } }
/// <exclude /> public static bool TryGetDescriptors(XElement fieldReferenceElement, out DataTypeDescriptor typeDescriptor, out DataFieldDescriptor fieldDescriptor) { typeDescriptor = null; fieldDescriptor = null; if (fieldReferenceElement.Name != _fieldReferenceElementName) { throw new InvalidOperationException(string.Format("Unexpected element name '{0}'. Expected '{1}'", fieldReferenceElement.Name, _fieldReferenceElementName)); } string typeManagerName = fieldReferenceElement.Attribute(_fieldReferenceTypeAttributeName).Value; string fieldName = fieldReferenceElement.Attribute(_fieldReferenceFieldAttributeName).Value; Type t = TypeManager.TryGetType(typeManagerName); if (t == null) { return(false); } typeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(t.GetImmutableTypeId()); if (typeDescriptor == null) { return(false); } if (fieldName == "DataSourceId") { fieldDescriptor = new DataFieldDescriptor(Guid.Empty, "DataSourceId", StoreFieldType.LargeString, typeof(string)); return(true); } fieldDescriptor = typeDescriptor.Fields.Where(f => f.Name == fieldName).FirstOrDefault(); if (fieldDescriptor == null) { return(false); } return(true); }
public static void UpdateKeyType(DataFieldDescriptor idField, GeneratedTypesHelper.KeyFieldType selectedFieldType) { switch (selectedFieldType) { case GeneratedTypesHelper.KeyFieldType.Guid: idField.StoreType = StoreFieldType.Guid; idField.InstanceType = typeof(Guid); idField.DefaultValue = null; break; case GeneratedTypesHelper.KeyFieldType.RandomString4: idField.StoreType = StoreFieldType.String(22); idField.InstanceType = typeof(string); idField.DefaultValue = DefaultValue.RandomString(4, true); break; case GeneratedTypesHelper.KeyFieldType.RandomString8: idField.StoreType = StoreFieldType.String(22); idField.InstanceType = typeof(string); idField.DefaultValue = DefaultValue.RandomString(8, false); break; } }
/// <exclude /> public static bool TryGetDescriptors(XElement fieldReferenceElement, out DataTypeDescriptor typeDescriptor, out DataFieldDescriptor fieldDescriptor) { typeDescriptor = null; fieldDescriptor = null; if (fieldReferenceElement.Name != _fieldReferenceElementName) { throw new InvalidOperationException(string.Format("Unexpected element name '{0}'. Expected '{1}'", fieldReferenceElement.Name, _fieldReferenceElementName)); } string typeManagerName = fieldReferenceElement.Attribute(_fieldReferenceTypeAttributeName).Value; string fieldName = fieldReferenceElement.Attribute(_fieldReferenceFieldAttributeName).Value; Type t = TypeManager.TryGetType(typeManagerName); if (t == null) { return false; } typeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(t.GetImmutableTypeId()); if (typeDescriptor == null) { return false; } if(fieldName == "DataSourceId") { fieldDescriptor = new DataFieldDescriptor(Guid.Empty, "DataSourceId", StoreFieldType.LargeString, typeof (string)); return true; } fieldDescriptor = typeDescriptor.Fields.Where(f => f.Name == fieldName).FirstOrDefault(); if (fieldDescriptor == null) { return false; } return true; }
public static GeneratedTypesHelper.KeyFieldType GetKeyFieldType(DataFieldDescriptor field) { if (field.InstanceType == typeof(Guid)) { return GeneratedTypesHelper.KeyFieldType.Guid; } if (field.InstanceType == typeof(string) && field.DefaultValue != null) { if (field.DefaultValue.Equals(DefaultValue.RandomString(4, true))) { return GeneratedTypesHelper.KeyFieldType.RandomString4; } if (field.DefaultValue.Equals(DefaultValue.RandomString(8, false))) { return GeneratedTypesHelper.KeyFieldType.RandomString8; } } return GeneratedTypesHelper.KeyFieldType.Undefined; }
private Type GetFieldBindingType(DataFieldDescriptor fieldDescriptor) { var bindingType = fieldDescriptor.InstanceType; // Nullable<T> handling. Allowed types: Nullable<Guid>, Nullable<int>, Nullable<decimal> if (bindingType != typeof(Guid?) && bindingType != typeof(int?) && bindingType != typeof(decimal?) && bindingType.IsGenericType && bindingType.GetGenericTypeDefinition() == typeof(Nullable<>)) { return bindingType.GetGenericArguments()[0]; } return bindingType; }
private void ConfigureColumn(string tableName, string columnName, DataFieldDescriptor fieldDescriptor, DataFieldDescriptor originalFieldDescriptor, bool changes) { if (columnName != fieldDescriptor.Name) { RenameColumn(tableName, columnName, fieldDescriptor.Name); } if(changes) { bool fieldBecameRequired = !fieldDescriptor.IsNullable && originalFieldDescriptor.IsNullable; if(fieldBecameRequired) { if (fieldDescriptor.StoreType.ToString() != originalFieldDescriptor.StoreType.ToString()) { AlterColumn(tableName, GetColumnInfo(tableName, fieldDescriptor.Name, fieldDescriptor, false, true)); } string defaultValue = TranslatesIntoDefaultConstraint(fieldDescriptor.DefaultValue) ? GetDefaultValueText(fieldDescriptor.DefaultValue) : GetDefaultValueText(fieldDescriptor.StoreType); ExecuteNonQuery("UPDATE [{0}] SET [{1}] = {2} WHERE [{1}] IS NULL" .FormatWith(tableName, fieldDescriptor.Name, defaultValue)); } AlterColumn(tableName, GetColumnInfo(tableName, fieldDescriptor.Name, fieldDescriptor, false, false)); } ExecuteNonQuery(SetDefaultValue(tableName, fieldDescriptor.Name, fieldDescriptor.DefaultValue)); }
private string GetDefaultWidgetFunctionMarkup(DataFieldDescriptor fieldDescriptor) { // Auto generating a widget for not code generated data types Type fieldType; if (!fieldDescriptor.ForeignKeyReferenceTypeName.IsNullOrEmpty()) { string referenceTypeName = fieldDescriptor.ForeignKeyReferenceTypeName; Type foreignKeyType = TypeManager.GetType(referenceTypeName); Verify.IsNotNull(foreignKeyType, "Failed to find type '{0}'".FormatWith(referenceTypeName)); var referenceTemplateType = fieldDescriptor.IsNullable ? typeof(NullableDataReference<>) : typeof(DataReference<>); fieldType = referenceTemplateType.MakeGenericType(foreignKeyType); } else { fieldType = fieldDescriptor.InstanceType; } var widgetFunctionProvider = StandardWidgetFunctions.GetDefaultWidgetFunctionProviderByType(fieldType); if (widgetFunctionProvider != null) { return widgetFunctionProvider.SerializedWidgetFunction.ToString(); } return null; }
internal ExistingFieldInfo(DataFieldDescriptor originalField, DataFieldDescriptor alteredField) { _originalField = originalField; _alteredField = alteredField; }
private void Field_Save_UpdatePosition(DataFieldDescriptor field) { var visibleFields = CurrentFields.Where(f => f.Name != CurrentKeyFieldName).ToList(); int idFieldsCount = CurrentFields.Count(f => f.Name == CurrentKeyFieldName); int newPosition = int.Parse(this.PositionField.SelectedValue); if (newPosition == -1) newPosition = visibleFields.Count - 1; if (field.Position != newPosition) { this.CurrentFields.Remove(field); foreach (DataFieldDescriptor laterField in visibleFields.Where(f => f.Position > field.Position)) { laterField.Position--; } foreach (DataFieldDescriptor laterField in visibleFields.Where(f => f.Position >= newPosition)) { laterField.Position++; } field.Position = newPosition; this.CurrentFields.Insert(newPosition + idFieldsCount, field); } }
/// <summary> /// Builds a default "Id" field. /// </summary> /// <returns></returns> public static DataFieldDescriptor BuildIdField() { var idFieldDescriptor = new DataFieldDescriptor(Guid.NewGuid(), IdFieldName, StoreFieldType.Guid, typeof (Guid)); idFieldDescriptor.DataUrlProfile = new DataUrlProfile { Order = 0 }; return idFieldDescriptor; }
private DataTypeDescriptor CreateNewDataTypeDescriptor( string typeNamespace, string typeName, string typeTitle, string labelFieldName, string internalUrlPrefix, bool cachable, bool publishControlled, bool localizedControlled, IEnumerable<DataFieldDescriptor> dataFieldDescriptors, DataFieldDescriptor foreignKeyDataFieldDescriptor, DataTypeAssociationDescriptor dataTypeAssociationDescriptor, DataFieldDescriptor compositionRuleForeignKeyDataFieldDescriptor) { Guid id = Guid.NewGuid(); var dataTypeDescriptor = new DataTypeDescriptor(id, typeNamespace, typeName, true) { Cachable = cachable, Title = typeTitle, LabelFieldName = labelFieldName, InternalUrlPrefix = internalUrlPrefix }; dataTypeDescriptor.DataScopes.Add(DataScopeIdentifier.Public); if (publishControlled && _dataAssociationType != DataAssociationType.Composition) { dataTypeDescriptor.AddSuperInterface(typeof(IPublishControlled)); } if (localizedControlled) { dataTypeDescriptor.AddSuperInterface(typeof(ILocalizedControlled)); } //bool addKeyField = true; if (_dataAssociationType == DataAssociationType.Aggregation) { dataTypeDescriptor.AddSuperInterface(typeof(IPageDataFolder)); } else if (_dataAssociationType == DataAssociationType.Composition) { //addKeyField = false; dataTypeDescriptor.AddSuperInterface(typeof(IPageData)); dataTypeDescriptor.AddSuperInterface(typeof(IPageRelatedData)); dataTypeDescriptor.AddSuperInterface(typeof(IPageMetaData)); } //if (addKeyField) //{ // var idDataFieldDescriptor = BuildKeyFieldDescriptor(); // dataTypeDescriptor.Fields.Add(idDataFieldDescriptor); // dataTypeDescriptor.KeyPropertyNames.Add(IdFieldName); //} foreach (DataFieldDescriptor dataFieldDescriptor in dataFieldDescriptors) { dataTypeDescriptor.Fields.Add(dataFieldDescriptor); } if (_newKeyFieldName != null) { dataTypeDescriptor.KeyPropertyNames.Add(_newKeyFieldName); } int position = 100; if (_foreignKeyDataFieldDescriptor != null) { _foreignKeyDataFieldDescriptor.Position = position++; if (foreignKeyDataFieldDescriptor.Name != PageReferenceFieldName) { dataTypeDescriptor.Fields.Add(foreignKeyDataFieldDescriptor); dataTypeDescriptor.DataAssociations.Add(dataTypeAssociationDescriptor); } } return dataTypeDescriptor; }
private void Initialize() { if (_oldDataTypeDescriptor.DataAssociations.Count > 0) { DataTypeAssociationDescriptor dataTypeAssociationDescriptor = _oldDataTypeDescriptor.DataAssociations.Single(); _associatedType = dataTypeAssociationDescriptor.AssociatedInterfaceType; } foreach (DataFieldDescriptor dataFieldDescriptor in _oldDataTypeDescriptor.Fields) { if (dataFieldDescriptor.ForeignKeyReferenceTypeName != null) { if (_associatedType != null) { string associatedTypeTypeName = TypeManager.SerializeType(_associatedType); if (dataFieldDescriptor.ForeignKeyReferenceTypeName == associatedTypeTypeName) { _foreignKeyDataFieldDescriptor = dataFieldDescriptor; } } } if (dataFieldDescriptor.Name == CompositionDescriptionFieldName) { _pageMetaDataDescriptionForeignKeyDataFieldDescriptor = dataFieldDescriptor; } } _publishControlled = this.IsPublishControlled; _localizedControlled = this.IsLocalizedControlled; }
/// <exclude /> public void SetForeignKeyReference(DataTypeDescriptor targetDataTypeDescriptor, DataAssociationType dataAssociationType) { if (dataAssociationType == DataAssociationType.None) throw new ArgumentException("dataAssociationType"); if ((dataAssociationType == DataAssociationType.Aggregation || dataAssociationType == DataAssociationType.Composition) && _pageMetaDataDescriptionForeignKeyDataFieldDescriptor != null) { throw new InvalidOperationException("The type already has a foreign key reference"); } Type targetType = TypeManager.GetType(targetDataTypeDescriptor.TypeManagerTypeName); string fieldName = null; if (targetType == typeof(IPage)) { fieldName = PageReferenceFieldName; _dataAssociationType = dataAssociationType; } string foreignKeyFieldName; _foreignKeyDataFieldDescriptor = CreateReferenceDataFieldDescriptor(targetDataTypeDescriptor, out foreignKeyFieldName, fieldName); if (dataAssociationType != DataAssociationType.None) { _dataTypeAssociationDescriptor = new DataTypeAssociationDescriptor( targetType, foreignKeyFieldName, dataAssociationType ); } if (dataAssociationType == DataAssociationType.Composition) { DataTypeDescriptor compositionRuleDataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(typeof(IPageMetaDataDefinition)); _pageMetaDataDescriptionForeignKeyDataFieldDescriptor = CreateWeakReferenceDataFieldDescriptor(compositionRuleDataTypeDescriptor, compositionRuleDataTypeDescriptor.Fields["Name"], CompositionDescriptionFieldName); } }
private bool IsDataFieldBindable(DataTypeDescriptor dataTypeDescriptor, DataFieldDescriptor dataFieldDescriptor) { if (dataFieldDescriptor.Inherited) { Type superInterface = dataTypeDescriptor.SuperInterfaces.FirstOrDefault(type => type.GetProperty(dataFieldDescriptor.Name) != null); if(superInterface != null && superInterface.Assembly == typeof(IData).Assembly) { return false; } } if ((dataFieldDescriptor.Name == IdFieldName || dataFieldDescriptor.Name == CompositionDescriptionFieldName) && dataTypeDescriptor.IsPageMetaDataType) { return false; } if (PageFolderFacade.GetAllFolderTypes().Contains(this._oldType) && dataFieldDescriptor.Name == PageReferenceFieldName) { return false; } if (dataFieldDescriptor.ForeignKeyReferenceTypeName != null) { DataTypeAssociationDescriptor dataTypeAssociationDescriptor = dataTypeDescriptor.DataAssociations.FirstOrDefault(); if (dataTypeAssociationDescriptor != null) { if (!this.AllowForeignKeyEditing && dataFieldDescriptor.Name == dataTypeAssociationDescriptor.ForeignKeyPropertyName) { return false; } if (dataFieldDescriptor.Name == CompositionDescriptionFieldName && dataTypeDescriptor.IsPageMetaDataType) { return false; } } } return true; }
private void Field_Save() { if (this.CurrentFields.Count(f => f.Id == this.CurrentlySelectedFieldId) == 0) { DataFieldDescriptor newField = new DataFieldDescriptor(this.CurrentlySelectedFieldId, this.NameField.Text, StoreFieldType.Boolean, this.CurrentlySelectedType); newField.Position = this.CurrentFields.Count; this.CurrentFields.Add(newField); } if (FieldNameSyntaxValid(this.NameField.Text) == false) { ShowMessage(this.NameField.ClientID, GetString("FieldNameSyntaxInvalid")); return; } var field = this.CurrentFields.Single(f => f.Id == this.CurrentlySelectedFieldId); if (field.Name != this.NameField.Text) { nameChanged = true; } if (this.CurrentFields.Count<DataFieldDescriptor>(f => f.Name.ToLower() == this.NameField.Text.ToLower() && f.Id != field.Id) > 0) { ShowMessage(this.NameField.ClientID, GetString("CannotSave")); return; } field.Name = this.NameField.Text; field.InstanceType = this.CurrentlySelectedType; field.ForeignKeyReferenceTypeName = this.CurrentForeignKeyReferenceTypeName; field.StoreType = this.CurrentlySelectedStoreFieldType; if (this.IsTitleFieldDateTimeSelector.Checked == true) { this.CurrentLabelFieldName = field.Name; } else { if (this.CurrentLabelFieldName == field.Name) { this.CurrentLabelFieldName = ""; } } bool generateLabel = (this.LabelField.Text == "" && this.NameField.Text.StartsWith(_defaultFieldNamePrefix) == false); string label = (generateLabel ? this.NameField.Text : this.LabelField.Text); field.IsNullable = bool.Parse(this.OptionalSelector.SelectedValue); field.FormRenderingProfile.Label = label; field.FormRenderingProfile.HelpText = this.HelpField.Text; if (!btnWidgetFunctionMarkup.Value.IsNullOrEmpty()) { XElement functionElement = XElement.Parse(btnWidgetFunctionMarkup.Value); if (functionElement.Name.Namespace != Namespaces.Function10) { functionElement = functionElement.Elements().First(); } field.FormRenderingProfile.WidgetFunctionMarkup = functionElement.ToString(SaveOptions.DisableFormatting); } else { field.FormRenderingProfile.WidgetFunctionMarkup = ""; } if (!btnDefaultValueFunctionMarkup.Value.IsNullOrEmpty()) { XElement functionElement = XElement.Parse(btnDefaultValueFunctionMarkup.Value); if (functionElement.Name.Namespace != Namespaces.Function10) functionElement = functionElement.Elements().First(); field.NewInstanceDefaultFieldValue = functionElement.ToString(SaveOptions.DisableFormatting); } else { field.NewInstanceDefaultFieldValue = null; } field.ValidationFunctionMarkup = null; if (field.IsNullable == false) { switch (this.CurrentlySelectedStoreFieldType.PhysicalStoreType) { case PhysicalStoreFieldType.Integer: case PhysicalStoreFieldType.Long: field.DefaultValue = DefaultValue.Integer(0); break; case PhysicalStoreFieldType.Decimal: field.DefaultValue = DefaultValue.Decimal(0); break; case PhysicalStoreFieldType.String: case PhysicalStoreFieldType.LargeString: field.DefaultValue = DefaultValue.String(""); break; case PhysicalStoreFieldType.DateTime: field.DefaultValue = DefaultValue.Now; break; case PhysicalStoreFieldType.Guid: field.DefaultValue = DefaultValue.Guid(Guid.Empty); break; case PhysicalStoreFieldType.Boolean: field.DefaultValue = DefaultValue.Boolean(false); break; default: break; } } else { field.DefaultValue = null; } if (!btnValidationRulesFunctionMarkup.Value.IsNullOrEmpty()) { field.ValidationFunctionMarkup = (from element in XElement.Parse(btnValidationRulesFunctionMarkup.Value).Elements() select element.ToString()).ToList(); } int newPosition = int.Parse(this.PositionField.SelectedValue); if (newPosition == -1) newPosition = this.CurrentFields.Count - 1; if (field.Position != newPosition) { this.CurrentFields.Remove(field); foreach (DataFieldDescriptor laterField in this.CurrentFields.Where(f => f.Position > field.Position)) { laterField.Position--; } foreach (DataFieldDescriptor laterField in this.CurrentFields.Where(f => f.Position >= newPosition)) { laterField.Position++; } field.Position = newPosition; this.CurrentFields.Insert(newPosition, field); } int newGroupByPriority = int.Parse(this.GroupByPriorityField.SelectedValue); if (field.GroupByPriority != newGroupByPriority) { int assignGroupByPriority = 1; foreach (DataFieldDescriptor otherField in this.CurrentFields.Where(f => f.GroupByPriority > 0 && f.Id != field.Id).OrderBy(f => f.GroupByPriority)) { if (assignGroupByPriority == newGroupByPriority) assignGroupByPriority++; otherField.GroupByPriority = assignGroupByPriority; assignGroupByPriority++; } } field.GroupByPriority = newGroupByPriority; EnsureGroupByPrioritySequence(); if (field.TreeOrderingProfile.ToString() != this.TreeOrderingField.SelectedValue) { field.TreeOrderingProfile = DataFieldTreeOrderingProfile.FromString(this.TreeOrderingField.SelectedValue); int assignTreeOrderPriority = 1; foreach (DataFieldDescriptor otherField in this.CurrentFields.Where(f => f.TreeOrderingProfile.OrderPriority > 0 && f.Id != field.Id).OrderBy(f => f.TreeOrderingProfile.OrderPriority)) { if (assignTreeOrderPriority == field.TreeOrderingProfile.OrderPriority) assignTreeOrderPriority++; otherField.TreeOrderingProfile.OrderPriority = assignTreeOrderPriority; assignTreeOrderPriority++; } } EnsureTreeOrderPrioritySequence(); }
/// <exclude /> public static XElement GetReferenceElement(this DataFieldDescriptor fieldToReference, DataTypeDescriptor ownerTypeDescriptor) { return(GetReferenceElement(fieldToReference.Name, ownerTypeDescriptor.TypeManagerTypeName)); }
private static string CreateFieldName(DataFieldDescriptor dataFieldDescriptor) { return string.Format("_{0}", dataFieldDescriptor.Name.ToLowerInvariant()); }
private DataFieldDescriptor CreateWeakReferenceDataFieldDescriptor(DataTypeDescriptor targetDataTypeDescriptor, DataFieldDescriptor targetDataFieldDescriptor, string fieldName) { TypeManager.GetType(targetDataTypeDescriptor.TypeManagerTypeName); WidgetFunctionProvider widgetFunctionProvider = StandardWidgetFunctions.TextBoxWidget; return new DataFieldDescriptor( Guid.NewGuid(), fieldName, targetDataFieldDescriptor.StoreType, targetDataFieldDescriptor.InstanceType ) { IsNullable = targetDataFieldDescriptor.IsNullable, DefaultValue = targetDataFieldDescriptor.DefaultValue, ValidationFunctionMarkup = targetDataFieldDescriptor.ValidationFunctionMarkup, FormRenderingProfile = new DataFieldFormRenderingProfile { Label = fieldName, HelpText = fieldName, WidgetFunctionMarkup = widgetFunctionProvider.SerializedWidgetFunction.ToString(SaveOptions.DisableFormatting) } }; }
private static object GetDefaultValue(DataFieldDescriptor fieldDescriptor) { Verify.ArgumentNotNull(fieldDescriptor, "fieldDescriptor"); if (fieldDescriptor.DefaultValue != null) { return fieldDescriptor.DefaultValue.Value; } switch (fieldDescriptor.StoreType.PhysicalStoreType) { case PhysicalStoreFieldType.Boolean: return false; case PhysicalStoreFieldType.DateTime: return DateTime.Now; case PhysicalStoreFieldType.Integer: case PhysicalStoreFieldType.Long: case PhysicalStoreFieldType.Decimal: return 0m; case PhysicalStoreFieldType.Guid: return Guid.Empty; case PhysicalStoreFieldType.String: case PhysicalStoreFieldType.LargeString: return string.Empty; } throw new NotImplementedException("Supplied StoreFieldType contains an unsupported PhysicalStoreType '{0}'." .FormatWith(fieldDescriptor.StoreType.PhysicalStoreType)); }
/// <summary> /// Deserialize a <see cref="DataFieldDescriptor"/>. /// </summary> /// <param name="element">Deserialized DataFieldDescriptor</param> /// <returns></returns> public static DataFieldDescriptor FromXml(XElement element) { if (element.Name != "DataFieldDescriptor") { throw new ArgumentException("The xml is not correctly formatted"); } Guid id = (Guid)element.GetRequiredAttribute("id"); string name = element.GetRequiredAttributeValue("name"); bool isNullable = (bool)element.GetRequiredAttribute("isNullable"); int position = (int)element.GetRequiredAttribute("position"); bool inherited = (bool)element.GetRequiredAttribute("inherited"); XAttribute groupByPriorityAttribute = element.Attribute("groupByPriority"); XAttribute instanceTypeAttribute = element.GetRequiredAttribute("instanceType"); XAttribute storeTypeAttribute = element.GetRequiredAttribute("storeType"); XAttribute isReadOnlyAttribute = element.Attribute("isReadOnly"); XAttribute newInstanceDefaultFieldValueAttribute = element.Attribute("newInstanceDefaultFieldValue"); bool isReadOnly = isReadOnlyAttribute != null && (bool)isReadOnlyAttribute; int groupByPriority = groupByPriorityAttribute != null ? (int)groupByPriorityAttribute : 0; XAttribute defaultValueAttribute = element.Attribute("defaultValue"); XAttribute foreignKeyReferenceTypeNameAttribute = element.Attribute("foreignKeyReferenceTypeName"); XElement formRenderingProfileElement = element.Element("FormRenderingProfile"); XElement treeOrderingProfileElement = element.Element("TreeOrderingProfile"); XElement validationFunctionMarkupsElement = element.Element("ValidationFunctionMarkups"); XElement dataUrlProfileElement = element.Element("DataUrlProfile"); XElement searchProfileElement = element.Element(nameof(SearchProfile)); Type instanceType = TypeManager.GetType(instanceTypeAttribute.Value); StoreFieldType storeType = StoreFieldType.Deserialize(storeTypeAttribute.Value); var dataFieldDescriptor = new DataFieldDescriptor(id, name, storeType, instanceType, inherited) { IsNullable = isNullable, Position = position, GroupByPriority = groupByPriority, IsReadOnly = isReadOnly }; if (newInstanceDefaultFieldValueAttribute != null) { dataFieldDescriptor.NewInstanceDefaultFieldValue = newInstanceDefaultFieldValueAttribute.Value; } if (defaultValueAttribute != null) { DefaultValue defaultValue = DefaultValue.Deserialize(defaultValueAttribute.Value); dataFieldDescriptor.DefaultValue = defaultValue; } if (foreignKeyReferenceTypeNameAttribute != null) { string typeName = foreignKeyReferenceTypeNameAttribute.Value; typeName = TypeManager.FixLegasyTypeName(typeName); dataFieldDescriptor.ForeignKeyReferenceTypeName = typeName; } if (formRenderingProfileElement != null) { XAttribute labelAttribute = formRenderingProfileElement.Attribute("label"); XAttribute helpTextAttribute = formRenderingProfileElement.Attribute("helpText"); XAttribute widgetFunctionMarkupAttribute = formRenderingProfileElement.Attribute("widgetFunctionMarkup"); var dataFieldFormRenderingProfile = new DataFieldFormRenderingProfile(); if (labelAttribute != null) { dataFieldFormRenderingProfile.Label = labelAttribute.Value; } if (helpTextAttribute != null) { dataFieldFormRenderingProfile.HelpText = helpTextAttribute.Value; } if (widgetFunctionMarkupAttribute != null) { dataFieldFormRenderingProfile.WidgetFunctionMarkup = widgetFunctionMarkupAttribute.Value; } dataFieldDescriptor.FormRenderingProfile = dataFieldFormRenderingProfile; } if (dataUrlProfileElement != null) { int order = (int)dataUrlProfileElement.GetRequiredAttribute("Order"); var formatStr = (string)dataUrlProfileElement.Attribute("Format"); DataUrlSegmentFormat?format = null; if (formatStr != null) { format = (DataUrlSegmentFormat)Enum.Parse(typeof(DataUrlSegmentFormat), formatStr); } dataFieldDescriptor.DataUrlProfile = new DataUrlProfile { Order = order, Format = format }; } if (searchProfileElement != null) { Func <string, bool> getAttr = fieldName => (bool)searchProfileElement.GetRequiredAttribute(CamelCase(fieldName)); dataFieldDescriptor.SearchProfile = new SearchProfile { IndexText = getAttr(nameof(DynamicTypes.SearchProfile.IndexText)), EnablePreview = getAttr(nameof(DynamicTypes.SearchProfile.EnablePreview)), IsFacet = getAttr(nameof(DynamicTypes.SearchProfile.IsFacet)) }; } if (treeOrderingProfileElement != null) { int? orderPriority = (int?)treeOrderingProfileElement.Attribute("orderPriority"); bool orderDescending = (bool)treeOrderingProfileElement.Attribute("orderDescending"); dataFieldDescriptor.TreeOrderingProfile = new DataFieldTreeOrderingProfile { OrderPriority = orderPriority, OrderDescending = orderDescending }; } dataFieldDescriptor.ValidationFunctionMarkup = new List <string>(); if (validationFunctionMarkupsElement != null) { foreach (XElement validationFunctionMarkupElement in validationFunctionMarkupsElement.Elements("ValidationFunctionMarkup")) { string markup = validationFunctionMarkupElement.GetRequiredAttributeValue("markup"); dataFieldDescriptor.ValidationFunctionMarkup.Add(markup); } } return(dataFieldDescriptor); }
/// <summary> /// Adds an interface the data type should inherit from /// </summary> /// <param name="interfaceType"></param> /// <param name="addInheritedFields"></param> internal void AddSuperInterface(Type interfaceType, bool addInheritedFields) { if (_superInterfaces.Contains(interfaceType) || interfaceType == typeof(IData)) { return; } _superInterfaces.Add(interfaceType); if (addInheritedFields) { foreach (PropertyInfo propertyInfo in interfaceType.GetProperties()) { if (propertyInfo.Name == "PageId" && interfaceType == typeof(IPageData)) { continue; } DataFieldDescriptor dataFieldDescriptor = ReflectionBasedDescriptorBuilder.BuildFieldDescriptor(propertyInfo, true); this.Fields.Add(dataFieldDescriptor); } } foreach (string propertyName in interfaceType.GetKeyPropertyNames()) { if (KeyPropertyNames.Contains(propertyName)) { continue; } PropertyInfo property = interfaceType.GetProperty(propertyName); if (property == null) { List <Type> superInterfaces = interfaceType.GetInterfacesRecursively(t => typeof(IData).IsAssignableFrom(t) && t != typeof(IData)); foreach (Type superInterface in superInterfaces) { property = superInterface.GetProperty(propertyName); if (property != null) { break; } } } Verify.IsNotNull(property, "Missing property '{0}' on type '{1}' or one of its interfaces".FormatWith(propertyName, interfaceType)); if (DynamicTypeReflectionFacade.IsKeyField(property)) { this.KeyPropertyNames.Add(propertyName, false); } } foreach (DataScopeIdentifier dataScopeIdentifier in DynamicTypeReflectionFacade.GetDataScopes(interfaceType)) { if (!this.DataScopes.Contains(dataScopeIdentifier)) { this.DataScopes.Add(dataScopeIdentifier); } } foreach (Type superSuperInterfaceType in interfaceType.GetInterfaces().Where(t => typeof(IData).IsAssignableFrom(t))) { AddSuperInterface(superSuperInterfaceType, addInheritedFields); } }
/// <exclude /> public bool Equals(DataFieldDescriptor dataFieldDescriptor) { return(dataFieldDescriptor != null && dataFieldDescriptor.Id == Id); }
internal static DataTypeDescriptor FromXml(XElement element, bool inheritedFieldsIncluded) { Verify.ArgumentNotNull(element, "element"); if (element.Name != "DataTypeDescriptor") { throw new ArgumentException("The xml is not correctly formatted."); } Guid dataTypeId = (Guid)element.GetRequiredAttribute("dataTypeId"); string name = element.GetRequiredAttributeValue("name"); string @namespace = element.GetRequiredAttributeValue("namespace"); // TODO: check why "hasCustomPhysicalSortOrder" is not used bool hasCustomPhysicalSortOrder = (bool)element.GetRequiredAttribute("hasCustomPhysicalSortOrder"); bool isCodeGenerated = (bool)element.GetRequiredAttribute("isCodeGenerated"); XAttribute cachableAttribute = element.Attribute("cachable"); XAttribute buildNewHandlerTypeNameAttribute = element.Attribute("buildNewHandlerTypeName"); XElement dataAssociationsElement = element.GetRequiredElement("DataAssociations"); XElement dataScopesElement = element.GetRequiredElement("DataScopes"); XElement keyPropertyNamesElement = element.GetRequiredElement("KeyPropertyNames"); // TODO: check why "superInterfaceKeyPropertyNamesElement" is not used // XElement superInterfaceKeyPropertyNamesElement = element.Element("SuperInterfaceKeyPropertyNames"); XElement superInterfacesElement = element.GetRequiredElement("SuperInterfaces"); XElement fieldsElement = element.GetRequiredElement("Fields"); XElement indexesElement = element.Element("Indexes"); XAttribute titleAttribute = element.Attribute("title"); XAttribute labelFieldNameAttribute = element.Attribute("labelFieldName"); XAttribute internalUrlPrefixAttribute = element.Attribute("internalUrlPrefix"); string typeManagerTypeName = (string)element.Attribute("typeManagerTypeName"); bool cachable = cachableAttribute != null && (bool)cachableAttribute; var dataTypeDescriptor = new DataTypeDescriptor(dataTypeId, @namespace, name, isCodeGenerated) { Cachable = cachable }; if (titleAttribute != null) { dataTypeDescriptor.Title = titleAttribute.Value; } if (labelFieldNameAttribute != null) { dataTypeDescriptor.LabelFieldName = labelFieldNameAttribute.Value; } if (internalUrlPrefixAttribute != null) { dataTypeDescriptor.InternalUrlPrefix = internalUrlPrefixAttribute.Value; } if (typeManagerTypeName != null) { typeManagerTypeName = TypeManager.FixLegasyTypeName(typeManagerTypeName); dataTypeDescriptor.TypeManagerTypeName = typeManagerTypeName; } if (buildNewHandlerTypeNameAttribute != null) { dataTypeDescriptor.BuildNewHandlerTypeName = buildNewHandlerTypeNameAttribute.Value; } foreach (XElement elm in dataAssociationsElement.Elements()) { var dataTypeAssociationDescriptor = DataTypeAssociationDescriptor.FromXml(elm); dataTypeDescriptor.DataAssociations.Add(dataTypeAssociationDescriptor); } foreach (XElement elm in dataScopesElement.Elements("DataScopeIdentifier")) { string dataScopeName = elm.GetRequiredAttributeValue("name"); if (DataScopeIdentifier.IsLegasyDataScope(dataScopeName)) { Log.LogWarning("DataTypeDescriptor", "Ignored legacy data scope '{0}' on type '{1}.{2}' while deserializing DataTypeDescriptor. The '{0}' data scope is no longer supported.".FormatWith(dataScopeName, @namespace, name)); continue; } DataScopeIdentifier dataScopeIdentifier = DataScopeIdentifier.Deserialize(dataScopeName); dataTypeDescriptor.DataScopes.Add(dataScopeIdentifier); } foreach (XElement elm in superInterfacesElement.Elements("SuperInterface")) { string superInterfaceTypeName = elm.GetRequiredAttributeValue("type"); if (superInterfaceTypeName.StartsWith("Composite.Data.ProcessControlled.IDeleteControlled")) { Log.LogWarning("DataTypeDescriptor", string.Format("Ignored legacy super interface '{0}' on type '{1}.{2}' while deserializing DataTypeDescriptor. This super interface is no longer supported.", superInterfaceTypeName, @namespace, name)); continue; } Type superInterface; try { superInterface = TypeManager.GetType(superInterfaceTypeName); } catch (Exception ex) { throw XmlConfigurationExtensionMethods.GetConfigurationException("Failed to load super interface '{0}'".FormatWith(superInterfaceTypeName), ex, elm); } dataTypeDescriptor.AddSuperInterface(superInterface, !inheritedFieldsIncluded); } foreach (XElement elm in fieldsElement.Elements()) { var dataFieldDescriptor = DataFieldDescriptor.FromXml(elm); try { dataTypeDescriptor.Fields.Add(dataFieldDescriptor); } catch (Exception ex) { throw XmlConfigurationExtensionMethods.GetConfigurationException("Failed to add a data field: " + ex.Message, ex, elm); } } foreach (XElement elm in keyPropertyNamesElement.Elements("KeyPropertyName")) { var propertyName = elm.GetRequiredAttributeValue("name"); bool isDefinedOnSuperInterface = dataTypeDescriptor.SuperInterfaces.Any(f => f.GetProperty(propertyName) != null); if (!isDefinedOnSuperInterface) { dataTypeDescriptor.KeyPropertyNames.Add(propertyName); } } if (indexesElement != null) { dataTypeDescriptor.Indexes = indexesElement.Elements("Index").Select(DataTypeIndex.FromXml).ToList(); } // Loading field rendering profiles for static data types if (!isCodeGenerated && typeManagerTypeName != null) { Type type = Type.GetType(typeManagerTypeName); if (type != null) { foreach (var fieldDescriptor in dataTypeDescriptor.Fields) { var property = type.GetProperty(fieldDescriptor.Name); if (property != null) { var formRenderingProfile = DynamicTypeReflectionFacade.GetFormRenderingProfile(property); if (formRenderingProfile != null) { fieldDescriptor.FormRenderingProfile = formRenderingProfile; } } } } } return(dataTypeDescriptor); }
private string GetUrlSegmentPreview(DataFieldDescriptor field) { string formatString = ""; //if (field.InstanceType == typeof (DateTime)) //{ // string year = Texts.DataUrlDateFormat_Year; // string month = Texts.DataUrlDateFormat_Month; // string day = Texts.DataUrlDateFormat_Day; // var format = DataUrlSegmentFormat.DateTime_YearMonthDay; // if (field.DataUrlProfile != null && field.DataUrlProfile.Format != null) // { // format = field.DataUrlProfile.Format.Value; // } // switch (format) // { // case DataUrlSegmentFormat.DateTime_Year: // formatString = ":" + year; // break; // case DataUrlSegmentFormat.DateTime_YearMonth: // formatString = ":" + year + "," + month; // break; // case DataUrlSegmentFormat.DateTime_YearMonthDay: // formatString = ":" + year + "," + month + "," + day; // break; // } //} return "{" + field.Name + formatString + "}"; }
internal string GetColumnInfo(string tableName, string columnName, DataFieldDescriptor fieldDescriptor, bool includeDefault, bool forceNullable) { string defaultInfo = string.Empty; if (TranslatesIntoDefaultConstraint(fieldDescriptor.DefaultValue)) { if (includeDefault) { defaultInfo = string.Format("CONSTRAINT [{0}] DEFAULT {1}", SqlSafeName("DF", tableName, columnName), GetDefaultValueText(fieldDescriptor.DefaultValue)); } } // Enabling case sensitive comparison for the random string fields var defaultValue = fieldDescriptor.DefaultValue; string collation = string.Empty; if (defaultValue != null && defaultValue.ValueType == DefaultValueType.RandomString) { collation = "COLLATE Latin1_General_CS_AS"; } return string.Format( "[{0}] {1} {2} {3} {4}", fieldDescriptor.Name, DynamicTypesCommon.MapStoreTypeToSqlDataType(fieldDescriptor.StoreType), collation, fieldDescriptor.IsNullable || forceNullable ? "NULL" : "NOT NULL", defaultInfo); }
protected string GetTreeIcon(DataFieldDescriptor dataItem) { return "${icon:" + (dataItem.Name == CurrentKeyFieldName ? "key" : "parameter") + "}"; }
private void CreateColumn(string tableName, DataFieldDescriptor fieldDescriptor, object defaultValue = null) { if (defaultValue == null && !fieldDescriptor.IsNullable && fieldDescriptor.DefaultValue != null) { ExecuteNonQuery("ALTER TABLE [{0}] ADD {1};" .FormatWith(tableName, GetColumnInfo(tableName, fieldDescriptor.Name, fieldDescriptor, true, false))); return; } // Creating a column, making it nullable ExecuteNonQuery("ALTER TABLE [{0}] ADD {1};" .FormatWith(tableName, GetColumnInfo(tableName, fieldDescriptor.Name, fieldDescriptor, true, true))); // Setting default value with "UPDATE" statement if (defaultValue != null || (!fieldDescriptor.IsNullable && fieldDescriptor.DefaultValue == null)) { string defaultValueStr; if(defaultValue != null) { Type typeOfDefaultValue = defaultValue.GetType(); defaultValueStr = (typeOfDefaultValue == typeof(string) || typeOfDefaultValue == typeof(Guid)) ? ("'" + defaultValue + "'") : defaultValue.ToString(); } else { defaultValueStr = GetDefaultValueText(fieldDescriptor.StoreType); } ExecuteNonQuery("UPDATE [{0}] SET [{1}] = {2};" .FormatWith(tableName, fieldDescriptor.Name, defaultValueStr)); } // Making column not nullable if necessary if(!fieldDescriptor.IsNullable) { AlterColumn(tableName, GetColumnInfo(tableName, fieldDescriptor.Name, fieldDescriptor, false, false)); } }
private void Field_Save_UpdateDataUrl(DataFieldDescriptor field, bool dataUrlApplicable) { bool enabled = chkShowInDataUrl.Checked; if (!dataUrlApplicable || !enabled) { field.DataUrlProfile = null; return; } int order = lstDataUrlOrder.SelectedIndex; DataUrlSegmentFormat? format = null; if (field.InstanceType == typeof (DateTime)) { string selectedValue = lstDataUrlDateFormat.SelectedValue; if (!string.IsNullOrEmpty(selectedValue)) { format = (DataUrlSegmentFormat)Enum.Parse(typeof(DataUrlSegmentFormat), selectedValue); } } field.DataUrlProfile = new DataUrlProfile { Order = order, Format = format }; // Updating order of theother fields var otherUrlSegments = CurrentFields .Where(f => f.DataUrlProfile != null && f.Id != field.Id) .OrderBy(f => f.DataUrlProfile.Order) .ToList(); int index = 0; foreach (var urlSegment in otherUrlSegments) { if (index == order) index++; urlSegment.DataUrlProfile.Order = index++; } }
private string GetBindingName(DataFieldDescriptor dataFieldDescriptor) { if (string.IsNullOrEmpty(_bindingNamesPrefix)) { return dataFieldDescriptor.Name; } return GetBindingName(_bindingNamesPrefix, dataFieldDescriptor.Name); }
private void Field_Save_UpdateGroupByPriority(DataFieldDescriptor field) { int newGroupByPriority = int.Parse(this.GroupByPriorityField.SelectedValue); if (field.GroupByPriority != newGroupByPriority) { int assignGroupByPriority = 1; foreach (DataFieldDescriptor otherField in this.CurrentFields.Where(f => f.GroupByPriority > 0 && f.Id != field.Id).OrderBy(f => f.GroupByPriority)) { if (assignGroupByPriority == newGroupByPriority) assignGroupByPriority++; otherField.GroupByPriority = assignGroupByPriority; assignGroupByPriority++; } } field.GroupByPriority = newGroupByPriority; EnsureGroupByPrioritySequence(); }
internal static string GenerateListTableName(DataTypeDescriptor typeDescriptor, DataFieldDescriptor fieldDescriptor) { return string.Format("{0}_{1}", GenerateTableName(typeDescriptor), fieldDescriptor.Name); }
private bool Field_Save_UpdateName(DataFieldDescriptor field, DataInput nameInput) { string newName = nameInput.Text; if (!FieldNameSyntaxValid(newName)) { Baloon(nameInput, Texts.FieldNameSyntaxInvalid); return false; } if (this.CurrentFields.Any(f => String.Equals(f.Name, newName, StringComparison.InvariantCultureIgnoreCase) && f.Id != field.Id)) { Baloon(nameInput.ClientID, Texts.CannotSave); return false; } if (field.Name != newName) { _nameChanged = true; } if (field.Name == CurrentKeyFieldName) { CurrentKeyFieldName = newName; } field.Name = newName; return true; }
private void Field_Save_UpdateTreeOrderingProfile(DataFieldDescriptor field) { if (field.TreeOrderingProfile.ToString() != this.TreeOrderingField.SelectedValue) { field.TreeOrderingProfile = DataFieldTreeOrderingProfile.FromString(this.TreeOrderingField.SelectedValue); int assignTreeOrderPriority = 1; foreach (DataFieldDescriptor otherField in this.CurrentFields.Where(f => f.TreeOrderingProfile.OrderPriority > 0 && f.Id != field.Id).OrderBy(f => f.TreeOrderingProfile.OrderPriority)) { if (assignTreeOrderPriority == field.TreeOrderingProfile.OrderPriority) assignTreeOrderPriority++; otherField.TreeOrderingProfile.OrderPriority = assignTreeOrderPriority; assignTreeOrderPriority++; } } EnsureTreeOrderPrioritySequence(); }
/// <exclude /> public ReferenceFailingPropertyInfo(DataFieldDescriptor dataFieldDescriptor, Type referencedType, IData originLocaleDataValue, bool optionalReferenceWithValue) { this.DataFieldDescriptor = dataFieldDescriptor; this.ReferencedType = referencedType; this.OriginLocaleDataValue = originLocaleDataValue; this.OptionalReferenceWithValue = optionalReferenceWithValue; }