void SourceGrid_KeyDown(object sender, KeyEventArgs e) { // If DisplayFormat field and Insert is pushed if (sourceGrid.SelectedGridItem.Label == "DisplayFormat" && e.KeyCode == Keys.Insert && !e.Alt && !e.Control && !e.Shift) { Type selectedObjectType = ((MappedProperty)sourceGrid.SelectedObject).Type; MappedProperty property = sourceGrid.SelectedObject as MappedProperty; using (SelectDisplayFormats form = new SelectDisplayFormats()) { form.DisplayFormat = property.DisplayFormat; form.DisplayFormatDataType = selectedObjectType; if (form.ShowDialog() == DialogResult.OK) { property.DisplayFormat = form.DisplayFormat; sourceGrid.Refresh(); } } } }
//output protected virtual void ConstructOutput(StringBuilder sql) { List <MappedProperty> outputProperties = Output.GetSelectedFlat(); if (outputProperties.Count == 0) { return; } sql.Append(" OUTPUT "); sql.Append(_sourceAlias + "." + SOURCE_ID_COLUMN_NAME + ","); for (int i = 0; i < outputProperties.Count; i++) { MappedProperty prop = outputProperties[i]; string name = $"INSERTED.{prop.EfMappedName}"; sql.Append(name); bool isLast = i == outputProperties.Count - 1; if (isLast == false) { sql.Append(","); } } }
/// <summary> /// Processes all rows of a query with nested results /// </summary> /// <param name="mappedProperty">the created child objects will be assigned to the property as array</param> /// <param name="mappedQuery">mapped query object</param> /// <param name="reader">current reader</param> /// <param name="jsonWriter">current json writer</param> /// <param name="rowFinishedAction">action will be fired when the rowset for one object (idColumn equals) was read</param> public void ProcessResults(MappedProperty mappedProperty, MappedQuery mappedQuery, IDataReader reader, JsonTextWriter jsonWriter, Action <IDictionary <string, object>, RowSet, List <string> > rowFinishedAction) { var arrayWriter = new ConditionalJsonArrayWriter(jsonWriter, mappedProperty); List <string> fieldNameList = null; var queryWithNestedResults = mappedQuery as MappedQueryWithNestedResults; var currentRowSet = new RowSet(queryWithNestedResults.IdColumn, new List <IDictionary <string, object> >()); IDictionary <string, object> lastRow = null; var lookUpTable = reader.GetFieldIndexLookupTable(); while (reader.Read()) { arrayWriter.StartArray(); fieldNameList = fieldNameList == null?reader.GetFieldNameList() : fieldNameList; var currentRow = reader.ToDictionary(lookUpTable); if (lastRow != null && !Object.Equals(lastRow[queryWithNestedResults.IdColumn], currentRow[queryWithNestedResults.IdColumn])) { rowFinishedAction(lastRow, currentRowSet, fieldNameList); currentRowSet = new RowSet(queryWithNestedResults.IdColumn, new List <IDictionary <string, object> >()); } currentRowSet.Rows.Add(currentRow); lastRow = currentRow; } if (currentRowSet.Rows.Count > 0) { rowFinishedAction(lastRow, currentRowSet, fieldNameList); } arrayWriter.EndArray(); }
public MappedProperty SaveOrUpdateMerge(MappedProperty mappedProperty) { object mergedObj = Session.Merge(mappedProperty); HibernateTemplate.SaveOrUpdate(mergedObj); return((MappedProperty)mergedObj); }
private void SelectMappedPropertyFromPropertyMap_Load(object sender, EventArgs e) { if (ValidMappedPropertyList != null) { foreach (MappedProperty property in ValidMappedPropertyList) { comboBoxList.Add(new ComboBoxShowMappedProperty() { Title = property.Name, MappedProperty = property }); } } MappedProperty savedMappedProperty = SelectedMappedProperty; comboBoxShowMappedPropertyBindingSource.DataSource = comboBoxList; if (savedMappedProperty != null) { if (!FindMappedProperty(savedMappedProperty)) { comboBoxShowMappedPropertyBindingSource.MoveFirst(); } } EnableDisableButtons(); }
private void sourceGrid_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e) { foreach (Control cntrl in sourceGrid.Controls[2].Controls) { cntrl.KeyDown -= new KeyEventHandler(SourceGrid_KeyDown); } lblInformation.Text = string.Empty; if (e.NewSelection != null && e.NewSelection.Label == "DisplayFormat") { MappedProperty mappedProperty = (MappedProperty)sourceGrid.SelectedObject; // Check if the type is one of DateTime or Numeric (decimal, double or int) if (mappedProperty != null && mappedProperty.CanChangeDisplayFormat()) { lblInformation.Text = "Push the \"Insert\" button in the inputfield for help on different used DisplayFormats."; foreach (Control cntrl in sourceGrid.Controls[2].Controls) { cntrl.KeyDown += new KeyEventHandler(SourceGrid_KeyDown); } } } }
private void tsbDelete_Click(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count > 0) { foreach (ListViewItem item in propertyListView.SelectedItems) { MappedProperty mp = item.Tag as MappedProperty; if (mp != null) { // Check if has real Id then it should be deleted in database also. if (mp.Id != Guid.Empty) { deletedList.Add(mp); } // Remove item in list PropertyMap.MappedProperties.Remove(mp); // Recalculate sequence ResetSequenceOnPropertyMap(); ShowProperties(); ChangesMade = true; } } } }
private void renameBtn_Click(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count > 0) { MappedProperty mappedProperty = propertyListView.SelectedItems[0].Tag as MappedProperty; if (mappedProperty.Target != null) { using (RenamePropertyForm form = new RenamePropertyForm()) { if (string.IsNullOrEmpty(mappedProperty.Name)) { form.OldName = mappedProperty.Target.Name; } else { form.OldName = mappedProperty.Name; } if (form.ShowDialog() == DialogResult.OK) { mappedProperty.Name = form.NewName; UpdateResponseProperty(mappedProperty); UpdateListViewItemMappedPropertyName(propertyListView.SelectedItems[0]); UpdateListViewColors(); } } } } }
private void propertyListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (propertyListView.SelectedItems.Count == 1) { MappedProperty property = propertyListView.SelectedItems[0].Tag as MappedProperty; if (property != null) { if (!this.IsEditable || LockPropertyGrid) { TypeDescriptor.AddAttributes(property, new Attribute[] { new ReadOnlyAttribute(true) }); } sourceGrid.SelectedObject = property; } SetMultiSelectMode(false); } else if (propertyListView.SelectedItems.Count > 1) { NewMultiSelItem(); SetMultiSelectMode(true); } else { sourceGrid.SelectedObject = null; SetMultiSelectMode(false); } }
private void UpdateListViewItemMappedPropertyName(ListViewItem item) { if (item != null) { MappedProperty mappedProperty = (MappedProperty)item.Tag; if (mappedProperty != null) { if (string.IsNullOrEmpty(mappedProperty.Name)) { if (mappedProperty.Target != null) { item.SubItems[3].Text = mappedProperty.Target.Name; } else { item.SubItems[3].Text = string.Empty; } } else { item.SubItems[3].Text = mappedProperty.Name; } } } }
public void WhithDefaultValue() { MappedProperty mp = Factory.getVanillaTestObject(); mp.DefaultValue = "Def Val"; Assert.IsTrue(mp.IsMapped); }
public EventPropertyGetterMapped GetPropertyProvidedGetterMap( IDictionary <String, Object> nestableTypes, String mappedPropertyName, MappedProperty mappedProperty, EventAdapterService eventAdapterService) { return(mappedProperty.GetGetterMap(nestableTypes, eventAdapterService) as EventPropertyGetterMapped); }
internal void WriteStaticValue(MappedProperty mappedProperty, JsonTextWriter jsonWriter) { if (mappedProperty.StaticValue != null) { jsonWriter.WritePropertyName(mappedProperty.TargetPropertyName); jsonWriter.WriteValue(mappedProperty.StaticValue); } }
public void WhithBlankDefaultValue() { MappedProperty mp = Factory.getVanillaTestObject(); mp.DefaultValue = ""; Assert.IsFalse(mp.IsMapped); }
private void UpdateListViewColors() { foreach (ListViewItem item in propertyListView.Items) { item.Font = new Font(item.Font, FontStyle.Regular); item.ForeColor = Color.Black; } foreach (ListViewItem item in propertyListView.Items) { MappedProperty mappedProperty = (MappedProperty)item.Tag; if (IsPossibleBoolean(mappedProperty) && mappedProperty.Target != null && (mappedProperty.Target.Type != typeof(bool))) { item.Font = new Font(item.Font, FontStyle.Bold); } } IList <string> nonUniqueNames; nonUniqueNames = GetNonUniqueNames(RequestMap); if (nonUniqueNames.Count > 0) { foreach (string name in nonUniqueNames) { foreach (MappedProperty prop in RequestMap.MappedProperties) { if (prop.Name == name) { ListViewItem item = FindListViewItemTag(prop); item.ForeColor = Color.OrangeRed; } } } } nonUniqueNames = GetNonUniqueNames(ResponseMap); if (nonUniqueNames.Count > 0) { foreach (string name in nonUniqueNames) { foreach (MappedProperty prop in ResponseMap.MappedProperties) { if (prop.Name == name) { ListViewItem item = FindListViewItemTag(prop); item.ForeColor = Color.OrangeRed; } } } } }
/// <summary> /// 映射资源和实体属性对应字段 /// </summary> /// <param name="propertyName"></param> /// <param name="revert"></param> public PropertyMappingAttribute(string propertyName = null, bool revert = false) { if (string.IsNullOrWhiteSpace(propertyName)) { return; } MappedProperty = new MappedProperty(propertyName, revert); }
public MappedProperty Save(MappedProperty mappedProperty) { if (mappedProperty.Id == Guid.Empty) { mappedProperty.Id = Guid.NewGuid(); } HibernateTemplate.Save(mappedProperty); return(mappedProperty); }
public void WhithTarget() { MappedProperty mp = Factory.getVanillaTestObject(); IMappableProperty newTarget = Factory.getMappedPropertyObject(); mp.Target = newTarget; Assert.IsTrue(mp.IsMapped); }
private void mapNewBtn_Click(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count > 0) { MappedProperty mappedProperty = propertyListView.SelectedItems[0].Tag as MappedProperty; if (FindTargetProperty((DbProperty)mappedProperty.Source) != null) { if (MessageBox.Show("You are trying to map a field, that has been found to be connected to a table and column, to a new custom property.\nIs this what you want?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } using (CreatePropertyForm createPropertyForm = new CreatePropertyForm(BusinessEntity)) { createPropertyForm.BackendApplication = BackendApplication; createPropertyForm.DbProperty = mappedProperty.Source as DbProperty; if (createPropertyForm.ShowDialog() == DialogResult.OK) { try { mappedProperty.Target = createPropertyForm.Property; UpdateResponseProperty(mappedProperty); DbProperty dbProp = mappedProperty.Source as DbProperty; if (string.IsNullOrEmpty(dbProp.DbDatatype)) { if (mappedProperty.Target.Type == typeof(string)) { dbProp.DbDatatype = "VARCHAR2"; if ((dbProp.PropertyType == DbPropertyType.InOut) || (dbProp.PropertyType == DbPropertyType.Out)) { dbProp.Length = 255; } } } propertyListView.SelectedItems[0].SubItems[3].Text = mappedProperty.Target.Name; propertyListView.SelectedItems[0].SubItems[4].Text = mappedProperty.Target.Type.ToString(); detailGrid.SelectedObject = mappedProperty; // Update the colors UpdateListViewColors(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } } }
internal void WriteCustomResolvedValue(MappedProperty mappedProperty, JsonTextWriter jsonWriter, IDictionary <string, object> row, IDictionary <string, object> context) { if (mappedProperty.ValueResolver != null) { var resolver = mappedProperty.ValueResolver; jsonWriter.WritePropertyName(mappedProperty.TargetPropertyName); jsonWriter.WriteValue(resolver.ResolveValue(row, context)); } }
private bool IsPossibleBoolean(MappedProperty mappedProperty) { DbProperty dbProperty = mappedProperty.Source as DbProperty; return(dbProperty != null && !string.IsNullOrEmpty(dbProperty.DbDatatype) && dbProperty.DbDatatype.ToUpper() == "VARCHAR2" && dbProperty.Length == 1); }
public Expression Transform(MethodCallExpression methodCallExpression) { ArgumentUtility.CheckNotNull("methodCallExpression", methodCallExpression); var isInstanceMethod = !methodCallExpression.Method.IsStatic; var isExtensionMethod = !isInstanceMethod && AttributeUtility.IsDefined <ExtensionAttribute> (methodCallExpression.Method, false); if (isInstanceMethod) { if (methodCallExpression.Arguments.Any()) { throw CreateNotSupportedException(methodCallExpression, "Only methods without parameters can be redirected."); } } else if (isExtensionMethod) { if (methodCallExpression.Arguments.Count != 1) { throw CreateNotSupportedException( methodCallExpression, "Extensions method expecting parameters other than the instance parameter cannot be redirected."); } } else { throw CreateNotSupportedException( methodCallExpression, "Only instance or extension methods can be redirected, but the method is static."); } if (methodCallExpression.Method.Equals(MappedProperty.GetGetMethod(true))) { throw CreateNotSupportedException(methodCallExpression, "The method would redirect to itself."); } Expression instanceExpression = isInstanceMethod ? methodCallExpression.Object : methodCallExpression.Arguments.Single(); try { if (instanceExpression.Type != MappedProperty.DeclaringType) { instanceExpression = Expression.Convert(instanceExpression, MappedProperty.DeclaringType); } } catch (InvalidOperationException ex) { throw CreateNotSupportedException(methodCallExpression, ex.Message, ex); } var memberAccess = Expression.MakeMemberAccess(instanceExpression, MappedProperty); if (!methodCallExpression.Type.IsAssignableFrom(memberAccess.Type)) { throw CreateNotSupportedException(methodCallExpression, "The property has an incompatible return type."); } return(memberAccess); }
public EventPropertyGetterMappedSPI GetPropertyProvidedGetterMap( IDictionary<string, object> nestableTypes, string mappedPropertyName, MappedProperty mappedProperty, EventBeanTypedEventFactory eventBeanTypedEventFactory, BeanEventTypeFactory beanEventTypeFactory) { return (EventPropertyGetterMappedSPI) mappedProperty .GetGetterMap(nestableTypes, eventBeanTypedEventFactory, beanEventTypeFactory); }
public void SetValue(object model, MappedProperty p, IValueProvider valueProvider) { var value = valueProvider.GetValue(p.Target)?.AttemptedValue; if (value == null) { return; } p.Info.SetValue(model, this.Convert(p.Info.PropertyType, value)); }
public EventPropertyGetterMapped GetGetterMapped(string mappedPropertyName) { EventPropertyDescriptor desc = _propertyDescriptorMap.Get(mappedPropertyName); if (desc == null || !desc.IsMapped) { return null; } var mappedProperty = new MappedProperty(mappedPropertyName); return (EventPropertyGetterMapped) mappedProperty.GetGetter(this, _eventAdapterService); }
public void WhithDefaultSessionProperty() { MappedProperty mp = Factory.getVanillaTestObject(); UXSessionProperty sessionProperty = Factory.getDefaultSessionPropertyObject(); mp.DefaultSessionProperty = sessionProperty; Assert.IsTrue(mp.IsMapped); }
public void AddPropertiesToPropertyMap(List <Property> properties) { bool tooLongPropertiesAdded = false; int sequence = 1; if (PropertyMap.MappedProperties.Count > 0) { sequence = PropertyMap.MappedProperties.Max(p => p.Sequence) + 1; } foreach (Property property in properties) { MappedProperty mappedProperty = new MappedProperty(); mappedProperty.Source = null; mappedProperty.Target = property; string name = UseColumnNames && property.StorageInfo != null ? property.StorageInfo.ColumnName : property.Name; if (NameUpperCase) { name = name.ToUpper(); } // Check lengths if (MaxPropertyLength > 0 && (name.Length + NameSuffix.Length) > MaxPropertyLength) { tooLongPropertiesAdded = true; mappedProperty.Name = name.Substring(0, MaxPropertyLength - NameSuffix.Length) + NameSuffix; } else { mappedProperty.Name = name + NameSuffix; } mappedProperty.Sequence = sequence++; mappedProperty.PropertyMap = PropertyMap; mappedProperty.IsSearchable = true; // If storageinfo is not set then it's custom mappedProperty.IsCustom = property.StorageInfo == null; PropertyMap.MappedProperties.Add(mappedProperty); } if (tooLongPropertiesAdded) { MessageBox.Show("One or more properties was added that was longer than " + MaxPropertyLength.ToString() + " characters.\n" + "The names of these properties has been cut to maximum length.\n" + "Check the names of the properties if they are usable before saving.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
void SourcePropertyClickEventHandler(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count == 1) { MappedProperty property = propertyListView.SelectedItems[0].Tag as MappedProperty; property.Source = (sender as ToolStripMenuItem).Tag as IMappableProperty; UpdateListItem(propertyListView.SelectedItems[0]); } }
private void NewMultiSelItem() { MappedProperty multiProp = new MappedProperty(); if (!this.IsEditable || LockPropertyGrid) { TypeDescriptor.AddAttributes(multiProp, new Attribute[] { new ReadOnlyAttribute(true) }); } sourceGrid.SelectedObject = multiProp; }
public SelectMappedPropertyFromPropertyMap() { InitializeComponent(); comboBoxList = new List <ComboBoxShowMappedProperty>(); actionService = MetaManagerServices.GetUXActionService(); dialogService = MetaManagerServices.GetDialogService(); SelectedMappedProperty = null; }