public FileConfigurationStore(IList<string> filePaths)
        {
            if (filePaths == null ||
                filePaths.Count == 0 ||
                !filePaths.All(c => !String.IsNullOrWhiteSpace(c)))
                throw new ArgumentNullException("filePaths", "The parameter filePaths cannot be empty or contains empty string");

            this.fileIniDataParser = new FileIniDataParser();
            this.fileIniDataParser.Parser.Configuration.CommentString = "#";
            this.filePaths = filePaths;
        }
        public PropertyChangeWatcher AddWatcher(IList<string> propertyNames, Action handler)
        {
            Contract.Requires(handler != null);
            Contract.Requires(propertyNames != null);
            Contract.Requires(propertyNames.Count > 0);
            Contract.Requires(propertyNames.AllUnique());
            Util.ThrowUnless(propertyNames.All(name => OwnerType.HasPublicInstanceProperty(name)), "The target object does not contain one or more of the properties provided");

            lock (_handlers)
            {
                foreach (var key in propertyNames)
                {
                    Util.ThrowUnless<ArgumentException>(!IsWatching(key), "Must not already be watching property '{0}'".DoFormat(key));
                }

                if (_handlers.Count == 0)
                {
                    _owner.PropertyChanged += _owner_PropertyChanged;
                }

                foreach (var propertyName in propertyNames)
                {
                    _handlers[propertyName] = handler;
                }
                return this;
            }
        }
Example #3
1
 internal static CompareResult Create(IList<StringDifferencePair> stringDifferenceEnumerable)
 {
     return Set(
         stringDifferenceEnumerable.All(sd => sd.Similar),
         stringDifferenceEnumerable
     );
 }
        private static void CleanOldFiles(IList<string> files, string referencesFile, string sourceFolder, bool needsExtending)
        {
            if (needsExtending)
            {
                files = files.Select(x => string.Format("{0}{1}", x, Program.NEEDS_EXTENDING_EXTENSION)).ToList();
            }

            var lines = File.ReadAllLines(referencesFile).ToList();
            var stringBuilder = new StringBuilder();

            var linesToRemove = lines
                .Where(x => IsAReferenceInFolderButNotSubfolder(x, sourceFolder) && files.All(y => y != GetFileName(x)))
                .ToList();

            foreach (var line in linesToRemove)
            {
                lines.Remove(line);
            }

            var linesToAdd = files
                .Where(x => lines.All(y => GetFileName(y) != x))
                .Select(x => string.Format("/// <reference path=\"{0}/{1}.ts\" />", sourceFolder.Replace('\\', '/'), x))
                .ToList();

            lines.AddRange(linesToAdd);

            if (linesToRemove.Any() || linesToAdd.Any()) {
                File.WriteAllLines(referencesFile, lines);
            }
        }
        public static IEnumerable<EntitySet> Convert(
            IList<EntitySet> sourceEntitySets,
            Version targetEntityFrameworkVersion,
            string providerInvariantName,
            string providerManifestToken,
            IDbDependencyResolver dependencyResolver)
        {
            Debug.Assert(sourceEntitySets != null, "sourceEntitySets != null");
            Debug.Assert(sourceEntitySets.All(e => e.DefiningQuery == null), "unexpected defining query");
            Debug.Assert(!string.IsNullOrWhiteSpace(providerInvariantName), "invalid providerInvariantName");
            Debug.Assert(!string.IsNullOrWhiteSpace(providerManifestToken), "invalid providerManifestToken");
            Debug.Assert(dependencyResolver != null, "dependencyResolver != null");

            if (!sourceEntitySets.Any())
            {
                // it's empty anyways
                return sourceEntitySets;
            }

            var providerServices = dependencyResolver.GetService<DbProviderServices>(providerInvariantName);
            Debug.Assert(providerServices != null, "providerServices != null");

            var transientWorkspace =
                CreateTransientMetadataWorkspace(
                    sourceEntitySets,
                    targetEntityFrameworkVersion,
                    providerInvariantName,
                    providerManifestToken,
                    providerServices.GetProviderManifest(providerManifestToken));

            return sourceEntitySets.Select(
                e => CloneWithDefiningQuery(
                    e,
                    CreateDefiningQuery(e, transientWorkspace, providerServices)));
        }
Example #6
1
 private static IEnumerable<Sim> Compare(Quest fromQuest, string[] fromRoute, IList<Quest> questDB)
 {
     DolRoute EL = new DolRoute();
     var simList = new List<Sim>();
     questDB.All(quest =>
     {
         if (quest.ID == fromQuest.ID)
             return true;
         if (quest.RouteForSim.Count != 0)
         {
             var min = quest.RouteForSim.Min(route =>
             {
                 if (route.Count < 2)
                     return 2001;
                 var value = EL.Compute(fromRoute, route.ToArray());
                 return value;
             });
             if (min < 2000)
             {
                 simList.Add(new Sim()
                 {
                     CompareID = quest.ID,
                     QuestID = fromQuest.ID,
                     Value = min,
                     StartCity = EL.GetCityID(fromRoute[0])
                 });
             }
         }
         return true;
     });
     return simList.OrderBy(sim => sim.Value).Take(300);
 }
 static void SlowButSureAssertCollected(IList<WeakReference> nextIterationHolder) {
     GC.GetTotalMemory(true);
     if(nextIterationHolder.All(wr => !wr.IsAlive))
         return;
     GC.Collect();
     if(nextIterationHolder.All(wr => !wr.IsAlive))
         return;
     GC.GetTotalMemory(true);
     var notCollected = nextIterationHolder.Select(wr => wr.Target).Where(t => t != null).ToArray();
     if(notCollected.Length == 0)
         return;
     var objectsReport = string.Join("\n", notCollected.GroupBy(o => o.GetType()).OrderBy(gr => gr.Key.FullName)
         .Select(gr => string.Format("\t{0} object(s) of type {1}:\n{2}", gr.Count(), gr.Key.FullName
             , string.Join("\n", gr.Select(o => o.ToString()).OrderBy(s => s).Select(s => string.Format("\t\t{0}", s)))
             )));
     throw new Exception(string.Format("{0} garbage object(s) not collected:\n{1}", notCollected.Length, objectsReport));
 }
        private bool ContainsRequiredHeaders(IList<string> headers)
        {
            var requiredHeaders = new List<string>();
            requiredHeaders.Add("header1");
            requiredHeaders.Add("header2");

            return headers.All(requiredHeaders.Contains) && headers.Count == requiredHeaders.Count;
        }
Example #9
1
 public bool ValidateBarcodes(IList<string> barcodes)
 {
     if (barcodes == null)
     {
         return false;
     }
     return barcodes.All(b => m_productRepository.GetByBarcodes(b).IsNotEmpty());
 }
        private static Language? TopScore(IList<AnalysisResult> source)
        {
            if (source.All(x => x.Score == 0))
            {
                return null;
            }

            return source?.Aggregate((l, r) => l.Score > r.Score ? l : r).Language;
        }
Example #11
1
        private static void LoadNextTheme(string currentThemeName, IList<Theme> allThemes)
        {
            if (allThemes.All(x => !x.Active)) return; // No active theme, so exit immediatly.

            var idx = GetCurrentThemeIndex(allThemes, currentThemeName);
            var themeToLoad = GetNextActiveTheme(allThemes, idx);

            ThemeLoader.LoadTheme(themeToLoad);
        }
Example #12
1
        protected static int HeightOf(IList<RectangularStep> upstream)
        {
            if (upstream == null || upstream.Count == 0) throw new ArgumentException();

            int height = upstream[0].Height;

            if (!upstream.All(step => step.Height == height)) throw new ArgumentException();

            return height;
        }
Example #13
1
        protected static int WidthOf(IList<RectangularStep> upstream)
        {
            if (upstream == null || upstream.Count == 0) throw new ArgumentException();

            int width = upstream[0].Width;

            if (!upstream.All(step => step.Width == width)) throw new ArgumentException();

            return width;
        }
Example #14
1
        public override double GetDiscountAmount(IList<BasketItem> items)
        {
            //If there is no bread, do not fuss
            if (items.All(i => i.ItemType != BasketItemType.Milk))
            {
                return 0.0;
            }

            return items.First(i => i.ItemType == BasketItemType.Milk).Price;
        }
        public string BuildMessage(IList<TeamCityModel> buildStatuses, out bool notify)
        {
            var success = buildStatuses.Count == _expectedBuildCount &&
                          buildStatuses.All(buildStatus => IsSuccesfullBuild(buildStatus.build));

            notify = !success;

            return success ? BuildSuccessMessage(buildStatuses.First().build) :
                             BuildFailureMessage(buildStatuses.Select(m => m.build).ToList());
        }
        public static void ListsEqual(IList<BrokenRule> expected, IList<BrokenRule> actual)
        {
            Assert.NotNull(expected);
            Assert.NotNull(actual);
            Assert.Equal(expected.Count, actual.Count);

            Assert.True(expected.All(
                    ex => actual.Any(act=> AreEqual(ex,act))
                ));
        }
        static ArgumentProcessor()
        {
            // Initialise the set of valid descriptors.
            // To add a new argument, just add it to the list.
            Descriptors = new List<ArgumentDescriptor>();

            Descriptors.Add(CmdLineArgPropertyProvider.Descriptor);

            Debug.Assert(Descriptors.All(d => d.Prefixes != null && d.Prefixes.Any()), "All descriptors must provide at least one prefix");
            Debug.Assert(Descriptors.Select(d => d.Id).Distinct().Count() == Descriptors.Count, "All descriptors must have a unique id");
        }
        /// <summary>
        /// Returns the submission status for an entire assignment.
        /// </summary>
        public static SubmissionStatus ForAssignment(
            IList<SubmissionStatus> questionStatus)
        {
            var completion = questionStatus.All(q => q.Completion == Completion.Completed)
                ? Completion.Completed
                : questionStatus.Any(q => q.Completion != Completion.NotStarted)
                    ? Completion.InProgress
                    : Completion.NotStarted;

            var late = questionStatus.Any(q => q.Late);

            return new SubmissionStatus(completion, late);
        }
        public override double GetDiscountAmount(IList<BasketItem> items)
        {
            //If there is no bread, do not fuss
            if (items.All(i => i.ItemType != BasketItemType.Bread))
            {
                return 0.0;
            }

            //We know that there is bread here;
            double breadPrice = items.First(i => i.ItemType == BasketItemType.Bread).Price;

            return breadPrice / 2;
        }
        public async Task<int> ThinkAsync(IList<char> gameBoard)
        {
            // Copy the contents of the IList to a string.
            char[] arrayTmp = new char[9];
            gameBoard.CopyTo(arrayTmp, 0);
            string board = new String(arrayTmp);

            // Frequently take the center square if the board is empty.
            System.Random random = new System.Random((int)System.DateTime.Now.Ticks);
            if (random.Next() % 2 == 0 && gameBoard.All<char>((ch) => ch == m_emptySymbol.Symbol))
            {
                return 4;
            }

            // Approximate counts of iterations the algorithm makes for each number of available moves at the root level.
            uint[] allIterations = { 0u, 2u, 5u, 15u, 50u, 200u, 930u, 7300u, 60000u, 550000u };
            var moves = MiniMax.AvailableMoves(board, m_emptySymbol.Symbol);
            uint totalIterations = allIterations[moves.Length - 1];

            // Report every 1%.
            uint nextReportIter = totalIterations / 100;
            uint iterBy = nextReportIter;

            // This is called on every iteration of the minimax algorithm.
            MiniMax.CallBackFn callback = /*[total_iterations, &next_report_iter, iter_by, reporter]*/(int iter_count) =>
            {
                if (iter_count == nextReportIter)
                {
                    double progress = 100.0 * iter_count / totalIterations;
                    //reporter.report(Math.Min(progress, 100.0));
                    nextReportIter += iterBy;
                }
            };

            // Run the minimax algorithm in parallel if there are enough iterations.
            // Otherwise, run it serially, as the overhead of parallelism may not benefit.
            int iterCount = 0;
            System.Tuple<int, int> t;
            //if (totalIterations > 500)
            //{
            //    t = parallel_minimax(board, m_symbol, m_opponentSymbol, m_emptySymbol, m_symbol, iterCount, callback);
            //}
            //else
            //{
            t = await MiniMax.Minimax(board, m_symbol.Symbol, m_opponentSymbol.Symbol, m_emptySymbol.Symbol, m_symbol.Symbol, iterCount, callback);
            //}

            // Return the index part.
            return t.Item1;
        }
Example #21
0
        /// <summary>Compares the two Lists of Transports and says if they are equal.</summary>
        /// <param name="transports1">first List of Transports</param>
        /// <param name="transports2">second List of Transports</param>
        /// <returns>
        ///     True if both lists are null or if both lists contain the same transport values
        /// </returns>
        public static bool ContainSameTransports(IList<SecurityKeyDataTransports> transports1,
            IList<SecurityKeyDataTransports> transports2)
        {
            if (transports1 == null && transports2 == null)
            {
                return true;
            }
            if (transports1 == null || transports2 == null)
            {
                return false;
            }

            return transports1.All(transports2.Contains) && transports2.All(transports1.Contains);
        }
        static ArgumentProcessor()
        {
            // Initialise the set of valid descriptors.
            // To add a new argument, just add it to the list.
            Descriptors = new List<ArgumentDescriptor>();

            Descriptors.Add(new ArgumentDescriptor(
                id: KeywordIds.AnalyzerRef, prefixes: new string[] { "/analyzer:", "/a:" }, required: true, allowMultiple: false, description: CmdLineResources.ArgDescription_AnalzyerRef));
            Descriptors.Add(new ArgumentDescriptor(
                id: KeywordIds.SqaleXmlFile, prefixes: new string[] { "/sqale:", "/s:" }, required: false, allowMultiple: false, description: CmdLineResources.ArgDescription_SqaleXmlFile));

            Debug.Assert(Descriptors.All(d => d.Prefixes != null && d.Prefixes.Any()), "All descriptors must provide at least one prefix");
            Debug.Assert(Descriptors.Select(d => d.Id).Distinct().Count() == Descriptors.Count, "All descriptors must have a unique id");
        }
Example #23
0
        public static bool Validieren(Schicht schicht, IList<Validierungsfehler> fehler, int okGrenzwert = int.MaxValue)
        {
            if (schicht == null) return false;
            if (schicht.GeldNachher < schicht.GeldVorher) fehler.Add(new Validierungsfehler { Meldung = "Schicht: nachher weniger Geld in der Kasse als vorher", Schwere = 1 });
            if (schicht.Trinkgeld < 0.0F) fehler.Add(new Validierungsfehler { Meldung = "Schicht: Trinkgeld negativ", Schwere = 1 });
            if (schicht.Abzaehlen < 0.0F) fehler.Add(new Validierungsfehler { Meldung = "Schicht: Abzählen negativ", Schwere = 1 });
            if (schicht.GeldNachher < schicht.GeldVorher) fehler.Add(new Validierungsfehler { Meldung = "Schicht: nachher weniger Geld in der Kasse als vorher", Schwere = 1 });
            if (schicht.Ende < schicht.Anfang) fehler.Add(new Validierungsfehler { Meldung = "Schicht: Ende liegt vor Anfang", Schwere = 0 });
            if (!schicht.Fahrzeuge.Any()) fehler.Add(new Validierungsfehler { Meldung = "Schicht: kein Fahrzeug", Schwere = 0 });
            if (!schicht.Fahrzeuge.All(p => p.Fahrten.Any())) fehler.Add(new Validierungsfehler { Meldung = "Fahrzeug: keine Fahrten", Schwere = 0 });
            if (schicht.Fahrzeuge.Any(p => p.Nummer == 0)) fehler.Add(new Validierungsfehler { Meldung = "Fahrzeug: Nummer ungültig", Schwere = 1 });
            if (Math.Round(schicht.Fahrzeuge.Sum(p => p.Preisdifferenz), 2) >= 0.01F) fehler.Add(new Validierungsfehler { Meldung = "Fahrzeug: Diff. zw. Uhr und Einzelfahrpreisen ist nicht 0.00 €", Schwere = 0 });

            return fehler.All(p => p.Schwere >= okGrenzwert);
        }
		public void ApplyUniverslaLinkSettings(IList<LibraryFileLink> targetLinks, LibraryFileLink templateLink = null)
		{
			foreach (var template in SettingsTemplates)
			{
				if (templateLink == null)
					templateLink = ParentFolder.AllLinks
						.FirstOrDefault(link => link.Type == template.FileType &&
						targetLinks.All(tl => tl != link));

				if (templateLink == null) continue;

				foreach (var targetLink in targetLinks)
					ApplyUniversalLinkSettings(template.SettingsType, targetLink, templateLink);
			}
		}
Example #25
0
 public List<KeyValuePair<int, Quest>> FindSim(Quest target, IList<Quest> questList)
 {
     var result=new SortedList<int, Quest>();
     questList.All(quest =>
     {
         var value = GetSimValue(target, quest);
         if (value == Int32.MaxValue)
             return true;
         while (result.ContainsKey(value) == true)
             value += 1;
         result.Add(value, quest);
         if (value == Int32.MinValue)
             return false;
         return true;
     });
     return result.OrderBy(x => x.Key).Take(10).ToList();
 }
        public void Put(IList<Telefone> telefones , int copId , Contexto ctx)
        {
            try
            {
                var tels = ctx.DbTelefone.Where(x => x.CoperativaId == copId).ToList();

                foreach (var telefone in tels.Where(telefone => telefones.All(x => x.Id != telefone.Id)))
                    ctx.DbTelefone.Remove(telefone);

                foreach (var telefone in telefones)
                    ctx.DbTelefone.AddOrUpdate(telefone);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #27
0
		protected ServiceProxyBase( object unavailableImpl, Type typeInterface, IList<MethodInfo> mRefs, IList<EventInfo> eRefs )
		{
            Debug.Assert( mRefs.All( r => r != null ) && mRefs.Distinct().SequenceEqual( mRefs ) );
            _typeInterface = typeInterface;
            _status = RunningStatus.Disabled;
            RawImpl = _unavailableImpl = unavailableImpl;
            _mRefs = new MEntry[mRefs.Count];
            for( int i = 0; i < mRefs.Count; i++ )
            {
                _mRefs[i].Method = mRefs[i];
            }
            _eRefs = new EEntry[eRefs.Count];
            for( int i = 0; i < eRefs.Count; i++ )
            {
                _eRefs[i].Event = eRefs[i];
            }
        }
Example #28
0
        public bool AreSolvable(IList<IList<Group>> groups)
        {
            var initial = groups[0];
            int ng = initial.Count;

            if (!groups.All(gr => gr.Count == ng))
                return false;

            for (int k = 1; k < groups.Count; k++)
            {
                var group = groups[k];
                for (int j = 0; j < ng; j++)
                    if (initial[j].Letter != group[j].Letter)
                        return false;
            }

            return true;
        }
        static ArgumentProcessor()
        {
            // Initialise the set of valid descriptors.
            // To add a new argument, just add it to the list.
            Descriptors = new List<ArgumentDescriptor>();

            Descriptors.Add(new ArgumentDescriptor(
                id: BeginId, prefixes: new string[] { BeginVerb }, required: false, allowMultiple: false, description: Resources.CmdLine_ArgDescription_Begin, isVerb: true));

            Descriptors.Add(new ArgumentDescriptor(
                id: EndId, prefixes: new string[] { EndVerb }, required: false, allowMultiple: false, description: Resources.CmdLine_ArgDescription_End, isVerb: true));

            Descriptors.Add(FilePropertyProvider.Descriptor);
            Descriptors.Add(CmdLineArgPropertyProvider.Descriptor);

            Debug.Assert(Descriptors.All(d => d.Prefixes != null && d.Prefixes.Any()), "All descriptors must provide at least one prefix");
            Debug.Assert(Descriptors.Select(d => d.Id).Distinct().Count() == Descriptors.Count, "All descriptors must have a unique id");
        }
		public void GetCombinedBaseTemplates(IItem item, IList<IItem> baseTemplates, IEnumerable<IItem> items)
		{
			if (item != null && baseTemplates.All(i => i.Id != item.Id))
			{
				baseTemplates.Add(item);

				var baseTemplateField = item.SharedFields.FirstOrDefault(i => IsBaseTemplateField(i.Id));

				if (baseTemplateField != null)
				{
					foreach (var value in baseTemplateField.Value.Split(StringSeparators, StringSplitOptions.None))
					{
						var baseTemplateItem = items.FirstOrDefault(i => IsIdEqual(i.Id, value));

						this.GetCombinedBaseTemplates(baseTemplateItem, baseTemplates, items);
					}
				}
			}
		}