本文整理汇总了C#中IReadOnlyCollection.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection.ToArray方法的具体用法?C# IReadOnlyCollection.ToArray怎么用?C# IReadOnlyCollection.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyCollection
的用法示例。
在下文中一共展示了IReadOnlyCollection.ToArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureContainer
public static IContainer ConfigureContainer(this IAppBuilder app, HttpConfiguration config, IReadOnlyCollection<Assembly> applicationAssemblies, IEnumerable<Module> dependencyModules, WebOption webOption)
{
var builder = new ContainerBuilder();
foreach (var module in dependencyModules)
builder.RegisterModule(module);
var assemblies = applicationAssemblies.ToArray();
ConfigureContainer(builder, webOption, assemblies);
if (webOption.UseApi)
builder.RegisterWebApiFilterProvider(config);
var container = builder.Build();
if (webOption.UseApi)
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
if (webOption.UseMvc)
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
app.UseAutofacMiddleware(container);
if (webOption.UseApi)
app.UseAutofacWebApi(config);
return container;
}
示例2: IndexCollection
public IndexCollection(IReadOnlyCollection<Index> latest,
IndexCollection previous,
FileInfo info,
Encoding encoding)
{
Info = info;
Encoding = encoding;
Count = latest.Select(idx => idx.LineCount).Sum();
Indicies = latest.ToArray();
Diff = Count - (previous?.Count ?? 0);
//need to check whether
if (previous == null)
{
ChangedReason = LinesChangedReason.Loaded;
TailInfo = new TailInfo(latest.Max(idx => idx.End));
}
else
{
var mostRecent = latest.OrderByDescending(l => l.TimeStamp).First();
ChangedReason = mostRecent.Type == IndexType.Tail
? LinesChangedReason.Tailed
: LinesChangedReason.Paged;
TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End));
}
}
示例3: Create
public virtual IRelationalValueBufferFactory Create(
IReadOnlyCollection<Type> valueTypes, IReadOnlyList<int> indexMap)
{
Check.NotNull(valueTypes, nameof(valueTypes));
return new TypedRelationalValueBufferFactory(
_cache.GetOrAdd(
new CacheKey(valueTypes.ToArray(), indexMap),
CreateArrayInitializer));
}
示例4: DirectRouteBuilder
/// <summary>Initializes a new instance of the <see cref="DirectRouteBuilder"/> class.</summary>
/// <param name="actions">The action descriptors to which to create a route.</param>
/// <param name="targetIsAction">
/// A value indicating whether the route is configured at the action or controller level.
/// </param>
public DirectRouteBuilder(IReadOnlyCollection<TActionDescriptor> actions, bool targetIsAction)
{
if (actions == null)
{
throw new ArgumentNullException("actions");
}
_actions = actions.ToArray();
_targetIsAction = targetIsAction;
}
示例5: Init
public Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection<Uri> hosts,
Dictionary<string, object> opts = null) {
Contract.Requires<ArgumentNullException>(folder != null);
Contract.Requires<ArgumentNullException>(hosts != null);
if (opts == null)
opts = new Dictionary<string, object>();
var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName);
if (rsyncFolder.Exists)
throw new Exception("Already appears to be a repository");
var packFolder = Path.Combine(opts.ContainsKey("pack_path")
? ((string) opts["pack_path"])
: rsyncFolder.ToString(),
Repository.PackFolderName).ToAbsoluteDirectoryPath();
var configFile = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName);
var wdVersionFile = rsyncFolder.GetChildFileWithName(Repository.VersionFileName);
var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName);
this.Logger().Info("Initializing {0}", folder);
rsyncFolder.MakeSurePathExists();
packFolder.MakeSurePathExists();
var config = new RepoConfig {Hosts = hosts.ToArray()};
if (opts.ContainsKey("pack_path"))
config.PackPath = (string) opts["pack_path"];
if (opts.ContainsKey("include"))
config.Include = (string[]) opts["include"];
if (opts.ContainsKey("exclude"))
config.Exclude = (string[]) opts["exclude"];
var guid = opts.ContainsKey("required_guid")
? (string) opts["required_guid"]
: Guid.NewGuid().ToString();
var packVersion = new RepoVersion {Guid = guid};
if (opts.ContainsKey("archive_format"))
packVersion.ArchiveFormat = (string) opts["archive_format"];
var wdVersion = YamlExtensions.NewFromYaml<RepoVersion>(packVersion.ToYaml());
config.SaveYaml(configFile);
packVersion.SaveYaml(packVersionFile);
wdVersion.SaveYaml(wdVersionFile);
return TryGetRepository(folder.ToString(), opts, rsyncFolder.ToString());
}
示例6: RemoveLikesForRemovedSongs
private void RemoveLikesForRemovedSongs(IReadOnlyCollection<string> removedSongIds)
{
using (var session = Get.A<IDocumentStore>().OpenSession())
{
var deleteCommands = session.Query<Like>()
.Where(l => l.SongId.In(removedSongIds.ToArray()))
.AsEnumerable()
.Select(id => new Raven.Abstractions.Commands.DeleteCommandData { Key = "likes/" + id.ToString() })
.AsEnumerable<Raven.Abstractions.Commands.ICommandData>();
session.Advanced.Defer(deleteCommands.ToArray());
session.SaveChanges();
}
}
示例7: IndexCollection
public IndexCollection(IReadOnlyCollection<Index> latest,
IndexCollection previous,
FileInfo info,
Encoding encoding)
{
Info = info;
Encoding = encoding;
Count = latest.Select(idx => idx.LineCount).Sum();
Indicies = latest.ToArray();
Diff = Count - (previous?.Count ?? 0);
//need to check whether
if (previous == null)
{
TailInfo = new TailInfo(latest.Max(idx => idx.End));
}
else
{
TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End));
}
}
示例8: IsLegalMove
public static bool IsLegalMove(Cell cell, IReadOnlyCollection<Cell> sodukuGameData, int trialValue)
{
bool isLegalMove = false;
Cell[] trialGame = Program.CreateBoard();
//Save off cell, as to not affect the original
Cell trialCell = new Cell() { Value = cell.Value, XCoordinates = cell.XCoordinates, YCoordinates = cell.YCoordinates };
//copy, so we don't change the original data
trialGame = sodukuGameData.ToArray();
if (trialValue < 1 || trialValue > 9)
{
throw new ArgumentOutOfRangeException("Value must be between 1 and 9");
}
if (trialCell.Value > 0)
{
return false;//value already given
}
trialCell.Value = trialValue;
trialGame[trialCell.PositionInArray] = trialCell;
//is row legal?
if (IsRowLegal(trialCell, trialGame))
{
if (IsColumnLegal(trialCell, trialGame))
{
//is box legal?
if(IsBoxLegal(trialCell, trialGame))
{
isLegalMove = true;
}
}
}
return isLegalMove;
}
示例9: InstallTrayIcon
public void InstallTrayIcon(
string boldMenuItemTitle,
IReadOnlyCollection<MenuItem> contextMenuItems)
{
trayIcon.Click += (sender, e) =>
OnIconClicked(new TrayIconClickedEventArgument());
var contextMenu = new ContextMenu();
contextMenu.MenuItems.Add(
new MenuItem(boldMenuItemTitle)
{
DefaultItem = true,
BarBreak = true
});
contextMenu
.MenuItems
.AddRange(contextMenuItems.ToArray());
trayIcon.Icon = Resources.ShapeshifterIcon;
trayIcon.ContextMenu = contextMenu;
trayIcon.Text = "Shapeshifter version " + updateService.GetCurrentVersion();
trayIcon.Visible = true;
}
示例10: CompositeDataAttribute
/// <summary>
/// Initializes a new instance of the <see cref="CompositeDataAttribute"/> class.
/// </summary>
/// <param name="attributes">The attributes representing a data source for a data theory.
/// </param>
public CompositeDataAttribute(IReadOnlyCollection<DataAttribute> attributes)
: this(attributes.ToArray())
{
}
示例11: TypeResolutionTable
/// <summary>
/// Initializes a new instance of the <see cref="TypeResolutionTable"/>
/// class.
/// </summary>
/// <param name="entries">The entries of the resolution table.</param>
/// <remarks>
/// <para>
/// The constructor arguments are subsequently available on the object
/// as properties.
/// </para>
/// </remarks>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="entries" /> is <see langword="null" />.
/// </exception>
public TypeResolutionTable(
IReadOnlyCollection<TypeResolutionEntry> entries)
: this(entries.ToArray())
{
}
示例12: AggregateActionItems
private static IActionItem AggregateActionItems(IReadOnlyCollection<IActionItem> actionItems, string name = null)
{
if (actionItems.Count == 1)
{
var actionItem = actionItems.First();
if (!string.IsNullOrEmpty(name))
actionItem.Name = name;
return actionItem;
}
return new AggregateActionItem(name, actionItems.ToArray());
}
示例13: CheckIn
private static CheckInResult CheckIn(IReadOnlyCollection<PendingChange> targetPendingChanges, string comment,
Workspace workspace, IReadOnlyCollection<int> workItemIds, PolicyOverrideInfo policyOverride, WorkItemStore workItemStore)
{
var result = new CheckInResult();
// Another user can update workitem. Need re-read before update.
var workItems = GetWorkItemCheckinInfo(workItemIds, workItemStore);
var evaluateCheckIn = workspace.EvaluateCheckin2(CheckinEvaluationOptions.All,
targetPendingChanges,
comment,
null,
workItems);
var skipPolicyValidate = !policyOverride.PolicyFailures.IsNullOrEmpty();
if (!CanCheckIn(evaluateCheckIn, skipPolicyValidate))
{
result.CheckinResult = MergeResult.CheckInEvaluateFail;
}
var changesetId = workspace.CheckIn(targetPendingChanges.ToArray(), null, comment,
null, workItems, policyOverride);
if (changesetId > 0)
{
result.ChangesetId = changesetId;
result.CheckinResult = MergeResult.CheckIn;
}
else
{
result.CheckinResult = MergeResult.CheckInFail;
}
return result;
}
示例14: VerifyDiagnosticResults
/// <summary>
/// Checks each of the actual Diagnostics found and compares them with the corresponding DiagnosticResult in the array of expected results.
/// Diagnostics are considered equal only if the DiagnosticResultLocation, Id, Severity, and Message of the DiagnosticResult match the actual diagnostic.
/// </summary>
/// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code</param>
/// <param name="analyzer">The analyzer that was being run on the sources</param>
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param>
private static void VerifyDiagnosticResults(IReadOnlyCollection<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
{
var expectedCount = expectedResults.Length;
var actualCount = actualResults.Count;
if (expectedCount != actualCount)
{
var diagnosticsOutput = actualResults.Any() ? FormatDiagnostics(analyzer, actualResults.ToArray()) : " NONE.";
Assert.IsTrue(false, $"Mismatch between number of diagnostics returned, expected \"{expectedCount}\" actual \"{actualCount}\"\r\n\r\nDiagnostics:\r\n{diagnosticsOutput}\r\n");
}
for (var i = 0; i < expectedResults.Length; i++)
{
var actual = actualResults.ElementAt(i);
var expected = expectedResults[i];
if (expected.Line == -1 && expected.Column == -1)
{
if (actual.Location != Location.None)
{
Assert.IsTrue(false, $"Expected:\nA project diagnostic with No location\nActual:\n{FormatDiagnostics(analyzer, actual)}");
}
}
else
{
VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
var additionalLocations = actual.AdditionalLocations.ToArray();
if (additionalLocations.Length != expected.Locations.Length - 1)
{
Assert.IsTrue(false, $"Expected {expected.Locations.Length - 1} additional locations but got {additionalLocations.Length} for Diagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
for (var j = 0; j < additionalLocations.Length; ++j)
{
VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
}
}
if (actual.Id != expected.Id)
{
Assert.IsTrue(false, $"Expected diagnostic id to be \"{expected.Id}\" was \"{actual.Id}\"\r\n\r\nDiagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
if (actual.Severity != expected.Severity)
{
Assert.IsTrue(false, $"Expected diagnostic severity to be \"{expected.Severity}\" was \"{actual.Severity}\"\r\n\r\nDiagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
if (actual.GetMessage() != expected.Message)
{
Assert.IsTrue(false, $"Expected diagnostic message to be \"{expected.Message}\" was \"{actual.GetMessage()}\"\r\n\r\nDiagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
}
}