public Card(Suit suit, Value value) { this.value = value; this.suit = suit; this.name = GetName(); this.owner = null; }
/// <summary> /// Creates a new mathematical constant with a particular symbol and value. /// </summary> /// <param name="Symbol">The symbol to associate with the mathematical constant</param> /// <param name="Value">The value to associate with the mathematical constant</param> public Constant(string Symbol, Value Value) { this.Symbol = Symbol; this.Value = Value; this.ID = Simplex.Math.Random.AlphaNumeric(100); this.Scope.Register(this); }
public Value Add(Value val1, Value val2) { IntegerValue intVal1 = (IntegerValue) val1; IntegerValue intVal2 = (IntegerValue) val2; return new IntegerValue(intVal1.value + intVal2.value); }
public override void Apply(ComputedStyle style,Value value){ // Get the border: BorderProperty border=GetBorder(style); if(value!=null && value.Type==ValueType.Text){ if(value.Text=="transparent"){ // Currently assume the default colour (black): // (Use #00000000 instead) value=null; } } // Apply the base colour: border.BaseColour=value; // Reset the border colour: border.ResetColour(); // Tell it a colour changed: border.ColourChanged(); }
public override void Apply(ComputedStyle style,Value value){ // E.g. relative, fixed. if(style.SetupTransform(value)){ if(value==null){ style.Transform.OriginPosition=PositionType.Relative; }else{ if(value.Text=="fixed"){ style.Transform.OriginPosition=PositionType.Fixed; }else if(value.Text=="absolute"){ style.Transform.OriginPosition=PositionType.Absolute; }else{ style.Transform.OriginPosition=PositionType.Relative; } } } style.RequestTransform(); }
public ArrayExplicit(CellAddr ulCa, CellAddr lrCa, Value[,] values) { this.ulCa = ulCa; this.lrCa = lrCa; this.values = values; this.cols = lrCa.col - ulCa.col + 1; this.rows = lrCa.row - ulCa.row + 1; }
public Value Add(Value val1, Value val2) { HeapValue heapVal1 = (HeapValue) val1; HeapValue heapVal2 = (HeapValue) val2; return new HeapValue(_content, heapVal1.size + heapVal2.size); }
public PluginProperty(PropertyInfo info, PluginPropertyAttribute attribute) { this.info = info; this.attribute = attribute; Type type = info.PropertyType; if (type.IsEnum) { AvailableValues = Enum.GetNames(type).Select(x => "\"" + x + "\""); } else if (type == typeof(bool)) { AvailableValues = new object[] { true, false }; } else { AvailableValues = Enumerable.Empty<object>(); } object rawDefault = attribute.DefaultValue; if (null == rawDefault) { if (type.IsValueType) { rawDefault = Activator.CreateInstance(type); } } defaultValue = new Value(rawDefault, true); }
private static bool Load(BinaryReader reader, out Value value) { List<KeyValuePair<Value, Value>> array; Value arrayKey; Value arrayValue; int count; ValueContent type; type = (ValueContent)reader.ReadInt32 (); switch (type) { case ValueContent.Boolean: value = reader.ReadBoolean () ? BooleanValue.True : BooleanValue.False; break; case ValueContent.Map: count = reader.ReadInt32 (); array = new List<KeyValuePair<Value, Value>> (count); while (count-- > 0) { if (!ValueAccessor.Load (reader, out arrayKey) || !ValueAccessor.Load (reader, out arrayValue)) { value = null; return false; } array.Add (new KeyValuePair<Value, Value> (arrayKey, arrayValue)); } value = array; break; case ValueContent.Number: value = reader.ReadDecimal (); break; case ValueContent.String: value = reader.ReadString (); break; case ValueContent.Void: value = VoidValue.Instance; break; default: value = null; return false; } return true; }
public override void Apply(ComputedStyle style,Value value){ // Get the background image: PowerUI.Css.BackgroundImage image=GetBackground(style); if(value==null){ image.SizeX=null; image.SizeY=null; }else if(value.Type==Css.ValueType.Text){ if(value.Text=="auto" || value.Text=="initial"){ // Same as the default: image.SizeX=null; image.SizeY=null; }else if(value.Text=="cover"){ // Same as 100% on both axis: image.SizeX=new Css.Value("100%",Css.ValueType.Percentage); image.SizeY=new Css.Value("100%",Css.ValueType.Percentage); } }else{ // It's a vector: image.SizeX=value[0]; image.SizeY=value[1]; } // Request a layout: image.RequestLayout(); }
public void MoveTouch(int id, float x, float y) { moveValues[0] = new Value(id, MovieID); moveValues[1] = new Value(x / Screen.width, MovieID); moveValues[2] = new Value(1 - y / Screen.height, MovieID); Invoke("root.Scaleform_moveTouch", moveValues, 3); }
public void WhenCardIsConstructedWithShortNotation(string shortNotation, Value expectedValue, Suit expectedSuit) { var card = new Card(shortNotation); Assert.That(card.Value, Is.EqualTo(expectedValue)); Assert.That(card.Suit, Is.EqualTo(expectedSuit)); }
public void Nils() { var val = new Value(); Assert.IsTrue( val.IsNil ); Assert.IsFalse( val.ToBool() ); Assert.AreEqual( LValueType.Nil, val.ValueType ); val.Set( true ); Assert.IsFalse( val.IsNil ); val.Set( Value.Nil ); Assert.IsTrue( val.IsNil ); val = new Value(); Assert.IsTrue( val.IsNil ); val = Value.Nil; Assert.IsTrue( val.IsNil ); val.Set( true ); Assert.IsFalse( val.IsNil ); val.SetNil(); Assert.IsTrue( val.IsNil ); }
protected override Value Operate(Value value1, Value value2) { if (value1.Type == ValType.Integer && value2.Type == ValType.Integer) { // 5 / 4; => Integer (1) if (value2.IntValue == 0) { // division by 0 throw new CompilerException(-1, 205); } return new Value(value1.IntValue/value2.IntValue, ValType.Integer); } else if (value1.TypeEquals(ValType.Double) && value2.TypeEquals(ValType.Double)) { // 1.423 / 2; => Float if (value2.DoubleValue == 0) { // division by 0 throw new CompilerException(-1, 205); } return new Value(value1.DoubleValue/value2.DoubleValue, ValType.Double); } else { throw new CompilerException(Line, 202, "/", value1.TypeString, value2.TypeString); } }
public override void Apply(ComputedStyle style,Value value){ // The new overlay colour: Color overlay=Color.white; if(value!=null){ overlay=value.ToColor(); } // Apply it: style.ColorOverlay=overlay; // Special case here - everything needs to be told! if(style.BGImage!=null){ style.BGImage.SetOverlayColour(overlay); } if(style.BGColour!=null){ style.BGColour.SetOverlayColour(overlay); } if(style.Border!=null){ style.Border.SetOverlayColour(overlay); } if(style.Text!=null){ style.Text.SetOverlayColour(overlay); } }
public override void Apply(ComputedStyle style,Value value){ if(style.SetupTransform(value)){ if(value==null){ style.Transform.Scale=Vector3.one; }else{ float x=1f; float y=1f; float z=1f; if(value[0]!=null){ x=value[0].Single; } if(value[1]!=null){ y=value[1].Single; } if(value[2]!=null){ z=value[2].Single; } style.Transform.Scale=new Vector3(x,y,z); } } style.RequestTransform(); }
public bool Render(IStore store, TextWriter output, out Value result) { bool halt; foreach (KeyValuePair<IEvaluator, INode> branch in this.branches) { if (branch.Key.Evaluate (store, output).AsBoolean) { store.Enter (); halt = branch.Value.Render (store, output, out result); store.Leave (); return halt; } } if (this.fallback != null) { store.Enter (); halt = this.fallback.Render (store, output, out result); store.Leave (); return halt; } result = VoidValue.Instance; return false; }
protected internal override Value VisitValue(Value value) { if (value == null) return null; var unresolvedValue = value as UnresolvedValue; if (unresolvedValue == null) return value; if (value.Type is CapnpReference) throw new Exception("unexpected reference in value"); //if (value.Type == CapnpPrimitive.Void) //{ // if (unresolvedValue.RawData == "void") return value; // throw new Exception("invalid Void value: " + unresolvedValue.RawData); //} var genericType = value.Type as CapnpGenericType; if (genericType != null && genericType.IsGeneric) throw new InvalidOperationException("cannot parse unresolved value with open generic type"); if (value.Type is CapnpGenericParameter) throw new InvalidOperationException("cannot parse an unresolved value for a generic parameter"); // todo: double check no const refs here? return CapnpParser.ParseValue(unresolvedValue.RawData, value.Type); // < todo relative positioning for errors yadida }
public Card(Value value, Suit suit) { if (value < (Value)6) value = (Value)6; if (value > Value.A) value = Value.A; this.value = value; this.suit = suit; }
public bool LessThan(Value other) { if (other is IntValue == false) return false; IntValue typed_other = (IntValue)other; return value < typed_other.value; }
void addKey(Value value) { }
public override void Apply(ComputedStyle style,Value value){ // Get the border: BorderProperty border=GetBorder(style); if(value==null){ border.WidthTop=border.WidthLeft=0; border.WidthRight=border.WidthBottom=0; }else{ border.WidthTop=value.GetPX(0); border.WidthRight=value.GetPX(1); border.WidthBottom=value.GetPX(2); border.WidthLeft=value.GetPX(3); } // Does the border have any corners? If so, we need to update them: if(border.Corners!=null){ border.Corners.Recompute(); } // Request a layout: border.RequestLayout(); // Set the styles size: style.SetSize(); }
public override void Apply(ComputedStyle style,Value value){ // Get the border: BorderProperty border=GetBorder(style); if(value==null){ // No corners: border.Corners=null; }else{ // Apply top left: border.SetCorner(RoundCornerPosition.TopLeft,value.GetPX(0)); // Apply top right: border.SetCorner(RoundCornerPosition.TopRight,value.GetPX(1)); // Apply bottom right: border.SetCorner(RoundCornerPosition.BottomLeft,value.GetPX(2)); // Apply bottom left: border.SetCorner(RoundCornerPosition.BottomRight,value.GetPX(3)); } // Request a layout: border.RequestLayout(); }
/// <summary>Retrieve the body off the argument</summary> internal static List<DelimiterList> ExtractBody(Value arg) { Map map = arg.AsMap; if (map == null || !map.ContainsKey(keyBody)) return null; return map[keyBody].AsLine; }
public AmbiguousDataContainer(Value value, string name) { this.value = value; this.entityOrComponentName = name; value.AddHandler<ScopeChanged>(OnScopeChanged); }
protected GeglBWProcessor(Gegl.Node _gegl) : base() { gegl = _gegl; SList children = gegl.Children; load = mixer = contrast = tint = null; foreach (Node c in children) { string op = c.Operation; if (op == "load") load = c; else if (op == "mono-mixer") mixer = c; else if (op == "contrast-curve") contrast = c; else if (op == "tint") tint = c; } if (load == null || mixer == null || contrast == null || tint == null) throw new ApplicationException("not all nodes found"); Value val = new Value(Gegl.Curve.GType); contrastCurve = (GLib.Object)contrast.GetProperty("curve", ref val) as Gegl.Curve; }
/// <summary> /// Internal constructor, must only be called by Sheet.CreateCell /// </summary> public Cell (Sheet sheet, int col, int row) { Sheet = sheet; Col = col; Row = row; val = DefaultValue; }
public Value Invoke(Value objectVar, List<Value> parameters) { if (parameters.Count == parameterNames.Count) { // create new scope for the method call var methodScope = new Scope(); methodScope.Define("this"); methodScope.Assign("this", objectVar); for (int i = 0; i < parameterNames.Count; i++) { methodScope.Define(parameterNames[i]); methodScope.Assign(parameterNames[i], parameters[i]); } var nodeStream = new CommonTreeNodeStream(functionBody); // Create a tree walker to evaluate this method's code block var walker = new SGLTreeWalker(nodeStream, methodScope); Value returnValue = null; // Ok, executing the function then returnValue = walker.main().Evaluate(); // we shouldn't check the return type /*if (!returnValue.GetVarType().Equals(this.returnType)) { throw new Exception("The method doesn't return the expected return type (" + returnValue.ToString() + " is not from type " + this.returnType + ")"); }*/ return returnValue; } throw new CompilerException(definedLine, 318, name, parameterNames.Count.ToString(), parameters.Count.ToString()); }
public ThisDataContainer(Value value) { this.value = value; Entity = value.Entity; value.AddHandler<ScopeChanged>(OnScopeChanged); }
public Card(int input) { integerValue = input; int tempValue = input % 13; int tempSuit = input / 13; switch (tempValue) { case 0: value = Value.ACE; break; case 1: value = Value.TWO; break; case 2: value = Value.THREE; break; case 3: value = Value.FOUR; break; case 4: value = Value.FIVE; break; case 5: value = Value.SIX; break; case 6: value = Value.SEVEN; break; case 7: value = Value.EIGHT; break; case 8: value = Value.NINE; break; case 9: value = Value.TEN; break; case 10: value = Value.JACK; break; case 11: value = Value.QUEEN; break; case 12: value = Value.KING; break; } switch (tempSuit) { case 0: suit = Suit.SPADES; break; case 1: suit = Suit.HEARTS; break; case 2: suit = Suit.DIAMONDS; break; case 3: suit = Suit.CLUBS; break; } }
public DateTime ToDateTime(IFormatProvider provider) { return(Value.ToDateTime(provider)); }
protected override string GetValueAsString() { return(Value.ToString()); }
protected override string GetValueAsString() { return(Value == null ? DefaultValue.ToString() : Value.ToString()); }
// For hashing purpose /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override int GetHashCode() { return(IsNull ? 0 : Value.GetHashCode()); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "input"; output.TagMode = TagMode.StartTagOnly; output.Attributes.Add("type", "text"); output.Attributes.Add("name", Field.Name); Value = (Field.Model as DateTime?) ?? Value; output.Attributes.Add("value", Value?.ToString(DateTimeFormatDic[Type])); output.Attributes.Add("class", "layui-input"); if (Range.HasValue && Range.Value && string.IsNullOrEmpty(RangeSplit)) { RangeSplit = "~"; } if (!string.IsNullOrEmpty(Min)) { if (int.TryParse(Min, out int minRes)) { Min = minRes.ToString(); } else { Min = $"'{Min}'"; } } if (!string.IsNullOrEmpty(Max)) { if (int.TryParse(Max, out int maxRes)) { Max = maxRes.ToString(); } else { Max = $"'{Max}'"; } } var content = $@" <script> var laydate = layui.laydate; var ins1 = laydate.render({{ elem: '#{Id}', type: '{Type.ToString().ToLower()}' {(string.IsNullOrEmpty(RangeSplit) ? string.Empty : $",range:'{RangeSplit}'")} {(string.IsNullOrEmpty(Format) ? string.Empty : $",format: '{Format}'")} {(string.IsNullOrEmpty(Min) ? string.Empty : $",min: {Min}")} {(string.IsNullOrEmpty(Max) ? string.Empty : $",max: {Max}")} {(!ZIndex.HasValue ? string.Empty : $",zIndex: {ZIndex.Value}")} {(!ShowBottom.HasValue ? string.Empty : $",showBottom: {ShowBottom.Value.ToString().ToLower()}")} {(!Calendar.HasValue ? string.Empty : $",calendar: {Calendar.Value.ToString().ToLower()}")} {(!Lang.HasValue ? string.Empty : $",lang: '{Lang.Value.ToString().ToLower()}'")} {(Mark == null || Mark.Count == 0 ? string.Empty : $",mark: {JsonConvert.SerializeObject(Mark)}")} {(string.IsNullOrEmpty(ReadyFunc) ? string.Empty : $",ready: function(value){{{ReadyFunc}(value,ins1)}}")} {(string.IsNullOrEmpty(ChangeFunc) ? string.Empty : $",change: function(value,date,endDate){{{ChangeFunc}(value,date,endDate,ins1)}}")} {(string.IsNullOrEmpty(DoneFunc) ? string.Empty : $",done: function(value,date,endDate){{{DoneFunc}(value,date,endDate,ins1)}}")} //,theme: 'molv',btns: ['clear','now','confirm'] }}); </script> "; output.PostElement.AppendHtml(content); base.Process(context, output); }
public override string ToString() { return(Value.ToString().ToLower()); }
public TypeCode GetTypeCode() { return(Type.GetTypeCode(Value.GetType())); }
public char ToChar(IFormatProvider provider) { return(Value.ToChar(provider)); }
public short ToInt16(IFormatProvider provider) { return(Value.ToInt16(provider)); }
public bool ToBoolean(IFormatProvider provider) { return(Value.ToBoolean(provider)); }
public long ToInt64(IFormatProvider provider) { return(Value.ToInt64(provider)); }
public sbyte ToSByte(IFormatProvider provider) { return(Value.ToSByte(provider)); }
public double ToDouble(IFormatProvider provider) { return(Value.ToDouble(provider)); }
public int ToInt32(IFormatProvider provider) { return(Value.ToInt32(provider)); }
public string ToString(string str, IFormatProvider provider) { return(Value.ToString(str, provider)); }
public float ToSingle(IFormatProvider provider) { return(Value.ToSingle(provider)); }
public override int GetHashCode() { return(Value.GetHashCode()); }
public decimal ToDecimal(IFormatProvider provider) { return(Value.ToDecimal(provider)); }
} //getUserTweets public void updatePasswordUsingUDF() { Record userRecord = null; Key userKey = null; // Get username string username; Console.WriteLine("\nEnter username:"******"test", "users", username); userRecord = client.Get(null, userKey); if (userRecord != null) { // Get new password string password; Console.WriteLine("Enter new password for " + username + ":"); password = Console.ReadLine(); // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. // NOTE: The recommended way of registering UDFs in production env is via AQL string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "updateUserPwd.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); string updatedPassword = client.Execute(null, userKey, "updateUserPwd", "updatePassword", Value.Get(password)).ToString(); Console.WriteLine("\nINFO: The password has been set to: " + updatedPassword); } else { Console.WriteLine("ERROR: User record not found!"); } } else { Console.WriteLine("ERROR: User record not found!"); } } //updatePasswordUsingUDF
public object ToType(Type type, IFormatProvider provider) { return(Value.ToType(type, provider)); }
public static WeekNDay Load(IValueStream stream) { var temp = Value <byte[]> .Load(stream); return(new WeekNDay(temp)); }
void DrawValue(ICanvas canvas, NGraphics.Point center, double radius, NGraphics.Font font, NGraphics.Color textColor, double middleRadian) { var valueCenter = new NGraphics.Point(center.X, center.Y); DrawText(Value.ToString("N"), canvas, valueCenter, radius, font, textColor, middleRadian); }
/// <summary> Synchronously calls a function and returns its return value </summary> public static Value InvokeMethod(MethodInfo method, Value thisValue, Value[] args) { return(AsyncInvokeMethod(method, thisValue, args).EvaluateNow()); }
public static void Save(IValueSink sink, WeekNDay value) { Value <byte[]> .Save(sink, value.Item); }
protected override byte [] ValueToBytes() { return(Value.SelectMany(item => item.ToBytes()).ToArray()); }
public override BasicBlock code() { block = bb(); IRBuilder builder = new IRBuilder(block); Value alloc; Constant valLength = new Constant(Parser.context, 8, 50L); if (vars.Count == 0) { CompileException ex = new CompileException("Expected input variable"); ex.message = "INPUT statements require at least one input variable"; throw ex; } bool isNumeric = !(vars[0] is StringVariable); if (!isNumeric) { StringVariable var = (StringVariable)vars[0]; if (Parser.variables.strings.ContainsKey(var.name)) { alloc = Parser.variables.strings[var.name]; // already allocated } else { Parser.variables.strings[var.name] = builder.CreateAlloca(Parser.i8, valLength, var.name); // new allocation alloc = Parser.variables.strings[var.name]; // remember allocation } Parser.variables.stringIsPointer[var.name] = false; } else { if (vars[0] is SimpleNumericVariable) { SimpleNumericVariable var = (SimpleNumericVariable)vars[0]; if (Parser.variables.numbers.ContainsKey(var.name)) { alloc = Parser.variables.numbers[var.name]; } else { Parser.variables.numbers[var.name] = builder.CreateAlloca(Parser.dbl, var.name); alloc = Parser.variables.numbers[var.name]; } } else { NumericArrayElement var = (NumericArrayElement)vars[0]; alloc = Parser.variables.arrayItem(builder, var.numericarrayname, var.index.code(builder)); } } // Import scanf function LLVM.Type[] argTypes = isNumeric ? new LLVM.Type[] { Parser.i8p, Parser.dblp } : new LLVM.Type[] { Parser.i8p, Parser.i8p }; FunctionType stringToInt = new FunctionType(Parser.vd, argTypes); Constant scanf = Parser.module.GetOrInsertFunction("scanf", stringToInt); string formatString = isNumeric ? "%lf" : "%79s"; StringConstant format = new StringConstant(formatString); Value formatValue = format.code(builder); Value gep = builder.CreateGEP(alloc, Parser.zero, "gepTest"); Value[] args = { formatValue, gep }; Value hop = (Value)alloc; Value outputs = builder.CreateCall(scanf, args); return(block); }
public override int GetHashCode() { return(Value?.GetHashCode() ?? 0); }
/// <summary> Synchronously calls a function and returns its return value </summary> public static Value InvokeMethod(Process process, System.Type type, string name, Value thisValue, Value[] args) { return(InvokeMethod(MethodInfo.GetFromName(process, type, name, args.Length), thisValue, args)); }
public override string ToString() { return($"key:{Key.ToString()},value:{Value.ToString()}"); }
public ListMessageElement AddElements(params MessageElement [] elements) { Value.AddRange(elements); return(this); }