コード例 #1
0
            private double _prev = 0d;      // make sure that all access to this variable is threadsafe

            public ContainerTracker(IContainer container, LifeEventType? up, LifeEventType? down)
            {
                _container = container;
                _up = up;
                _down = down;
                _prev = container.QuantityCurrent;
            }
コード例 #2
0
            public static Tuple<LifeEventType, double> ExamineValue(double diff, double max, LifeEventType? up, LifeEventType? down)
            {
                const double TOLERANCEPERCENT = .01;

                // Don't report if the % change is too small
                if (Math.Abs(diff) < max * TOLERANCEPERCENT)
                {
                    return null;
                }

                // Report the direction and percent change
                if (diff > 0 && up != null)
                {
                    return Tuple.Create(up.Value, diff / max);
                }
                else if (diff < 0 && down != null)
                {
                    return Tuple.Create(down.Value, -diff / max);
                }

                return null;        // if execution gets here, the corresponding enum was null
            }
コード例 #3
0
ファイル: DbInitializer.cs プロジェクト: ryanjmurry/TruppEx
        public static void Initialize(TruppContext context)
        {
            context.Database.EnsureCreated();

            if (context.Employees.Any())
            {
                return;
            }

            var employees = new Employee[]
            {
                new Employee
                {
                    FullName = "Ricky Carmichael"
                },
                new Employee
                {
                    FullName = "Ryan Dungey"
                }
            };

            foreach (Employee e in employees)
            {
                context.Employees.Add(e);
            }
            context.SaveChanges();

            var lifeEventTypes = new LifeEventType[]
            {
                new LifeEventType
                {
                    Type = "Date of hire"
                },
                new LifeEventType
                {
                    Type = "Marriage"
                },
                new LifeEventType
                {
                    Type = "Birth/Adoption"
                },
                new LifeEventType
                {
                    Type = "Gain of other coverage"
                },
                new LifeEventType
                {
                    Type = "Loss of other coverage"
                }
            };

            foreach (LifeEventType let in lifeEventTypes)
            {
                context.LifeEventTypes.Add(let);
            }
            context.SaveChanges();

            var lifeEvents = new LifeEvent[]
            {
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Date of hire").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID,
                    EventDate       = DateTime.Parse("2008-07-04")
                },
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Marriage").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID,
                    EventDate       = DateTime.Parse("2010-04-12")
                },
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Gain of other coverage").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID,
                    EventDate       = DateTime.Parse("2011-01-01")
                },
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Date of hire").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ryan Dungey").EmployeeID,
                    EventDate       = DateTime.Parse("2015-08-10")
                },
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Birth/Adoption").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ryan Dungey").EmployeeID,
                    EventDate       = DateTime.Parse("2016-02-15")
                },
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Birth/Adoption").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ryan Dungey").EmployeeID,
                    EventDate       = DateTime.Parse("2017-11-30")
                },
                new LifeEvent
                {
                    LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Loss of other coverage").LifeEventTypeID,
                    EmployeeID      = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID,
                    EventDate       = DateTime.Parse("2018-06-05")
                }
            };

            foreach (LifeEvent le in lifeEvents)
            {
                context.Add(le);
            }
            context.SaveChanges();
        }
コード例 #4
0
 public LifeEventArgs(DateTime time, LifeEventType type, double strength)
 {
     this.Time = time;
     this.Type = type;
     this.Strength = strength;
 }
コード例 #5
0
 public LifeEventToVector(LifeEventWatcher watcher, LifeEventType[] types)
     : this(watcher, types.Select(o => Tuple.Create(o, 0d)).ToArray()) { }
コード例 #6
0
 public LifeEventArgs(DateTime time, LifeEventType type, double strength)
 {
     this.Time     = time;
     this.Type     = type;
     this.Strength = strength;
 }