Esempio n. 1
0
 public StatHolder(int kills, int deaths, DoubleWrapper timeAlive, double maxTimeAlive, bool isAlive, int casualties)
 {
     this.kills        = kills;
     this.deaths       = deaths;
     this.timeAlive    = timeAlive;
     this.maxTimeAlive = maxTimeAlive;
     this.isAlive      = isAlive;
     this.casualties   = casualties;
 }
 public Task PutComplexPrimitiveDouble() => TestStatus(async(host, pipeline) =>
 {
     var value = new DoubleWrapper
     {
         Field1 = 3e-100D,
         Field56ZerosAfterTheDotAndNegativeZeroBeforeDotAndThisIsALongFieldNameOnPurpose = -0.000000000000000000000000000000000000000000000000000000005D
     };
     return(await new PrimitiveClient(ClientDiagnostics, pipeline, host).PutDoubleAsync(value));
 });
 public virtual Response PutDouble(DoubleWrapper complexBody, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("PrimitiveClient.PutDouble");
     scope.Start();
     try
     {
         return(RestClient.PutDouble(complexBody, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 public virtual async Task <Response> PutDoubleAsync(DoubleWrapper complexBody, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("PrimitiveClient.PutDouble");
     scope.Start();
     try
     {
         return(await RestClient.PutDoubleAsync(complexBody, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Esempio n. 5
0
        public void TestBasicSimplify()
        {
            var dims = new List <Dimension> {
                new Dimension("metre"), new Dimension("metre")
            };
            var value = new DoubleWrapper(10);
            List <Dimension> newDims = dims.Simplify(ref value);

            Assert.AreEqual(2, dims.Count);
            Assert.AreEqual(1, newDims.Count);
            Assert.AreEqual(10, value.Value);
            Assert.AreEqual(2, newDims[0].Power);
            Assert.AreEqual("metre", newDims[0].Unit.Name);
        }
Esempio n. 6
0
        public void TestDerivedSystemSimplify()
        {
            var dims = new List <Dimension> {
                new Dimension("metre"), new Dimension("second", -1)
            };
            var value = new DoubleWrapper(10);
            List <Dimension> newDims = dims.Simplify(ref value);

            Assert.AreEqual(2, dims.Count);
            Assert.AreEqual(1, newDims.Count);
            Assert.AreEqual(10, value.Value);
            Assert.AreEqual(1, newDims[0].Power);
            Assert.AreEqual("metrePerSecond", newDims[0].Unit.Key);
        }
        protected override void Invoke(object parameter)
        {
            var currentMargin = TargetElement.Margin;
            var targetMargin  = IsChecked ? CheckboxSelectedToMarginConverter.CheckedMargin : CheckboxSelectedToMarginConverter.UncheckedMargin;

            var globalTweenHandler = App.GlobalTweenHandler;

            globalTweenHandler.ClearTweensOf(TargetElement);

            var tweens = new List <Timeline>();

            var wrapper = new DoubleWrapper {
                Value = currentMargin.Left
            };

            tweens.Add(wrapper.Tween(x => x.Value).To(targetMargin.Left).In(Duration).Ease(Easing.ExpoEaseOut).OnUpdate((sender, objects) => { TargetElement.Margin = new Thickness(wrapper.Value, 0, 0, 0); }));

            globalTweenHandler.Add(tweens.ToSequenceWithTarget(TargetElement));
        }
        public void UpdateDerived()
        {
            Derived.Clear();
            if (string.IsNullOrEmpty(DerivedString))
            {
                return;
            }
            foreach (Match match in Regex.Matches(DerivedString, @"(^\w+|([\*|/])(\w+))"))
            {
                if (match.Success)
                {
                    string type;
                    string systemName;
                    if (!string.IsNullOrEmpty(match.Groups[3].Value))
                    {
                        type       = match.Groups[2].Value;
                        systemName = match.Groups[3].Value;
                    }
                    else
                    {
                        type       = "*";
                        systemName = match.Groups[1].Value;
                    }
                    if (systemName != "1")
                    {
                        Unit baseUnit = MeasurementCorpus.FindBaseUnit(systemName);
                        if (baseUnit == null)
                        {
                            throw new Exception("All derived entries must be the name of a dimension or the '1' placeholder");
                        }
                        if (type != "*" && type != "/")
                        {
                            throw new Exception("Derived divider is not valid - must be either '*' or '/'");
                        }
                        int power = (type == "*") ? 1 : -1;
                        Derived.Add(new Dimension(baseUnit, power));
                    }
                }
            }
            var computedValue = new DoubleWrapper(1);

            Derived = Derived.SimpleSimplify(ref computedValue);
        }
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task PutDoubleAsync(this IPrimitiveOperations operations, DoubleWrapper complexBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     await operations.PutDoubleWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false);
 }
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 public static void PutDouble(this IPrimitiveOperations operations, DoubleWrapper complexBody)
 {
     System.Threading.Tasks.Task.Factory.StartNew(s => ((IPrimitiveOperations)s).PutDoubleAsync(complexBody), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
Esempio n. 11
0
        public override void Execute(Database database, IProviderCollection providers)
        {
            double damping = 0.85;

            DatabaseDictionary <TableID, DoubleWrapper> ranks          = DictionaryFactory.CreateTableID <DoubleWrapper>();
            DatabaseDictionary <TableID, DoubleWrapper> rankCalculator = DictionaryFactory.CreateTableID <DoubleWrapper>();
            DatabaseDictionary <TableID, Table[]>       neighborMatrix = DictionaryFactory.CreateTableID <Table[]>();

            var initialRank = 1f / database.Tables.Count;

            foreach (var table in database.Tables)
            {
                ranks.Add(table, new DoubleWrapper {
                    Value = 1
                });
                var referencedBy = new List <Table>();
                foreach (var fkTable in table.ReferencedBy)
                {
                    foreach (var foreignKey in fkTable.ForeignKeys)
                    {
                        if (foreignKey.PKTable.Equals(table))
                        {
                            referencedBy.Add(fkTable);
                        }
                    }
                }
                neighborMatrix.Add(table, referencedBy.ToArray());
            }

            foreach (var tableID in ranks.Keys)
            {
                rankCalculator[tableID] = new DoubleWrapper {
                    Value = 0
                };
                ranks[tableID] = new DoubleWrapper {
                    Value = 0
                };
            }

            for (int i = 0; i < 100; i++)
            {
                double error = 0;
                foreach (var tableID in ranks.Keys)
                {
                    double value      = 0;
                    var    references = neighborMatrix[tableID];
                    foreach (var reference in references)
                    {
                        var referenceRank = ranks[reference];
                        value += referenceRank.Value / reference.ForeignKeys.Count;
                    }
                    double newRank;
                    rankCalculator[tableID].Value = newRank = value * damping + initialRank * (1 - damping);
                    error += Math.Abs(ranks[tableID].Value - newRank);
                }

                {
                    var tmp = rankCalculator;
                    rankCalculator = ranks;
                    ranks          = tmp;
                }

                if (error < 0.001)
                {
                    break;
                }
            }

            double sum = 0;

            foreach (var key in ranks.Keys)
            {
                sum += ranks[key].Value;
            }

            foreach (var key in ranks.Keys)
            {
                _ranks[key] = ranks[key].Value / sum * 100;
            }
        }
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 public static void PutDouble(this IPrimitiveOperations operations, DoubleWrapper complexBody)
 {
     Task.Factory.StartNew(s => ((IPrimitiveOperations)s).PutDoubleAsync(complexBody), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
Esempio n. 13
0
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task PutDoubleAsync(this IPrimitive operations, DoubleWrapper complexBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     await operations.PutDoubleWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false);
 }
Esempio n. 14
0
 public static void Save(IValueSink sink, DoubleWrapper value)
 {
     Value <double> .Save(sink, value.Item);
 }
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 public static void PutDouble(this IPrimitive operations, DoubleWrapper complexBody)
 {
     operations.PutDoubleAsync(complexBody).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PutDoubleAsync(this IPrimitiveOperations operations, DoubleWrapper complexBody, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.PutDoubleWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false);
 }
 /// <summary>
 /// Put complex types with double properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 3e-100 and
 /// -0.000000000000000000000000000000000000000000000000000000005
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PutDoubleAsync(this IPrimitive operations, DoubleWrapper complexBody, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.PutDoubleWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Esempio n. 18
0
 public static void Save(IValueSink sink, DoubleWrapper value)
 {
     Value<double>.Save(sink, value.Item);
 }