public static int getRandomValueForProperty( System.Random rand , ValueProperty prop ) { int result= 1; switch (prop) { case ValueProperty.PrimeNumber: do { result = 1 + rand.Next() % 99; } while (Utility.isPrime(result)); break; case ValueProperty.DividedBy4: result = rand.Next() % 95 + 4; result = 4 * (result / 4); break; case ValueProperty.DSumIsBiggerThan10: while (true) { int DO = 1 + rand.Next() % 9; int DT = rand.Next() % 10; result = 10 * DT + DO; if (DO + DT > 10) break; } break; case ValueProperty.DOIsBiggerThanDT: while (true) { int DO = 1 + rand.Next() % 9; int DT = rand.Next() % 10; result = 10 * DT + DO; if (DO > DT) break; } break; } return result; }
set => SetValue(ValueProperty, value);
set => SetValue(ValueProperty, ClampValue(value));
set => SetValue(ValueProperty, AdjustValue(value));
void Clear() { valueProperty = null; }
get => (int?)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
public ValuePropertyBag(ValueProperty obj) : this(new[] { obj }) { }
get => (double)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
public static string GetFkParameterNameForParentProperty(CslaObjectInfo info, ValueProperty parentProperty) { var parameterName = GetFkColumnNameForParentProperty(info, parentProperty); if (parameterName == string.Empty) { parameterName = parentProperty.ParameterName; } return(parameterName); }
public static bool MultiplePropertyFKMatchesParent(CslaObjectInfo parent, CslaObjectInfo info, ValueProperty prop) { return(MultipleColumnFKMatchesParent(parent, info, prop.DbBindColumn.Column)); }
public static string PropertyFKMatchesParentProperty(CslaObjectInfo parent, CslaObjectInfo info, ValueProperty prop) { return(ColumnFKMatchesParentProperty(parent, info, prop.DbBindColumn.Column)); }
public static DbType GetDbType(this ValueProperty prop) { return(GetDbType(prop.DbBindColumn)); }
get => (string)GetValue(ValueProperty); set { SetValue(ValueProperty, value); }
get => GetOriginalValue(ValueProperty, _value);
private void Detach() { ValueProperty.Detach(OnValueChanged); MaximumProperty.Detach(OnMaximumChanged); }
public string GetSearchWhereClause(CslaObjectInfo info, CslaObjectInfo originalInfo, Criteria crit) { StringBuilder sb = new StringBuilder(); bool first = true; foreach (CriteriaProperty parm in crit.Properties) { DbBindColumn dbc = parm.DbBindColumn; if (dbc == null) { ValueProperty prop = GetValuePropertyByName(info, parm.Name); dbc = prop.DbBindColumn; } if (dbc != null) { if (!first) { sb.Append(" AND" + Environment.NewLine); } else { sb.Append(Indent(2) + "WHERE" + Environment.NewLine); first = false; } sb.Append(Indent(3) + " "); if (IsStringType(dbc.DataType)) { sb.Append("ISNULL("); sb.Append(GetAliasedFieldString(dbc)); sb.Append(", '')"); // ValueProperty prop = GetValuePropertyByName(info, parm.Name); // if (prop.DbBindColumn.DataType.ToString() == "StringFixedLength") if (dbc.DataType.ToString() == "StringFixedLength") { sb.Append(" LIKE RTRIM(@"); sb.Append(parm.ParameterName); sb.Append(")"); } else { sb.Append(" LIKE @"); sb.Append(parm.ParameterName); } } else { sb.Append(GetAliasedFieldString(dbc)); sb.Append(" = ISNULL(@"); sb.Append(parm.ParameterName); sb.Append(", "); sb.Append(GetAliasedFieldString(dbc)); sb.Append(")"); } } } sb.Append(SoftDeleteWhereClause(info, originalInfo, crit, false, first)); sb.Append(Environment.NewLine); return(sb.ToString()); }
get => (decimal)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
public virtual string GetReaderAssignmentStatement(ValueProperty prop) { return(GetReaderAssignmentStatement(prop, false)); }
get { return (decimal)GetValue(ValueProperty); }
get => (uint)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
public DeviceMessage(string id, string value) { Id = "urn:ngsi-ld:Device:" + id; Type = "Device"; Value = new ValueProperty(value); }
get => (ulong)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
static IntRow() { DefaultStyleKeyProperty.OverrideMetadata(typeof(IntRow), new FrameworkPropertyMetadata(typeof(IntRow))); ValueProperty.OverrideMetadataWithUpdateSourceTrigger(typeof(IntRow), UpdateSourceTrigger.LostFocus); }
get => (ushort)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
void Clear() { valueProperty = null; valuePropertyCreatedWithType = null; }
get => (sbyte)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
/// <summary> /// Get the dependency property tests. /// </summary> /// <returns>The dependency property tests.</returns> public override IEnumerable <DependencyPropertyTestMethod> GetDependencyPropertyTests() { // Get the base Control dependency property tests IList <DependencyPropertyTestMethod> tests = TagInherited(base.GetDependencyPropertyTests()); // Value Property tests tests.Add(ValueProperty.InvalidValueFailsTest); tests.Add(ValueProperty.InvalidValueIsIgnoredTest); tests.Add(ValueProperty.DoesNotChangeVisualStateTest(1, 2)); // Minimum Property tests tests.Add(MinimumProperty.CheckDefaultValueTest); tests.Add(MinimumProperty.ChangeClrSetterTest); tests.Add(MinimumProperty.ChangeSetValueTest); tests.Add(MinimumProperty.ClearValueResetsDefaultTest); tests.Add(MinimumProperty.CanBeStyledTest); tests.Add(MinimumProperty.TemplateBindTest); tests.Add(MinimumProperty.SetXamlAttributeTest.Bug("523623 - NumericUpDown - Cannot set Minimum/Maximum value via xaml - XamlParseException", true)); tests.Add(MinimumProperty.SetXamlElementTest); tests.Add(MinimumProperty.InvalidValueFailsTest); tests.Add(MinimumProperty.InvalidValueIsIgnoredTest); tests.Add(MinimumProperty.DoesNotChangeVisualStateTest(1, 2)); // Maximum Property tests tests.Add(MaximumProperty.CheckDefaultValueTest); tests.Add(MaximumProperty.ChangeClrSetterTest); tests.Add(MaximumProperty.ChangeSetValueTest); tests.Add(MaximumProperty.ClearValueResetsDefaultTest); tests.Add(MaximumProperty.CanBeStyledTest); tests.Add(MaximumProperty.TemplateBindTest); tests.Add(MaximumProperty.SetXamlAttributeTest.Bug("523623 - NumericUpDown - Cannot set Minimum/Maximum value via xaml - XamlParseException", true)); tests.Add(MaximumProperty.SetXamlElementTest); tests.Add(MaximumProperty.InvalidValueFailsTest); tests.Add(MaximumProperty.InvalidValueIsIgnoredTest); tests.Add(MaximumProperty.DoesNotChangeVisualStateTest(1, 2)); // Increment Property tests tests.Add(IncrementProperty.CheckDefaultValueTest); tests.Add(IncrementProperty.ChangeClrSetterTest); tests.Add(IncrementProperty.ChangeSetValueTest); ////tests.Add(IncrementProperty.ClearValueResetsDefaultTest); ////tests.Add(IncrementProperty.CanBeStyledTest); tests.Add(IncrementProperty.TemplateBindTest); tests.Add(IncrementProperty.SetXamlAttributeTest); tests.Add(IncrementProperty.SetXamlElementTest); tests.Add(IncrementProperty.InvalidValueFailsTest.Bug("528187 - NumericUpDown - The Increment property should larger than 0, not include 0", true)); tests.Add(IncrementProperty.InvalidValueIsIgnoredTest); tests.Add(IncrementProperty.DoesNotChangeVisualStateTest(1, 2)); // DecimalPlaces Property tests tests.Add(DecimalPlacesProperty.CheckDefaultValueTest); tests.Add(DecimalPlacesProperty.ChangeClrSetterTest); tests.Add(DecimalPlacesProperty.ChangeSetValueTest); tests.Add(DecimalPlacesProperty.ClearValueResetsDefaultTest); tests.Add(DecimalPlacesProperty.CanBeStyledTest); tests.Add(DecimalPlacesProperty.TemplateBindTest); tests.Add(DecimalPlacesProperty.SetXamlAttributeTest); tests.Add(DecimalPlacesProperty.SetXamlElementTest); tests.Add(DecimalPlacesProperty.InvalidValueFailsTest); tests.Add(DecimalPlacesProperty.InvalidValueIsIgnoredTest); tests.Add(DecimalPlacesProperty.DoesNotChangeVisualStateTest(1, 2)); return(tests); }
get => (float)GetValue(ValueProperty); set => SetValue(ValueProperty, value);
set => this.SetValue(ValueProperty, value);
public void AddPropertiesForSelectedColumns() { if (frmGenerator.ColumnList.SelectedIndices.Count > 0) { StringCollection addedProps = new StringCollection(); foreach (int index in frmGenerator.ColumnList.SelectedIndices) { DictionaryEntry e = (DictionaryEntry)frmGenerator.ColumnList.Items[index]; // use name of column to see if a property of the same name exists if (!PropertyExists((string)e.Value)) { object prop = e.Key; if (prop is ColumnSchema) { ValueProperty newProp = new ValueProperty(); newProp.DbBindColumn.TableSchema = ((ColumnSchema)prop).Table; newProp.DbBindColumn.TableColumn = (ColumnSchema)prop; newProp.Name = ((ColumnSchema)prop).Name; newProp.PropertyType = TypeHelper.GetTypeCodeEx(SchemaUtility.GetSystemType(((ColumnSchema)prop).DataType)); if (newProp.DbBindColumn.Identity || newProp.DbBindColumn.NativeType == "timestamp") { newProp.ReadOnly = true; newProp.MarkDirtyOnChange = false; newProp.Undoable = false; } if (((ColumnSchema)prop).IsUnique && newProp.PropertyType == TypeCodeEx.Guid) { newProp.DefaultValue = "Guid.NewGuid()"; } _currentCslaObject.ValueProperties.Add(newProp); addedProps.Add(newProp.Name); } else if (prop is ViewColumnSchema) { ValueProperty newProp = new ValueProperty(); newProp.DbBindColumn.ViewSchema = ((ViewColumnSchema)prop).View; newProp.DbBindColumn.ViewColumn = (ViewColumnSchema)prop; newProp.Name = ((ViewColumnSchema)prop).Name; newProp.PropertyType = TypeHelper.GetTypeCodeEx(SchemaUtility.GetSystemType(((ViewColumnSchema)prop).DataType)); if (newProp.DbBindColumn.NativeType == "timestamp") { newProp.ReadOnly = true; newProp.MarkDirtyOnChange = false; newProp.Undoable = false; } _currentCslaObject.ValueProperties.Add(newProp); addedProps.Add(newProp.Name); } else if (prop is CommandResultColumnSchema) { ValueProperty newProp = new ValueProperty(); newProp.DbBindColumn.SpSchema = ((CommandResultColumnSchema)prop).Command.CommandResults[GetCurrentResultSetIndex()]; newProp.DbBindColumn.SpColumn = (CommandResultColumnSchema)prop; newProp.DbBindColumn.SpResultIndex = GetCurrentResultSetIndex(); newProp.Name = ((CommandResultColumnSchema)prop).Name; newProp.PropertyType = TypeHelper.GetTypeCodeEx(SchemaUtility.GetSystemType(((CommandResultColumnSchema)prop).DataType)); if (newProp.DbBindColumn.NativeType == "timestamp") { newProp.ReadOnly = true; newProp.MarkDirtyOnChange = false; newProp.Undoable = false; } _currentCslaObject.ValueProperties.Add(newProp); addedProps.Add(newProp.Name); } else { throw new InvalidOperationException("Unexpected column schema type."); } } } // Add Get-, New- and DeleteObjectCriteria and linked parameters AddCriteriaAndParameters(); // Display message to the user if (addedProps.Count > 0) { StringBuilder sb = new StringBuilder(); sb.Append("Successfully added the following properties:" + Environment.NewLine); foreach (string propName in addedProps) { sb.Append("\t" + propName + Environment.NewLine); } MessageBox.Show(frmGenerator, sb.ToString(), "Properties Added Successfully"); } else { MessageBox.Show(frmGenerator, "All columns selected already have corresponding properties", "Properties Already Exist"); } } }
public void AddCriteriaAndParameters() { ArrayList primaryKeyProperties = new ArrayList(); ValueProperty timeStampProperty = null; // retrieve all primary key and timestamp properties foreach (ValueProperty prop in _currentCslaObject.ValueProperties) { if (prop.DbBindColumn.IsPrimaryKey()) { primaryKeyProperties.Add(prop); } else if (prop.DbBindColumn.NativeType == "timestamp") { timeStampProperty = prop; } } if (primaryKeyProperties.Count > 0 || timeStampProperty != null) { // Try to find default Criteria object Criteria defaultCriteria = _currentCslaObject.CriteriaObjects.Find("Criteria"); // If one of the criteria objects is not set if (_currentCslaObject.GetObjectCriteriaType == null || _currentCslaObject.NewObjectCriteriaType == null || _currentCslaObject.DeleteObjectCriteriaType == null) { // If default criteria doesn't exists, create a new criteria if (defaultCriteria == null) { defaultCriteria = new Criteria(); defaultCriteria.Name = "Criteria"; _currentCslaObject.CriteriaObjects.Add(defaultCriteria); } if (_currentCslaObject.GetObjectCriteriaType == null) { _currentCslaObject.GetObjectCriteriaType = defaultCriteria; } if (_currentCslaObject.ObjectType != CslaObjectType.ReadOnlyObject) { if (_currentCslaObject.NewObjectCriteriaType == null) { _currentCslaObject.NewObjectCriteriaType = defaultCriteria; } if (_currentCslaObject.DeleteObjectCriteriaType == null) { _currentCslaObject.DeleteObjectCriteriaType = defaultCriteria; } } } // Refresh criteria properties and parameters for Get, New and Delete methods if (_currentCslaObject.GetObjectCriteriaType != null) { AddPropertiesToCriteria(primaryKeyProperties, null, _currentCslaObject.GetObjectCriteriaType); foreach (Property prop in _currentCslaObject.GetObjectCriteriaType.Properties) { if (!_currentCslaObject.GetObjectParameters.Contains(_currentCslaObject.GetObjectCriteriaType, prop)) { _currentCslaObject.GetObjectParameters.Add(new Parameter(_currentCslaObject.GetObjectCriteriaType, prop)); } } } if (_currentCslaObject.NewObjectCriteriaType != null) { AddPropertiesToCriteria(primaryKeyProperties, null, _currentCslaObject.NewObjectCriteriaType); foreach (Property prop in _currentCslaObject.NewObjectCriteriaType.Properties) { if (!_currentCslaObject.NewObjectParameters.Contains(_currentCslaObject.NewObjectCriteriaType, prop)) { _currentCslaObject.NewObjectParameters.Add(new Parameter(_currentCslaObject.NewObjectCriteriaType, prop)); } } } if (_currentCslaObject.DeleteObjectCriteriaType != null) { AddPropertiesToCriteria(primaryKeyProperties, timeStampProperty, _currentCslaObject.DeleteObjectCriteriaType); foreach (Property prop in _currentCslaObject.DeleteObjectCriteriaType.Properties) { if (!_currentCslaObject.DeleteObjectParameters.Contains(_currentCslaObject.DeleteObjectCriteriaType, prop)) { _currentCslaObject.DeleteObjectParameters.Add(new Parameter(_currentCslaObject.DeleteObjectCriteriaType, prop)); } } } // Refresh Equals, HashCode and ToString properties foreach (ValueProperty prop in primaryKeyProperties) { if (!_currentCslaObject.EqualsProperty.Contains(prop)) { _currentCslaObject.EqualsProperty.Add(prop); } if (!_currentCslaObject.HashcodeProperty.Contains(prop)) { _currentCslaObject.HashcodeProperty.Add(prop); } if (!_currentCslaObject.ToStringProperty.Contains(prop)) { _currentCslaObject.ToStringProperty.Add(prop); } } } }
public string GetAliasedFieldString(ValueProperty prop) { return("[" + prop.ParameterName + "].[" + prop.DbBindColumn.ColumnName + "]"); }