protected override void AddChildItemToVisualTree(object newItem) { if (_useNativeComboBox) { object value = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(newItem, DisplayMemberPath); //if (value is UIElement) //{ // SwitchToNonNativeComboBox(); // If the value is a UI element, we should switch to a non-native combo box: //} //else //{ if (value != null) { if (_nativeComboBoxDomElement != null) { var optionDomElement = INTERNAL_HtmlDomManager.AddOptionToNativeComboBox(_nativeComboBoxDomElement, value.ToString()); _itemContainerGenerator.INTERNAL_RegisterContainer(optionDomElement, newItem); } } //todo: else --> ? //} } else { base.AddChildItemToVisualTree(newItem); } }
//holding in a form such as List <EDOID>, not as List<string>, makes it possible to identify whether the ID of any part. It would be easier to debug. private static void CollectIds(IIDPropertiesProvider obj, List <string> ids) { foreach (string propertyName in obj.IdProperties) { string id = (string)PropertyPathHelper.GetValue(obj, propertyName); ids.Add(id); } }
public void Finds_Property_At_Top_Level() { var p = PropertyPathHelper.GetProperty(typeof(MyFilteredItem), "MyInt"); Assert.IsNotNull(p); Assert.AreEqual("MyInt", p.Name); Assert.AreEqual(typeof(int), p.PropertyType); }
public void Finds_SubSub_Property() { var p = PropertyPathHelper.GetProperty(typeof(MyFilteredItem), "MyInner.MySubSubItem.MySubSubString"); Assert.IsNotNull(p); Assert.AreEqual("MySubSubString", p.Name); Assert.AreEqual(typeof(string), p.PropertyType); }
protected virtual void ManageSelectedIndex_Changed(DependencyPropertyChangedEventArgs e) { // Note: in this method, we use "Convert.ToInt32()" intead of casting to "(int)" because otherwise the JS code is not compatible with IE 9 (or Windows Phone 8.0). //if (!AreObjectsEqual(e.OldValue, e.NewValue)) //{ int newValue = Convert.ToInt32(e.NewValue); if (newValue < Items.Count) //The new value is ignored if it is bigger or equal than the amount of elements in the list of Items. { if (!_selectionChangeIsOnValue && !_selectionChangeIsOnItem) //we only want to change the other ones if the change comes from SelectedIndex (otherwise it's already done by the one that was originally changed (SelectedItem or SelectedValue) { object oldItem = SelectedItem; _selectionChangeIsOnIndex = true; if (newValue == -1) { SetLocalValue(SelectedItemProperty, null); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay SetLocalValue(SelectedValueProperty, null); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay //todo: update binding of SelectedIndex //selector.SelectedItem = null; //selector.SelectedValue = null; } else { object item = Items[newValue]; //todo: make sure that the index always corresponds (I think it does but I didn't check) SetLocalValue(SelectedItemProperty, item); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay SetLocalValue(SelectedValueProperty, PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(item, SelectedValuePath)); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay //todo: update binding of SelectedIndex //selector.SelectedItem = item; //selector.SelectedValue = selector.AccessValueByApplyingPropertyPathIfAny(item, selector.SelectedValuePath); } _selectionChangeIsOnIndex = false; List <object> oldItems = new List <object>(); oldItems.Add(oldItem); List <object> newItems = new List <object>(); newItems.Add(SelectedItem); RefreshSelectedItem(); if (!ChangingSelectionInHtml) //the SelectionChanged event is already fired from the javascript event. { OnSelectionChanged(new SelectionChangedEventArgs(oldItems, newItems)); } } if (!ChangingSelectionInHtml) { ChangingSelectionProgrammatically = true; //so that it doesn't end up in a loop ApplySelectedIndex(newValue); ChangingSelectionProgrammatically = false; } } //} }
private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Selector s = (Selector)d; object newValue = e.NewValue; // we only want to change the other ones if the change comes from // SelectedItem (otherwise it's already done by the one that was // originally changed (SelectedIndex or SelectedValue) if (!s._selectionChangeIsOnValue && !s._selectionChangeIsOnIndex) { s._selectionChangeIsOnItem = true; try { if (newValue == null) { // we use SetCurrentValue to preserve any potential bindings. s.SetCurrentValue(Selector.SelectedValueProperty, null); s.SetCurrentValue(Selector.SelectedIndexProperty, -1); } else { // we use SetCurrentValue to preserve any potential bindings. s.SetCurrentValue(Selector.SelectedValueProperty, PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(newValue, s.SelectedValuePath)); s.SetCurrentValue(Selector.SelectedIndexProperty, s.Items.IndexOf(newValue)); s.OnSelectedItemChanged(newValue); if (s.ItemsSource is ICollectionView view) { view.MoveCurrentToPosition(s.Items.IndexOf(newValue)); } } } finally { s._selectionChangeIsOnItem = false; } } //calling the methods to update the Visual Tree/Selection: s.ApplySelectedIndex(s.SelectedIndex); s.ManageSelectedIndex_Changed(s._indexChangeEventArgs); //We do not want to raise the event here when we have a MultiSelector (or when SelectionMode is not Single ?) if (!(s is MultiSelector)) { // Raise the selection changed event List <object> removedItems = new List <object>(); removedItems.Add(e.OldValue); List <object> addedItems = new List <object>(); addedItems.Add(e.NewValue); SelectionChangedEventArgs args = new SelectionChangedEventArgs(removedItems, addedItems); s.OnSelectionChanged(args); } }
protected long GetNumericMember(object item) { if (item is FlagControlItem == true) { return((item as FlagControlItem).Value); } var value = PropertyPathHelper.GetValue(item, this.NumericMemberPath); return(Convert.ToInt64(value)); }
private void UpdateOrder() { if (Items != null) { RunWithSelectedItemRestore(() => { Items.IsTracking = false; Items.Order = new Func <object, object>(o => PropertyPathHelper.Evaluate(o, SelectedColumn.OrderPropertyPath)); Items.Ascending = SelectedColumn.IsAscending; Items.IsTracking = true; }); } }
public void Filter(string text) { string lowerText = text.ToLower(); objects.Clear(); foreach (T obj in allObjects) { string objValue = (string)PropertyPathHelper.GetValue(obj, DisplayMemberPath) as string; if (string.IsNullOrEmpty(lowerText) || (objValue != null && objValue.ToLower().Contains(lowerText))) { objects.Add(obj); } } }
private static RenameResult RenameId(IIDPropertiesProvider obj, string propertyName, List <string> ids) { RenameResult result = new RenameResult(propertyName); string id = (string)PropertyPathHelper.GetValue(obj, propertyName); if (ids.Contains(id)) { string newId = IDUtils.NewGuid(); PropertyPathHelper.SetValue(obj, propertyName, newId); result.OldId = id; result.NewId = newId; return(result); } return(result); }
internal override FrameworkElement GenerateEditingElement(object childData) { Binding b = Binding as Binding; if (b.Mode == BindingMode.OneWay) { if (!b.INTERNAL_WasModeSetByUserRatherThanDefaultValue()) { b.Mode = BindingMode.TwoWay; } } object value = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(childData, b.Path.Path); if (!(value is Enum)) { throw new NotImplementedException("DataGridComboBoxColumns currently only works with Enum types"); } Type enumType = value.GetType(); var enumValues = Enum.GetValues(enumType);// enumType.GetEnumValues(); NativeComboBox cb = new NativeComboBox(); cb.DataContext = childData; if (enumValues != null && enumValues.Length > 0) { #if BRIDGE //Note: work around the fact that Enum is not a persistant type (the value is replaced by the base type of the enum (int32 by default)) // because of that, we need to set the ItemsSource of the ComboBox to a list of the names (as strings) of the possible enum values. // Otherwise, the value shown in the comboBox would be the base type value (so 0 or 1 for example). // Create a list of the enum's values' names and set it as the ItemsSource of the ComboBox: var enumValuesAsStrings = new List <string>(); Type valueType = value.GetType(); foreach (object val in enumValues) { enumValuesAsStrings.Add(Enum.GetName(valueType, val)); } cb.ItemsSource = enumValuesAsStrings; //Add a converter so that we go smoothly between the selected value in the ComboBox and the expected value in the source of the binding: b.Converter = new MyConverter(); b.ConverterParameter = valueType; #else cb.ItemsSource = enumValues; #endif cb.SetBinding(NativeComboBox.SelectedItemProperty, b); } return(cb); }
private void AddOption(object option, int index) { if (this._nativeComboBoxDomElement == null) { return; } object value = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(option, this.DisplayMemberPath); if (value != null) { INTERNAL_HtmlDomManager.AddOptionToNativeComboBox( this._nativeComboBoxDomElement, value.ToString(), index); } }
private PropertyInfo ResolveProperty() { var target = TargetObject; var type = target.GetType(); var property = PropertyPathHelper.GetProperty(type, PropertyPath); if (property == null) { throw new ArgumentException($"Unable to find the property '{PropertyPath}' for the type '{type}'"); } if (!property.CanWrite) { throw new InvalidOperationException($"Unable to write for the property '{PropertyPath}' for the type '{type}'"); } return(property); }
private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Selector s = (Selector)d; object newValue = e.NewValue; // we only want to change the other ones if the change comes from // SelectedItem (otherwise it's already done by the one that was // originally changed (SelectedIndex or SelectedValue) if (!s._selectionChangeIsOnValue && !s._selectionChangeIsOnIndex) { s._selectionChangeIsOnItem = true; try { if (newValue == null) { // we use SetCurrentValue to preserve any potential bindings. s.SetCurrentValue(Selector.SelectedValueProperty, null); s.SetCurrentValue(Selector.SelectedIndexProperty, -1); } else { // we use SetCurrentValue to preserve any potential bindings. s.SetCurrentValue(Selector.SelectedValueProperty, PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(newValue, s.SelectedValuePath)); s.SetCurrentValue(Selector.SelectedIndexProperty, s.Items.IndexOf(newValue)); } } finally { s._selectionChangeIsOnItem = false; } } // Raise the selection changed event List <object> removedItems = new List <object>(); removedItems.Add(e.OldValue); List <object> addedItems = new List <object>(); addedItems.Add(e.NewValue); SelectionChangedEventArgs args = new SelectionChangedEventArgs(removedItems, addedItems); s.OnSelectionChanged(args); }
//Compares the current value of the text box and the properties of the source that is bound, //return true if modified, false otherwise public static bool IsChanged(TextBox sender) { DependencyObject element = null; DependencyProperty dp = null; GetTargetElement(sender, out element, out dp); if (element == null || dp == null) { return(false); } BindingExpression bindingExpression = BindingOperations.GetBindingExpression(element, dp); //using the current BindingExpression, get the string when of the target text property was set to the value of the source //Otherwise, when StringFormat or converter is set or the type of the property is not a string //problem happens how to convert it string propertyValue = PropertyPathHelper.GetTargetValue(bindingExpression); string elementValue = element.GetValue(dp) as string; return(!IsSame(propertyValue, elementValue)); }
private static void SelectedValue_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!AreObjectsEqual(e.OldValue, e.NewValue)) { Selector selector = (Selector)d; object newValue = (object)e.NewValue; object oldItem = selector.SelectedItem; if (!selector._selectionChangeIsOnItem && !selector._selectionChangeIsOnIndex) //we only want to change the other ones if the change comes from SelectedItem (otherwise it's already done by the one that was originally changed (SelectedIndex or SelectedValue) { selector._selectionChangeIsOnValue = true; if (newValue == null) { selector.SetLocalValue(SelectedIndexProperty, -1); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay selector.SetLocalValue(SelectedItemProperty, null); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay //todo: update binding of SelectedIndex //selector.SelectedIndex = -1; //selector.SelectedItem = null; } else { var selectedPropertyPath = selector.SelectedValuePath; object item = selector.Items.First(element => Object.Equals(PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(element, selectedPropertyPath), newValue)); //todo: perf? //Note: there is no way we can know which value was intended in the case of multiple items with the same values. selector.SetLocalValue(SelectedIndexProperty, GetIndexOfElementInItems(selector, item)); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay selector.SetLocalValue(SelectedItemProperty, item); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay //todo: update binding of SelectedIndex //selector.SelectedIndex = GetIndexOfElementInItems(selector, item); //selector.SelectedItem = item; } selector._selectionChangeIsOnValue = false; List <object> oldItems = new List <object>(); oldItems.Add(oldItem); List <object> newItems = new List <object>(); newItems.Add(selector.SelectedItem); selector.RefreshSelectedItem(); selector.OnSelectionChanged(new SelectionChangedEventArgs(oldItems, newItems)); } } }
protected FrameworkElement GenerateFrameworkElementToRenderTheItem(object item) { FrameworkElement result; if (item is FrameworkElement) { //--------------- // The item is already a FrameworkElement, so we return itself: //--------------- result = (FrameworkElement)item; } else { object displayElement = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(item, this.DisplayMemberPath); if (this.ItemTemplate != null) { //--------------- // An ItemTemplate was specified, so we instantiate it and return it: //--------------- // Apply the data template: result = ItemTemplate.INTERNAL_InstantiateFrameworkTemplate(); result.DataContext = displayElement; } else { //--------------- // Otherwise we simply call "ToString()" to display the item as a string inside a TextBlock: //--------------- // Show as string: //result = new TextBlock() { Text = displayElement.ToString() }; TextBlock t = new TextBlock(); Binding b = new Binding(DisplayMemberPath); t.SetBinding(TextBlock.TextProperty, b); t.DataContext = item; result = t; } } return(result); }
/// <summary> /// Helper method that returns a QueryCriteria used by the GetHardwareAssetBy.. methods /// </summary> /// <param name="property">Property to query</param> /// <param name="value">Property value to look for</param> /// <returns></returns> private static QueryCriteria BuildCriteria(PropertyPathHelper property, string value) { QueryCriteriaExpression expression = new QueryCriteriaExpression { PropertyName = property.ToString(), PropertyType = QueryCriteriaPropertyType.Property, Operator = QueryCriteriaExpressionOperator.Equal, Value = value }; QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.HardwareAsset.Id) { GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression }; criteria.Expressions.Add(expression); return(criteria); }
private static void SelectedItem_changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!AreObjectsEqual(e.OldValue, e.NewValue)) { Selector selector = (Selector)d; object newValue = (object)e.NewValue; if (!selector._selectionChangeIsOnValue && !selector._selectionChangeIsOnIndex) //we only want to change the other ones if the change comes from SelectedItem (otherwise it's already done by the one that was originally changed (SelectedIndex or SelectedValue) { selector._selectionChangeIsOnItem = true; if (newValue == null) { selector.SetLocalValue(SelectedIndexProperty, -1); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay selector.SetLocalValue(SelectedValueProperty, null); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay //todo: update binding of SelectedIndex //selector.SelectedIndex = -1; //selector.SelectedValue = null; } else { selector.SetLocalValue(SelectedIndexProperty, GetIndexOfElementInItems(selector, newValue)); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay selector.SetLocalValue(SelectedValueProperty, PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(newValue, selector.SelectedValuePath)); //we call SetLocalvalue directly to avoid replacing the BindingExpression that could be here on Mode = TwoWay //todo: update binding of SelectedIndex //selector.SelectedIndex = GetIndexOfElementInItems(selector, newValue); //selector.SelectedValue = selector.AccessValueByApplyingPropertyPathIfAny(newValue, selector.SelectedValuePath); } selector._selectionChangeIsOnItem = false; List <object> oldItems = new List <object>(); oldItems.Add(e.OldValue); List <object> newItems = new List <object>(); newItems.Add(e.NewValue); selector.RefreshSelectedItem(); selector.OnSelectionChanged(new SelectionChangedEventArgs(oldItems, newItems)); } } }
private string GetDisplayMember(object item) { string text = string.Empty; if (item is ContentControl) { text = (item as ContentControl).Content.ToString(); } else { text = PropertyPathHelper.GetValue(item, this.DisplayMemberPath).ToString(); } if (text.IndexOf(' ') >= 0) { return("\"" + text + "\""); } return(text); }
public static void PropertyPathHelper_Test() { var a = new A(); object valueA = PropertyPathHelper.GetValueFromPropertyInfo(a, "Value"); object valueB = PropertyPathHelper.GetValueFromPropertyInfo(a, "B.Value"); object valueC = PropertyPathHelper.GetValueFromPropertyInfo(a, "B.C.Value"); bool cachedA = PropertyPathHelper._cacheDic.ContainsKey(new Tuple <Type, string>(typeof(A), "Value")); bool cachedC = PropertyPathHelper._cacheDic.ContainsKey(new Tuple <Type, string>(typeof(C), "Value")); Assert.AreEqual("A", valueA); Assert.AreEqual("B", valueB); Assert.AreEqual("C", valueC); Assert.AreEqual("C", valueC); Assert.IsTrue(cachedA); Assert.IsTrue(cachedC); }
protected FrameworkElement GenerateFrameworkElementToRenderTheItem(object item) { //--------------------------------------------------- // if the item is a FrameworkElement, return itself //--------------------------------------------------- FrameworkElement result = item as FrameworkElement; if (result == null) { object displayElement = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(item, this.DisplayMemberPath); if (this.ItemTemplate != null) { //--------------------------------------------------- // An ItemTemplate was specified, so we instantiate // it and return it //--------------------------------------------------- // Apply the data template result = ItemTemplate.INTERNAL_InstantiateFrameworkTemplate(); result.DataContext = displayElement; } else { //--------------------------------------------------- // Otherwise we simply call "ToString()" to display // the item as a string inside a TextBlock //--------------------------------------------------- ContentPresenter container = new ContentPresenter(); Binding b = new Binding(this.DisplayMemberPath); container.SetBinding(ContentControl.ContentProperty, b); container.DataContext = item; result = container; } } #if WORKINPROGRESS this.PrepareContainerForItemOverride(result, item); #endif return(result); }
private static void OnSelectedValuePathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Selector s = (Selector)d; s._selectionChangeIsOnItem = true; s._selectionChangeIsOnIndex = true; try { object item = null; if (s.SelectedItem != null) { item = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(s.SelectedItem, (string)e.NewValue); } s.SetCurrentValue(Selector.SelectedValueProperty, item); } finally { s._selectionChangeIsOnItem = false; s._selectionChangeIsOnIndex = false; } }
private static void OnSelectedValuePathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { NativeComboBox cb = (NativeComboBox)d; cb._selectionChangeIsOnItem = true; cb._selectionChangeIsOnIndex = true; try { object item = null; if (cb.SelectedItem != null) { item = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(cb.SelectedItem, (string)e.NewValue); } cb.SetCurrentValue(NativeComboBox.SelectedValueProperty, item); } finally { cb._selectionChangeIsOnItem = false; cb._selectionChangeIsOnIndex = false; } }
private object FindItemWithValue(object value, out int index) { index = -1; if (this.Items.Count == 0) { return(DependencyProperty.UnsetValue); } string selectedValuePath = this.SelectedValuePath; // optimize for case where there is no SelectedValuePath if (string.IsNullOrEmpty(selectedValuePath)) { index = this.Items.IndexOf(value); if (index >= 0) { return(value); } else { return(DependencyProperty.UnsetValue); } } index = 0; foreach (object item in this.Items) { object displayedItem = PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(item, selectedValuePath); if (ItemsControl.EqualsEx(displayedItem, value)) { return(item); } ++index; } index = -1; return(DependencyProperty.UnsetValue); }
public static bool UpdateSource(TextBox sender) { DependencyObject element = null; DependencyProperty dp = null; GetTargetElement(sender, out element, out dp); if (element == null || dp == null) { return(true); } BindingExpression bindingExpression = BindingOperations.GetBindingExpression(element, dp); if (bindingExpression == null) { return(true); } string elementValue = element.GetValue(dp) as string; bindingExpression.UpdateSource(); string propertyValue = PropertyPathHelper.GetTargetValue(bindingExpression); return(IsSame(elementValue, propertyValue)); }
/// <summary> /// Convenience method that gets a list of all Locations that are active /// </summary> /// <param name="authToken">AuthorizationToken to use</param> /// <returns></returns> public static async Task<List<Location>> GetAll(AuthorizationToken authToken) { PropertyPathHelper pathHelper = new PropertyPathHelper(); pathHelper.PropertyName = "ObjectStatus"; pathHelper.ObjectClass = ClassConstants.GetClassIdByType<Location>(); QueryCriteriaExpression expr = new QueryCriteriaExpression { PropertyName = pathHelper.ToString(), PropertyType = QueryCriteriaPropertyType.Property, Operator = QueryCriteriaExpressionOperator.Equal, Value = EnumerationConstants.ConfigItem.BuiltinValues.ObjectStatus.Active.ToString("D") }; QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.Location.Id) { GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression }; criteria.Expressions.Add(expr); return await GetByCriteria(authToken, criteria); }
/// <summary> /// Executes the action. /// </summary> protected override void Invoke() { if (TargetObject == null) { throw new ArgumentException("No TargetObject provided"); } if (PropertyPath == null) { throw new ArgumentException("No PropertyPath provided"); } if (this.property == null) { this.property = ResolveProperty(); } var value = TypeConversionHelper.TryConvert(property.PropertyType, Value, Culture); var owner = PropertyPathHelper.GetOwner(TargetObject, PropertyPath); if (owner != null) // a sub property can be null if not instantied { property.SetValue(owner, value); } }
private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { NativeComboBox cb = (NativeComboBox)d; object newValue = e.NewValue; // we only want to change the other ones if the change comes from // SelectedItem (otherwise it's already done by the one that was // originally changed (SelectedIndex or SelectedValue) if (!cb._selectionChangeIsOnValue && !cb._selectionChangeIsOnIndex) { cb._selectionChangeIsOnItem = true; try { if (newValue == null) { // we use SetCurrentValue to preserve any potential bindings. cb.SetCurrentValue(NativeComboBox.SelectedValueProperty, null); cb.SetCurrentValue(NativeComboBox.SelectedIndexProperty, -1); } else { // we use SetCurrentValue to preserve any potential bindings. cb.SetCurrentValue(NativeComboBox.SelectedValueProperty, PropertyPathHelper.AccessValueByApplyingPropertyPathIfAny(newValue, cb.SelectedValuePath)); cb.SetCurrentValue(NativeComboBox.SelectedIndexProperty, cb.Items.IndexOf(newValue)); } } finally { cb._selectionChangeIsOnItem = false; } } // Raise the selection changed event cb.OnSelectionChanged(e.OldValue, e.NewValue); }
/// <summary> /// Convenience method that gets a list of all Locations that are active /// </summary> /// <param name="authToken">AuthorizationToken to use</param> /// <returns></returns> public static async Task <List <Location> > GetAll(AuthorizationToken authToken) { PropertyPathHelper pathHelper = new PropertyPathHelper(); pathHelper.PropertyName = "ObjectStatus"; pathHelper.ObjectClass = ClassConstants.GetClassIdByType <Location>(); QueryCriteriaExpression expr = new QueryCriteriaExpression { PropertyName = pathHelper.ToString(), PropertyType = QueryCriteriaPropertyType.Property, Operator = QueryCriteriaExpressionOperator.Equal, Value = EnumerationConstants.ConfigItem.BuiltinValues.ObjectStatus.Active.ToString("D") }; QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.Location.Id) { GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression }; criteria.Expressions.Add(expr); return(await GetByCriteria(authToken, criteria)); }
protected virtual IEnumerable getSubEntries(object item) { return(PropertyPathHelper.GetValueFromPropertyInfo(item, SubentriesPath) as IEnumerable); }
/// <summary> /// Helper method that returns a QueryCriteria used by the GetHardwareAssetBy.. methods /// </summary> /// <param name="property">Property to query</param> /// <param name="value">Property value to look for</param> /// <returns></returns> private static QueryCriteria BuildCriteria(PropertyPathHelper property, string value) { QueryCriteriaExpression expression = new QueryCriteriaExpression { PropertyName = property.ToString(), PropertyType = QueryCriteriaPropertyType.Property, Operator = QueryCriteriaExpressionOperator.Equal, Value = value }; QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.HardwareAsset.Id) { GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression }; criteria.Expressions.Add(expression); return criteria; }