public void Update_null_values() { using (var context = Context.UseTransaction(true)) { var value = new DataTypeValue(); value.DecimalValue = null; value.StringValue = null; value.DateTimeValue = null; value.FloatValue = null; value.Id = context.Insert("DataTypeValue") .Column("DecimalValue", value.DecimalValue) .Column("StringValue", value.StringValue) .Column("DateTimeValue", value.DateTimeValue) .Column("FloatValue", value.FloatValue) .ExecuteReturnLastId <int>(); Assert.IsTrue(value.Id > 0); context.Update("DataTypeValue") .Column("DecimalValue", value.DecimalValue) .Column("StringValue", value.StringValue) .Column("DateTimeValue", value.DateTimeValue) .Column("FloatValue", value.FloatValue) .Where("Id", value.Id) .Execute(); } }
public void Day1Test() { DataTypeValue value = Day1.MainMethod(); Assert.AreEqual(value.InputInt, 16); Assert.AreEqual(value.InputDouble, 8); Assert.AreEqual(value.InputString, "Masaab"); }
public virtual void TestGetInstance_String() { string value = "10.10.10.10/255.255:10"; DataTypeValue expResult = new IpAddressDataType("10.10.10.10/255.255:10"); DataTypeValue result = IpAddressDataType.GetInstance(value); Assert.AreEqual(expResult, result); }
private IValue GetIValueFromDslToken() { IValue returnValue = null; DslObject obj = GetObject(_lookaheadFirst); if (obj == DslObject.Variable) { returnValue = new VariableValue(); var varName = _lookaheadFirst.Value; if (varName.StartsWith("[") && varName.EndsWith("]")) { varName = varName.Remove(varName.Length - 1).Substring(1); } (returnValue as VariableValue).VariableName = varName; DiscardToken(); } else if (obj == DslObject.FixedValue) { returnValue = new FixedValue(); (returnValue as FixedValue).Value = _lookaheadFirst.Value; DiscardToken(); } else if (obj == DslObject.NULL) { returnValue = new NullValue(); DiscardToken(); } else if (obj == DslObject.DataType) { returnValue = new DataTypeValue(); (returnValue as DataTypeValue).TypeName = _lookaheadFirst.Value; DiscardToken(); } else if (obj == DslObject.Function) { returnValue = new FunctionCallValue(); var x = returnValue as FunctionCallValue; x.FunctionName = _lookaheadFirst.Value.Remove(_lookaheadFirst.Value.Length - 1); DiscardToken(); while (_lookaheadFirst.TokenType != TokenType.CloseParenthesis) { x.Parameters.Add(GetIValueFromDslToken()); if (!(_lookaheadFirst.TokenType == TokenType.Comma || _lookaheadFirst.TokenType == TokenType.CloseParenthesis)) { throw new ArgumentException(", or ) expected " + _lookaheadFirst.Value + " found"); } if (_lookaheadFirst.TokenType == TokenType.Comma) { DiscardToken(); } } DiscardToken(); } return(returnValue); }
public IElement Evaluate(EvaluationContext ctx, string SchemeID, string effect) { DataTypeValue value = this._evaluatable.Evaluate(ctx, SchemeID); if (value is BagDataType == false) { throw new Indeterminate(Indeterminate.IndeterminateSyntaxError); } return(new AttributeAssignment( this._attributeId, this._category, this._issuer, new AttributeValue((BagDataType)value))); }
public DataTypeValue Evaluate(EvaluationContext ctx, string SchemeID) { foreach (object o in this._anyofs) { DataTypeValue ret = ((AnyOf)o).Evaluate(ctx, SchemeID); if (ret.Equals(BooleanDataType.False)) { return(ret); } } return(BooleanDataType.True); }
public DataTypeValue Evaluate(EvaluationContext ctx, string SchemeID) { foreach (object o in this._matchs) { DataTypeValue value = ((Match)o).Evaluate(ctx, SchemeID); if (value.Equals(BooleanDataType.False)) { return(BooleanDataType.False); } } return(BooleanDataType.True); }
public static DataTypeValue ConvertDataTypeValue(byte b) { try { DataTypeValue dtv = (DataTypeValue)b; // get the enum value return(dtv); } catch (Exception) { return(DataTypeValue.Unknown); } }
private void ExcuteOne(string functionid, DataTypeValue input, BagDataType output, EvaluationContext ctx) { DataTypeValue[] newparams = { input }; try { output.AddDataType(FunctionFactory.Evaluate(functionid, newparams, ctx)); } catch (Indeterminate ex) { throw new IllegalExpressionEvaluationException(ex.Message); } }
private bool isContainedInBag(IList children, DataTypeValue value) { for (int j = 0; j < children.Count; j++) { var child2 = (DataTypeValue)children[j]; if (value.Equals(child2)) { return(true); } } return(false); }
private void addDataType(BagDataType bag, DataTypeValue value) { IList children = bag.Children; for (int j = 0; j < children.Count; j++) { var child = (DataTypeValue)children[j]; if (child.Equals(value)) { return; } } bag.AddDataType(value); }
public DataTypeValue Evaluate(EvaluationContext ctx, string SchemeID) { var args = (BagDataType)this._evaluatable.Evaluate(ctx, SchemeID); IList children = args.Children; DataTypeValue ret = null; foreach (object o in children) { var arg = (DataTypeValue)o; var @params = new[] { this._attributeValue.DataTypeValue, arg }; ret = FunctionFactory.Evaluate(this._matchId.Value, @params, ctx); if (BooleanDataType.True.Equals(ret)) { return(ret); } } return(BooleanDataType.False); }
protected internal virtual DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx, Type cls) { var bag = new BagDataType(); for (int i = 0; i < @params.Length; i++) { DataTypeValue param = @params[i]; if (cls.IsInstance(param)) { bag.AddDataType(param); } else { throw new IllegalExpressionEvaluationException(this.StringIdentifer); } } return(bag); }
private bool IsOneOfBag(string functionid, DataTypeValue one, BagDataType bag, EvaluationContext ctx) { IList children = bag.Children; for (int j = 0; j < children.Count; j++) { DataTypeValue[] newparams = { one, (DataTypeValue)children[j] }; try { if (BooleanDataType.False.Equals(FunctionFactory.Evaluate(functionid, newparams, ctx))) { return(false); } } catch (Indeterminate ex) { throw new IllegalExpressionEvaluationException(ex.Message); } } return(true); }
public void Update_values_automap() { using (var context = Context.UseTransaction(true)) { var value = new DataTypeValue(); value.DecimalValue = 5; value.StringValue = "test"; value.DateTimeValue = DateTime.Now; value.FloatValue = 12.12F; value.Id = context.Insert("DataTypeValue", value) .AutoMap(x => x.Id) .ExecuteReturnLastId <int>(); Assert.IsTrue(value.Id > 0); context.Update("DataTypeValue", value) .AutoMap(x => x.Id) .Where(x => x.Id) .Execute(); Assert.IsTrue(value.Id > 0); } }
/// <summary> /// Loads this scene node from a given binary reader. /// </summary> /// <param name="reader">Binary reader to load this scene node from.</param> public override void Load(BinaryReader reader) { // Load all the basic entity details. base.Load(reader); // Load all the scripted specific details. if (reader.ReadBoolean() == true) { string url = reader.ReadString(); // Load the objects script from the memory stream we dumped it into. ScriptProcess process = VirtualMachine.GlobalInstance.LoadScript(url); #region Property Loading int propertyCount = reader.ReadInt16(); for (int i = 0; i < propertyCount; i++) { string identifier = reader.ReadString(); DataTypeValue dataTypeValue = new DataTypeValue((DataType)reader.ReadByte(), false, false); bool isArray = reader.ReadBoolean(); // Look through the script processes global variables to see if this // variable exists. VariableSymbol variableSymbol = null; if (process != null) { foreach (Symbol symbol in process.GlobalScope.Symbols) { if (symbol is VariableSymbol == false || ((VariableSymbol)symbol).Identifier != identifier || ((VariableSymbol)symbol).DataType != dataTypeValue) { continue; } variableSymbol = symbol as VariableSymbol; break; } } // Quickly find out the meta data of this symbol. string editMethod = ""; if (variableSymbol != null) { foreach (Symbol subSymbol in variableSymbol.Symbols) { if (subSymbol is MetaDataSymbol) { if (((MetaDataSymbol)subSymbol).Identifier.ToLower() == "editmethod") { editMethod = ((MetaDataSymbol)subSymbol).Value; break; } } } } // Read in value based on data type. if (isArray == true && reader.ReadBoolean() == true) { int arrayLength = reader.ReadInt32(); int arrayIndex = process == null ? 0 : process[0].AllocateArray(dataTypeValue.DataType, arrayLength); for (int k = 0; k < arrayLength; k++) { switch (dataTypeValue.DataType) { case DataType.Bool: { bool value = reader.ReadBoolean(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.Byte: { byte value = reader.ReadByte(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.Double: { double value = reader.ReadDouble(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.Float: { float value = reader.ReadSingle(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.Int: { int value = reader.ReadInt32(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.Long: { long value = reader.ReadInt64(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.Short: { short value = reader.ReadInt16(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, k, value); } } break; case DataType.String: { string value = reader.ReadString(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, i, value); } } break; case DataType.Object: { if (reader.ReadBoolean() == true) { int type = reader.ReadByte(); if (type == 0) { string imageUrl = reader.ReadString(); int cellWidth = reader.ReadInt32(); int cellHeight = reader.ReadInt32(); int hSpacing = reader.ReadInt16(); int vSpacing = reader.ReadInt16(); if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, i, new Fusion.Engine.ScriptingFunctions.ImageScriptObject(GraphicsManager.LoadImage(imageUrl, cellWidth, cellHeight, hSpacing, vSpacing, 0))); } } else if (type == 1) { string soundUrl = reader.ReadString(); int freq = reader.ReadInt32(); float innerRadius = reader.ReadSingle(); float outerRadius = reader.ReadSingle(); bool loop = reader.ReadBoolean(); float pan = reader.ReadSingle(); float volume = reader.ReadSingle(); bool streaming = reader.ReadBoolean(); bool positional = reader.ReadBoolean(); Audio.SoundFlags flags = 0; if (streaming == true) { flags |= Audio.SoundFlags.Streamed; } if (positional == true) { flags |= Audio.SoundFlags.Positional; } Audio.Sound sound = Audio.AudioManager.LoadSound(soundUrl, flags); sound.Frequency = freq; sound.InnerRadius = innerRadius; sound.OuterRadius = outerRadius; sound.Looping = loop; sound.Pan = pan; sound.Volume = volume; if (process != null && variableSymbol != null) { process[0].SetArrayElement(arrayIndex, i, new Fusion.Engine.ScriptingFunctions.SoundScriptObject(sound)); } } } } break; } } } else { switch (dataTypeValue.DataType) { case DataType.Bool: { bool value = reader.ReadBoolean(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Byte: { byte value = reader.ReadByte(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Double: { double value = reader.ReadDouble(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Float: { float value = reader.ReadSingle(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Int: { int value = reader.ReadInt32(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Long: { long value = reader.ReadInt64(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Short: { short value = reader.ReadInt16(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.String: { string value = reader.ReadString(); if (process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, value); } } break; case DataType.Object: { if (reader.ReadBoolean() == true) { int type = reader.ReadByte(); if (type == 0) { string imageUrl = reader.ReadString(); int cellWidth = reader.ReadInt32(); int cellHeight = reader.ReadInt32(); int hSpacing = reader.ReadInt16(); int vSpacing = reader.ReadInt16(); if (ResourceManager.ResourceExists(imageUrl) == true && process != null && variableSymbol != null) { process[0].SetGlobalVariable(identifier, new Fusion.Engine.ScriptingFunctions.ImageScriptObject(GraphicsManager.LoadImage(imageUrl, cellWidth, cellHeight, hSpacing, vSpacing, 0))); } } else if (type == 1) { string soundUrl = reader.ReadString(); int freq = reader.ReadInt32(); float innerRadius = reader.ReadSingle(); float outerRadius = reader.ReadSingle(); bool loop = reader.ReadBoolean(); float pan = reader.ReadSingle(); float volume = reader.ReadSingle(); bool streaming = reader.ReadBoolean(); bool positional = reader.ReadBoolean(); Audio.SoundFlags flags = 0; if (streaming == true) { flags |= Audio.SoundFlags.Streamed; } if (positional == true) { flags |= Audio.SoundFlags.Positional; } if (ResourceManager.ResourceExists(soundUrl) == true && process != null && variableSymbol != null) { Audio.Sound sound = Audio.AudioManager.LoadSound(soundUrl, flags); sound.Frequency = freq; sound.InnerRadius = innerRadius; sound.OuterRadius = outerRadius; sound.Looping = loop; sound.Pan = pan; sound.Volume = volume; process[0].SetGlobalVariable(identifier, new Fusion.Engine.ScriptingFunctions.SoundScriptObject(sound)); } } } } break; } } } #endregion // Now set the process! _process.Process = process; if (_process.Process != null) { _process.Process.OnStateChange += OnStateChange; } if (_process.Process != null && _process.Process.State != null) { OnStateChange(_process.Process, _process.Process.State); } SyncCollisionEvents(); } }
public Column(string displayName, string dataExample, string colName, DataTypeValue dataType, bool sortable, bool orderable, bool visible) : this(displayName, dataExample, colName, dataType, sortable, orderable) { IsVisible = visible; }
public static bool IsInstance(this Type type, DataTypeValue dataTypeValue) { return((dataTypeValue != null) && (dataTypeValue.GetType().FullName == type.FullName)); }
public static (string result, BluetoothCompanyIdentifier.CommonManufacturerType manufacturerType) Parse(BluetoothLEAdvertisementDataSection section, sbyte txPower, string indent) { string str = "??"; byte b = section.DataType; DataTypeValue dtv = ConvertDataTypeValue(b); // get the enum value BluetoothCompanyIdentifier.CommonManufacturerType manufacturerType = BluetoothCompanyIdentifier.CommonManufacturerType.Other; try { var printAsHex = false; switch (dtv) { case DataTypeValue.ManufacturerData: (str, manufacturerType) = BluetoothCompanyIdentifier.ParseManufacturerData(section, txPower); break; case DataTypeValue.Flags: str = ParseFlags(section); break; case DataTypeValue.ShortenedLocalName: { var buffer = section.Data.ToArray(); var allNul = true; foreach (var namebyte in buffer) { if (namebyte != 0) { allNul = false; } } if (allNul) { str = ""; } else { printAsHex = true; } } break; case DataTypeValue.TxPowerLevel: var db = ParseTxPowerLevel(section); str = $"{db}"; break; default: printAsHex = true; break; } if (printAsHex) { var result = ValueParser.Parse(section.Data, "BYTES|HEX"); str = $"section {dtv.ToString()} data={result.AsString}\n"; } } catch (Exception) { var result = ValueParser.Parse(section.Data, "BYTES|HEX"); str = $"error section {section.DataType} data={result.AsString}\n"; } if (!string.IsNullOrWhiteSpace(str)) { str = indent + str; } return(str, manufacturerType); }
public Column(string displayName, string dataExample, string colName, DataTypeValue dataType, bool sortable) : this(displayName, dataExample, colName, dataType) { Sortable = sortable; }