/// <summary> /// 对象格式化 /// </summary> /// <param name="name">属性名称</param> /// <param name="value">属性值</param> /// <param name="valueType">属性类型</param> /// <returns></returns> public static string ObjectFormat(string name, object value, ValueTypeEnum valueType) { object formatValue = null; switch (valueType) { case ValueTypeEnum.DateTime: formatValue = DateTimeFormat(value); break; case ValueTypeEnum.Single: formatValue = FloatFormat(value); break; case ValueTypeEnum.Double: formatValue = DoubleFormat(value); break; case ValueTypeEnum.Decimal: formatValue = DecimalFormat(value); break; case ValueTypeEnum.Boolean: formatValue = BooleanFormat(value); break; case ValueTypeEnum.Guid: formatValue = GuidFormat(value); break; case ValueTypeEnum.SByte: case ValueTypeEnum.Int16: case ValueTypeEnum.Int32: case ValueTypeEnum.Int64: case ValueTypeEnum.Byte: case ValueTypeEnum.UInt16: case ValueTypeEnum.UInt32: case ValueTypeEnum.UInt64: case ValueTypeEnum.Char: case ValueTypeEnum.String: formatValue = value; break; default: break; } return(formatValue == null ? string.Empty : string.Format("{0}{1}", name, formatValue)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="name">属性名称</param> /// <param name="value">属性值</param> /// <param name="valueType">属性类型</param> public PropertyObject(string name, object value, ValueTypeEnum valueType) { this.name = name; this.lowerName = name.ToLower(); this.value = value; this.valueType = valueType; }
public Value Resolve(int index, ValueTypeEnum context = ValueTypeEnum.Void, bool isRequired = false) { if (index >= Size) { throw new CalcError(CalcError.ErrorMessageTooFewArgumentsToFunction); } Value value = ArgsList[index]; if (value.Type == ValueTypeEnum.Any) { ContextScope scope = new ContextScope(this, context, isRequired); value = Expr.AsExpr(value).Calc(scope, Locus, Depth); if (isRequired && value.Type != context) { throw new CalcError(String.Format(CalcError.ErrorMessageExpectedSmthForArgumentSmthButReceivedSmth, context, index, value)); } // DM - update the original value (Args) with expression result. Note the difference between Sequence (List inside) and a regular value if (Args.Type == ValueTypeEnum.Sequence) { Args.AsSequence[index] = value; } else { Args = value; } } return(value); }
public SectionParam(string name, string value, ValueTypeEnum valueType, string description) { Name = name; Value = value; ValueType = valueType; Description = description; }
public Rule AddValueTypeRule(ValueTypeEnum typeEnum) { ValueTypeRule rule = new ValueTypeRule(ValueTypeEnumHelper.ToValue(typeEnum)); this.Add(rule); return(rule); }
public SectionParam(string name, string value, ValueTypeEnum valueType, string description) { Name = name; Value = value; ValueType = valueType; Description = description; }
public static string ToValue(ValueTypeEnum valueTypeEnum) { switch (valueTypeEnum) { case ValueTypeEnum.TEXT: return "text"; case ValueTypeEnum.TEXTAREA: return "textarea"; case ValueTypeEnum.DECIMAL: return "decimal"; case ValueTypeEnum.INTEGER: return "integer"; case ValueTypeEnum.LONG: return "long"; case ValueTypeEnum.DATE: return "date"; case ValueTypeEnum.TIME: return "time"; case ValueTypeEnum.URL: return "url"; case ValueTypeEnum.HTML: return "html"; default: return "Unknown ValueTypeEnum"; } }
public VariableType(Token token) : base(token.Spelling) { CheckTokenType(Token.TokenType.VARIABLE_TYPE, token.TheTokenType); VariableType_ = token.Spelling == "booly" ? ValueTypeEnum.BOOLY : ValueTypeEnum.INTY; }
public IList <BaseDictionary> GetBaseDictionaries(ValueTypeEnum valueType) { using (var session = GetSession()) { return(session.QueryOver <BaseDictionary>().Where(m => m.ValueType == valueType).OrderBy(m => m.DicId).Asc.List()); } }
public static double Convert(DistanceValue value, ValueTypeEnum convertTo) { int fval = (int)value.ValueType; //from int tval = (int)convertTo; //to return(value.Value * Math.Pow(10, tval - fval)); }
private void ExpectType(ValueTypeEnum type) { if (ValueType != type) { Debug.LogError("Cant read " + type + " value from token!"); } }
public static string ToValue(ValueTypeEnum valueTypeEnum) { switch (valueTypeEnum) { case ValueTypeEnum.TEXT: return("text"); case ValueTypeEnum.TEXTAREA: return("textarea"); case ValueTypeEnum.DECIMAL: return("decimal"); case ValueTypeEnum.INTEGER: return("integer"); case ValueTypeEnum.LONG: return("long"); case ValueTypeEnum.DATE: return("date"); case ValueTypeEnum.TIME: return("time"); case ValueTypeEnum.URL: return("url"); case ValueTypeEnum.HTML: return("html"); default: return("Unknown ValueTypeEnum"); } }
public ValueTypeCastException(object value, ValueTypeEnum valueTypeID) : base(string.Format( "Cannot cast serialized value {0} to type {1}", value ?? "NULL", valueTypeID.ToString() )) { }
public void AttribAdd <T>(string name, List <T> vals, ValueTypeEnum VT) { attSet = doc.AttributeSets.Add(name); for (int i = 0; i < vals.Count; i++) { attSet.Add(name + i, VT, vals[i]); } attSet = null; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.ValueType = ((ValueTypeEnum)(binaryReader.ReadInt32())); this.DefaultValue = binaryReader.ReadSingle(); this.MinimumValue = binaryReader.ReadSingle(); this.MaximumValue = binaryReader.ReadSingle(); return(pointerQueue); }
public void AttribAdd <T>(string name, T val, ValueTypeEnum VT) { attSets = doc.AttributeSets; if (attSets.NameIsUsed[name]) { AttribDelete(name); } attSet = attSets.Add(name); attSet.Add(name, VT, val); attSet = null; }
public static Inventor.Attribute CreateAttribute(string name, ValueTypeEnum typ, object value, AttributeSet parent) { var attMock = new Mock <Inventor.Attribute>(); attMock.Setup(x => x.Value).Returns(value); attMock.Setup(x => x.Name).Returns(name); attMock.Setup(x => x.Value).Returns(typ); attMock.Setup(x => x.Parent).Returns(parent); return(attMock.Object); }
public void AttribAdd <T, TVal>(T ob, string name, TVal val, ValueTypeEnum VT) { AttributeSets attSets = InvDoc.Reflect.getProp <T, AttributeSets>(ob, "AttributeSets"); if (attSets.NameIsUsed[name]) { AttribDelete(name); } attSet = attSets.Add(name); attSet.Add(name, VT, val); attSet = null; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.ValueType = ((ValueTypeEnum)(binaryReader.ReadInt16())); this.BooleanValue = ((BooleanValueEnum)(binaryReader.ReadInt16())); this.IntegerValue = binaryReader.ReadInt32(); this.FpValue = binaryReader.ReadSingle(); this.TextValueStringId = binaryReader.ReadStringID(); this.TextLabelStringId = binaryReader.ReadStringID(); return(pointerQueue); }
public static BaseDictionary Create(ValueTypeEnum valueType, int dicId, string val, string description, string operat, string operatorDescription) { return(new BaseDictionary() { ValueType = valueType, DicId = dicId, Value = val, Description = description, Operator = operat, OperatorTime = DateTime.Now, OperatorDescritpion = operatorDescription }); }
private ValueNode WithValue(string value, ValueTypeEnum leafType) { var leafNode = Children.FirstOrDefault(n => n.Value == value); if (leafNode != null) { return(leafNode as ValueNode); } var newLeafNode = new ValueNode(value, NodeTypeEnum.ValueNode, this); newLeafNode.LeafType = leafType; Children.Add(newLeafNode); return(newLeafNode as ValueNode); }
public ActionResult DictionaryList() { PageDictionary pageModel = new PageDictionary(); ValueTypeEnum valueType = ValueTypeEnum.Language; if (!string.IsNullOrEmpty(Request["valueType"])) { valueType = (ValueTypeEnum)short.Parse(Request["valueType"].ToString()); } ViewBag.ValueType = valueType; pageModel.BaseDictionaries = BaseService.GetBaseDictionaries(valueType); pageModel.ValueTypes = EnumTools.GetEnumDescriptions <ValueTypeEnum>(); return(View(pageModel)); }
public T Get <T>(int index, bool convert = true) { // DM - this method was completely rewritten to handle conversion to the expected type // #remove-boxing - Consider removing excess boxing in this method. if (typeof(T) == typeof(int)) { convert = true; // see - inline int call_scope_t::get<int>(std::size_t index, bool) { } if (typeof(T) == typeof(ExprOp)) { return((T)(object)Args.AsSequence[index].AsAny <ExprOp>()); // see - call_scope_t::get<expr_t::ptr_op_t>(std::size_t index, bool) } ValueTypeEnum valType = NValue.GetValueType <T>(); Value val = Resolve(index, NValue.GetValueType <T>(), !convert); switch (valType) { case ValueTypeEnum.Amount: return((T)(object)val.AsAmount); case ValueTypeEnum.Any: return(val.AsAny <T>()); case ValueTypeEnum.Balance: return((T)(object)val.AsBalance); case ValueTypeEnum.Boolean: return((T)(object)val.AsBoolean); case ValueTypeEnum.Date: return((T)(object)val.AsDate); case ValueTypeEnum.DateTime: return((T)(object)val.AsDateTime); case ValueTypeEnum.Integer: return((T)Convert.ChangeType(val.AsLong, typeof(T))); case ValueTypeEnum.Mask: return((T)(object)val.AsMask); case ValueTypeEnum.Scope: return((T)(object)val.AsScope); case ValueTypeEnum.Sequence: return((T)(object)val.AsSequence); case ValueTypeEnum.String: return((T)(object)val.AsString); case ValueTypeEnum.Void: return(default(T)); default: return(default(T)); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Use: Read attribute and returns its value in out parameter. // Returns true if attribute exists, false otherwise // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static bool ReadAttribute(object target, string setName, string attName, out object value, out ValueTypeEnum type) { value = null; type = ValueTypeEnum.kIntegerType; try { AttributeSets sets = AdnInventorUtilities.GetProperty(target, "AttributeSets") as AttributeSets; if (sets == null) { return(false); } if (!sets.get_NameIsUsed(setName)) { return(false); } AttributeSet set = sets[setName]; if (!set.get_NameIsUsed(attName)) { return(false); } Inventor.Attribute att = set[attName]; type = att.ValueType; value = att.Value; return(true); } catch { return(false); } }
protected override ConfigEntry Create(Type objectType, JObject jObject) { ValueTypeEnum valueType = jObject.GetValue("valueType").ToObject <ValueTypeEnum>(); switch (valueType) { case ValueTypeEnum.STRING: return(new StringConfig()); case ValueTypeEnum.DEVICE: return(new DeviceConfig()); case ValueTypeEnum.MODE: return(new ModeConfig()); default: throw new NotImplementedException("Unknown value for ValueTypeEnum"); } }
/// <summary> /// Конструктор для типов скрипта. /// </summary> /// <param name="type"></param> /// <param name="value"></param> /// <returns></returns> public static IValue Create(ValueTypeEnum type, string value) { switch (type) { case ValueTypeEnum.NUMBER: if (decimal.TryParse(value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out decimal result)) { return(Create(result)); } else { throw new Exception($"Ошибка преобразования в число, значения [{value}]"); } case ValueTypeEnum.STRING: return(Create(value)); case ValueTypeEnum.BOOLEAN: if (String.Equals(value, "ложь", StringComparison.OrdinalIgnoreCase) || String.Equals(value, "false", StringComparison.OrdinalIgnoreCase)) { return(Create(false)); } if (String.Equals(value, "истина", StringComparison.OrdinalIgnoreCase) || String.Equals(value, "true", StringComparison.OrdinalIgnoreCase)) { return(Create(true)); } throw new Exception($"Ошибка преобразования в логический тип, значения [{value}]"); case ValueTypeEnum.DATE: string[] formats = { "yyyyMMddHHmmss", "yyyyMMdd", "yyyyMMddHHmm" }; if (DateTime.TryParseExact(value, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out DateTime date)) { return(Create(date)); } throw new Exception($"Ошибка преобразования в тип даты, значения [{value}]"); } return(Create()); }
public ActionResult DictionaryEdit(long id, string dataValue, string description, string datasort, ValueTypeEnum valueType) { int dataSort = 1; if (!int.TryParse(datasort, out dataSort)) { dataSort = 1; } BaseDictionary baseDictionary = BaseService.GetDictionaryById(id); if (baseDictionary != null) { baseDictionary.Value = dataValue; baseDictionary.Description = description; baseDictionary.DicId = dataSort; baseDictionary.ValueType = valueType; string responseCode = BaseService.SaveDictionary(baseDictionary); return(Json(InfoTools.GetMsgInfo(responseCode))); } return(Json(InfoTools.GetMsgInfo(ResponseCode.NotFoundData), JsonRequestBehavior.AllowGet)); }
public ContextScope(Scope parent, ValueTypeEnum typeContext = ValueTypeEnum.Void, bool isRequired = true) : base(parent) { _TypeContext = typeContext; IsRequired = isRequired; }
public static TopCard ConvertToTopCard(this Show[] list, string title, string unit, string valueSelector, ValueTypeEnum valueTypeEnum) { return(ConvertToTopCard(list, title, unit, valueSelector, valueTypeEnum, true)); }
public static TopCard ConvertToTopCard <T>(T[] list, string title, string unit, string valueSelector, ValueTypeEnum valueTypeEnum, bool unitNeedsTranslation) where T : Extra { var values = list.Select(x => { var propertyInfo = typeof(T).GetProperty(valueSelector); var value = propertyInfo?.GetValue(x, null)?.ToString(); if (propertyInfo?.PropertyType == typeof(DateTimeOffset?)) { value = DateTimeOffset.Parse(value).ToString("O"); } return(new TopCardItem { Value = value, Label = x.Name, MediaId = x.Id, Image = x.Primary }); }).ToArray(); return(new TopCard { Title = title, Values = values, Unit = unit, UnitNeedsTranslation = unitNeedsTranslation, ValueType = valueTypeEnum }); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Use: Read attribute and returns its value in out parameter. // Returns true if attribute exists, false otherwise // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static bool ReadAttribute(object target, string setName, string attName, out object value, out ValueTypeEnum type) { value = null; type = ValueTypeEnum.kIntegerType; try { AttributeSets sets = AdnInventorUtilities.GetProperty(target, "AttributeSets") as AttributeSets; if (sets == null) return false; if (!sets.get_NameIsUsed(setName)) return false; AttributeSet set = sets[setName]; if (!set.get_NameIsUsed(attName)) return false; Inventor.Attribute att = set[attName]; type = att.ValueType; value = att.Value; return true; } catch { return false; } }
private object SerializeAppParameter(object obj) { if (obj is IMeasurement) { _AppParameterType = ValueTypeEnum.Measurement; return Measurement.PString((IMeasurement)obj); } else return obj; }
/// <summary> /// Initializes a new instance of the <see cref="DataType" /> class. /// </summary> /// <param name="href">href.</param> /// <param name="typeValueRange">The available values are: Open, Closed (required).</param> /// <param name="id">id (required).</param> /// <param name="displayName">displayName (required).</param> /// <param name="description">description (required).</param> /// <param name="valueType">The available values are: String, Int, Decimal, DateTime, Boolean, Map, List, PropertyArray, Percentage, Code, Id, Uri, CurrencyAndAmount, TradePrice, Currency, MetricValue, ResourceId, ResultValue, CutLocalTime, DateOrCutLabel (required).</param> /// <param name="acceptableValues">acceptableValues.</param> /// <param name="unitSchema">The available values are: NoUnits, Basic, Iso4217Currency.</param> /// <param name="acceptableUnits">acceptableUnits.</param> /// <param name="links">links.</param> public DataType(string href = default(string), TypeValueRangeEnum typeValueRange = default(TypeValueRangeEnum), ResourceId id = default(ResourceId), string displayName = default(string), string description = default(string), ValueTypeEnum valueType = default(ValueTypeEnum), List <string> acceptableValues = default(List <string>), UnitSchemaEnum?unitSchema = default(UnitSchemaEnum?), List <IUnitDefinitionDto> acceptableUnits = default(List <IUnitDefinitionDto>), List <Link> links = default(List <Link>)) { this.Href = href; // to ensure "typeValueRange" is required (not null) if (typeValueRange == null) { throw new InvalidDataException("typeValueRange is a required property for DataType and cannot be null"); } else { this.TypeValueRange = typeValueRange; } // to ensure "id" is required (not null) if (id == null) { throw new InvalidDataException("id is a required property for DataType and cannot be null"); } else { this.Id = id; } // to ensure "displayName" is required (not null) if (displayName == null) { throw new InvalidDataException("displayName is a required property for DataType and cannot be null"); } else { this.DisplayName = displayName; } // to ensure "description" is required (not null) if (description == null) { throw new InvalidDataException("description is a required property for DataType and cannot be null"); } else { this.Description = description; } // to ensure "valueType" is required (not null) if (valueType == null) { throw new InvalidDataException("valueType is a required property for DataType and cannot be null"); } else { this.ValueType = valueType; } this.AcceptableValues = acceptableValues; this.AcceptableUnits = acceptableUnits; this.Links = links; this.Href = href; this.AcceptableValues = acceptableValues; this.UnitSchema = unitSchema; this.AcceptableUnits = acceptableUnits; this.Links = links; }
/// <summary> /// Adds a property to the json object. If the valuetype is a string it is escaped and quoted. If it is not it ouputs the value directly. /// if the value is empty then it oupts null as the value for the property /// </summary> /// <param name="name">Property name {name}: {value}</param> /// <param name="value">Property value. string will be escaped and quoted</param> /// <param name="ValueType">The type of value being added. If a string, it will be escaped and quoted</param> public JSObject Add(string name, string value, ValueTypeEnum ValueType) { if (ValueType == ValueTypeEnum.String) value = JSBuilder.GetString(value, true); Data.Add(name, value); return this; }
private void ExpectType(ValueTypeEnum type) { if (ValueType != type) { Debug.LogError("Cant read " + type + " value from token!"); } }
public BaseValue(ValueTypeEnum valueType) : base(BaseTypeEnum.Value) { _valueType = valueType; }
public Value InPlaceCast(ValueTypeEnum type) { if (Storage == null) // VOID { switch (type) { case ValueTypeEnum.Integer: Storage = ValueStorageExtensions.Create(0); return(this); case ValueTypeEnum.Amount: Storage = ValueStorageExtensions.Create(new Amount(0)); return(this); case ValueTypeEnum.String: Storage = ValueStorageExtensions.Create(String.Empty); return(this); default: throw new InvalidOperationException(String.Format("Cannot cast VOID to {0}", type)); } } switch (type) { case ValueTypeEnum.Integer: Storage = ValueStorageExtensions.Create(Storage.AsLong); return(this); case ValueTypeEnum.Boolean: Storage = ValueStorageExtensions.Create(Storage.AsBoolean); return(this); case ValueTypeEnum.Date: Storage = ValueStorageExtensions.Create(Storage.AsDate); return(this); case ValueTypeEnum.DateTime: Storage = ValueStorageExtensions.Create(Storage.AsDateTime); return(this); case ValueTypeEnum.Amount: Storage = ValueStorageExtensions.Create(Storage.AsAmount); return(this); case ValueTypeEnum.Balance: Storage = ValueStorageExtensions.Create(Storage.AsBalance); return(this); case ValueTypeEnum.String: Storage = ValueStorageExtensions.Create(Storage.AsString); return(this); case ValueTypeEnum.Mask: Storage = ValueStorageExtensions.Create(Storage.AsMask); return(this); case ValueTypeEnum.Any: Storage = ValueStorageExtensions.Create(Storage.StoredValue); return(this); case ValueTypeEnum.Scope: Storage = ValueStorageExtensions.Create(Storage.AsScope); return(this); case ValueTypeEnum.Sequence: Storage = ValueStorageExtensions.Create(Storage.AsSequence); return(this); default: throw new InvalidOperationException(); } }
public static UInt64 PackSequenceAndType(UInt64 seq, ValueTypeEnum t) { Debug.Assert(seq <= kMaxSequenceNumber); Debug.Assert(t <= kValueTypeForSeek); return (seq << 8) | (UInt64)t; }
/// <summary> /// Merges a property into to the json object, if the property exists it overrides it otherwise it adds it. /// If the valuetype is a string it is escaped and quoted. If it is not it ouputs the value directly. /// if the value is empty then it oupts null as the value for the property /// </summary> /// <param name="name">Property name {name}: {value}</param> /// <param name="value">Property value. string will be escaped and quoted</param> /// <param name="ValueType">The type of value being added. If a string, it will be escaped and quoted</param> public JSObject Merge(string name, string value, ValueTypeEnum ValueType) { if (ValueType == ValueTypeEnum.String) value = JSBuilder.GetString(value); if (HasMember(name)) Data[name] = value; else Data.Add(name, value); return this; }
public Rule AddValueTypeRule(ValueTypeEnum typeEnum) { ValueTypeRule rule = new ValueTypeRule(ValueTypeEnumHelper.ToValue(typeEnum)); this.Add(rule); return rule; }
public static IList<BaseDictionary> GetBaseDictionaries(ValueTypeEnum valueType) { return baseDictionaryRepository.GetBaseDictionaries(valueType); }