当前位置: 首页>>代码示例>>C#>>正文


C# IReadOnlyCollection.ToArray方法代码示例

本文整理汇总了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;
        }
开发者ID:tomekjanicki,项目名称:architecture2,代码行数:29,代码来源:AutofacExtension.cs

示例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));
            }
        }
开发者ID:ItsJustSean,项目名称:TailBlazer,代码行数:27,代码来源:IndexCollection.cs

示例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));
        }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:10,代码来源:TypedValueBufferFactoryFactory.cs

示例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;
        }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:16,代码来源:DirectRouteBuilder.cs

示例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());
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:52,代码来源:RepositoryFactory.cs

示例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();
     }
 }
开发者ID:usoundradio,项目名称:Usound,代码行数:13,代码来源:NewSongFinder.cs

示例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));
            }
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:21,代码来源:IndexCollection.cs

示例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;
        }
开发者ID:RyanBetker,项目名称:SodukuSolver,代码行数:39,代码来源:LegalMoveChecker.cs

示例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;
        }
开发者ID:gitter-badger,项目名称:Shapeshifter,代码行数:23,代码来源:TrayIconManager.cs

示例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())
 {
 }
开发者ID:Tungsten78,项目名称:AutoFixture,代码行数:9,代码来源:CompositeDataAttribute.cs

示例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())
 {
 }
开发者ID:iancooper,项目名称:AtomEventStore,代码行数:19,代码来源:TypeResolutionTable.cs

示例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());
 }
开发者ID:FERRERDEV,项目名称:xenko,代码行数:11,代码来源:TransactionalActionStack.cs

示例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;
        }
开发者ID:Manuel-S,项目名称:AutoMerge,代码行数:33,代码来源:BranchesViewModel.cs

示例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");
                }
            }
        }
开发者ID:ycherkes,项目名称:MockIt,代码行数:63,代码来源:DiagnosticVerifier.cs


注:本文中的IReadOnlyCollection.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。