public override void Deserialize(Common.Serialization.IO.CompactReader reader) { _value = reader.ReadObject() as IComparable; _order = (SortOrder)reader.ReadByte(); _type = (FieldDataType)reader.ReadByte(); _actualType = (TypeCode)reader.ReadInt32(); }
public ActionResult AddField(string InfoName, FieldDataType DataType, int GroupID, TextType TextType = TextType.Libre, IntType IntType = IntType.Nombre, int?minValue = null, int?maxValue = null, string HaveMany = "no", string Required = "no", int Echelle = 5, string Defaults = null) { string def = ""; if (Defaults != null) { var Listedefaults = Defaults.Trim().Split('\r', '\n'); foreach (var item in Listedefaults) { def += String.IsNullOrWhiteSpace(item) ? "" : ";" + item; } } var group = _db.CustomGroups.Find(GroupID); var fields = group.CustomFields; if (fields.Where(g => g.InfoName == InfoName).FirstOrDefault() == null) { if (maxValue == null) { maxValue = Echelle; } service.AddField(InfoName, DataType, group.GroupName, TextType, IntType, minValue, maxValue, HaveMany == "on", Required == "on", def); return(Json("OK")); } else { return(Json("NO")); } }
IValue ConvertToIValue(FieldDataType fieldDataType, object value) { if (DBNull.Value.Equals(value) || value == null) { return(new NullValue()); } switch (fieldDataType) { case FieldDataType.Numeric: return(new NumericValue <double>((double)value)); case FieldDataType.Text: return(new TextValue((string)value)); case FieldDataType.DateTime: return(new DateTimeValue((DateTime)value)); case FieldDataType.Boolean: return(new BooleanValue((bool)value)); default: throw new NotSupportedException("Datatype for between not supported."); } }
public object GetDefaultPrecommitValueForDataType(FieldDataType dataType) { if (PrecommitValues != null) { foreach (PrecommitValueInfo value in PrecommitValues) { if (dataType == value.DataType) { return(value.Value); } } } switch (DefaultPrecommitValues) { case DefaultPrecommitValues.None: return(null); case DefaultPrecommitValues.Zero: return(FieldHandlerFactory.GetFieldHandler(dataType).DefaultPrecommitValue()); case DefaultPrecommitValues.Null: return(NullPrecommitValue); default: throw new NotImplementedException(DefaultPrecommitValues.ToString()); } }
public FieldNode(XmlNode xml) { this.intFieldId = int.Parse(xml.Attributes["FieldId"].Value); this.strFieldName = xml.Attributes["FieldName"].Value; this.dataType = (FieldDataType)Enum.Parse(typeof(FieldDataType), xml.Attributes["DataType"].Value); this.boolIsEnabled = bool.Parse(xml.Attributes["IsEnabled"].Value); }
private static string GetBaseReadOperation(FieldDataType t) { switch (t) { case FieldDataType.FLOAT32: return("ReadSingle"); case FieldDataType.INT8: return("ReadSByte"); case FieldDataType.UINT8: return("ReadByte"); case FieldDataType.INT16: return("ReadInt16"); case FieldDataType.UINT16: return("ReadUInt16"); case FieldDataType.INT32: return("ReadInt32"); case FieldDataType.UINT32: return("ReadUInt32"); case FieldDataType.INT64: return("ReadInt64"); case FieldDataType.UINT64: return("ReadUInt64"); case FieldDataType.CHAR: return("ReadChar"); default: Console.WriteLine("ERROR: Unknown uavType: " + t); return("UNKNOWN_UAS_TYPE"); } }
public FieldNode(int _fieldId, string _fieldName, FieldDataType _dataType, bool _isEnabled = true) { this.intFieldId = _fieldId; this.strFieldName = _fieldName; this.dataType = _dataType; this.boolIsEnabled = _isEnabled; }
//return true if value can be converted to FieldDataType public static bool CheckType(string value, FieldDataType fdt) { bool result = true; try { switch (fdt) { case FieldDataType.DATE: DateTime.Parse(value); break; case FieldDataType.FLOAT: float.Parse(value); break; case FieldDataType.INT: int.Parse(value); break; case FieldDataType.TEXT: // nothing to check break; default: throw new Exception("FieldDataType invalid."); } } catch { result = false; } return(result); }
public static IComparable Enforce(object value, out FieldDataType matchType, out TypeCode actualType) { matchType = GetJSONType(value, out actualType); switch (matchType) { case FieldDataType.Number: switch (actualType) { case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.Byte: case TypeCode.SByte: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: return(Convert.ToInt64(value)); default: return(Convert.ToDouble(value)); } case FieldDataType.String: return(value.ToString()); case FieldDataType.Bool: return((bool)value); default: return((IComparable)value); } }
/* * Throws ArgumentException if list isn't valid. */ public RangeList(string rangeList, FieldDataType rangeListType) { try { _ranges = new List <Range>(); _rangeListType = rangeListType; _rangeListRaw = rangeList; if (string.IsNullOrEmpty(rangeList) || rangeListType == FieldDataType.UNKNOWN) { throw new ArgumentException("rangeList can't be empty or rangeListType invalid."); } string[] items = rangeList.Trim().Split(new char[] { ',' }); foreach (string item in items) { _ranges.Add(new Range(item, this)); } } catch (Exception e) { _ranges = null; _rangeListType = FieldDataType.UNKNOWN; _rangeListRaw = null; throw new ArgumentException("An error ocurred while construction RangeList: " + e.Message); } }
/// <summary> /// Map from a Haestad.Domain FieldDataType to a .NET Type. /// </summary> static public Type TypeFromFieldDataType(FieldDataType type) { switch (type) { case FieldDataType.Boolean: return(typeof(bool)); case FieldDataType.DateTime: return(typeof(DateTime)); case FieldDataType.Integer: case FieldDataType.Referenced: case FieldDataType.Enumerated: return(typeof(int)); case FieldDataType.Text: case FieldDataType.LongText: return(typeof(String)); case FieldDataType.Real: return(typeof(double)); //TODO 0 Review later for robustness. case FieldDataType.Collection: return(typeof(byte)); default: Debug.Assert(false); return(null); } }
private static string GetBaseCSharpType(FieldDataType t) { switch (t) { case FieldDataType.FLOAT32: return("float"); case FieldDataType.INT8: return("SByte"); case FieldDataType.UINT8: return("byte"); case FieldDataType.INT16: return("Int16"); case FieldDataType.UINT16: return("UInt16"); case FieldDataType.INT32: return("Int32"); case FieldDataType.UINT32: return("UInt32"); case FieldDataType.INT64: return("Int64"); case FieldDataType.UINT64: return("UInt64"); case FieldDataType.CHAR: return("char"); default: return("!!!!"); } }
/// <summary> /// Serialize an object using .NET's Binary formatter and returns it encoded into base64 string /// </summary> /// <param name="obj">Object to serialize</param> /// <param name="culture">Culture to use during the serialization</param> /// <returns>Base64 string</returns> static public String SerializeToString(FieldDataType fieldDataType, Object obj, CultureInfo culture) { if (obj == null) { return(""); // DO NOT LOCALIZE <ccla> } switch (fieldDataType) { case FieldDataType.Real: return(((Double)obj).ToString(culture.NumberFormat)); case FieldDataType.DateTime: return(((DateTime)obj).ToString(culture)); case FieldDataType.Boolean: case FieldDataType.Enumerated: case FieldDataType.Integer: case FieldDataType.Referenced: case FieldDataType.LongText: case FieldDataType.Text: return(obj.ToString()); default: using (MemoryStream stream = new MemoryStream()) { BinaryWriter bw = new BinaryWriter(stream); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); return(Convert.ToBase64String(stream.GetBuffer())); } } }
public void AddField(string InfoName, FieldDataType DataType, string GroupName, TextType TextType = TextType.Libre, int?minValue = null, int?maxValue = null, bool HaveMany = false, bool Required = false) { CustomField cf = new CustomField { InfoName = InfoName, DataType = DataType, HaveMany = HaveMany, required = Required }; switch (DataType) { case FieldDataType.String: { cf.TextType = TextType; break; }; case FieldDataType.Int: case FieldDataType.Decimal: case FieldDataType.Double: { cf.Min = minValue; cf.Max = maxValue; break; }; case FieldDataType.DateTime: {; break; }; default: {; break; }; } var group = _db.CustomGroups.Where(g => g.GroupName == GroupName).Single(); group.CustomFields.Add(cf); _db.Entry(group).State = EntityState.Modified; _db.SaveChanges(); }
/// <summary> /// Returns a default (zero) value for a FieldDataType. /// </summary> /// <param name="atype">FieldDataType to return a default value for.</param> /// <returns>Default value for the passed FieldDataType.</returns> static public Object DefaultValueFor(FieldDataType atype) { switch (atype) { case FieldDataType.Enumerated: case FieldDataType.Integer: case FieldDataType.Referenced: return(0); case FieldDataType.Real: return(0.0); case FieldDataType.Text: case FieldDataType.LongText: return(String.Empty); case FieldDataType.Boolean: return(false); case FieldDataType.DateTime: return(DateTime.Now); case FieldDataType.LongBinary: case FieldDataType.Collection: return(null); default: throw new IndexOutOfRangeException(); } }
private IComparable PerformArithmeticOperation(IEvaluable evaluable, IJSONDocument document, ArithmeticOperation operation) { IJsonValue value1, value2; if (!Evaluate(out value1, document)) { return(null); } if (!evaluable.Evaluate(out value2, document)) { return(null); } TypeCode actualType1, actualType2; FieldDataType fieldDataType1 = JSONType.GetJSONType(value1.Value, out actualType1); FieldDataType fieldDataType2 = JSONType.GetJSONType(value2.Value, out actualType2); if (fieldDataType1.CompareTo(fieldDataType2) != 0) { return(null); } return(Evaluator.PerformArithmeticOperation(value1, actualType1, value2, actualType2, operation, fieldDataType1)); }
public virtual void LoadFromXml(XElement xml) { Name = XmlUtilits.GetFieldValue(xml, "Name", "ERROR"); String datatypeStr = XmlUtilits.GetFieldValue(xml, "DataType", "ERROR"); datatype = (FieldDataType)Enum.Parse(typeof(FieldDataType), datatypeStr); }
public Field(string dbFName, string clsFName, string formField, FieldType type, FieldDataType dataType) { this.clsFieldName = clsFName; this.dbFieldName = dbFName; this.formFieldName = formField; this.type = type; this.dataType = dataType; }
/// <summary> /// Initializes a new instance of the <see cref="T:Kamtro_Bot.Nodes.MessageFieldNode"/> class. /// </summary> /// <param name="name">The displayed name of the field.</param> /// <param name="page">The page that the field is on.</param> /// <param name="pos">The field's position on it's page.</param> /// <param name="value">The value of the field.</param> /// <param name="dataType">Data type of the field. Default is string.</param> public MessageFieldNode(string name, int page, int pos, string value = "[Enter Value]", FieldDataType dataType = FieldDataType.STR) { Name = name; Page = page; Pos = pos; Value = value; Type = dataType; }
public void GenerateBetweenSqlString_AddBetweenCondition(FieldDataType dataType, object value1, object value2, string expected) { _csb.AddBetweenCondition("Field1", dataType, value1, value2); var actual = _csb.ToString(); Assert.AreEqual(expected, actual); }
public void GenerateSqlString_FieldAndValue(object fieldName, FieldDataType dataType, RelationalOperators relationalOperator, object value, string expected) { _csb.Add(fieldName, dataType, relationalOperator, value); var actual = _csb.ToString(); Assert.AreEqual(expected, actual); }
public void SetData(byte[] data, FieldDataType type) { _opFlags = _opFlags.SetBitAtIndex(LoadDataFromImageFlag, false); _opFlags = _opFlags.SetBitAtIndex(LoadDataFromStateFlag, (data != null && data.Length > 0)); _dataType = type; _module.FieldDataBlob[_rid - 1] = data; OnChanged(); }
public void GenerateSqlString_DbNullValue(FieldDataType dataType, RelationalOperators relationalOperator) { _csb.Add("Field1", dataType, relationalOperator, System.DBNull.Value); _csb.Add("Field2", dataType, relationalOperator, System.DBNull.Value); var actual = _csb.ToString(); Assert.AreEqual(string.Empty, actual); }
private SoqlLiteralValueModifiers ParseLiteralValueModifiers() { SoqlLiteralValueModifiers retVal = new SoqlLiteralValueModifiers(); string typeName = tokenizer.EatKeyword(); FieldDataType typeOverride = (FieldDataType)FieldDataType.Parse(typeof(FieldDataType), typeName); retVal.DataTypeOverride = typeOverride; return(retVal); }
public void GenerateSqlString_ConcatBetweenDbNullValue(FieldDataType dataType) { _csb.Add("Field1", FieldDataType.Text, RelationalOperators.Between, new object[] { System.DBNull.Value, "xyz" }); _csb.Add("Field2", FieldDataType.Numeric, RelationalOperators.Between, new object[] { 133.45, System.DBNull.Value }); _csb.Add("Field3", dataType, RelationalOperators.Between, new object[] { System.DBNull.Value, System.DBNull.Value }); var actual = _csb.ToString(); Assert.AreEqual("Field1 <= 'xyz' And Field2 >= 133.45", actual); }
public void GenerateBetweenSqlString_Values(FieldDataType dataType, object value1, object value2, string expected) { var betweenValues = new object[] { value1, value2 }; _csb.Add("Field1", dataType, RelationalOperators.Between, betweenValues); var actual = _csb.ToString(); Assert.AreEqual(expected, actual); }
public void GenerateSqlStringFieldAndValue_Between(object fieldName, FieldDataType fieldDataType, RelationalOperators relationalOperator, object value1, object value2, string expected) { object[] values = new[] { value1, value2 }; _csb.Add(fieldName, fieldDataType, relationalOperator, values); var actual = _csb.ToString(); Assert.AreEqual(expected, actual); }
public static List <FieldDisplayType> GetDependentDisplayTypesFor(FieldDataType dataType) { List <FieldDisplayType> relatedDisplayTypes; if (!_dataMappingToDisplayCache.TryGetValue(dataType, out relatedDisplayTypes)) { return(new List <FieldDisplayType>()); // emptty list } return(relatedDisplayTypes); }
protected virtual AttributeValue GetBound(FieldDataType type, Bound bound) { var boundary = new BoundaryValueMask(type, bound); var enumerator = GetEnumerator(boundary); while (enumerator.MoveNext()) { ; } return(boundary.State); }
public void GenerateBetweenSqlString_DbNullValue(FieldDataType dataType) { var betweenValues = new object[] { System.DBNull.Value, System.DBNull.Value }; _csb.Add("Field1", dataType, RelationalOperators.Between, betweenValues); _csb.Add("Field2", dataType, RelationalOperators.Between, betweenValues); var actual = _csb.ToString(); Assert.AreEqual(string.Empty, actual); }
public static IHtmlString EditFieldAttributes(TextContent data, string fieldName, FieldDataType dataType) { if (dataType == FieldDataType.Auto) { dataType = QueryFieldDataType(data, fieldName); } if (data == null || !Page_Context.Current.EnabledInlineEditing(EditingType.Content) || !Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableToEditContent(data, Page_Context.Current.ControllerContext.HttpContext.User.Identity.Name)) { return new HtmlString(""); } return new HtmlString(string.Format("editType=\"field\" dataType=\"{0}\" schema=\"{1}\" folder=\"{2}\" uuid=\"{3}\" fieldName=\"{4}\"", dataType.ToString(), data.SchemaName, data.FolderName, data.UUID, fieldName)); }
public static IHtmlString EditField(TextContent data, string fieldName, FieldDataType dataType) { if (dataType == FieldDataType.Auto) { dataType = QueryFieldDataType(data, fieldName); } if (data == null || !Page_Context.Current.EnabledInlineEditing(EditingType.Content) || !Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableToEditContent(data, Page_Context.Current.ControllerContext.HttpContext.User.Identity.Name)) { return new HtmlString(data[fieldName] == null ? "" : data[fieldName].ToString()); } var format = "<var start=\"true\" editType=\"field\" dataType=\"{0}\" schema=\"{1}\" folder=\"{2}\" uuid=\"{3}\" fieldName=\"{4}\" style=\"display:none;\"></var>{5}<var end=\"true\" style=\"display:none;\"></var>"; return new HtmlString(string.Format(format, dataType.ToString(), data.SchemaName, data.FolderName, data.UUID, fieldName, data[fieldName])); }
internal void Merge(FieldInfo merge) { this.DataType = merge.DataType; if (merge.Description != null) this.Description = (this.Description != null ? this.Description + "\n" : "") + merge.Description; if (merge.Size != -1) this.Size = merge.Size; if (merge.Precision != -1) this.Precision = merge.Size; if (merge.References != null) this.References = merge.References; if (merge.PrecommitValue != null) this.PrecommitValue = merge.PrecommitValue; this.IsPrimaryKey = merge.IsPrimaryKey; this.IsNullable = merge.IsNullable; this.ReadOnly = merge.ReadOnly; this.ForceTrigger = merge.ForceTrigger; this.DeleteAction = merge.DeleteAction; this.IsLabel = merge.IsLabel; this.PrefetchLevel = merge.PrefetchLevel; this.FindMethod = merge.FindMethod; this.FindListMethod = merge.FindListMethod; if (merge.dbcolumn != null) this.DBColumnName = merge.dbcolumn; }
internal void ResolveReferences(SchemaInfo schema) { if (References == null) return; ClassInfo ci = schema.FindClassByName(References); if (ci == null) throw new SoodaSchemaException("Class " + References + " not found."); DataType = ci.GetFirstPrimaryKeyField().DataType; ReferencedClass = ci; }
public static bool IsMatch(FieldDataType testTypeIndicator, Type actualType) { if (testTypeIndicator == FieldDataType.Int && actualType == typeof(int)) return true; if (testTypeIndicator == FieldDataType.Float && actualType == typeof(Single)) return true; if (testTypeIndicator == FieldDataType.Double && actualType == typeof(double)) return true; if (testTypeIndicator == FieldDataType.DateTime && actualType == typeof(DateTime)) return true; if (testTypeIndicator == FieldDataType.Bool && actualType == typeof(bool)) return true; if (testTypeIndicator == FieldDataType.String && actualType == typeof(string)) return true; return false; }
/// <summary> /// Creates a new field with a specific name and using a simplified enumeration of possible types. /// </summary> /// <param name="inColumnName">the string column name.</param> /// <param name="type">The type enumeration that clarifies which basic data type to use.</param> public Field(string inColumnName, FieldDataType type) : base(inColumnName) { if (type == FieldDataType.Double) DataType = typeof(double); if (type == FieldDataType.Integer) DataType = typeof(int); if (type == FieldDataType.String) DataType = typeof(string); }
public static Type ToType(FieldDataType testTypeIndicator) { switch (testTypeIndicator) { case FieldDataType.Int: return typeof (int); case FieldDataType.Float: return typeof (float); case FieldDataType.Double: return typeof (double); case FieldDataType.Bool: return typeof (bool); case FieldDataType.DateTime: return typeof (DateTime); default: return typeof (string); } }
public FieldDataType[] ToFieldDataTypeArray(string input) { if (string.IsNullOrWhiteSpace(input)) return null; var fields = input.Split(','); var result = new FieldDataType[fields.Length]; for (int i = 0; i < fields.Length; i++) { var field = fields[i]; result[i] = (FieldDataType)int.Parse(field); } return result; }
public object GetDefaultPrecommitValueForDataType(FieldDataType dataType) { if (PrecommitValues != null) { foreach (PrecommitValueInfo value in PrecommitValues) if (dataType == value.DataType) return value.Value; } switch (DefaultPrecommitValues) { case DefaultPrecommitValues.None: return null; case DefaultPrecommitValues.Zero: return FieldHandlerFactory.GetFieldHandler(dataType).DefaultPrecommitValue(); case DefaultPrecommitValues.Null: return NullPrecommitValue; default: throw new NotImplementedException(DefaultPrecommitValues.ToString()); } }
private static string GetBaseReadOperation(FieldDataType t) { switch (t) { case FieldDataType.FLOAT32: return "ReadSingle"; case FieldDataType.INT8: return "ReadSByte"; case FieldDataType.UINT8: return "ReadByte"; case FieldDataType.INT16: return "ReadInt16"; case FieldDataType.UINT16: return "ReadUInt16"; case FieldDataType.INT32: return "ReadInt32"; case FieldDataType.UINT32: return "ReadUInt32"; case FieldDataType.INT64: return "ReadInt64"; case FieldDataType.UINT64: return "ReadUInt64"; case FieldDataType.CHAR: return "ReadChar"; default: Console.WriteLine("ERROR: Unknown uavType: " + t); return "UNKNOWN_UAS_TYPE"; } }
private static string GetBaseCSharpType(FieldDataType t) { switch (t) { case FieldDataType.FLOAT32: return "float"; case FieldDataType.INT8: return "SByte"; case FieldDataType.UINT8: return "byte"; case FieldDataType.INT16: return "Int16"; case FieldDataType.UINT16: return "UInt16"; case FieldDataType.INT32: return "Int32"; case FieldDataType.UINT32: return "UInt32"; case FieldDataType.INT64: return "Int64"; case FieldDataType.UINT64: return "UInt64"; case FieldDataType.CHAR: return "char"; default: return "!!!!"; } }
internal void AddField(FieldDataType type, String name) { _fields[_nextFieldIdx] = new FieldInfo() { type = type, name = name }; ++_nextFieldIdx; }
public static SoodaFieldHandler GetFieldHandler(FieldDataType type) { return _nullableHandlers[(int) type]; }
public static SoodaFieldHandler GetFieldHandler(FieldDataType type, bool nullable) { return (nullable ? _nullableHandlers : _notNullHandlers)[(int) type]; }