本文整理汇总了C#中Collection.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.ToList方法的具体用法?C# Collection.ToList怎么用?C# Collection.ToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.ToList方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToAbsoluteCoordinates
private static List<AbsoluteBlock> ConvertToAbsoluteCoordinates(this RawShapeBlocksGroup elem)
{
var offsetX = 0;
var absoluteBlockCollection = new Collection<AbsoluteBlock>();
RawShapeBlock previousRawShapeBlock = null;
foreach (var block in elem.Collection)
{
if (previousRawShapeBlock != null)
{
offsetX += previousRawShapeBlock.Length;
}
offsetX += block.Offsetx;
previousRawShapeBlock = block;
var absoluteBlock = new AbsoluteBlock(offsetX, block.Length, elem.RowIndex);
absoluteBlockCollection.Add(absoluteBlock);
}
return absoluteBlockCollection.ToList();
}
示例2: LineString
/// <summary>
/// Initializes an instance of a LineString
/// </summary>
/// <param name="points"></param>
public LineString(IEnumerable<double[]> points)
{
var vertices = new Collection<Point>();
foreach (var point in points)
{
vertices.Add(new Point(point));
}
Vertices = vertices.ToList();
}
示例3: PlatformApplication
static PlatformApplication()
{
var applications = new Collection<PlatformApplication>();
ConfigureApplications(applications);
AllApplications = applications.ToList().AsReadOnly();
UnknownApplication = new PlatformApplication("[Unknown]");
Current = GetCurrentApplication();
}
示例4: CasoDeTeste
/// <summary>
/// Construtor default
/// </summary>
protected CasoDeTeste()
{
id = this.GetType().FullName.ToString();
comandos = MontarListaComandos();
//Força a aplicação do método Executar no comando do tipo Code da Lista
((CodeCommand)comandos.ToList().Where(c => c.CommandType == CommandType.Code).First()).FunctionToExecute = Executar;
TempoEsperaDefault = 5000;
this.Assert = new RealAssert();
}
示例5: GetDistributedCounterPartBlocksInternal
public Collection<AbsoluteBlockContainer> GetDistributedCounterPartBlocksInternal(List<AbsoluteBlock> piactureElements, Collection<RawColorBlock> secondPartBlocks)
{
if (secondPartBlocks.Count == 0) return new Collection<AbsoluteBlockContainer>();
_enumerator = secondPartBlocks.ToList().GetEnumerator();
_blockEnumerator = piactureElements.ToList().GetEnumerator();
var blockContainerCollection = new Collection<AbsoluteBlockContainer>();
var currentCounterBlock = FetchCounterBlock();
var currentBlock = FetchBlock();
var currentBlockContainer = new AbsoluteBlockContainer(currentBlock);
blockContainerCollection.Add(currentBlockContainer);
var blockLengthNeeded = GetBlockLengthNeeded(currentCounterBlock);
while (true)
{
int lengthAdded;
if (TryToAppendCounterBlock(currentBlockContainer, currentCounterBlock, blockLengthNeeded, out lengthAdded))
{
currentCounterBlock = FetchCounterBlock();
if (currentCounterBlock == null) break;
blockLengthNeeded = GetBlockLengthNeeded(currentCounterBlock);
}
else
{
currentBlock = FetchBlock();
if (currentBlock == null) break;
currentBlockContainer = new AbsoluteBlockContainer(currentBlock);
blockContainerCollection.Add(currentBlockContainer);
blockLengthNeeded -= lengthAdded;
}
}
_enumerator.Dispose();
_blockEnumerator.Dispose();
return blockContainerCollection;
}
示例6: PublishWorkflow
public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, Collection<ExternalVariable> externalVariables, IDictionary<string, string> configValues, SubscriptionFilter activationFilter = null)
{
// publish the activity description related with the workflow
client.Activities.Publish(
new ActivityDescription(WorkflowUtils.Translate(xamlFilePath)) { Name = workflowName },true,true);
// now, publish the workflow description
WorkflowDescription description = new WorkflowDescription
{
Name = workflowName,
ActivityPath = workflowName,
};
// add external variables
if (externalVariables != null)
{
externalVariables
.ToList()
.ForEach(ev => description.ExternalVariables.Add(ev));
}
// add config
if (configValues != null)
{
description.Configuration = new WorkflowConfiguration();
configValues
.ToList()
.ForEach(c => description.Configuration.AppSettings.Add(c));
}
// add activation filter
if (activationFilter != null)
{
description.ActivationDescription = new SubscriptionActivationDescription
{
Filter = activationFilter
};
}
// publish!
client.Workflows.Publish(description);
}
示例7: Prompt
public override Dictionary<string, PSObject> Prompt(string caption, string message,
Collection<FieldDescription> descriptions)
{
_control.WriteLine(String.Empty);
_control.WriteLine(caption);
_control.WriteLine(message);
var results = new Dictionary<string, PSObject>();
descriptions.ToList().ForEach(
d =>
{
var prompt = (d.Label + ": ").Replace("&", String.Empty);
_control.WritePrompt(prompt);
_control.CommandEnteredEvent.WaitOne();
results[d.Name] = _control.ReadLine().Trim().ToPSObject();
}
);
return results;
}
示例8: PopulateColumns
/// <summary>
/// Populates columns with the view model column
/// property and rebinds the columns
/// </summary>
/// <param name="selectedLayerMap">Selected layer map</param>
/// <param name="columns">Collection of columns</param>
internal void PopulateColumns(LayerMap selectedLayerMap, Collection<Column> columns)
{
this.ColumnsView = new ObservableCollection<ColumnViewModel>();
int index = 0;
foreach (string headerData in selectedLayerMap.HeaderRowData)
{
ColumnViewModel columnViewModel = new ColumnViewModel();
columnViewModel.ExcelHeaderColumn = headerData;
columnViewModel.WWTColumns = new ObservableCollection<Column>();
columns.ToList().ForEach(col => columnViewModel.WWTColumns.Add(col));
columnViewModel.SelectedWWTColumn = columns.Where(column => column.ColType == selectedLayerMap.MappedColumnType[index]).FirstOrDefault() ?? columns.Where(column => column.ColType == ColumnType.None).FirstOrDefault();
this.ColumnsView.Add(columnViewModel);
index++;
}
SetRAUnitVisibility();
}
示例9: PromptForChoice
public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> choices,
int defaultChoice)
{
_control.WriteWarningLine(caption);
_control.WriteLine(message);
while (true)
{
int choiceIndex = 0;
string defaultChoicePrompt = String.Empty;
List<char> hotkeys = new List<char>();
choices.ToList().ForEach(
choice =>
{
var index = choice.Label.IndexOf('&') + 1;
if (-1 == index || index > (choice.Label.Length - 1))
{
return;
}
var c = choice.Label.ToUpperInvariant()[index];
hotkeys.Add(c);
ConsoleColor color = _settings.ForegroundColor;
ConsoleColor back = _settings.BackgroundColor;
if (choiceIndex == defaultChoice)
{
color = _settings.WarningForegroundColor;
back = _settings.WarningBackgroundColor;
defaultChoicePrompt = String.Format(" (default is \"{0}\")", c);
}
_control.Write(
String.Format("[{0}]", c),
color,
_control.ConsoleBackColor);
_control.Write(String.Format(" {0} ", choice.Label.Replace("&", String.Empty)), color, back);
++choiceIndex;
}
);
_control.WritePrompt(String.Format(" [?] Help{0}:", defaultChoicePrompt));
_control.CommandEnteredEvent.WaitOne();
var line = _control.ReadLine().Trim();
if (line.Length == 0)
{
if (-1 == defaultChoice)
{
continue;
}
return defaultChoice;
}
char charChoice = line.ToUpperInvariant()[0];
if ('?' == charChoice)
{
choices.ToList().ForEach(
choice => _control.WriteLine(
String.Format(
" {0} - {1}",
choice.Label.Replace("&", String.Empty),
choice.HelpMessage)
));
continue;
}
choiceIndex = hotkeys.IndexOf(charChoice);
if (-1 == choiceIndex)
{
continue;
}
return choiceIndex;
}
}
示例10: Prompt
public override Dictionary<string, PSObject> Prompt(string caption, string message,
Collection<FieldDescription> descriptions)
{
_control.WriteLine(String.Empty);
if( ! String.IsNullOrEmpty( caption ) )
{
_control.WriteLine(caption);
}
if (!String.IsNullOrEmpty(message))
{
_control.WriteLine(message);
}
var results = new Dictionary<string, PSObject>();
descriptions.ToList().ForEach(
d =>
{
bool isSecure = d.ParameterTypeFullName == typeof (SecureString).FullName;
var label = String.IsNullOrEmpty( d.Label ) ? d.Name : d.Label;
var prompt = (label + ": ").Replace("&", String.Empty);
_control.WritePrompt(prompt);
if (isSecure)
{
results[d.Name] = ReadLineAsSecureString().ToPSObject();
}
else
{
_control.CommandEnteredEvent.WaitOne();
results[d.Name] = _control.ReadLine().Trim().ToPSObject();
}
}
);
return results;
}
示例11: TrimAttributes
void TrimAttributes(Collection<CustomAttribute> customAttributes)
{
foreach (var customAttribute in customAttributes.ToList())
{
if (allAttributes.Contains(customAttribute.AttributeType.Name))
{
customAttributes.Remove(customAttribute);
}
}
}
示例12: Visit
public override void Visit(Collection<MethodDefinition> methodDefinitionCollection)
{
var snapshot = methodDefinitionCollection.ToList();
foreach (var method in snapshot) {
if (method.IsPropertyAccessor()) {
continue;
}
if (method.IsEventAccessor()) {
continue;
}
MorphMethod(method);
}
}
示例13: InitializeSpellCheck
public void InitializeSpellCheck(Collection<string> parameterNames, SelectionType selectionType)
{
if (parameterNames != null)
{
m_selectedParameterNames = parameterNames.ToList<string>();
}
else
{
throw new ArgumentException("Null parameter names list");
}
m_selectionType = selectionType;
}