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


C# IDictionary.ForEach方法代码示例

本文整理汇总了C#中IDictionary.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.ForEach方法的具体用法?C# IDictionary.ForEach怎么用?C# IDictionary.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDictionary的用法示例。


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

示例1: FindFirst

        /// <summary>
        /// Finds the first node that match the given XPath query.
        /// </summary>
        /// <param name="xPathExpression">The XPath expression to use to locate the first node</param>
        /// <param name="namespaces">A list of namespaces and prefixes with which to query</param>
        /// <returns></returns>
        public IXmlProcessorNode FindFirst(string xPathExpression, IDictionary<string, string> namespaces)
        {
            Guard.NotNullOrEmpty(() => xPathExpression, xPathExpression);
            Guard.NotNull(() => namespaces, namespaces);

            if (!IsDocumentLoaded())
            {
                throw new InvalidOperationException(Resources.XmlProcessor_ErrorLoadNotCalledFirst);
            }

            try
            {
                var nsManager = new XmlNamespaceManager(this.document.NameTable);
                namespaces.ForEach(ns => nsManager.AddNamespace(ns.Key, ns.Value));
                var node = this.document.SelectSingleNode(xPathExpression, nsManager);
                if (node != null)
                {
                    return new XmlProcessorNode(node);
                }

                return null;
            }
            catch (Exception ex)
            {
                throw new XPathException(
                    string.Format(CultureInfo.CurrentCulture, Resources.XmlProcessor_ErrorXPathSearchFailed, xPathExpression), ex);
            }
        }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:34,代码来源:XmlProcessor.cs

示例2: WriteJustifiedOutput

        protected virtual void WriteJustifiedOutput(IDictionary<string, string> lines, int padding)
        {
            if (lines.Any())
            {
                var totalPadding = lines.Max(l => l.Key.Length) + padding;

                lines.ForEach(a => WriteJustifiedItem(a.Key, a.Value, totalPadding));

                Output.WriteLine();
            }
        }
开发者ID:asbjornu,项目名称:args,代码行数:11,代码来源:ConsoleHelpFormatter.cs

示例3: ChomskyNormalFormTransformer

        private ChomskyNormalFormTransformer(Variable startVariable, IDictionary<Variable, ICollection<IEnumerable<Symbol>>> rules)
        {
            _rules = new Dictionary<Variable, ICollection<IEnumerable<Symbol>>>();
            rules.ForEach(p =>
            {
                _rules.Add(p.Key, new List<IEnumerable<Symbol>>());
                p.Value.ForEach(r => _rules[p.Key].Add(r));
            });

            _startVariable = GetNewVariableBasedOn(startVariable);
            AddRule(_startVariable, startVariable);
        }
开发者ID:oliverhanappi,项目名称:computation,代码行数:12,代码来源:ChomskyNormalFormTransformer.cs

示例4: TwitterOAuthClient

		public TwitterOAuthClient(TwitterToken token, string endpoint, IDictionary<string, object> param = null)
			: base(token.Application.ConsumerKey, token.Application.ConsumerSecret, token.TokenKey, token.TokenSecret)
		{
			this.endpoint = token.Endpoints[endpoint];

			var url = this.endpoint.Definition.Url;
			if (param != null) param.ForEach(kvp => url = url.Replace(kvp.Key, kvp.Value.ToString()));

			this.Url = url;
			this.MethodType = this.endpoint.Definition.MethodType == HttpMethod.Get
				? MethodType.Get
				: MethodType.Post;
		}
开发者ID:Grabacr07,项目名称:Mukyutter.Old,代码行数:13,代码来源:TwitterOAuthClient.cs

示例5: Begin

        public void Begin( string status, IDictionary<string, string> headers )
        {
            var builder = new DelimitedBuilder("\r\n");
            var headerBuilder = new HeaderBuilder( headers );

            builder.AppendFormat( "HTTP/1.1 {0}", status );

            headers.ForEach( x => builder.AppendFormat( "{0}: {1}", x.Key, x.Value ) );
            builder.Append( "\r\n" );
            var header = builder.ToString();
            var headerBuffer = Encoding.UTF8.GetBytes( header );
			PendingWrite.Reset();
            OnNext( new ArraySegment<byte>(headerBuffer), () => PendingWrite.Set() );
        }
开发者ID:code-attic,项目名称:hyperstack,代码行数:14,代码来源:ResponseWriter.cs

示例6: FFTText

 internal FFTText( Context context, IDictionary<Guid, ISerializableFile> files, IList<Glyph> customGlyphs, QuickEdit quickEdit )
 {
     this.customGlyphs = customGlyphs;
     Filetype = context;
     List<IFile> filesList = new List<IFile>( files.Count + 1 );
     files.ForEach( kvp => filesList.Add( kvp.Value ) );
     filesList.Sort( ( a, b ) => a.DisplayName.CompareTo( b.DisplayName ) );
     if (quickEdit != null)
     {
         filesList.Insert(0, quickEdit);
     }
     Files = filesList.AsReadOnly();
     CharMap = filesList[0].CharMap;
 }
开发者ID:Glain,项目名称:FFTPatcher,代码行数:14,代码来源:FFTText.cs

示例7: GetPsxCharMapPatches

        private IList<PatchedByteArray> GetPsxCharMapPatches( Stream iso, GenericCharMap baseCharmap, IDictionary<byte, string> dteInfo )
        {
            var dirEnt = DirectoryEntry.GetPsxDirectoryEntries( iso, PsxRootDirEntSector, 1 );

            var myDict = new Dictionary<int, string>( baseCharmap );
            dteInfo.ForEach( kvp => myDict[kvp.Key] = kvp.Value );

            System.Text.StringBuilder myString = new System.Text.StringBuilder();
            myString.AppendLine( CharmapHeader );
            myDict.ForEach( kvp => myString.AppendFormat( "{0:X4}\t{1}" + Environment.NewLine, kvp.Key, kvp.Value ) );
            var bytes = System.Text.Encoding.UTF8.GetBytes( myString.ToString() );

            var baseDirEntry = dirEnt.Find( d => d.Filename == "SCEAP.DAT;1" );
            var charmapDirEntry = new PatcherLib.Iso.DirectoryEntry(
                PsxCharmapSector, (uint)bytes.Length, DateTime.Now, baseDirEntry.GMTOffset,
                baseDirEntry.MiddleBytes, PsxCharmapFileName, baseDirEntry.ExtendedBytes );
            AddOrReplaceCharMapDirectoryEntry( dirEnt, charmapDirEntry );

            var dirEntPatches = PatcherLib.Iso.DirectoryEntry.GetPsxDirectoryEntryPatches(
                PsxRootDirEntSector, 1, dirEnt );
            dirEntPatches.Add( new PatchedByteArray( PsxCharmapSector, 0, bytes ) );
            return dirEntPatches;
        }
开发者ID:Glain,项目名称:FFTPatcher,代码行数:23,代码来源:FFTText.cs

示例8: GetPspCharMapPatches

        private IList<PatchedByteArray> GetPspCharMapPatches( Stream iso, GenericCharMap baseCharmap, IDictionary<byte, string> dteInfo )
        {
            var pspIsoInfo = PspIso.PspIsoInfo.GetPspIsoInfo( iso );
            var dirEnt = DirectoryEntry.GetPspDirectoryEntries( iso, pspIsoInfo, PspIso.Sectors.PSP_GAME_USRDIR, 1 );

            var currentEntry = dirEnt.Find( de => de.Filename == PspCharmapFileName );
            if (currentEntry != null)
            {
                dirEnt.Remove( currentEntry );
            }
            pspIsoInfo.RemoveFile( PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP );

            var myDict = new Dictionary<int, string>( baseCharmap );
            dteInfo.ForEach( kvp => myDict[kvp.Key] = kvp.Value );

            System.Text.StringBuilder myString = new System.Text.StringBuilder();
            myString.AppendLine( CharmapHeader );
            myDict.ForEach( kvp => myString.AppendFormat( "{0:X4}\t{1}" + Environment.NewLine, kvp.Key, kvp.Value ) );
            var bytes = System.Text.Encoding.UTF8.GetBytes( myString.ToString() );

            int insertSector = FindSectorToInsertPspCharmap( pspIsoInfo, bytes.Length );
            if (insertSector == -1)
            {
                throw new InvalidOperationException();
            }

            pspIsoInfo.AddFile( PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP, insertSector, bytes.Length );

            var baseDirEntry = dirEnt.Find( d => d.Filename == "fftpack.bin" );
            var charmapDirEntry = new PatcherLib.Iso.DirectoryEntry(
                (uint)insertSector, (uint)bytes.Length, DateTime.Now, baseDirEntry.GMTOffset,
                baseDirEntry.MiddleBytes, PspCharmapFileName, baseDirEntry.ExtendedBytes );

            AddOrReplaceCharMapDirectoryEntry( dirEnt, charmapDirEntry );

            var dirEntPatches = PatcherLib.Iso.DirectoryEntry.GetPspDirectoryEntryPatches(
                (int)PspIso.Sectors.PSP_GAME_USRDIR, 1, dirEnt );
            dirEntPatches.Add( new PatchedByteArray( PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP, 0, bytes ) );

            return dirEntPatches;
        }
开发者ID:Glain,项目名称:FFTPatcher,代码行数:41,代码来源:FFTText.cs

示例9: WithEntries

 /// <inheritdoc />
 public IAndMemoryCacheBuilder WithEntries(IDictionary<object, object> entries)
 {
     entries.ForEach(e => this.WithEntry(e.Key, e.Value));
     return this;
 }
开发者ID:Cream2015,项目名称:MyTested.AspNetCore.Mvc,代码行数:6,代码来源:MemoryCacheBuilder.cs

示例10: update_contact

        public int update_contact(DBColumn search_column, string key, IDictionary<string, object> new_values)
        {
            var update = new UpdateCommand(configuration, null);

            update.Where = new BinaryExpression(new ColumnExpression(search_column), new ConstantExpression(key, search_column), BinaryOperationType.Equal);
            new_values.ForEach(item => { update.UpdateData[configuration.ColumnMap[item.Key]] = item.Value; });
            ContactListTransaction transaction = new ContactListTransaction();
            transaction.Add(update);
            return configuration.RunTransaction(transaction);
        }
开发者ID:gildas,项目名称:DialerNetAPIDemo,代码行数:10,代码来源:ContactList.cs

示例11: GetForm

 private static FormCollection GetForm(IDictionary<string, string> nameValues) {
     var form = new FormCollection();
     nameValues.ForEach(kvp => form.Add(kvp.Key, kvp.Value));
     return form;
 }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:5,代码来源:ConcurrencyTest.cs

示例12: insert_contact

        public int insert_contact(IDictionary<string, object> columns, string status = null)
        {
            var insert = new InsertCommand(configuration);

            columns.ForEach(item => { insert.Contact[configuration.ColumnMap[item.Key]] = item.Value; });
            if (!string.IsNullOrWhiteSpace(status)) { insert.Contact[ContactListConfiguration.Status] = status; }
            ContactListTransaction transaction = new ContactListTransaction();
            transaction.Add(insert);
            return configuration.RunTransaction(transaction);
        }
开发者ID:gildas,项目名称:DialerNetAPIDemo,代码行数:10,代码来源:ContactList.cs

示例13: WithEntries

 /// <inheritdoc />
 public IAndTempDataBuilder WithEntries(IDictionary<string, object> entries)
 {
     entries.ForEach(e => this.WithEntry(e.Key, e.Value));
     return this;
 }
开发者ID:Cream2015,项目名称:MyTested.AspNetCore.Mvc,代码行数:6,代码来源:TempDataBuilder.cs

示例14: GetDataObject

      public static void GetDataObject(Action<System.Net.WebClient> action,
                                       Uri uri,
                                       IWebClientCaller caller,
                                       IDictionary<string, string> queryParameters = null,
                                       IDictionary<string, string> headers = null)
      {
        NameValueCollection queryParams;
        if (queryParameters != null)
        {
          queryParams = new NameValueCollection(queryParameters.Count);
          queryParameters.ForEach(kvp => queryParams.Add(kvp.Key, kvp.Value));
        }
        else
        {
          queryParams = new NameValueCollection();
        }

        var headerParams = new WebHeaderCollection();
        if (headers != null)
          headers.ForEach(kvp => headerParams.Add(kvp.Key, kvp.Value));

        using (var client = new WebClientTimeouted(caller))
        {
          client.Headers = headerParams;
          client.QueryString = queryParams;
          action(client);
        }
      }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:28,代码来源:WebClient.cs

示例15: FFTText

 internal FFTText( Context context, IDictionary<Guid, ISerializableFile> files, QuickEdit quickEdit )
 {
     Filetype = context;
     List<IFile> filesList = new List<IFile>( files.Count + 1 );
     files.ForEach( kvp => filesList.Add( kvp.Value ) );
     filesList.Sort( ( a, b ) => a.DisplayName.CompareTo( b.DisplayName ) );
     filesList.Add( quickEdit );
     Files = filesList.AsReadOnly();
     CharMap = filesList[0].CharMap;
 }
开发者ID:Wi150nZ,项目名称:lioneditor,代码行数:10,代码来源:FFTText.cs


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