Ejemplo n.º 1
0
        public static Conference Build(int participantCount, int eventCount)
        {
            var topics = new ConferenceTopic[]
            {
                new ConferenceTopic {
                    ID                = Guid.NewGuid(),
                    Name              = "Is There a life on Mars?",
                    Description       = "We will discuss how aliens eat donuts with honey sitting at a marsian lake shore",
                    PlannedAttendance = 80,
                    IsPhysics         = true,
                    AttendanceHistory = new int[] { 24, 27, 39, 50, 75, 234, 200, 198, 245, 188, 120, 90, 80, 24, 24, 55, 23, 45, 33 }
                },
                new ConferenceTopic {
                    ID                = Guid.NewGuid(),
                    Name              = "Solder-Free Welding",
                    Description       = "Soldering with sugar syrop",
                    PlannedAttendance = 120,
                    IsBiology         = true
                },
                new ConferenceTopic {
                    ID                = Guid.NewGuid(),
                    Name              = "2+2=5",
                    Description       = "What do we know about logic?",
                    PlannedAttendance = 4000,
                    IsMathematics     = true,
                    AttendanceHistory = new int[] { 3000, 3245, 2343, 2344, 4332, 23434, 23434, 2343, 545, 2322, 3453, 2332, 2323, 3234 }
                },
                new ConferenceTopic {
                    ID                = Guid.NewGuid(),
                    Name              = "Growing Corn",
                    Description       = "Corn starches and calories?",
                    PlannedAttendance = 233,
                    IsBiology         = true
                }
            };

            var people = new Participant[participantCount];

            for (var i = 0; i < participantCount; i++)
            {
                people[i] = Participant.Build();
            }

            foreach (var person in people)
            {
                if (ExternalRandomGenerator.Instance.NextRandomInteger < 750000000)
                {
                    continue;
                }
                person.Relationships = new List <Relationship>();
                for (var i = 0; i < ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 4); i++)
                {
                    var friend = people.FirstOrDefault(p => p != person && p.Relationships == null);
                    person.Relationships.Add(new Relationship {
                        Other = friend, RelationshipName = "Good Friend #" + i.ToString()
                    });
                }
            }


            var confStartDate = DateTime.Now.AddDays(30);

            var events = new Event[eventCount];
            var sd     = confStartDate;

            for (var i = 0; i < eventCount; i++)
            {
                var evt = new Event();
                evt.ID           = Guid.NewGuid();
                evt.StartTime    = sd;
                evt.EndTime      = sd.AddMinutes(ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 480));
                sd               = evt.EndTime.AddMinutes(1);
                evt.Participants = new List <Participant>();
                for (var j = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, people.Length); j < people.Length; j++)
                {
                    evt.Participants.Add(people[j]);
                }

                evt.Topics = new List <ConferenceTopic>();
                for (var j = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, topics.Length); j < topics.Length; j++)
                {
                    evt.Topics.Add(topics[j]);
                }

                events[i] = evt;
            }



            var result = new Conference
            {
                ID        = Guid.NewGuid(),
                StartDate = confStartDate,
                Location  = Address.Build(),
                Events    = new List <Event>(events)
            };

            return(result);
        }
Ejemplo n.º 2
0
        public static Conference Build(int participantCount, int eventCount)
        {
            var topics = new ConferenceTopic[]
             {
            new ConferenceTopic{ ID = Guid.NewGuid(),
                                 Name = "Is There a life on Mars?",
                                 Description="We will discuss how aliens eat donuts with honey sitting at a marsian lake shore",
                                 PlannedAttendance = 80,
                                 IsPhysics = true,
                                 AttendanceHistory = new int[]{24, 27, 39, 50, 75, 234, 200, 198, 245, 188, 120, 90, 80, 24, 24, 55, 23, 45, 33} } ,
            new ConferenceTopic{ ID = Guid.NewGuid(),
                                 Name = "Solder-Free Welding",
                                 Description="Soldering with sugar syrop",
                                 PlannedAttendance = 120,
                                 IsBiology=true },
            new ConferenceTopic{ ID = Guid.NewGuid(),
                                 Name = "2+2=5",
                                 Description="What do we know about logic?",
                                 PlannedAttendance = 4000,
                                 IsMathematics=true,
                                 AttendanceHistory = new int[]{3000, 3245, 2343, 2344, 4332, 23434, 23434, 2343, 545, 2322, 3453, 2332, 2323, 3234}  },
            new ConferenceTopic{ ID = Guid.NewGuid(),
                                 Name = "Growing Corn",
                                 Description="Corn starches and calories?",
                                 PlannedAttendance = 233,
                                 IsBiology=true }
             };

             var people = new Participant[participantCount];
             for(var i=0; i<participantCount; i++) people[i] = Participant.Build();

             foreach(var person in people)
             {
               if (ExternalRandomGenerator.Instance.NextRandomInteger<750000000) continue;
               person.Relationships = new List<Relationship>();
               for (var i=0; i<ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 4); i++)
               {
             var friend = people.FirstOrDefault( p => p!=person && p.Relationships==null);
             person.Relationships.Add( new Relationship{ Other = friend, RelationshipName = "Good Friend #"+i.ToString()} );
               }
             }

             var confStartDate = DateTime.Now.AddDays(30);

             var events = new Event[eventCount];
             var sd = confStartDate;
             for(var i=0; i<eventCount; i++)
             {
               var evt = new Event();
               evt.ID = Guid.NewGuid();
               evt.StartTime = sd;
               evt.EndTime = sd.AddMinutes( ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 480));
               sd = evt.EndTime.AddMinutes( 1 );
               evt.Participants = new List<Participant>();
               for(var j=ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, people.Length); j<people.Length; j++)
            evt.Participants.Add( people[j] );

               evt.Topics = new List<ConferenceTopic>();
               for(var j=ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, topics.Length); j<topics.Length; j++)
            evt.Topics.Add( topics[j] );

               events[i] = evt;
             }

             var result = new Conference
             {
               ID = Guid.NewGuid(),
               StartDate = confStartDate,
               Location = Address.Build(),
               Events = new List<Event>(events)
             };
             return result;
        }