本文整理汇总了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);
}
}
示例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();
}
}
示例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);
}
示例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;
}
示例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() );
}
示例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;
}
示例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;
}
示例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;
}
示例9: WithEntries
/// <inheritdoc />
public IAndMemoryCacheBuilder WithEntries(IDictionary<object, object> entries)
{
entries.ForEach(e => this.WithEntry(e.Key, e.Value));
return this;
}
示例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);
}
示例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;
}
示例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);
}
示例13: WithEntries
/// <inheritdoc />
public IAndTempDataBuilder WithEntries(IDictionary<string, object> entries)
{
entries.ForEach(e => this.WithEntry(e.Key, e.Value));
return this;
}
示例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);
}
}
示例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;
}