本文整理汇总了C#中System.Collections.Dictionary.AddOrReplace方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.AddOrReplace方法的具体用法?C# Dictionary.AddOrReplace怎么用?C# Dictionary.AddOrReplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.AddOrReplace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChildrenTypes
public Dictionary<Type, ISPNode> GetChildrenTypes(ISPNode parentNode)
{
IEnumerable<Lazy<SPNode>> importedNodes = CompositionProvider.GetExports<SPNode>(parentNode.Descriptor.ClassType);
var types = new Dictionary<Type, ISPNode>();
foreach (var lazyItem in importedNodes)
{
SPNode node = lazyItem.Value;
node.NodeProvider = parentNode.NodeProvider;
if (node.Descriptor.AdapterItemType != null)
{
types.AddOrReplace(node.Descriptor.AdapterItemType, node);
}
}
return types;
}
示例2: ProcessLabels
//.........这里部分代码省略.........
}
RemoveFromQueue = RemoveFromQueue || labels.Any( l => l.FileGuid == designatedLabelGuid );
}
else
{
labels.AddRange( selectedGroupTypes.Where( gt => gt.Labels != null )
.SelectMany( gt => gt.Labels )
.Where( l => ( !RemoveFromQueue || l.FileGuid != designatedLabelGuid ) )
);
// don't continue processing if printing all info on one label
break;
}
}
// Print client labels
if ( labels.Any( l => l.PrintFrom == PrintFrom.Client ) )
{
var clientLabels = labels.Where( l => l.PrintFrom == PrintFrom.Client ).ToList();
var urlRoot = string.Format( "{0}://{1}", Request.Url.Scheme, Request.Url.Authority );
clientLabels.ForEach( l => l.LabelFile = urlRoot + l.LabelFile );
AddLabelScript( clientLabels.ToJson() );
pnlContent.Update();
}
// Print server labels
if ( labels.Any( l => l.PrintFrom == PrintFrom.Server ) )
{
string delayCut = @"^XB";
string endingTag = @"^XZ";
var printerIp = string.Empty;
var labelContent = new StringBuilder();
// make sure labels have a valid ip
var lastLabel = labels.Last();
foreach ( var label in labels.Where( l => l.PrintFrom == PrintFrom.Server && !string.IsNullOrEmpty( l.PrinterAddress ) ) )
{
var labelCache = KioskLabel.Read( label.FileGuid );
if ( labelCache != null )
{
if ( printerIp != label.PrinterAddress )
{
printQueue.AddOrReplace( label.PrinterAddress, labelContent );
printerIp = label.PrinterAddress;
labelContent = new StringBuilder();
}
var printContent = labelCache.FileContent;
foreach ( var mergeField in label.MergeFields )
{
if ( !string.IsNullOrWhiteSpace( mergeField.Value ) )
{
printContent = Regex.Replace( printContent, string.Format( @"(?<=\^FD){0}(?=\^FS)", mergeField.Key ), ZebraFormatString( mergeField.Value ) );
}
else
{
printContent = Regex.Replace( printContent, string.Format( @"\^FO.*\^FS\s*(?=\^FT.*\^FD{0}\^FS)", mergeField.Key ), string.Empty );
printContent = Regex.Replace( printContent, string.Format( @"\^FD{0}\^FS", mergeField.Key ), "^FD^FS" );
}
}
// send a Delay Cut command at the end to prevent cutting intermediary labels
if ( label != lastLabel )
{
printContent = Regex.Replace( printContent.Trim(), @"\" + endingTag + @"$", delayCut + endingTag );
}
labelContent.Append( printContent );
}
}
printQueue.AddOrReplace( printerIp, labelContent );
if ( printQueue.Any() )
{
PrintLabels( printQueue );
printQueue.Clear();
}
else
{ // give the user feedback when no server labels are configured
phPrinterStatus.Controls.Add( new LiteralControl( "No labels were created. Please verify that the grouptype is configured with labels and cache is reset." ) );
}
}
if ( printIndividually || checkinArray.Count == 1 )
{
// reset selections to what they were before queue
selectedPeople.ForEach( p => p.Selected = p.PreSelected );
personSchedules.ForEach( s => s.Selected = s.PreSelected );
selectedGroupTypes.ForEach( gt => gt.Selected = gt.PreSelected );
availableGroups.ForEach( g => g.Selected = g.PreSelected );
availableLocations.ForEach( l => l.Selected = l.PreSelected );
availableSchedules.ForEach( s => s.Selected = s.PreSelected );
}
}
// refresh the currently checked in flag
BindGrid();
}