当前位置: 首页>>代码示例>>C#>>正文


C# StringComparer类代码示例

本文整理汇总了C#中StringComparer的典型用法代码示例。如果您正苦于以下问题:C# StringComparer类的具体用法?C# StringComparer怎么用?C# StringComparer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringComparer类属于命名空间,在下文中一共展示了StringComparer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EACodeLanguage

        /// <summary>
        /// Creates a new Event Assembler code language
        /// </summary>
        /// <param name="name">Name of the language</param>
        /// <param name="pointerMaker">Pointer maker for this language</param>
        /// <param name="pointerList">Pointer list of this langauge, String is the name of the 
        /// label to point to, List are the priorities that are pointed to.</param>
        /// <param name="pointerListParameters">Array of amount of pointers per POIN code for pointer list.</param>
        public EACodeLanguage(string name, IPointerMaker pointerMaker,
            Tuple<string, List<Priority>>[][] pointerList,
            ICodeTemplateStorer codeStorer, StringComparer stringComparer)
        {
            this.name = name;
            this.codeStorage = codeStorer;

            //codeStorage.AddCode(new RawCodeTemplate(stringComparer), Priority.low);
            //codeStorage.AddCode(new CodeFillerTemplate(stringComparer), Priority.low);

            foreach (ICodeTemplate template in codeStorer)
            {
                CodeTemplate template2 = template as CodeTemplate;
                if (template2 != null)
                {
                    template2.PointerMaker = pointerMaker;
                }
            }

            reservedWords = new List<string> {
                offsetChanger,  //Offset changing code
                alignOffset,    //Offset aligning code
                currentOffset,  //Referances current offset
                messagePrinter, //Print message to message box/something
                errorPrinter,   //Print message to message box/something
                warningPrinter  //Print message to message box/something
            };

            this.assembler = new EAExpressionAssembler(codeStorage, null);

            this.disassembler = new EACodeLanguageDisassembler(
                codeStorage, pointerMaker, pointerList);
        }
开发者ID:Diegoisawesome,项目名称:AwesomeMapEditor-old,代码行数:41,代码来源:EACodeLanguage.cs

示例2: CopyOnWriteHashtable

        /// <summary>
        /// Construct over an IDictionary instance.
        /// </summary>
        /// <param name="dictionary"></param>
        /// <param name="stringComparer">The string comparer to use.</param>
        internal CopyOnWriteHashtable(IDictionary dictionary, StringComparer stringComparer)
        {
            ErrorUtilities.VerifyThrowArgumentNull(dictionary, "dictionary");
            ErrorUtilities.VerifyThrowArgumentNull(stringComparer, "stringComparer");

            this.sharedLock = new object();
            CopyOnWriteHashtable source = dictionary as CopyOnWriteHashtable;
            if (source != null)
            {
                if (source.stringComparer.GetHashCode() == stringComparer.GetHashCode())
                {
                    // If we're copying another CopyOnWriteHashtable then we can defer the clone until later.
                    ConstructFrom(source);
                    return;
                }
                else
                {
                    // Technically, it would be legal to fall through here and let a new hashtable be constructed.
                    // However, Engine is supposed to use consistent case comparisons everywhere and so, for us,
                    // this means a bug in the engine code somewhere.
                    throw new InternalErrorException("Bug: Changing the case-sensitiveness of a copied hash-table.");
                }

            }

            // Can't defer this because we don't control what gets written to the dictionary exogenously.
            writeableData = new Hashtable(dictionary, stringComparer);
            readonlyData = null;
            this.stringComparer = stringComparer;
        }
开发者ID:nikson,项目名称:msbuild,代码行数:35,代码来源:CopyOnWriteHashtable.cs

示例3: Choose

        public static ParserResult<object> Choose(
            Func<IEnumerable<string>, IEnumerable<OptionSpecification>, Result<IEnumerable<Token>, Error>> tokenizer,
            IEnumerable<Type> types,
            IEnumerable<string> arguments,
            StringComparer nameComparer,
            CultureInfo parsingCulture,
            IEnumerable<ErrorType> nonFatalErrors)
        {
            Func<ParserResult<object>> choose = () =>
            {
                var firstArg = arguments.First();

                Func<string, bool> preprocCompare = command =>
                        nameComparer.Equals(command, firstArg) ||
                        nameComparer.Equals(string.Concat("--", command), firstArg);

                var verbs = Verb.SelectFromTypes(types);

                return preprocCompare("help")
                    ? MakeNotParsed(types,
                        MakeHelpVerbRequestedError(verbs,
                            arguments.Skip(1).SingleOrDefault() ?? string.Empty, nameComparer))
                    : preprocCompare("version")
                        ? MakeNotParsed(types, new VersionRequestedError())
                        : MatchVerb(tokenizer, verbs, arguments, nameComparer, parsingCulture, nonFatalErrors);
            };

            return arguments.Any()
                ? choose()
                : MakeNotParsed(types, new NoVerbSelectedError());
        }
开发者ID:Rusk85,项目名称:commandline,代码行数:31,代码来源:InstanceChooser.cs

示例4: NUnitTestAttributeName

		/// <summary>
		/// Creates a new instance of the NUnit Test Attribute class.
		/// </summary>
		/// <param name="name">The name of the attribute (e.g. Test) not
		/// the full name of the attribute (e.g. TestAttribute).</param>
		/// <param name="nameComparer">The string comparer to use
		/// when comparing attribute names.</param>
		public NUnitTestAttributeName(string name, StringComparer nameComparer)
		{
			this.name = name;
			this.nameComparer = nameComparer;
			qualifiedName = String.Concat(name, "Attribute");
			fullyQualifiedName = String.Concat("NUnit.Framework.", name, "Attribute");
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:14,代码来源:TestAttributeName.cs

示例5: Choose

        public static ParserResult<object> Choose(
            Func<IEnumerable<string>, IEnumerable<OptionSpecification>, StatePair<IEnumerable<Token>>> tokenizer,
            IEnumerable<Type> types,
            IEnumerable<string> arguments,
            StringComparer nameComparer,
            CultureInfo parsingCulture)
        {
            if (arguments.Empty())
            {
                return MakeNotParsed(types, new NoVerbSelectedError());
            }

            var firstArg = arguments.First();

            Func<string, bool> preprocCompare = command =>
                    nameComparer.Equals(command, firstArg) ||
                    nameComparer.Equals(string.Concat("--", command), firstArg);

            var verbs = Verb.SelectFromTypes(types);

            if (preprocCompare("help"))
            {
                return MakeNotParsed(types,
                    MakeHelpVerbRequestedError(verbs,
                        arguments.Skip(1).SingleOrDefault() ?? string.Empty, nameComparer));
            }

            if (preprocCompare("version"))
            {
                return MakeNotParsed(types, new VersionRequestedError());
            }

            return MatchVerb(tokenizer, verbs, arguments, nameComparer, parsingCulture);
        }
开发者ID:TeaDrivenDev,项目名称:commandline,代码行数:34,代码来源:InstanceChooser.cs

示例6: MapValues

 public static Result<IEnumerable<SpecificationProperty>, Error> MapValues(
     IEnumerable<SpecificationProperty> propertyTuples,
     IEnumerable<KeyValuePair<string, IEnumerable<string>>> options,
     Func<IEnumerable<string>, Type, bool, Maybe<object>> converter,
     StringComparer comparer)
 {
     var sequencesAndErrors = propertyTuples
         .Select(pt =>
             options.FirstOrDefault(
                     s =>
                     s.Key.MatchName(((OptionSpecification)pt.Specification).ShortName, ((OptionSpecification)pt.Specification).LongName, comparer))
                        .ToMaybe()
                        .MapValueOrDefault(sequence =>
                             converter(sequence.Value, pt.Property.PropertyType, pt.Specification.TargetType != TargetType.Sequence)
                             .MapValueOrDefault(converted =>
                                     Tuple.Create(
                                         pt.WithValue(Maybe.Just(converted)),
                                         Maybe.Nothing<Error>()),
                                     Tuple.Create<SpecificationProperty, Maybe<Error>>(
                                         pt,
                                         Maybe.Just<Error>(new BadFormatConversionError(((OptionSpecification)pt.Specification).FromOptionSpecification())))),
                         Tuple.Create(pt, Maybe.Nothing<Error>()))
         );
     return Result.Succeed(
         sequencesAndErrors.Select(se => se.Item1),
         sequencesAndErrors.Select(se => se.Item2).OfType<Just<Error>>().Select(se => se.Value));
 }
开发者ID:Thilas,项目名称:commandline,代码行数:27,代码来源:OptionMapper.cs

示例7: SisoEnvironment

 static SisoEnvironment()
 {
     Formatting = new SisoDbFormatting();
     StringConverter = new StringConverter(Formatting);
     StringComparer = StringComparer.InvariantCultureIgnoreCase;
     HashService = new Crc32HashService();
 }
开发者ID:mahizsas,项目名称:SisoDb-Provider,代码行数:7,代码来源:SisoEnvironment.cs

示例8: FieldDescriptor

        /// <summary>
        /// Initializes a new instance of the <see cref="FieldDescriptor" /> class.
        /// </summary>
        /// <param name="fieldInfo">The property information.</param>
        /// <param name="defaultNameComparer">The default name comparer.</param>
        /// <exception cref="System.ArgumentNullException">fieldInfo</exception>
        public FieldDescriptor(FieldInfo fieldInfo, StringComparer defaultNameComparer)
            : base(fieldInfo, defaultNameComparer)
        {
            if (fieldInfo == null) throw new ArgumentNullException("fieldInfo");

            this.fieldInfo = fieldInfo;
        }
开发者ID:mattrudder,项目名称:SharpYaml,代码行数:13,代码来源:FieldDescriptor.cs

示例9: FindNodes

        /// <summary>
        /// Gets all the node indices with matching names per the <paramref name="comparer" />.
        /// </summary>
        private IEnumerable<int> FindNodes(string name, StringComparer comparer)
        {
            // find any node that matches case-insensitively
            var startingPosition = BinarySearch(name);

            if (startingPosition != -1)
            {
                // yield if this matches by the actual given comparer
                if (comparer.Equals(name, _nodes[startingPosition].Name))
                {
                    yield return startingPosition;
                }

                int position = startingPosition;
                while (position > 0 && s_nodeSortComparer.Equals(_nodes[position - 1].Name, name))
                {
                    position--;

                    if (comparer.Equals(_nodes[position].Name, name))
                    {
                        yield return position;
                    }
                }

                position = startingPosition;
                while (position + 1 < _nodes.Count && s_nodeSortComparer.Equals(_nodes[position + 1].Name, name))
                {
                    position++;
                    if (comparer.Equals(_nodes[position].Name, name))
                    {
                        yield return position;
                    }
                }
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:38,代码来源:SymbolTreeInfo.cs

示例10: SortLines

		public void SortLines(IDocument document, int startLine, int endLine, StringComparer comparer, bool removeDuplicates)
		{
			List<string> lines = new List<string>();
			for (int i = startLine; i <= endLine; ++i) {
				IDocumentLine line = document.GetLine(i);
				lines.Add(document.GetText(line.Offset, line.Length));
			}
			
			lines.Sort(comparer);
			
			if (removeDuplicates) {
				lines = lines.Distinct(comparer).ToList();
			}
			
			using (document.OpenUndoGroup()) {
				for (int i = 0; i < lines.Count; ++i) {
					IDocumentLine line = document.GetLine(startLine + i);
					document.Replace(line.Offset, line.Length, lines[i]);
				}
				
				// remove removed duplicate lines
				for (int i = startLine + lines.Count; i <= endLine; ++i) {
					IDocumentLine line = document.GetLine(startLine + lines.Count);
					document.Remove(line.Offset, line.TotalLength);
				}
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:27,代码来源:SortSelectionCommand.cs

示例11: FindNodes

        /// <summary>
        /// Gets all the node indices with matching names.
        /// </summary>
        private IEnumerable<int> FindNodes(string name, StringComparer comparer)
        {
            // find any node that matches
            var position = BinarySearch(name, comparer);

            if (position != -1)
            {
                // back up to the first node that matches.
                var start = position;
                while (start > 0 && comparer.Compare(nodes[start - 1].Name, name) == 0)
                {
                    start--;
                }

                // yield the nodes we already know that match
                for (int i = start; i <= position; i++)
                {
                    yield return i;
                }

                // also yield any following nodes that might also match
                for (int i = position + 1; i < nodes.Count; i++)
                {
                    var node = nodes[i];
                    if (comparer.Compare(node.Name, name) == 0)
                    {
                        yield return i;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
开发者ID:nagyist,项目名称:roslyn,代码行数:38,代码来源:SymbolTreeInfo.cs

示例12: MapValues

         MapValues(
             IEnumerable<SpecificationProperty> propertyTuples,
             IEnumerable<KeyValuePair<string, IEnumerable<string>>> options,
             Func<IEnumerable<string>, System.Type, bool, Maybe<object>> converter,
             StringComparer comparer)
 {
     var sequencesAndErrors = propertyTuples
         .Select(pt =>
             options.SingleOrDefault(
                     s =>
                     s.Key.MatchName(((OptionSpecification)pt.Specification).ShortName, ((OptionSpecification)pt.Specification).LongName, comparer))
                        .ToMaybe()
                        .Return(sequence =>
                             converter(sequence.Value, pt.Property.PropertyType, pt.Specification.ConversionType.IsScalar())
                             .Return(converted =>
                                     Tuple.Create(
                                         pt.WithValue(Maybe.Just(converted)),
                                         Maybe.Nothing<Error>()),
                                     Tuple.Create<SpecificationProperty, Maybe<Error>>(
                                         pt,
                                         Maybe.Just<Error>(new BadFormatConversionError(NameInfo.FromOptionSpecification((OptionSpecification)pt.Specification))))),
                         Tuple.Create(pt, Maybe.Nothing<Error>()))
         );
     return StatePair.Create(
         sequencesAndErrors.Select(se => se.Item1),
         sequencesAndErrors.Select(se => se.Item2).OfType<Just<Error>>().Select(se => se.Value));
 }
开发者ID:BiYiTuan,项目名称:commandline,代码行数:27,代码来源:OptionMapper.cs

示例13: SearchFileForm

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public SearchFileForm()
        {
            InitializeComponent();

            // リストビューのソートに関する設定
            listViewFileNameSorter = new ListViewItemSorter();
            listViewFileNameSorter.Column = 2;
            listViewFileNameSorter.SortOrder = SortOrder.Ascending;
            IComparer<string> ignoreCaseComparer = new StringComparer(false);
            IComparer<string> ignoreCaseDirectoryComparer = new DirectoryComparer(false);
            listViewFileNameSorter.Comparers.Add(ignoreCaseComparer);
            listViewFileNameSorter.Comparers.Add(ignoreCaseComparer);
            listViewFileNameSorter.Comparers.Add(ignoreCaseDirectoryComparer);
            listViewFileName.ListViewItemSorter = listViewFileNameSorter;
            listViewFileName.SetHeaderSortArrowStyle(
                listViewFileNameSorter.Column,
                SelectHeaderSortArrows(listViewFileNameSorter.SortOrder));

            // 検索ディレクトリにシステムディレクトリのルートディレクトリを設定する
            string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);

            if (!string.IsNullOrEmpty(systemPath))
            {
                textDirectory.Text = Path.GetPathRoot(systemPath);
            }
        }
开发者ID:star-diopside,项目名称:SearchFile,代码行数:29,代码来源:SearchFileForm.cs

示例14: Lookup

 public static IEnumerable<Func<IEnumerable<string>, IEnumerable<Error>>> Lookup(StringComparer nameComparer)
 {
     return new List<Func<IEnumerable<string>, IEnumerable<Error>>>
         {
             HelpCommand(nameComparer)
         };
 }
开发者ID:danbowker,项目名称:commandline,代码行数:7,代码来源:PreprocessorGuards.cs

示例15: Contains

 public static NameLookupResult Contains(string name, IEnumerable<OptionSpecification> specifications, StringComparer comparer)
 {
     var option = specifications.FirstOrDefault(a => name.MatchName(a.ShortName, a.LongName, comparer));
     if (option == null) return NameLookupResult.NoOptionFound;
     return option.ConversionType == typeof(bool)
         ? NameLookupResult.BooleanOptionFound
         : NameLookupResult.OtherOptionFound;
 }
开发者ID:nayanshah,项目名称:commandline,代码行数:8,代码来源:NameLookup.cs


注:本文中的StringComparer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。