Exemplo n.º 1
0
 public void Fill()
 {
     Books.AddRange(Filler.Fill().Books);
     Clients.AddRange(Filler.Fill().Clients);
     Suppliers.AddRange(Filler.Fill().Suppliers);
     Events.AddRange(Filler.Fill().Events);
 }
Exemplo n.º 2
0
        private static TimeSpan MeasureFill(IFiller filler, byte[] array, byte value)
        {
            // measure
            var elapsed = Measure(() => filler.Fill(array, value));

#if DEBUG
            // validate
            var equalityComparer = EqualityComparer <byte> .Default;
            for (var i = 0; i < array.Length; i++)
            {
                if (!equalityComparer.Equals(array[i], value))
                {
                    throw new Exception("Validation failed.");
                }
            }
#endif

            return(elapsed);
        }
        public ICollection <UserProfile> CreateProfiles(ICollection <ItemProfile> allItemProfiles, Shop shop)
        {
            ConcurrentBag <UserProfile> userProfiles = new ConcurrentBag <UserProfile>();
            int featuresNumber = GetFeaturesNumber(allItemProfiles.ToArray());
            var clients        = shop.Clients;

            Parallel.ForEach(clients, (client) =>
            {
                ICollection <ItemProfile> itemProfilesOfPurchasedProducts = SelectItemProfilesOfPurchasedProduct(allItemProfiles,
                                                                                                                 client.Orders);

                UserProfile userProfile = new UserProfile(client, itemProfilesOfPurchasedProducts, featuresNumber);

                userProfile.PreferencesMatrix = _matrixManager.Fill(itemProfilesOfPurchasedProducts,
                                                                    userProfile.PreferencesMatrix);

                userProfile.Preferences = SetUserPreferences(userProfile.PreferencesMatrix,
                                                             itemProfilesOfPurchasedProducts.Count, featuresNumber);

                userProfiles.Add(userProfile);
            });

            return(userProfiles.ToList());
        }
Exemplo n.º 4
0
 public DataRepository(IFiller filler)
 {
     _filler = filler;
     filler.Fill(_kontekstDanych);
 }