public static Var Create(string key, IValueType data) { return(new Var() { m_Key = key, m_Data = data }); }
//End add public FindOption Add(string strName, string strFieldMap, IValueType valueType1, IValueType valueType2, params FindOperator[] findOperators) { FindOption option = new FindOption(strName, strFieldMap, valueType1, valueType2, findOperators); this.Add(option); return(option); }
public bool Contains(IValueType leftTerm) { switch (leftTerm) { case BaseType _: return(Values.Contains(leftTerm)); case ListType type: { var copy = (ArrayList)Values.Clone(); foreach (var value in type.Values) { if (copy.Contains(value)) { copy.Remove(value); } else { return(false); } } return(true); } default: return(false); } }
/// <summary> /// <para> /// This method allows a generalized implementation of transfering /// a value from a /// <see cref="ResourceBuilder.ResourceAttributes"/> /// to a /// <see cref="MediaResource"/> /// object. /// </para> /// /// <para> /// Classes derived from the /// <see cref="ResourceBuilder.ResourceAttributes"/> /// class have fields, with names that match against fields in a /// <see cref="MediaResource"/> /// object. /// </para> /// </summary> /// <param name="attribName">name of the attribute to transfer</param> /// <param name="res">The /// <see cref="MediaResource"/> /// object to transfer to. /// </param> /// <param name="attribs"> /// The /// <see cref="ResourceBuilder.ResourceAttributes"/> /// object to transfer from. /// </param> private static void TransferValue(string attribName, MediaResource res, ResourceAttributes attribs) { object val = null; System.Type type = attribs.GetType(); FieldInfo info = type.GetField(attribName); if (info != null) { val = info.GetValue(attribs); if (val != null) { IValueType ivt = val as IValueType; bool ok = true; if (ivt != null) { ok = ivt.IsValid; } if (ok) { //res.m_Attributes[attribName] = val; res[attribName] = val; } } } }
private Field(string name, VariableType variableType, IValueType valueType, int position, int length) { Name = name; VariableType = variableType; ValueType = valueType; Position = position; Length = length; }
private static string ProcessValueOperators(bool isNegate, IValueType refType) { string val; if (refType.Value is bool value && isNegate) { val = (!value).ToString(); }
// =================================================================================== // Value Type // ========== public void RegisterBasicValueType(Type keyType, IValueType valueType) { AssertNotLocked(); if (_log.IsInfoEnabled) { _log.Info("...Registering basic valueType: keyType=" + keyType + " valueType=" + valueType); } ValueTypes.RegisterValueType(keyType, valueType); }
public static string[] ParseValueInstance(IValueType ivt, IEnumerable <string> strings) { var stringsList = strings.ToList(); if (!stringsList.Any()) { throw new RuntimeException("Error: Internal failure."); } var returns = new string[2]; var str = stringsList.FirstOrDefault(); var words = ivt.GetType().GetAttributeValue((KeywordAttribute itm) => itm.Words); var word = words.FirstOrDefault(); var reg = str.IndexOf(word, StringComparison.InvariantCulture); str = str.Remove(reg, word.Length); if (string.IsNullOrWhiteSpace(str)) { throw new RuntimeException("ERROR: Expected an instance name"); } if (str.Contains('=')) { try { var split = str.Split('=', 2); var inst = split[0].Trim(); CheckValidName(inst, returns); var val = split[1].Trim(); val = CheckValForOtherInst(val, word); if (string.IsNullOrWhiteSpace(val)) { throw new RuntimeException("ERROR: Expected Value"); } returns[1] = val; } catch (RuntimeException) { throw; } catch (Exception) { throw new RuntimeException("ERROR: Expected Value"); } } else { var instanceName = str.Trim(); if (!instanceName.ValidNewInstanceName()) { throw new RuntimeException($"ERROR: {instanceName} is an invalid instance name"); } returns[0] = instanceName; } return(returns); }
public bool Compare(IValueType leftTerm, IValueType rightTerm) { if (leftTerm.GetType() != typeof(BaseType) || rightTerm.GetType() != typeof(BaseType)) { return(false); } return((BaseType)leftTerm < (BaseType)rightTerm); }
/// <summary> /// Used to create: {UnaryOperation}{Value} /// </summary> public Expression(UnaryOperation unaryOperation, IValueType value) { StringBuilder sb = new StringBuilder(512); this._unaryOperator = Operation.GetUnaryOperator(unaryOperation); sb.Append(this._unaryOperator); sb.Append(value.ToString()); this.Value = sb.ToString(); }
/// <summary> /// Used to create: {UnaryOperation}{Value} /// </summary> public Expression(UnaryOperation unaryOperation, IValueType value) { StringBuilder sb = new StringBuilder(512); this.UnaryOperator = Operation.GetUnaryOperator(unaryOperation); sb.Append(this.UnaryOperator); sb.Append(value.ToString()); this.Value = sb.ToString(); }
public static TResult ConvertFrom <TResult>(IValueType valueType) //where TResult : class { if (valueType == null) { throw new ArgumentNullException(nameof(valueType)); } if (typeof(TResult) == typeof(IValueType)) { return((TResult)valueType); } return((TResult)valueType.GetValue()); }
/// <summary> /// Used to create: {ValueLeft}{ComparisonOperator}{ValueRight} /// </summary> public Expression(ComparisonOperation comparisonOperation, IValueType valueLeft, IValueType valueRight) { StringBuilder sb = new StringBuilder(512); this._comparisonOperator = Operation.GetComparisonOperator(comparisonOperation); sb.Append(valueLeft.ToString()); sb.Append(this._comparisonOperator); sb.Append(valueRight.ToString()); this.Value = sb.ToString(); }
/// <summary> /// Used to create: {ValueLeft}{ComparisonOperator}{ValueRight} /// </summary> public Expression(ComparisonOperation comparisonOperation, IValueType valueLeft, IValueType valueRight) { StringBuilder sb = new StringBuilder(512); this.ComparisonOperator = Operation.GetComparisonOperator(comparisonOperation); sb.Append(valueLeft.ToString()); sb.Append(this.ComparisonOperator); sb.Append(valueRight.ToString()); this.Value = sb.ToString(); }
protected RelationKey CreateRelationKey(IDataReader reader, IRelationPropertyType rpt , System.Collections.IList columnNames, System.Collections.Hashtable relKeyValues , Map <String, int?> selectIndexMap) { System.Collections.ArrayList keyList = new System.Collections.ArrayList(); IBeanMetaData bmd = rpt.BeanMetaData; for (int i = 0; i < rpt.KeySize; ++i) { IValueType valueType = null; IPropertyType pt = rpt.BeanMetaData.GetPropertyTypeByColumnName(rpt.GetYourKey(i)); String relationNoSuffix = BuildRelationNoSuffix(rpt); String columnName = RemoveQuoteIfExists(pt.ColumnName) + relationNoSuffix; if (columnNames.Contains(columnName)) { valueType = pt.ValueType; } else { // basically unreachable // because the referred column (basically PK or FK) must exist // if the relation's select clause is specified return(null); } Object value; if (selectIndexMap != null) { value = GetValue(reader, columnName, valueType, selectIndexMap); } else { value = valueType.GetValue(reader, columnName); } if (value == null) { // reachable when the referred column data is null // (treated as no relation data) return(null); } relKeyValues[columnName] = value; keyList.Add(value); } if (keyList.Count > 0) { object[] keys = keyList.ToArray(); return(new RelationKey(keys)); } else { return(null); } }
public static void AddValueType() { IValueType objType = ValueTypes.GetValueType(null); if (ValueTypes.GetValueType(typeof(UInt32)) == objType) { ValueTypes.RegisterValueType(typeof(UInt32), UINT32); } if (ValueTypes.GetValueType(typeof(Nullable <UInt32>)) == objType) { ValueTypes.RegisterValueType(typeof(Nullable <UInt32>), NULLABLE_UINT32); } }
// Added by Wirachai T. 2008 10 07 //private void Control_KeyDown(object sender, KeyEventArgs e) //{ // try // { // // ¶éÒà»ç¹ find dialog ¨ÐÁÕ¡Òü١ event ¹ÕéäÇéà¾×èÍãËé¡´ enter áÅéÇ search ¢éÍÁÙŷѹ·Õ // if (OnKeyEnterPressed == null) // { // Control ctrl = (Control)sender; // Form form = ctrl.FindForm(); // if (e.KeyCode == Keys.Enter) // { // form.SelectNextControl(form.ActiveControl, true, true, true, true); // } // else if (e.KeyCode == Keys.Back) // { // if ((sender is DateTextBoxWithCalendar) && ((DateTextBoxWithCalendar)sender).IsEmpty()) // { // form.SelectNextControl(form.ActiveControl, false, true, true, false); // } // else if (sender is ComboBox) // { // form.SelectNextControl(form.ActiveControl, false, true, true, false); // } // else if (((Control)sender).Text.Trim().Equals("")) // { // form.SelectNextControl(form.ActiveControl, false, true, true, false); // } // } // } // } // catch (Exception) // { // } //} // End private void ShowPopupValue(IValuePopup valuePopup, IValueType valueType) { if (valuePopup != null) { valuePopup.SetValues(valueType.GetValue()); BaseValuePopup dlg = (BaseValuePopup)valuePopup; dlg.Location = Cursor.Position; if (dlg.ShowDialog() == DialogResult.OK) { valueType.SetValue(valuePopup.GetValues()); } } }
public bool Compare(IValueType leftTerm, IValueType rightTerm) { if (!(leftTerm is BaseType)) { throw new Exception($"Can't cast {leftTerm.GetType().Name} to BaseType"); } if (!(rightTerm is ListType)) { throw new Exception($"Can't cast {rightTerm.GetType().Name} to ListType"); } return(((ListType)rightTerm).Between(leftTerm)); }
protected IDataReaderHandler CreateSpecifiedOutsideSqlCustomizeBeanListResultSetHandler(IBeanMetaData specifiedBeanMetaData, Type customizeEntityType) { IValueType valueType = ValueTypes.GetValueType(customizeEntityType); if (valueType == null || !valueType.Equals(ValueTypes.OBJECT)) { // Non generic because it cannot add the null value to generic list by abstract type. return(new InternalObjectListResultSetHandler(customizeEntityType, valueType)); } InternalRowCreator rowCreator = CreateInternalRowCreator(specifiedBeanMetaData); // For performance turning! InternalRelationRowCreator relationRowCreator = CreateInternalRelationRowCreator(specifiedBeanMetaData); return(new InternalBeanGenericListMetaDataResultSetHandler(specifiedBeanMetaData, rowCreator, relationRowCreator)); }
[Test] public void CanExpectMultipleInputsAndReturnAValue() { IMock mock = new DynamicMock(typeof(IValueType)); ArrayList ret = new ArrayList(); DateTime date = DateTime.Now; mock.ExpectAndReturn("Query", ret, "hello", date); IValueType blah = (IValueType)mock.MockInstance; Assertion.AssertEquals(ret, blah.Query("hello", date)); mock.Verify(); }
public bool Compare(IValueType leftTerm, IValueType rightTerm) { switch (rightTerm) { case ListType type: return(type.Contains(leftTerm)); case BaseType type: return(leftTerm is BaseType && type.Equals(leftTerm)); default: return(false); } }
protected Object GetValue(IDataReader rs, String columnName, IValueType valueType, Map <String, int?> selectIndexMap) // ResourceContext in Java // lower because of @see AbstractSqlClause { int?selectIndex = selectIndexMap != null?selectIndexMap.get(columnName.ToLower()) : null; if (selectIndex != null) { return(valueType.GetValue(rs, selectIndex.Value)); } else { return(valueType.GetValue(rs, columnName)); } }
public bool RegisterType(IValueType type) { if (_nameToValueType.ContainsKey(type.Name)) { return(false); } TypeGroup group = new TypeGroup { Value = type }; _valueTypes[type] = group; _nameToValueType[type.Name] = type; return(true); }
// GetListValue (not used yet) public void GetListValue(int index, IValueType value) { if (ValueIsList) { ((IList)PrimitiveValue)[index] = value; } else if (index == 0) { Value = value; // (assume at least "Value" if index is 0) } else { throw new IndexOutOfRangeException(); } }
public static bool GetInstance(string instanceName, out IValueType type) { foreach (var instance in Variables.Where(instance => IsInBounds(instanceName, instance))) { if (!(instance.Key is IValueType iv)) { continue; } type = iv; return(true); } type = null; return(false); }
/// <summary> /// Used to create: IF({Condition}, {CaseTrue}, IF({Condition}, {CaseTrue}, IF({Condition}, {CaseTrue}, {DefaultValue}))) /// </summary> public Switch(IValueType defaultValue, params KeyValuePair<IConditionalType, IValueType>[] conditionCaseTruePair) { StringBuilder sb = new StringBuilder(512); for (int i = 0; i < conditionCaseTruePair.Length; i++) { sb.AppendFormat("IF({0}" + SectionSeparator + "{1}" + SectionSeparator, conditionCaseTruePair[i].Key, conditionCaseTruePair[i].Value); if ((i + 1) == conditionCaseTruePair.Length) { sb.AppendFormat("{0}", defaultValue); sb.Append(')', conditionCaseTruePair.Length); } } this.Value = sb.ToString(); }
/// <summary> /// Used to create: IF({Condition}, {CaseTrue}, IF({Condition}, {CaseTrue}, IF({Condition}, {CaseTrue}, {DefaultValue}))) /// </summary> public Switch(IValueType defaultValue, params KeyValuePair<System.Linq.Expressions.Expression<Func<string>>, IValueType>[] conditionCaseTruePair) { StringBuilder sb = new StringBuilder(512); for (int i = 0; i < conditionCaseTruePair.Length; i++) { sb.AppendFormat("IF({0}" + SPFormulaBuilder.SectionSeparator + "{1}" + SPFormulaBuilder.SectionSeparator, new Expression(conditionCaseTruePair[i].Key).ToString(), conditionCaseTruePair[i].Value.ToString()); if ((i+1) == conditionCaseTruePair.Length) { sb.AppendFormat("{0}", defaultValue.ToString()); sb.Append(')', conditionCaseTruePair.Length); } } this.Value = sb.ToString(); }
/// <summary> /// Used to create: IF({Condition}, {CaseTrue}, IF({Condition}, {CaseTrue}, IF({Condition}, {CaseTrue}, {DefaultValue}))) /// </summary> public Switch(IValueType defaultValue, params KeyValuePair <Expression <Func <string> >, IValueType>[] conditionCaseTruePair) { StringBuilder sb = new StringBuilder(512); for (int i = 0; i < conditionCaseTruePair.Length; i++) { sb.AppendFormat("IF({0}" + SectionSeparator + "{1}" + SectionSeparator, new Expression(conditionCaseTruePair[i].Key), conditionCaseTruePair[i].Value); if ((i + 1) == conditionCaseTruePair.Length) { sb.AppendFormat("{0}", defaultValue); sb.Append(')', conditionCaseTruePair.Length); } } this.Value = sb.ToString(); }
//Apiwat add 2007-10-02 public FindOption(string strName, string strFieldMap, IValueType valueType1, params FindOperator[] findOperators) { m_strCaption = strName; m_strName = strName; m_strFieldMap = strFieldMap; m_valueType1 = valueType1; for (int i = 0; i < findOperators.Length; ++i) { m_findOperators.Add(findOperators[i]); if (i == 0) { this.m_selectedOperator = findOperators[0]; } } m_popupValue1 = new DefaultValuePopup(); m_popupValue1.AllowMultiValue = m_bAllowMultiValue; }
public bool Contains(IValueType leftTerm) { if (!(leftTerm is BaseType)) { return(false); } if (((BaseType)leftTerm).IsNumberOrBoolean()) { return(this == (BaseType)leftTerm); } else if (Value is string) { return(((string)Value).Contains(leftTerm.ToString())); } return(false); }
public IType GetType(IValueType valueType, PointerMode pointerMode) { if (!_valueTypes.TryGetValue(valueType, out TypeGroup typeGroup)) { throw new ArgumentException("Value type is not registered", nameof(valueType)); } IType?type = typeGroup.GetTypeForPointerMode(pointerMode); if (type == null) { IPointerType pointerType = new PointerTypeImpl(typeGroup.Value, pointerMode); type = pointerType; typeGroup.SetTypeForPointerMode(pointerMode, pointerType); _valueTypes[valueType] = typeGroup; } return(type); }
public bool Between(IValueType leftTerm) { if (Values.Count != 2) { throw new Exception("Invalid object. Proper range value has to be provided"); } if (!(leftTerm is BaseType)) { return(false); } if (!((BaseType)leftTerm).IsNumber() || !((BaseType)Values[0]).IsNumber() || !((BaseType)Values[1]).IsNumber()) { return(false); } return((BaseType)Values[0] <= ((BaseType)leftTerm) && (BaseType)Values[1] >= ((BaseType)leftTerm)); }
public void SetData(IValueType value) { // Do type checking if (Data?.GetType() != value.GetType()) { throw new ArgumentException( string.Format("Type mismatch when trying to assign '{0}' to Variable '{2}' of type '{1}'", value.GetType().Name, Data?.GetType().Name, Key) ); } if (!m_Data.Get().Equals(value.Get())) { Events.OnDataValueChanged.Invoke(Data, value); } m_Data = value; }
protected IPropertyType CreatePropertyTypeExtension(PropertyInfo pi, DBMeta dbmeta) { if (IsRelationProperty(pi, dbmeta)) { return(null); } String columnName = GetPropertyTypeColumnName(pi); IValueType valueType = ValueTypes.GetValueType(pi.PropertyType); IPropertyType pt = new PropertyTypeImpl(pi, valueType, columnName); if (dbmeta.HasPrimaryKey && dbmeta.HasColumn(pt.ColumnName)) { if (dbmeta.FindColumnInfo(pt.ColumnName).IsPrimary) { pt.IsPrimaryKey = true; } } pt.IsPersistent = IsPersistentProperty(pi, dbmeta); return(pt); }
/// <summary> /// Used to create: INT({Value}) /// </summary> public Int(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: DATE({Year},{Month},{Day}) /// </summary> public Date(IValueType year, IValueType month, IValueType day) { this.Year = year; this.Month = month; this.Day = day; }
/// <summary> /// Used to create: UPPER({Value}) /// </summary> public Upper(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: EXACT({ValueLeft},{ValueRight}) /// </summary> public Exact(IValueType valueLeft, IValueType valueRight) { this.ValueLeft = valueLeft; this.ValueRight = valueRight; }
/// <summary> /// Used to create: DATEDIF({ValueLeft},{ValueRight},{Format}) /// </summary> public DateDiff(IValueType valueLeft, IValueType valueRight, IValueType format) { this.ValueLeft = valueLeft; this.ValueRight = valueRight; this.Format = format; }
/// <summary> /// Used to create: TRIM({Value}) /// </summary> public Trim(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: ({Value}) /// </summary> public Group(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: ({Value}) /// </summary> public Group(System.Linq.Expressions.Expression<Func<string>> expression) { this.Value = new Expression(expression); }
/// <summary> /// Used to create: PROPER({Value}) /// </summary> public Proper(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: IF({Condition}, {CaseTrue}, {CaseFalse}) /// </summary> public If(System.Linq.Expressions.Expression<Func<string>> conditionalExpression, System.Linq.Expressions.Expression<Func<string>> expressionTrue, System.Linq.Expressions.Expression<Func<string>> expressionFalse) { this.Condition = new Expression(conditionalExpression); this.CaseTrue = new Expression(expressionTrue); this.CaseFalse = new Expression(expressionFalse); }
/// <summary> /// Used to create: IF({Condition}, {CaseTrue}, {CaseFalse}) /// </summary> public If(System.Linq.Expressions.Expression<Func<string>> conditionalExpression, IValueType caseTrue, IValueType caseFalse) { this.Condition = new Expression(conditionalExpression); this.CaseTrue = caseTrue; this.CaseFalse = caseFalse; }
/// <summary> /// Used to create: IF({Condition}, {CaseTrue}, {CaseFalse}) /// </summary> public If(IConditionalType condition, IValueType caseTrue, IValueType caseFalse) { this.Condition = condition; this.CaseTrue = caseTrue; this.CaseFalse = caseFalse; }
/// <summary> /// Used to create: ROUNDUP({Value},{DecimalPlaces}) /// </summary> public RoundUp(IValueType value, IValueType decimalPlaces) { this.Value = value; this.DecimalPlaces = decimalPlaces; }
/// <summary> /// Used to create: YEAR({Value}) /// </summary> public Year(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: LOWER({Value}) /// </summary> public Lower(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: "={Text}" /// Note: Formula class cannot be used directly. Instead of instantiating Formula class, use this method. /// </summary> public static string CreateFormula(IValueType element) { return new Formula(element).ToString(); }
/// <summary> /// Used to create: SECOND({Value}) /// </summary> public Second(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: POWER({ValueLeft}, {ValueRight}) /// </summary> public Power(IValueType valueLeft, IValueType valueRight) { this.ValueLeft = valueLeft; this.ValueRight = valueRight; }
/// <summary> /// Used to create: DATEVALUE({Value}) /// </summary> public DateValue(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: MINUTE({Value}) /// </summary> public Minute(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: WEEKDAY({Value}) /// </summary> public WeekDay(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: {Value} /// </summary> public Expression(IValueType value) { this.Value = value.ToString(); }
/// <summary> /// Used to create: ODD({Value}) /// </summary> public Odd(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: HOUR({Value}) /// </summary> public Hour(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: LEN({Value}) /// </summary> public Len(IValueType value) { this.Value = value; }
/// <summary> /// Used to create: MONTH({Value}) /// </summary> public Month(IValueType value) { this.Value = value; }