Ejemplo n.º 1
0
 private static void AssertStoredType(StoredValue value, StoredValueType required)
 {
     if (value.Type != required)
     {
         throw new InvalidOperationException($"This operation is supported with {required} types only");
     }
 }
Ejemplo n.º 2
0
        public StoredValue(object value, StoredValueType type, int?expirationSeconds)
        {
            Value = value;
            Type  = type;

            if (expirationSeconds.HasValue)
            {
                _expiration = DateTime.UtcNow.AddSeconds(expirationSeconds.Value);
            }
        }
Ejemplo n.º 3
0
 public StoredValue(object value, StoredValueType type)
 {
     Value = value;
     Type  = type;
 }
Ejemplo n.º 4
0
        public void DropNewThing(PolyType newShape, double newSize, System.Windows.Media.Color newColor, StoredValueType newValueType, int newValue = 0)
        {
            // Only drop within the center "square" area 
            double dropWidth = this.sceneRect.Bottom - this.sceneRect.Top;
            if (dropWidth > this.sceneRect.Right - this.sceneRect.Left)
            {
                dropWidth = this.sceneRect.Right - this.sceneRect.Left;
            }

            var newThing = new Thing
            {
                Size = newSize,
                YVelocity = ((0.5 * this.rnd.NextDouble()) - 0.25),
                XVelocity = ((0.5 * this.rnd.NextDouble()) - 0.25),
                Shape = newShape,
                Center = new System.Windows.Point(this.rnd.Next((int)this.sceneRect.Width), this.rnd.Next((int)this.sceneRect.Height)),
                SpinRate = ((this.rnd.NextDouble() * 12.0) - 6.0) * 2.0 * Math.PI / this.targetFrameRate / 4.0,
                Theta = 0,
                TimeLastHit = DateTime.MinValue,
                AvgTimeBetweenHits = 100,
                Color = newColor,
                Brush = null,
                Brush2 = null,
                BrushPulse = null,
                Dissolve = 0,
                State = ThingState.Falling,
                TouchedBy = 0,
                Hotness = 0,
                FlashCount = 0,
                ValueType = newValueType,
                Value = newValue
            };

            this.things.Add(newThing);
        }