/// <summary> /// 移除flag中指定的vt特性 /// </summary> public static void RemoveFlag(ref int flag, ValueType vt) { if (CheckFlag(flag, vt)) { flag &= ~(1 << (int)vt); } }
public Option(string name, ValueType valueType, string description, string example) : this(name, valueType) { Name = name; ValueType = valueType; Description = description; Example = example; }
static void ChangeProperties(ValueType instance) { instance.Number = 29; instance.String = "twentynine"; Console.WriteLine("value in method: {0} {1}", instance.Number, instance.String); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="name"></param> /// <param name="dataType"></param> /// <param name="pattern"></param> public PatternValidation(string name, string dataType, string pattern) { this.appliedTo = ValueType.All; this.name = name; this.dataType = dataType; this.pattern = pattern; }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="name"></param> /// <param name="dataType"></param> /// <param name="checkList"></param> public DomainValidation(string name, string dataType, List<string> checkList) { this.appliedTo = ValueType.All; this.name = name; this.dataType = dataType; this.checkList = checkList; }
public static int Test2() { ValueType vt = new ValueType(2); int i = vt.GetValue(); return i; }
internal static void AddIndexRuleConstraints(ConstraintBuilder constraintBuilder, ValueType stringType) { constraintBuilder .AssertAll<ValueField>(vf => (!vf.HasIndexAttribute && !vf.HasMaxLengthAttribute) ^ (vf.HasIndexAttribute && vf.Type != stringType) ^ (vf.HasIndexAttribute && vf.HasMaxLengthAttribute)) .AssertAll<ValueField>(vf => !(vf.HasKeyAttribute && vf.HasIndexAttribute)); }
private CssMediaFeature(string aName, RangeType aRangeType, ValueType aValueType, int[] aKeywordTable, string aMetric) { mName = aName; mRangeType = aRangeType; mValueType = aValueType; mKeywordTable = aKeywordTable; mMetric = aMetric; }
public CastFunction(ValueType type) : base(Fixity.Prefix, 1) { CastType = type; Signature.InputSignature.Clear(); Signature.InputSignature.Add(ValueType.BlankIdentifier); Signature.OutputSignature = ValueType.BlankIdentifier; }
public ValueCorrectionViewModel(ValueType type) { if (type == ValueType.Integer) _format = "0"; else if (type == ValueType.Percent) _format = "P2"; else _format = "0.00"; }
public FunctionType(Fixity fixity, int numArguments = 2) : base("FunctionType") { Fixity = fixity; InputSignature = new List<ValueType>(); if (fixity != Hype.Fixity.Prefix && numArguments != 2) throw new Exception("Infix functions can only take 2 arguments."); for (int i = 0; i < numArguments; ++i) { InputSignature.Add(ValueType.Uncertain); } OutputSignature = ValueType.Uncertain; }
private static string GetName(ValueType type) { var index = (int)type; var names = new string[] { "Null", "Boolean", "Integer", "UInteger", "Number", "String", "Array", "Object", }; return (index >= 0 && index < names.Length) ? names[index] : "Unknown"; }
static void Main(string[] args) { var referenceInstance = new ReferenceType(); referenceInstance.Number = 1; referenceInstance.String = "one"; ChangeProperties(referenceInstance); Console.WriteLine("reference: {0} {1}", referenceInstance.Number, referenceInstance.String); var valueInstance = new ValueType(); valueInstance.Number = 1; valueInstance.String = "one"; ChangeProperties(valueInstance); Console.WriteLine("value: {0} {1}", valueInstance.Number, valueInstance.String); }
/// <summary>Assigns all needed attributes to the tag</summary> /// <returns>This instance downcasted to base class</returns> public virtual IndexedTag attr( string id = null, string name = null, string value = null, ValueType? valuetype = null, MimeType type = null ) { Id = id; Name = name; Value = value; ValueType = valuetype; Type = type; return this; }
internal ConstNode(DataTable table, ValueType type, object constant, bool fParseQuotes) : base(table) { switch (type) { case ValueType.Null: _val = DBNull.Value; break; case ValueType.Numeric: _val = SmallestNumeric(constant); break; case ValueType.Decimal: _val = SmallestDecimal(constant); break; case ValueType.Float: _val = Convert.ToDouble(constant, NumberFormatInfo.InvariantInfo); break; case ValueType.Bool: _val = Convert.ToBoolean(constant, CultureInfo.InvariantCulture); break; case ValueType.Str: if (fParseQuotes) { // replace '' with one ' _val = ((string)constant).Replace("''", "'"); } else { _val = (string)constant; } break; case ValueType.Date: _val = DateTime.Parse((string)constant, CultureInfo.InvariantCulture); break; case ValueType.Object: _val = constant; break; default: Debug.Assert(false, "NYI"); goto case ValueType.Object; } }
internal static void AddDatabaseGeneratedRuleConstraints( ConstraintBuilder constraintBuilder, ValueType stringType, ValueType numberType, ValueType guidType) { constraintBuilder .AssertAll<ValueField>(f => (!f.IsPrimaryKey && f.DatabaseGeneratedAttribute == DatabaseGeneratedAttribute.None) ^ ( f.IsPrimaryKey && ( (f.Type == stringType && f.DatabaseGeneratedAttribute == DatabaseGeneratedAttribute.Computed) ^ (f.Type == numberType && f.DatabaseGeneratedAttribute != DatabaseGeneratedAttribute.Computed) ^ (f.Type == guidType && f.DatabaseGeneratedAttribute != DatabaseGeneratedAttribute.Identity) ) ) ); }
public Value(Value value) { Type = value.Type; switch (Type) { case ValueType.String: Str = value.Str; break; case ValueType.Number: Number = value.Number; break; case ValueType.Object: if (value.Obj != null) Obj = new Object(value.Obj); break; case ValueType.Array: Array = new Array(value.Array); break; case ValueType.Boolean: Boolean = value.Boolean; break; } }
/// <summary> /// 值类型转string /// </summary> /// <param name="inputObj">输入</param> /// <param name="defaultStr">转换失败默认值</param> /// <returns></returns> public static string TryToString(this ValueType inputObj, string defaultStr = "") { var output = inputObj.IsNull() ? defaultStr : inputObj.ToString(); return(output); }
public Task <string> FindJsonByIdAsync <T>(ValueType id, CancellationToken token) where T : class { return(findJsonByIdAsync <T>(id, token)); }
public static int test_0_more_cast_corner_cases () { ValueType[] vta = new ValueType [0]; Enum[] ea = new Enum [0]; Array a = vta; object[] oa; bool ok; if (!(a is object[])) return 1; if (!(a is ValueType[])) return 2; if (a is Enum[]) return 3; a = ea; if (!(a is object[])) return 4; if (!(a is ValueType[])) return 5; if (!(a is Enum[])) return 6; try { ok = true; oa = (object[])a; } catch { ok = false; } if (!ok) return 7; try { ok = true; oa = (Enum[])a; } catch { ok = false; } if (!ok) return 8; try { ok = true; oa = (ValueType[])a; } catch { ok = false; } if (!ok) return 9; a = vta; try { ok = true; oa = (object[])a; } catch { ok = false; } if (!ok) return 10; try { ok = true; oa = (ValueType[])a; } catch { ok = false; } if (!ok) return 11; try { ok = false; vta = (Enum[])a; } catch { ok = true; } if (!ok) return 12; return 0; }
private static bool BoxUnboxToQ1(ValueType vt) { return(BoxUnboxToQ2((ExplicitFieldOffsetStruct?)vt)); }
private static bool BoxUnboxToNQ1(ValueType vt) { Console.WriteLine("BoxUnboxToNQ1: {0}", vt); return(BoxUnboxToNQ2((char)vt)); }
public static void Main(string[] args) { // Ну куда же без Hello world Console.WriteLine("Hello world!"); #region Про числа // Разные численные типы имеют разные суффиксы: int a1 = 1; uint a2 = 1U; long a3 = 1L; ulong a4 = 1UL; double b1 = 1.1; float b2 = 1.1f; // 1.1F decimal b3 = 1.1m; // 1.1M // Отличия double от decimal double a = 0.1; double b = 0.2; decimal c = 0.1m; decimal d = 0.2m; Console.WriteLine($"a + b == 0.3? {a + b == 0.3}"); Console.WriteLine($"c + d == 0.3? {c + d == 0.3m}"); #endregion #region Про типы var x1 = new RefType { n = 1 }; var x2 = new ValueType { n = 1 }; RefMethod(x1); ValueMethod(x2); Console.WriteLine($"x1:{x1.n} x2:{x2.n}"); // В итоге у x1 поменялось значение, а у x2 - нет. #endregion #region ref и out ValueType x3 = x2; ValueMethodRef(ref x3); ValueMethodOut(out ValueType x4); Console.WriteLine($"x3:{x3.n} x4:{x4.n}"); // Что будет, есть в качестве ref-параметра передать ссылочный тип? RefMethodRef(x1); Console.WriteLine($"x1:{x1.n}"); RefMethodRef(ref x1); Console.WriteLine($"x1:{x1.n}"); #endregion #region is/as int a_is = 5; Console.WriteLine($"a is int: {a_is is int}; a is short: {a_is is short}; a is double: {a_is is double}; a is object: {a_is is object}"); object o = 5; int? a_as = o as int?; if (a_as != null) { Console.WriteLine($"a as int"); } else { Console.WriteLine($"a not as int"); } #endregion #region Pattern matching object ptn = 5; switch (ptn) { case int as_int: Console.WriteLine("As int"); break; case string as_string: Console.WriteLine("As string"); break; case object as_object: Console.WriteLine("As Object"); break; // Попробуем поменять кейсы местами } #endregion #region Контроль переполнения byte byteA = 200; byte byteB; try { byteB = checked ((byte)(2 * byteA)); //byteB = unchecked((byte)(2 * byteA)); //byteB = (byte)checked(2 * byteA); Console.WriteLine(byteB); } catch (Exception e) { Console.WriteLine(e.Message); } try { checked { byteB = checked ((byte)(2 * byteA)); Console.WriteLine(byteB); } } catch (Exception e) { Console.WriteLine(e.Message); } #endregion #region Про Nullable int?nullable_a = 42; Console.WriteLine(nullable_a?.ToString()); // Метод применяется, если объект не null int?null_a = null; int x_from_null = null_a ?? nullable_a ?? 5; // как тренарный оператор только про null Console.WriteLine($"x={x_from_null}"); #endregion #region Про перечисления Color color = Color.Blue; Console.WriteLine(color); color = (Color)Enum.Parse(typeof(Color), "Red"); Console.WriteLine(color); color = (Color)Enum.Parse(typeof(Color), "0"); Console.WriteLine(color); Permission permission = Permission.Move | Permission.Write; Console.WriteLine(permission.ToString()); #endregion }
List <Value> CoerceValuesToSingleType(List <Runtime.Object> parametersIn) { ValueType valType = ValueType.Int; ListValue specialCaseList = null; // Find out what the output type is // "higher level" types infect both so that binary operations // use the same type on both sides. e.g. binary operation of // int and float causes the int to be casted to a float. foreach (var obj in parametersIn) { var val = (Value)obj; if (val.valueType > valType) { valType = val.valueType; } if (val.valueType == ValueType.List) { specialCaseList = val as ListValue; } } // Coerce to this chosen type var parametersOut = new List <Value> (); // Special case: Coercing to Ints to Lists // We have to do it early when we have both parameters // to hand - so that we can make use of the List's origin if (valType == ValueType.List) { foreach (Value val in parametersIn) { if (val.valueType == ValueType.List) { parametersOut.Add(val); } else if (val.valueType == ValueType.Int) { int intVal = (int)val.valueObject; var list = specialCaseList.value.originOfMaxItem; InkListItem item; if (list.TryGetItemWithValue(intVal, out item)) { var castedValue = new ListValue(item, intVal); parametersOut.Add(castedValue); } else { throw new StoryException("Could not find List item with the value " + intVal + " in " + list.name); } } else { throw new StoryException("Cannot mix Lists and " + val.valueType + " values in this operation"); } } } // Normal Coercing (with standard casting) else { foreach (Value val in parametersIn) { var castedValue = val.Cast(valType); parametersOut.Add(castedValue); } } return(parametersOut); }
public PlayerPrefsEntry(string key, int value) { this.key = key; this.value = value; this.Type = ValueType.Int; }
static void ValueMethod(ValueType x) { x.n += 1; }
public abstract Value Cast(ValueType newType);
public static void RunTopFunction(VirtualMachine vm) { #if DEBUG_TRACE var debugSb = new StringBuilder(); #endif var bytes = vm.chunk.bytes.buffer; var memory = vm.memory; var codeIndex = vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex; var baseStackIndex = vm.callFrameStack.buffer[vm.callFrameStack.count - 1].baseStackIndex; while (true) { #if DEBUG_TRACE debugSb.Clear(); vm.memory = memory; VirtualMachineHelper.TraceStack(vm, debugSb); vm.chunk.DisassembleInstruction(codeIndex, debugSb); System.Console.WriteLine(debugSb); #endif var nextInstruction = (Instruction)bytes[codeIndex++]; switch (nextInstruction) { case Instruction.Halt: --vm.callFrameStack.count; vm.memory = memory; return; case Instruction.Call: { baseStackIndex = memory.stackCount - bytes[codeIndex++]; var functionIndex = memory.values[baseStackIndex - 1].asInt; vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex = codeIndex; codeIndex = vm.chunk.functions.buffer[functionIndex].codeIndex; vm.callFrameStack.PushBackUnchecked( new CallFrame( codeIndex, baseStackIndex, (ushort)functionIndex, CallFrame.Type.Function ) ); break; } case Instruction.CallNative: { var stackTop = memory.stackCount - bytes[codeIndex++]; var functionIndex = memory.values[stackTop - 1].asInt; var function = vm.chunk.nativeFunctions.buffer[functionIndex]; vm.memory = memory; vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex = codeIndex; vm.callFrameStack.PushBackUnchecked( new CallFrame( 0, stackTop, (ushort)functionIndex, CallFrame.Type.NativeFunction ) ); try { function.callback(vm, stackTop); } catch (System.Exception e) { vm.Error(string.Format("{0}\nnative stack trace:\n{1}", e.Message, e.StackTrace)); return; } memory = vm.memory; var dstIdx = --stackTop; var srcIdx = memory.stackCount - function.returnSize; while (srcIdx < memory.stackCount) { memory.values[dstIdx++] = memory.values[srcIdx++]; } memory.stackCount = stackTop + function.returnSize; --vm.callFrameStack.count; break; } case Instruction.Return: { var size = bytes[codeIndex++]; var dstIdx = --baseStackIndex; var srcIdx = memory.stackCount - size; while (srcIdx < memory.stackCount) { memory.values[dstIdx++] = memory.values[srcIdx++]; } memory.stackCount = baseStackIndex + size; --vm.callFrameStack.count; codeIndex = vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex; baseStackIndex = vm.callFrameStack.buffer[vm.callFrameStack.count - 1].baseStackIndex; break; } case Instruction.Print: { var type = ValueType.Read( bytes[codeIndex++], bytes[codeIndex++], bytes[codeIndex++], bytes[codeIndex++] ); var sb = new StringBuilder(); var size = type.GetSize(vm.chunk); VirtualMachineHelper.ValueToString( vm, memory.stackCount - size, type, sb ); memory.stackCount -= size; System.Console.WriteLine(sb); break; } case Instruction.Pop: --memory.stackCount; break; case Instruction.PopMultiple: memory.stackCount -= bytes[codeIndex++]; break; case Instruction.Move: { var sizeUnderMove = bytes[codeIndex++]; var sizeToMove = bytes[codeIndex++]; var srcIdx = memory.stackCount - sizeToMove; var dstIdx = srcIdx - sizeUnderMove; while (srcIdx < memory.stackCount) { memory.values[dstIdx++] = memory.values[srcIdx++]; } memory.stackCount = dstIdx; } break; case Instruction.LoadUnit: memory.PushBackStack(new ValueData()); break; case Instruction.LoadFalse: memory.PushBackStack(new ValueData(false)); break; case Instruction.LoadTrue: memory.PushBackStack(new ValueData(true)); break; case Instruction.LoadLiteral: { var index = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); memory.PushBackStack(vm.chunk.literalData.buffer[index]); break; } case Instruction.LoadFunction: case Instruction.LoadNativeFunction: { var index = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); memory.PushBackStack(new ValueData(index)); break; } case Instruction.SetLocal: { var index = baseStackIndex + bytes[codeIndex++]; memory.values[index] = memory.values[--memory.stackCount]; break; } case Instruction.LoadLocal: { var index = baseStackIndex + bytes[codeIndex++]; memory.PushBackStack(memory.values[index]); break; } case Instruction.SetLocalMultiple: { var dstIdx = baseStackIndex + bytes[codeIndex++]; var endIndex = memory.stackCount; memory.stackCount -= bytes[codeIndex++]; var srcIdx = memory.stackCount; while (srcIdx < endIndex) { memory.values[dstIdx++] = memory.values[srcIdx++]; } break; } case Instruction.LoadLocalMultiple: { var srcIdx = baseStackIndex + bytes[codeIndex++]; var dstIdx = memory.stackCount; memory.GrowStack(bytes[codeIndex++]); while (dstIdx < memory.stackCount) { memory.values[dstIdx++] = memory.values[srcIdx++]; } break; } case Instruction.IncrementLocalInt: { var index = baseStackIndex + bytes[codeIndex++]; ++memory.values[index].asInt; break; } case Instruction.IntToFloat: memory.values[memory.stackCount - 1] = new ValueData((float)memory.values[memory.stackCount - 1].asInt); break; case Instruction.FloatToInt: memory.values[memory.stackCount - 1] = new ValueData((int)memory.values[memory.stackCount - 1].asFloat); break; case Instruction.CreateArrayFromStack: { var elementSize = bytes[codeIndex++]; var arrayLength = bytes[codeIndex++]; var arraySize = elementSize * arrayLength; memory.GrowHeap(arraySize + 1); var headAddress = memory.heapStart; memory.stackCount -= arraySize; memory.values[headAddress++] = new ValueData(arrayLength); for (var i = 0; i < arraySize; i++) { memory.values[headAddress + i] = memory.values[memory.stackCount + i]; } memory.values[memory.stackCount++] = new ValueData(headAddress); break; } case Instruction.CreateArrayFromDefault: { var elementSize = bytes[codeIndex++]; var arrayLength = memory.values[--memory.stackCount].asInt; if (arrayLength < 0) { vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex = codeIndex; vm.Error("Negative array length"); vm.memory = memory; return; } var arraySize = elementSize * arrayLength; memory.GrowHeap(arraySize + 1); var headAddress = memory.heapStart; memory.stackCount -= elementSize; memory.values[headAddress++] = new ValueData(arrayLength); for (var i = 0; i < arraySize; i += elementSize) { for (var j = 0; j < elementSize; j++) { memory.values[headAddress + i + j] = memory.values[memory.stackCount + j]; } } memory.values[memory.stackCount++] = new ValueData(headAddress); break; } case Instruction.LoadArrayLength: memory.values[memory.stackCount - 1] = memory.values[memory.values[memory.stackCount - 1].asInt - 1]; break; case Instruction.SetArrayElement: { var elementSize = bytes[codeIndex++]; var fieldSize = bytes[codeIndex++]; var offset = bytes[codeIndex++]; memory.stackCount -= fieldSize; var stackStartIndex = memory.stackCount; var index = memory.values[--memory.stackCount].asInt; var heapStartIndex = memory.values[--memory.stackCount].asInt; var length = memory.values[heapStartIndex - 1].asInt; if (index < 0 || index >= length) { vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex = codeIndex; vm.Error(string.Format("Index out of bounds. Index: {0}. Array length: {1}", index, length)); vm.memory = memory; return; } heapStartIndex += index * elementSize + offset; for (var i = 0; i < fieldSize; i++) { memory.values[heapStartIndex + i] = memory.values[stackStartIndex + i]; } break; } case Instruction.LoadArrayElement: { var elementSize = bytes[codeIndex++]; var fieldSize = bytes[codeIndex++]; var offset = bytes[codeIndex++]; var index = memory.values[--memory.stackCount].asInt; var heapStartIndex = memory.values[--memory.stackCount].asInt; var length = memory.values[heapStartIndex - 1].asInt; if (index < 0 || index >= length) { vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex = codeIndex; vm.Error(string.Format("Index out of bounds. Index: {0}. Array length: {1}", index, length)); vm.memory = memory; return; } heapStartIndex += index * elementSize + offset; var stackStartIndex = memory.stackCount; memory.GrowStack(fieldSize); for (var i = 0; i < fieldSize; i++) { memory.values[stackStartIndex + i] = memory.values[heapStartIndex + i]; } break; } case Instruction.CreateStackReference: { var index = baseStackIndex + bytes[codeIndex++]; memory.PushBackStack(new ValueData(index)); break; } case Instruction.CreateArrayElementReference: { var elementSize = bytes[codeIndex++]; var arrayIndexOffset = elementSize * memory.values[--memory.stackCount].asInt; var index = memory.values[--memory.stackCount].asInt + arrayIndexOffset + bytes[codeIndex++]; memory.PushBackStack(new ValueData(index)); break; } case Instruction.SetReference: { var dstIdx = baseStackIndex + bytes[codeIndex++]; dstIdx = memory.values[dstIdx].asInt + bytes[codeIndex++]; var endIndex = memory.stackCount; memory.stackCount -= bytes[codeIndex++]; var srcIdx = memory.stackCount; while (srcIdx < endIndex) { memory.values[dstIdx++] = memory.values[srcIdx++]; } break; } case Instruction.LoadReference: { var srcIdx = baseStackIndex + bytes[codeIndex++]; srcIdx = memory.values[srcIdx].asInt + bytes[codeIndex++]; var dstIdx = memory.stackCount; memory.GrowStack(bytes[codeIndex++]); while (dstIdx < memory.stackCount) { memory.values[dstIdx++] = memory.values[srcIdx++]; } break; } case Instruction.NegateInt: memory.values[memory.stackCount - 1].asInt = -memory.values[memory.stackCount - 1].asInt; break; case Instruction.NegateFloat: memory.values[memory.stackCount - 1].asFloat = -memory.values[memory.stackCount - 1].asFloat; break; case Instruction.AddInt: memory.values[memory.stackCount - 2].asInt += memory.values[--memory.stackCount].asInt; break; case Instruction.AddFloat: memory.values[memory.stackCount - 2].asFloat += memory.values[--memory.stackCount].asFloat; break; case Instruction.SubtractInt: memory.values[memory.stackCount - 2].asInt -= memory.values[--memory.stackCount].asInt; break; case Instruction.SubtractFloat: memory.values[memory.stackCount - 2].asFloat -= memory.values[--memory.stackCount].asFloat; break; case Instruction.MultiplyInt: memory.values[memory.stackCount - 2].asInt *= memory.values[--memory.stackCount].asInt; break; case Instruction.MultiplyFloat: memory.values[memory.stackCount - 2].asFloat *= memory.values[--memory.stackCount].asFloat; break; case Instruction.DivideInt: memory.values[memory.stackCount - 2].asInt /= memory.values[--memory.stackCount].asInt; break; case Instruction.DivideFloat: memory.values[memory.stackCount - 2].asFloat /= memory.values[--memory.stackCount].asFloat; break; case Instruction.Not: memory.values[memory.stackCount - 1].asBool = !memory.values[memory.stackCount - 1].asBool; break; case Instruction.EqualBool: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asBool == memory.values[--memory.stackCount].asBool)); break; case Instruction.EqualInt: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asInt == memory.values[--memory.stackCount].asInt)); break; case Instruction.EqualFloat: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asFloat == memory.values[--memory.stackCount].asFloat)); break; case Instruction.EqualString: memory.PushBackStack(new ValueData( (vm.nativeObjects.buffer[memory.values[--memory.stackCount].asInt] as string).Equals( vm.nativeObjects.buffer[memory.values[--memory.stackCount].asInt] as string) )); break; case Instruction.GreaterInt: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asInt < memory.values[--memory.stackCount].asInt)); break; case Instruction.GreaterFloat: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asFloat < memory.values[--memory.stackCount].asFloat)); break; case Instruction.LessInt: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asInt > memory.values[--memory.stackCount].asInt)); break; case Instruction.LessFloat: memory.PushBackStack(new ValueData(memory.values[--memory.stackCount].asFloat > memory.values[--memory.stackCount].asFloat)); break; case Instruction.JumpForward: { var offset = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); codeIndex += offset; break; } case Instruction.JumpBackward: { var offset = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); codeIndex -= offset; break; } case Instruction.JumpForwardIfFalse: { var offset = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); if (!memory.values[memory.stackCount - 1].asBool) { codeIndex += offset; } break; } case Instruction.JumpForwardIfTrue: { var offset = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); if (memory.values[memory.stackCount - 1].asBool) { codeIndex += offset; } break; } case Instruction.PopAndJumpForwardIfFalse: { var offset = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); if (!memory.values[--memory.stackCount].asBool) { codeIndex += offset; } break; } case Instruction.RepeatLoopCheck: { var index = baseStackIndex + bytes[codeIndex++]; var less = memory.values[index].asInt < memory.values[index + 1].asInt; memory.PushBackStack(new ValueData(less)); break; } case Instruction.DebugHook: if (vm.debugger.isSome) { vm.memory = memory; vm.callFrameStack.buffer[vm.callFrameStack.count - 1].codeIndex = codeIndex; vm.debugger.value.OnDebugHook(); } break; case Instruction.DebugPushFrame: vm.debugData.frameStack.PushBack(new DebugData.Frame( (ushort)vm.debugData.stackTypes.count, (ushort)vm.debugData.stackNames.count )); break; case Instruction.DebugPopFrame: { var frame = vm.debugData.frameStack.PopLast(); vm.debugData.stackTypes.count = frame.stackTypesBaseIndex; vm.debugData.stackNames.count = frame.stackNamesBaseIndex; } break; case Instruction.DebugPushType: { var type = ValueType.Read( bytes[codeIndex++], bytes[codeIndex++], bytes[codeIndex++], bytes[codeIndex++] ); vm.debugData.stackTypes.PushBack(type); break; } case Instruction.DebugPopTypeMultiple: vm.debugData.stackTypes.count -= bytes[codeIndex++]; break; case Instruction.DebugPushLocalVariableName: { var literalIndex = BytesHelper.BytesToUShort(bytes[codeIndex++], bytes[codeIndex++]); var stringIndex = vm.chunk.literalData.buffer[literalIndex].asInt; var name = vm.chunk.stringLiterals.buffer[stringIndex]; vm.debugData.stackNames.PushBack(name); break; } case Instruction.DebugPopLocalVariableNameMultiple: vm.debugData.stackNames.count -= bytes[codeIndex++]; break; default: break; } } }
public ValueExpression(object value, ValueType type) { Value = value; Type = type; }
public string GetDescription(ValueType value) { return(_descriptionByValue[value]); }
void ValueMethod.CopyTo(ValueType into) => ((Reference)into).Set(Get());
public Task <T> LoadAsync <T>(ValueType id, CancellationToken token = default(CancellationToken)) { var documentKey = Conventions.FindFullDocumentKeyFromNonStringIdentifier(id, typeof(T), false); return(LoadAsync <T>(documentKey, token)); }
private static bool BoxUnboxToQ(ValueType o) { return(Helper.Compare((byte?)o, Helper.Create(default(byte)))); }
void OnGUI() { GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField); boldNumberFieldStyle.font = EditorStyles.boldFont; GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle); boldToggleStyle.font = EditorStyles.boldFont; GUI.enabled = !waitTillPlistHasBeenWritten; //Toolbar EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false)); if (GUILayout.Button(new GUIContent("Sort " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { OnChangeSortModeClicked(); } if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false))) { GenericMenu options = new GenericMenu(); options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked); options.AddSeparator(""); options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked); options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked); options.DropDown(optionsRect); } GUILayout.FlexibleSpace(); if (Application.platform == RuntimePlatform.WindowsEditor) { string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?"; autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(20)); } if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { RefreshKeys(); } Rect r; if (Application.platform == RuntimePlatform.OSXEditor) { r = GUILayoutUtility.GetRect(16, 16); } else { r = GUILayoutUtility.GetRect(9, 16); } if (waitTillPlistHasBeenWritten) { Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D; GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t); } } EditorGUILayout.EndHorizontal(); GUI.enabled = !waitTillPlistHasBeenWritten; if (showNewEntryBox) { GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); { newKey = EditorGUILayout.TextField("Key", newKey); switch (selectedType) { default: case ValueType.String: newValueString = EditorGUILayout.TextField("Value", newValueString); break; case ValueType.Float: newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat); break; case ValueType.Int: newValueInt = EditorGUILayout.IntField("Value", newValueInt); break; } selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(1)); { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false))) { showNewEntryBox = false; } } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value."))) { if (!string.IsNullOrEmpty(newKey)) { switch (selectedType) { case ValueType.Int: PlayerPrefs.SetInt(newKey, newValueInt); ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt)); break; case ValueType.Float: PlayerPrefs.SetFloat(newKey, newValueFloat); ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat)); break; default: case ValueType.String: PlayerPrefs.SetString(newKey, newValueString); ppeList.Add(new PlayerPrefsEntry(newKey, newValueString)); break; } PlayerPrefs.Save(); } newKey = newValueString = ""; newValueInt = 0; newValueFloat = 0; GUIUtility.keyboardControl = 0; //move focus from textfield, else the text won't be cleared showNewEntryBox = false; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } GUILayout.Space(2); GUI.backgroundColor = Color.white; EditorGUI.indentLevel++; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); { EditorGUILayout.BeginVertical(); { for (int i = 0; i < ppeList.Count; i++) { if (ppeList[i].Value != null) { EditorGUILayout.BeginHorizontal(); { ppeList[i].IsSelected = GUILayout.Toggle(ppeList[i].IsSelected, new GUIContent(ppeList[i].Key, "Toggle selection."), ppeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MinWidth(40), GUILayout.MaxWidth(125), GUILayout.ExpandWidth(true)); GUIStyle numberFieldStyle = ppeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField; switch (ppeList[i].Type) { default: case ValueType.String: ppeList[i].Value = EditorGUILayout.TextField("", (string)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; case ValueType.Float: ppeList[i].Value = EditorGUILayout.FloatField("", (float)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; case ValueType.Int: ppeList[i].Value = EditorGUILayout.IntField("", (int)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; } GUI.enabled = ppeList[i].HasChanged && !waitTillPlistHasBeenWritten; if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false))) { ppeList[i].SaveChanges(); } if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false))) { ppeList[i].RevertChanges(); } GUI.enabled = !waitTillPlistHasBeenWritten; if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false))) { PlayerPrefs.DeleteKey(ppeList[i].Key); ppeList.Remove(ppeList[i]); PlayerPrefs.Save(); break; } } EditorGUILayout.EndHorizontal(); } } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); EditorGUI.indentLevel--; }
/// <summary> /// Tests whether two specified vectors are not equal. /// </summary> /// <param name="u">The left-hand vector.</param> /// <param name="v">The right-hand vector.</param> /// <returns><see langword="true"/> if the two vectors are not equal; otherwise, <see langword="false"/>.</returns> public static bool operator !=(Vector4D u, Vector4D v) { return(!ValueType.Equals(u, v)); }
static void ValueMethodRef(ref ValueType x) { x.n += 1; }
/// <summary> /// Converts a list of DataValues to a list of test values. /// </summary> private ValueType[] ToValueTypes(SortedDictionary<DateTime, DataValue> values) { if (values == null || values.Count == 0) { return null; } List<ValueType> serializedValues = new List<ValueType>(); foreach (DataValue dv in values.Values) { ValueType value = new ValueType(); value.Timestamp = FormatTimestamp(dv.SourceTimestamp); value.Value = FormatValue(dv.WrappedValue); value.Quality = FormatQuality(dv.StatusCode); value.Comment = dv.Comment; serializedValues.Add(value); } return serializedValues.ToArray(); }
public PlayerPrefsEntry(string key, string value) { this.key = key; this.value = value; this.Type = ValueType.String; }
public PlayerPrefsEntry(string key, float value) { this.key = key; this.value = value; this.Type = ValueType.Float; }
public PlayerPrefsEntry(string key, int value) { this.key = key; this.value = value; this.Type = ValueType.Integer; }
public PlayerPrefsEntry(string key, string value) { this.key = key; this.value = value; this.Type = ValueType.String; }
public void VisitBooleanNotExpr(bool a, ValueType expected) { var target = new TypeCheckingVisitor(); var aExpression = new ConstantExpr(a); var expr = new NotExpr(aExpression); var actual = target.Visit(expr, scope); Assert.AreEqual(expected, actual); }
private void InitialSetter(ValueType type, object list) { BuiltObject = (ItemList <Item>)list; }
public void VisitBinaryOperatorTest(object a, object b, Type expressionType, ValueType expectedType) { var target = new TypeCheckingVisitor(); var lhs = new ConstantExpr(a); var rhs = new ConstantExpr(b); var expression = (Expression)Activator.CreateInstance(expressionType, new object[] { lhs, rhs }); var method = typeof(TypeCheckingVisitor).GetMethods() .First(m => m.Name == "Visit" && m.GetParameters().ElementAt(0).ParameterType == expressionType); ValueType actual; try { actual = (ValueType)method.Invoke(target, new object[] { expression, scope }); } catch (TargetInvocationException ex) { throw ex.InnerException; } Assert.AreEqual(expectedType, actual); }
protected StoryException BadCastException(ValueType targetType) { return(new StoryException("Can't cast " + this.valueObject + " from " + this.valueType + " to " + targetType)); }
public static bool TryConvertToValueType(this System.Type type, out ValueType value) => systemTypeToValueType.Reference.TryGetValue(type, out value);
/// <summary> /// Converts a list of test values to a list of DataValues. /// </summary> private SortedDictionary<DateTime, DataValue> ToDataValues(ValueType[] values) { SortedDictionary<DateTime, DataValue> dvs = new SortedDictionary<DateTime, DataValue>(); if (values != null) { foreach (ValueType value in values) { DataValue dv = new DataValue(); dv.Value = ValidateValue(value.Value); dv.StatusCode = ValidateQuality(value.Quality); dv.SourceTimestamp = ValidateTimestamp(value.Timestamp); dv.Comment = value.Comment; dvs[dv.SourceTimestamp] = dv; } } return dvs; }
/// <summary> /// Tests whether two specified vectors are not equal. /// </summary> /// <param name="left">A <see cref="Vector4"/> instance.</param> /// <param name="right">A <see cref="Vector4"/> instance.</param> /// <returns><see langword="true"/> if the two vectors are not equal; otherwise, <see langword="false"/>.</returns> public static bool operator !=(Vector4 left, Vector4 right) { return(!ValueType.Equals(left, right)); }
void OnGUI() { GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField); boldNumberFieldStyle.font = EditorStyles.boldFont; GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle); boldToggleStyle.font = EditorStyles.boldFont; GUI.enabled = !waitTillPlistHasBeenWritten; //Toolbar EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false)); if (GUILayout.Button(new GUIContent("Sort " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { OnChangeSortModeClicked(); } if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false))) { GenericMenu options = new GenericMenu(); options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked); options.AddSeparator(""); options.AddItem(new GUIContent("Import..."), false, OnImport); options.AddItem(new GUIContent("Export Selected..."), false, OnExportSelected); options.AddItem(new GUIContent("Export All Entries"), false, OnExportAllClicked); options.AddSeparator(""); options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked); options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked); options.DropDown(optionsRect); } GUILayout.Space(5); //Searchfield Rect position = GUILayoutUtility.GetRect(50, 250, 10, 50,EditorStyles.toolbarTextField); position.width -= 16; position.x += 16; SearchString = GUI.TextField(position, SearchString, EditorStyles.toolbarTextField); position.x = position.x - 18; position.width = 20; if (GUI.Button(position, "", ToolbarSeachTextFieldPopup)) { GenericMenu options = new GenericMenu(); options.AddItem(new GUIContent("All"), SearchFilter == SearchFilterType.All, OnSearchAllClicked); options.AddItem(new GUIContent("Key"), SearchFilter == SearchFilterType.Key, OnSearchKeyClicked); options.AddItem(new GUIContent("Value (Strings only)"), SearchFilter == SearchFilterType.Value , OnSearchValueClicked); options.DropDown(position); } position = GUILayoutUtility.GetRect(10, 10, ToolbarSeachCancelButton); position.x -= 5; if (GUI.Button(position, "", ToolbarSeachCancelButton)) { SearchString = string.Empty; } GUILayout.FlexibleSpace(); if (Application.platform == RuntimePlatform.WindowsEditor) { string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?"; autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(75)); } if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { RefreshKeys(); } Rect r; if (Application.platform == RuntimePlatform.OSXEditor) r = GUILayoutUtility.GetRect(16, 16); else r = GUILayoutUtility.GetRect(9, 16); if (waitTillPlistHasBeenWritten) { Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D; GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t); } } EditorGUILayout.EndHorizontal(); GUI.enabled = !waitTillPlistHasBeenWritten; if (showNewEntryBox) { GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); { newKey = EditorGUILayout.TextField("Key", newKey); switch (selectedType) { default: case ValueType.String: newValueString = EditorGUILayout.TextField("Value", newValueString); break; case ValueType.Float: newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat); break; case ValueType.Integer: newValueInt = EditorGUILayout.IntField("Value", newValueInt); break; } selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(1)); { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false))) { showNewEntryBox = false; } } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value."))) { if (!string.IsNullOrEmpty(newKey)) { switch (selectedType) { case ValueType.Integer: PlayerPrefs.SetInt(newKey, newValueInt); ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt)); break; case ValueType.Float: PlayerPrefs.SetFloat(newKey, newValueFloat); ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat)); break; default: case ValueType.String: PlayerPrefs.SetString(newKey, newValueString); ppeList.Add(new PlayerPrefsEntry(newKey, newValueString)); break; } PlayerPrefs.Save(); } newKey = newValueString = ""; newValueInt = 0; newValueFloat = 0; GUIUtility.keyboardControl = 0; //move focus from textfield, else the text won't be cleared showNewEntryBox = false; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } GUILayout.Space(2); GUI.backgroundColor = Color.white; EditorGUI.indentLevel++; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); { EditorGUILayout.BeginVertical(); { for (int i = 0; i < filteredPpeList.Count; i++) { if (filteredPpeList[i].Value != null) { EditorGUILayout.BeginHorizontal(); { filteredPpeList[i].IsSelected = GUILayout.Toggle(filteredPpeList[i].IsSelected, new GUIContent("", "Toggle selection."), filteredPpeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MaxWidth(20), GUILayout.MinWidth(20), GUILayout.ExpandWidth(false)); filteredPpeList[i].Key = GUILayout.TextField(filteredPpeList[i].Key, filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField, GUILayout.MaxWidth(125), GUILayout.MinWidth(40), GUILayout.ExpandWidth(true)); GUIStyle numberFieldStyle = filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField; switch (filteredPpeList[i].Type) { default: case ValueType.String: filteredPpeList[i].Value = EditorGUILayout.TextField("", (string)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; case ValueType.Float: filteredPpeList[i].Value = EditorGUILayout.FloatField("", (float)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; case ValueType.Integer: filteredPpeList[i].Value = EditorGUILayout.IntField("", (int)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; } GUILayout.Label(new GUIContent("?", filteredPpeList[i].Type.ToString()), GUILayout.ExpandWidth(false)); GUI.enabled = filteredPpeList[i].HasChanged && !waitTillPlistHasBeenWritten; if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false))) { filteredPpeList[i].SaveChanges(); } if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false))) { filteredPpeList[i].RevertChanges(); } GUI.enabled = !waitTillPlistHasBeenWritten; if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false))) { PlayerPrefs.DeleteKey(filteredPpeList[i].Key); ppeList.Remove(filteredPpeList[i]); PlayerPrefs.Save(); UpdateFilteredList(); break; } } EditorGUILayout.EndHorizontal(); } } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); EditorGUI.indentLevel--; }
/// <summary> /// Tests whether two specified arcs are not equal. /// </summary> /// <param name="left">A <see cref="Arc"/> instance.</param> /// <param name="right">A <see cref="Arc"/> instance.</param> /// <returns><see langword="true"/> if the two segments are not equal; otherwise, <see langword="false"/>.</returns> public static bool operator !=(Arc left, Arc right) { return(!ValueType.Equals(left, right)); }
public PlayerPrefsEntry(string key, float value) { this.key = key; this.value = value; this.Type = ValueType.Float; }
/// <summary> /// Tests whether two specified spheres are not equal. /// </summary> /// <param name="a">The left-hand sphere.</param> /// <param name="b">The right-hand sphere.</param> /// <returns><see langword="true"/> if the two spheres are not equal; otherwise, <see langword="false"/>.</returns> public static bool operator!=(Sphere a, Sphere b) { return(!ValueType.Equals(a, b)); }
public void RetrieveValue() { Key = oldKey; if (PlayerPrefs.GetString(Key, UNIQUE_STRING) != UNIQUE_STRING) { Type = ValueType.String; value = PlayerPrefs.GetString(Key); } else if (PlayerPrefs.GetInt(Key, UNIQUE_INT) != UNIQUE_INT) { Type = ValueType.Integer; value = PlayerPrefs.GetInt(Key); } else if (PlayerPrefs.GetFloat(Key, UNIQUE_FLOAT) != UNIQUE_FLOAT) { Type = ValueType.Float; value = PlayerPrefs.GetFloat(Key); } oldKey = Key; //Don't mark the first set Value as changed HasChanged = false; }
public static bool IsCheckAgainstNull(this BinaryExpressionSyntax expression, out ExpressionSyntax target, out ValueType valueType) { var kind = expression.Kind(); if (kind == SyntaxKind.NotEqualsExpression || kind == SyntaxKind.EqualsExpression) { var leftKind = expression.Left.Kind(); var rightKind = expression.Right.Kind(); if (leftKind == SyntaxKind.NullLiteralExpression && rightKind != SyntaxKind.NullLiteralExpression) { target = expression.Right; valueType = kind == SyntaxKind.NotEqualsExpression ? ValueType.NotNull : ValueType.Null; return(true); } if (rightKind == SyntaxKind.NullLiteralExpression) { target = expression.Left; valueType = kind == SyntaxKind.NotEqualsExpression ? ValueType.NotNull : ValueType.Null; return(true); } } target = null; valueType = ValueType.MaybeNull; return(false); }
public void VisitConditionalExpr(bool condition, object thenValue, object elseValue, ValueType expected) { var target = new TypeCheckingVisitor(); var conditionExpression = new ConstantExpr(condition); var thenExpression = new ConstantExpr(thenValue); var elseExpression = new ConstantExpr(elseValue); var expr = new ConditionalExpr(conditionExpression, thenExpression, elseExpression); var actual = target.Visit(expr, scope); Assert.AreEqual(expected, actual); }
/// <summary> /// Checks if the two given circles are not equal. /// </summary> /// <param name="a">The first of two 2D circles to compare.</param> /// <param name="b">The second of two 2D circles to compare.</param> /// <returns><b>true</b> if the circles are not equal; otherwise, <b>false</b>.</returns> public static bool operator!=(Circle a, Circle b) { return(!ValueType.Equals(a, b)); }
public ulong BeginSequence(ValueType sequenceType) { var type = GetValueType(); if (type == sequenceType) { Reader.ReadUInt64(); return Reader.ReadUInt64(); } throw new BindingException(sequenceType, type); }
private static void Append(StreamWriter sw, ValueType arg) { sw.Write(arg); sw.Write(','); }
private static bool BoxUnboxToQ(ValueType o) { return Helper.Compare((NestedStructGen<int>?)o, Helper.Create(default(NestedStructGen<int>))); }
private static bool BoxUnboxToQ(ValueType o) { return(Helper.Compare((NotEmptyStructConstrainedGen <int>?)o, Helper.Create(default(NotEmptyStructConstrainedGen <int>)))); }