本文整理汇总了C#中Dictionary.First方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.First方法的具体用法?C# Dictionary.First怎么用?C# Dictionary.First使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.First方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttributeManager
public AttributeManager()
{
InitializeComponent();
StepMapper = new Dictionary<string, Logic.Steps>
{
{"Create Temporary Attribute", Logic.Steps.CreateTemp},
{"Migrate to Temporary Attribute", Logic.Steps.MigrateToTemp},
{"Remove Existing Attribute", Logic.Steps.RemoveExistingAttribute},
{"Create New Attribute", Logic.Steps.CreateNewAttribute},
{"Migrate to New Attribute", Logic.Steps.MigrateToNewAttribute},
{"Remove Temporary Attribute", Logic.Steps.RemoveTemp}
};
DefaultSteps = StepMapper.Keys.Cast<Object>().ToArray();
RenameSteps = new Object[]
{
StepMapper.First(p => p.Value == Logic.Steps.CreateNewAttribute).Key,
StepMapper.First(p => p.Value == Logic.Steps.MigrateToNewAttribute).Key,
StepMapper.First(p => p.Value == Logic.Steps.RemoveExistingAttribute).Key
};
lblNewAttributeType.Visible = false;
cmbNewAttributeType.Visible = false;
tabAttributeType.Visible = false;
}
示例2: formAyuda
public formAyuda(Conexion con, List<string> columnasMostrar, List<object> listaDatos, int ancho, int alto, Dictionary<string, string> valorDesactivado)
{
try
{
InitializeComponent();
_listaDatos = new List<ElementoAyuda>();
foreach (object e in listaDatos)
{
ElementoAyuda ea = new ElementoAyuda();
ea.Elemento = (ElementoBase)e;
foreach (string s in columnasMostrar)
{
ea.Mostrar += e.GetType().GetProperty(s).GetValue(e, null).ToString() + " -- ";
}
ea.Habilitado = e.GetType().GetProperty(valorDesactivado.First().Key).GetValue(e, null).ToString() != valorDesactivado.First().Value;
ea.Mostrar = ea.Mostrar.Remove(ea.Mostrar.Length - 3);
lbDatos.Items.Add(ea);
_listaDatos.Add(ea);
}
lbDatos.DisplayMember = "Mostrar";
lbDatos.ValueMember = "Elemento";
lbDatos.SelectedIndex = 0;
}
catch (Exception e)
{
throw e;
}
this.Width = ancho;
this.Height = alto;
}
示例3: AttributeManagerPlugin
public AttributeManagerPlugin()
{
InitializeComponent();
StepMapper = new Dictionary<string, Logic.Steps>
{
{"Create Temporary Attribute", Logic.Steps.CreateTemp},
{"Migrate to Temporary Attribute", Logic.Steps.MigrateToTemp},
{"Remove Existing Attribute", Logic.Steps.RemoveExistingAttribute},
{"Create New Attribute", Logic.Steps.CreateNewAttribute},
{"Migrate to New Attribute", Logic.Steps.MigrateToNewAttribute},
{"Remove Temporary Attribute", Logic.Steps.RemoveTemp}
};
DefaultSteps = StepMapper.Keys.Cast<object>().ToArray();
RenameSteps = new object[]
{
StepMapper.First(p => p.Value == Logic.Steps.CreateNewAttribute).Key,
StepMapper.First(p => p.Value == Logic.Steps.MigrateToNewAttribute).Key,
StepMapper.First(p => p.Value == Logic.Steps.RemoveExistingAttribute).Key
};
cmbNewAttributeType.Visible = false;
SetTabVisible(tabStringAttribute, false);
SetTabVisible(tabNumberAttribute, false);
SetTabVisible(tabOptionSetAttribute, false);
SetCurrencyNumberVisible(false);
SetDecimalNumberVisible(false);
SetWholeNumberVisible(false);
SetFloatNumberVisible(false);
numAttFormatCmb.SelectedIndex = 0;
}
示例4: StringJoinTestCase
public void StringJoinTestCase()
{
var dictionary = new Dictionary<String, String>
{
{ RandomValueEx.GetRandomString(), RandomValueEx.GetRandomString() },
{ RandomValueEx.GetRandomString(), RandomValueEx.GetRandomString() }
};
var actual = dictionary.StringJoin();
var expected = "{0}={1}{2}={3}".F( dictionary.First()
.Key,
dictionary.First()
.Value,
dictionary.Last()
.Key,
dictionary.Last()
.Value );
Assert.AreEqual( expected, actual );
actual = dictionary.StringJoin( ",", ";" );
expected = "{0},{1};{2},{3}".F( dictionary.First()
.Key,
dictionary.First()
.Value,
dictionary.Last()
.Key,
dictionary.Last()
.Value );
Assert.AreEqual( expected, actual );
}
示例5: Do
/// <summary>
/// Do the specified input and output.
/// </summary>
/// <param name="input">Input.</param>
/// <param name="output">Output.</param>
public void Do(BlockingCollection<ISkeleton> input, Action<IEnumerable<Result>> fireNewCommand)
{
var data = new Dictionary<JointType, InputVector>();
foreach (var skeleton in input.GetConsumingEnumerable())
{
foreach (var joint in skeleton.Joints)
{
if (!data.ContainsKey(joint.JointType))
{
data.Add(joint.JointType, new InputVector());
}
data[joint.JointType].Stream.Add(joint.Point);
}
if (data.First().Value.Stream.Count < 5)
{
continue;
}
var results = Recognizer.Recognize(data);
try
{
fireNewCommand(results);
}
catch (Exception)
{
if (data.First().Value.Stream.Count > 40)
{
data.Clear();
}
continue;
}
data.Clear();
}
}
示例6: AnimationManager
/// <summary>
/// Create an AnimationManager, animations are later added using the
/// addAnimation method.
/// </summary>
/// <param name="animListingXML">XML document associating frames in a spritesheet with names.</param>
public AnimationManager(string animListingXML)
{
animSource = AbyssGame.Assets.Load<Dictionary<string, Rectangle>>(animListingXML+"Ref");
animSet = new Dictionary<string, Animation>();
//Set the initial current frame to the first image in the sprite sheet.
int h = animSource.First().Value.Height;
int w = animSource.First().Value.Width;
CurrentFrame = new Rectangle(0, 0, w, h);
}
示例7: FakeWorklistItem
public FakeWorklistItem(Dictionary<string, Type> activityTypes, int maxRetries = 0, int currentRetries = 0) :
base(9235,
new Guid(activityTypes.First().Value.Name.Substring(activityTypes.First().Value.Name.IndexOf("_", StringComparison.Ordinal) + 1, activityTypes.First().Value.Name.Length - 1 - activityTypes.First().Value.Name.IndexOf("_", System.StringComparison.Ordinal)).Replace("_", "-")),
"Fake Activity", maxRetries, currentRetries)
{
var random = new Random();
InstanceId = random.Next(1, 999999);
KeyValue = random.Next(1, 999999);
}
示例8: InstallSupplementalPackAction
public InstallSupplementalPackAction(Dictionary<Host, VDI> suppPackVdis, bool suppressHistory)
: base(null,
suppPackVdis.Count > 1
? string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE_MULTIPLE_HOSTS, suppPackVdis.Count)
: string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, suppPackVdis.First().Value, suppPackVdis.First().Key),
suppressHistory)
{
this.suppPackVdis = suppPackVdis;
}
示例9: ReadJson
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var dict = new Dictionary<string, Dictionary<string, Dictionary<string, IndexSettings>>>();
serializer.Populate(reader, dict);
var response = new IndexSettingsResponse();
if (!dict.HasAny() || !dict.First().Value.HasAny() || !dict.First().Value.First().Value.HasAny())
return response;
response.Nodes = dict.ToDictionary(k => k.Key, v => v.Value.First().Value.First().Value);
return response;
}
示例10: ControllerCode
/// <summary>
/// Builds the necessary code containing the simple controller logic required for the controller class.
/// </summary>
/// <param name="columnlist"> Dictionery containg the list of column name as key and datatype as value.</param>
/// <param name="moduleName">Module name.</param>
/// <returns>Returns the methods codes required for the controller class.</returns>
public static StringBuilder ControllerCode(Dictionary<string, string> columnlist, string moduleName)
{
StringBuilder code = new StringBuilder();
string firstColumnName = columnlist.First().Key;
string firstColumnDataType = columnlist.First().Value;
code.Append(ExecuteNonQueryCode(moduleName, "Insert"));
code.Append(ExecuteNonQueryCode(moduleName, "Update"));
code.Append(SelectQuery(moduleName, "GetallData", true, firstColumnName, firstColumnDataType));
code.Append(SelectQuery(moduleName, "GetByID", false, firstColumnName, firstColumnDataType));
code.Append(DeleteQuery(moduleName, "DeleteByID", firstColumnName, firstColumnDataType));
return code;
}
示例11: Transforming_keys_does_not_modify_original_dictionary
public void Transforming_keys_does_not_modify_original_dictionary()
{
var original = new Dictionary<string, int>
{
{ "Key 1", 1 }
};
original.TransformKeys(x => x.ToUpper());
Assert.AreEqual("Key 1", original.First().Key);
Assert.AreEqual(1, original.First().Value);
}
示例12: FillData
/// <summary>метод который формирует данные для chart-а на основе колекции серий,
/// поинтов и их пересечений </summary>
private SeriesCollection FillData(
Dictionary<string, float> seriesDef,
Dictionary<string, float> pointDef,
Dictionary<Intersection, float> intersections)
{
SeriesCollection result = new SeriesCollection();
if (!subDiagramMode)
{
switch (this.DiagramType)
{
case DiagramTypeEnum.Graph:
result.Add(CreateDataForFullDiagram(seriesDef, pointDef, intersections, true));
break;
case DiagramTypeEnum.ColumnDetail:
result.Add(CreateDataForFullDiagram(seriesDef, pointDef, intersections, false));
break;
case DiagramTypeEnum.ColumnGeneral:
result.Add(CreateDataForColumnGeneral(seriesDef));
break;
case DiagramTypeEnum.PieGeneral:
result.Add(CreateDataForPieGeneral(seriesDef));
break;
case DiagramTypeEnum.Speedometer:
case DiagramTypeEnum.TrafficLight:
if (seriesDef.Any( s => s.Key.Equals(defaultSeries)))
result.Add(FillSeriesData(seriesDef.First(s => s.Key.Equals(defaultSeries))));
break;
case DiagramTypeEnum.PieDetail:
if (seriesDef.Any(s => s.Key.Equals(defaultSeries)))
result.Add(FillPointsData(seriesDef.First(s => s.Key.Equals(defaultSeries)),
pointDef, intersections, false));
break;
}
}
else
{
if (string.IsNullOrEmpty(detalizedSeriesName)) detalizedSeriesName = this.defaultSeries;
if (seriesDef.Any(s => s.Key.Equals(detalizedSeriesName)))
{
switch (this.SubDiagramType)
{
case SubDiagramTypeEnum.Graph:
case SubDiagramTypeEnum.ColumnDetail:
case SubDiagramTypeEnum.PieDetail:
result.Add(FillPointsData(seriesDef.First(s => s.Key.Equals(detalizedSeriesName)),
pointDef, intersections, false));
break;
}
}
}
FillEmptyVisibleSeries(seriesDef.Keys.ToList());
return result;
}
示例13: TryGetLatestDate
/// <summary>
/// Returns true if the row is found. The LatestDate can still be null
/// </summary>
/// <param name="Table"></param>
/// <param name="PrimaryKeys"></param>
/// <param name="LatestDate"></param>
/// <returns></returns>
public bool TryGetLatestDate(JupiterTables Table, Dictionary<string, string> PrimaryKeys, out DateTime? LatestDate)
{
LatestDate = null;
if (PrimaryKeys.Values.Any(var => var == ""))
return false;
string sql = "select INSERTDATE, UPDATEDATE from " + Table.ToString();
switch (Table)
{
case JupiterTables.BOREHOLE:
sql = sql + " WHERE " + PrimaryKeys.First().Key + " = '" + PrimaryKeys.First().Value + "'";
break;
case JupiterTables.SCREEN:
sql = sql + " WHERE BOREHOLENO = '" + PrimaryKeys["BOREHOLENO"] + "' and SCREENNO = " + PrimaryKeys["SCREENNO"];
break;
case JupiterTables.DRWPLANTINTAKE:
sql = sql + " WHERE " + PrimaryKeys.First().Key + " = " + PrimaryKeys.First().Value + "";
break;
default:
break;
}
OleDbCommand command = new OleDbCommand(sql, odb);
OleDbDataReader reader2;
reader2 = command.ExecuteReader();
reader2.Read();
LatestDate = null;
if (!reader2.HasRows)
return false;
DateTime UpdateDate;
if (!reader2.IsDBNull(0))
{
LatestDate = reader2.GetDateTime(0);
}
if (!reader2.IsDBNull(1))
{
UpdateDate = reader2.GetDateTime(1);
if (LatestDate.HasValue)
{
if (LatestDate.Value.CompareTo(UpdateDate)<0)
LatestDate = UpdateDate;
}
else
LatestDate = UpdateDate;
}
command.Dispose();
reader2.Dispose();
return true;
}
示例14: should_map_paremeters
public void should_map_paremeters()
{
var dynRaml = new Dictionary<string, object>();
dynRaml.Add("type", "string");
dynRaml.Add("displayName", "ParameterName");
dynRaml.Add("description", "this is the description");
var parameters = new Dictionary<string, Parameter> {{"one", new ParameterBuilder().Build(dynRaml)}};
var generatorParameters = ParametersMapper.Map(parameters);
Assert.AreEqual(parameters.Count, generatorParameters.Count());
Assert.AreEqual(parameters.First().Value.Type, generatorParameters.First().Type);
Assert.AreEqual("one", generatorParameters.First().Name);
Assert.AreEqual(parameters.First().Value.Description, generatorParameters.First().Description);
}
示例15: MergeFiles
public bool MergeFiles(Dictionary<string, ReportContext> MergedFiles, string mergedFile, out string outputFile)
{
Excel.Workbook bookDest = null;
try
{
bookDest = excel.Workbooks.Add(Missing.Value);
//create a new work sheet
Excel.Worksheet sheetDest = bookDest.Worksheets[1] as Excel.Worksheet;
if (MergedFiles.Count > 0)
{
this.Logger.Message("Merge " + MergedFiles.First().Key);
sourceBook = excel.Workbooks.Open(MergedFiles.First().Value.OutputFullName);
Excel.Worksheet sheet = sourceBook.Worksheets[1];
sheet.Name = "Summary";
sheet.Copy(Missing.Value, sheetDest);
Excel.Worksheet copysheet = bookDest.Worksheets["Summary"];
this.FormatSummary(copysheet);
FunnelReportHelper.CloseWorkingWorkbook(sourceBook);
}
foreach (var item in bookDest.Worksheets)
{
Excel.Worksheet sheet = item as Excel.Worksheet;
if (sheet.Name != "Summary")
sheet.Delete();
}
//outputFile = "ChinaDash_" + DateTime.Now.ToString("yyyMMdd") + ".xls";
outputFile = mergedFile.Replace(".xls", "_" + DateTime.Now.ToString("yyyMMdd") + ".xls");
if (File.Exists(outputFile))
{
File.Delete(outputFile);
}
bookDest.SaveAs(outputFile);
bookDest.Close();
}
catch (Exception ex)
{
throw;
}
return true;
}