本文整理汇总了C#中ImmutableList类的典型用法代码示例。如果您正苦于以下问题:C# ImmutableList类的具体用法?C# ImmutableList怎么用?C# ImmutableList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImmutableList类属于命名空间,在下文中一共展示了ImmutableList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Solution
private Solution(
BranchId branchId,
int workspaceVersion,
SolutionServices solutionServices,
SolutionId id,
string filePath,
ImmutableList<ProjectId> projectIds,
ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
ProjectDependencyGraph dependencyGraph,
VersionStamp version,
Lazy<VersionStamp> lazyLatestProjectVersion)
{
this.branchId = branchId;
this.workspaceVersion = workspaceVersion;
this.id = id;
this.filePath = filePath;
this.solutionServices = solutionServices;
this.projectIds = projectIds;
this.projectIdToProjectStateMap = idToProjectStateMap;
this.projectIdToTrackerMap = projectIdToTrackerMap;
this.dependencyGraph = dependencyGraph;
this.projectIdToProjectMap = ImmutableHashMap<ProjectId, Project>.Empty;
this.version = version;
this.lazyLatestProjectVersion = lazyLatestProjectVersion;
CheckInvariants();
}
示例2: PathSpec
internal PathSpec(PathFlags flags, string directorySeparator, IEnumerable<string> elements)
{
ValidateFlags(flags);
Flags = flags;
DirectorySeparator = directorySeparator;
Components = elements.SelectMany(SplitComponent).ToImmutableList();
}
示例3: FreeVariableNames
public override ImmutableList<char> FreeVariableNames(ImmutableList<Symbol> boundVariables)
{
if (boundVariables.Contains(_variable))
return ImmutableList<char>.Empty;
else
return new char[] { _variable.Default }.ToImmutableList();
}
示例4: RecoursiveCheckGraph
private static bool RecoursiveCheckGraph(Task root, ImmutableList<Guid> previousTasks)
{
Contract.Requires(root != null);
Contract.Requires(root.Inputs != null);
Contract.Requires(previousTasks != null);
if (previousTasks.Contains(root.Id))
{
Logger.Write(
LogCategories.Error(string.Format(
"{0} is cycled.", root),
LogCategories.TaskServices));
return false;
}
foreach (var task in root.Inputs)
{
if (previousTasks.Contains(task.Id))
{
Logger.Write(
LogCategories.Error(string.Format(
"{0} is cycled.", task),
LogCategories.TaskServices));
return false;
}
if (!RecoursiveCheckGraph(task, previousTasks.Add(root.Id)))
return false;
}
return true;
}
示例5: BenchmarkDiff
public BenchmarkDiff(BenchmarkRun left, BenchmarkRun right, ImmutableList<SourceLogEntry> log)
{
Left = left;
Right = right;
var leftResults = left.AllResults.ToList();
var rightResults = right.AllResults.ToList();
LeftOnly = leftResults.ExceptBy(rightResults, result => result.FullMethod);
RightOnly = rightResults.ExceptBy(leftResults, result => result.FullMethod);
var pairs = (from l in leftResults
join r in rightResults on l.FullMethod equals r.FullMethod
select new BenchmarkPair(l, r)).ToList();
LeftBetter = pairs.Where(pair => pair.Percent < ImprovementThreshold).ToList();
RightBetter = pairs.Where(pair => pair.Percent > RegressionThreshold).ToList();
bool leftEarlier = BenchmarkRepository.BuildForLabel(left.Label) < BenchmarkRepository.BuildForLabel(right.Label);
var earlier = leftEarlier ? left : right;
var later = leftEarlier ? right : left;
var earlierHash = BenchmarkRepository.HashForLabel(earlier.Label);
var laterHash = BenchmarkRepository.HashForLabel(later.Label);
LogEntries = log.EntriesBetween(earlierHash, laterHash).ToList();
}
示例6: MainForm
public MainForm()
{
InitializeComponent();
cmv = new CMV();
rawframes = new List<CMVFrame>();
cmvframes = new ImmutableList<CMVFrame>(rawframes, "empty");
copybuffer = new List<CMVFrame>();
foregroundColourPicker.Colors = CMVColours.ForegroundColors;
backgroundColourPicker.Colors = CMVColours.BackgroundColors;
updateDelayTimer = new Timer();
updateDelayTimer.Interval = 24;
updateDelayTimer.Tick += handleUpdateDelayTimer;
aboutBox = new AboutBox();
aboutBox.HelpButtonClicked += new EventHandler(action_HelpTopics);
newFileDialog = new ChooseDimensionsBox();
loadTileset();
RefreshControls();
}
示例7: CompilationDocument
// --- Initialization ---
/// <summary>
/// Initializes a new compilation document from a list of text lines.
/// This method does not scan the inserted text lines to produce tokens.
/// You must explicitely call UpdateTokensLines() to start an initial scan of the document.
/// </summary>
public CompilationDocument(TextSourceInfo textSourceInfo, IEnumerable<ITextLine> initialTextLines, TypeCobolOptions compilerOptions, IProcessedTokensDocumentProvider processedTokensDocumentProvider)
{
TextSourceInfo = textSourceInfo;
CompilerOptions = compilerOptions;
this.processedTokensDocumentProvider = processedTokensDocumentProvider;
// Initialize the compilation document lines
compilationDocumentLines = ImmutableList<CodeElementsLine>.Empty.ToBuilder();
// ... with the initial list of text lines received as a parameter
if (initialTextLines != null)
{
// Insert Cobol text lines in the internal tree structure
compilationDocumentLines.AddRange(initialTextLines.Select(textLine => CreateNewDocumentLine(textLine, textSourceInfo.ColumnsLayout)));
}
// Initialize document views versions
currentTextLinesVersion = new DocumentVersion<ICobolTextLine>(this);
currentTokensLinesVersion = new DocumentVersion<ITokensLine>(this);
// Initialize performance stats
PerfStatsForText = new PerfStatsForCompilationStep(CompilationStep.Text);
PerfStatsForScanner = new PerfStatsForCompilationStep(CompilationStep.Scanner);
PerfStatsForPreprocessor = new PerfStatsForCompilationStep(CompilationStep.Preprocessor);
}
示例8: Prebuild
/// <summary>
/// 1. Expand the TOC reference
/// 2. Resolve homepage
/// </summary>
/// <param name="models"></param>
/// <param name="host"></param>
/// <returns></returns>
public override IEnumerable<FileModel> Prebuild(ImmutableList<FileModel> models, IHostService host)
{
var tocModelCache = new Dictionary<string, TocItemInfo>();
foreach (var model in models)
{
if (!tocModelCache.ContainsKey(model.OriginalFileAndType.FullPath))
{
tocModelCache[model.OriginalFileAndType.FullPath] = new TocItemInfo(model.OriginalFileAndType, (TocItemViewModel)model.Content);
}
}
var tocResolver = new TocResolver(host, tocModelCache);
foreach (var key in tocModelCache.Keys.ToList())
{
tocModelCache[key] = tocResolver.Resolve(key);
}
foreach (var model in models)
{
var wrapper = tocModelCache[model.OriginalFileAndType.FullPath];
// If the TOC file is referenced by other TOC, remove it from the collection
if (!wrapper.IsReferenceToc)
{
model.Content = wrapper.Content;
yield return model;
}
}
}
示例9: FakeHeaders
public FakeHeaders()
{
this.blockHeaders = ImmutableList.CreateBuilder<ChainedHeader>();
this.bits = DataCalculator.TargetToBits(UnitTestRules.Target0);
this.nonce = (UInt32)Interlocked.Increment(ref staticNonce);
this.totalWork = 0;
}
示例10: FakeHeaders
public FakeHeaders(IEnumerable<ChainedHeader> blockHeaders)
{
this.blockHeaders = ImmutableList.CreateRange(blockHeaders).ToBuilder();
this.bits = DataCalculator.ToCompact(UnitTestParams.Target0);
this.nonce = (UInt32)Interlocked.Increment(ref staticNonce);
this.totalWork = blockHeaders.LastOrDefault()?.TotalWork ?? 0;
}
示例11: Animator
public static Animator CreateAnimator
(this ImmutableList<IAnimationSection> animationSections,
ImmutableList<IRenderer> children)
{
return new Animator(animationSections, children);
}
示例12: ApplyOverrides
private void ApplyOverrides(ImmutableList<FileModel> models, IHostService host)
{
foreach (var uid in host.GetAllUids())
{
var ms = host.LookupByUid(uid);
var od = ms.SingleOrDefault(m => m.Type == DocumentType.Override);
if (od != null)
{
var ovm = ((List<ItemViewModel>)od.Content).Single(vm => vm.Uid == uid);
foreach (
var pair in
from model in ms
where model.Type == DocumentType.Article
from item in ((PageViewModel)model.Content).Items
where item.Uid == uid
select new { model, item })
{
var vm = pair.item;
// todo : fix file path
Merger.Merge(ref vm, ovm);
((HashSet<string>)pair.model.Properties.LinkToUids).UnionWith((HashSet<string>)od.Properties.LinkToUids);
((HashSet<string>)pair.model.Properties.LinkToFiles).UnionWith((HashSet<string>)od.Properties.LinkToFiles);
}
}
}
}
示例13: CompanyState
public CompanyState(Company company, int money, int loans, ImmutableList<Train> trains)
{
Company = company;
Money = money;
Loans = loans;
Trains = trains;
}
示例14: PrivateAuctionRound
private PrivateAuctionRound(ImmutableList<Player> players, ImmutableList<PrivateCompany> privates, Auction<PrivateCompany> auction, Player activePlayer, Player lastToAct, int seedMoney)
: base(players, activePlayer, lastToAct)
{
Privates = privates;
CurrentAuction = auction;
SeedMoney = seedMoney;
}
示例15: Main
public static void Main()
{
var list = new List<ClassWithStringProperty>() { "test1", "test2", "test3", "test4"};
var imlist = new ImmutableList<ClassWithStringProperty>(list);
Console.WriteLine("Lists created:");
Console.WriteLine(list.Stringify(e =>e.Prop));
Console.WriteLine(imlist.Stringify(e => e.Prop));
Console.WriteLine("Mutable list modified[immutable not modified]:");
list.Add("test5");
Console.WriteLine(list.Stringify(e => e.Prop));
Console.WriteLine(imlist.Stringify(e => e.Prop));
Console.WriteLine("Element in immutable changed[not really...]:");
var elem = imlist[2];
elem.Prop = "1234";
Console.WriteLine(imlist.Stringify(e => e.Prop));
Console.WriteLine("Element in mutable changed[& not in immutable]:");
elem = list[2];
elem.Prop = "12387";
Console.WriteLine(list.Stringify(e => e.Prop));
Console.WriteLine(imlist.Stringify(e => e.Prop));
Console.ReadLine();
}