本文整理汇总了C#中Solution类的典型用法代码示例。如果您正苦于以下问题:C# Solution类的具体用法?C# Solution怎么用?C# Solution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Solution类属于命名空间,在下文中一共展示了Solution类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RemoveAllRenameAnnotationsAsync
internal async Task RemoveAllRenameAnnotationsAsync(IEnumerable<DocumentId> documentWithRenameAnnotations, AnnotationTable<RenameAnnotation> annotationSet, CancellationToken cancellationToken)
{
foreach (var documentId in documentWithRenameAnnotations)
{
if (_renamedSpansTracker.IsDocumentChanged(documentId))
{
var document = _newSolution.GetDocument(documentId);
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
// For the computeReplacementToken and computeReplacementNode functions, use
// the "updated" node to maintain any annotation removals from descendants.
var newRoot = root.ReplaceSyntax(
nodes: annotationSet.GetAnnotatedNodes(root),
computeReplacementNode: (original, updated) => annotationSet.WithoutAnnotations(updated, annotationSet.GetAnnotations(updated).ToArray()),
tokens: annotationSet.GetAnnotatedTokens(root),
computeReplacementToken: (original, updated) => annotationSet.WithoutAnnotations(updated, annotationSet.GetAnnotations(updated).ToArray()),
trivia: SpecializedCollections.EmptyEnumerable<SyntaxTrivia>(),
computeReplacementTrivia: null);
_intermediateSolutionContainingOnlyModifiedDocuments = _intermediateSolutionContainingOnlyModifiedDocuments.WithDocumentSyntaxRoot(documentId, newRoot, PreservationMode.PreserveIdentity);
}
}
_newSolution = _intermediateSolutionContainingOnlyModifiedDocuments;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:25,代码来源:ConflictResolution.cs
示例2: GetInfoForMetadataReferenceAsync
/// <summary>
/// this gives you SymbolTreeInfo for a metadata
/// </summary>
public static async Task<SymbolTreeInfo> GetInfoForMetadataReferenceAsync(
Solution solution,
PortableExecutableReference reference,
bool loadOnly,
CancellationToken cancellationToken)
{
var metadata = reference.GetMetadata();
if (metadata == null)
{
return null;
}
// Find the lock associated with this piece of metadata. This way only one thread is
// computing a symbol tree info for a particular piece of metadata at a time.
var gate = s_metadataIdToGate.GetValue(metadata.Id, s_metadataIdToGateCallback);
using (await gate.DisposableWaitAsync(cancellationToken).ConfigureAwait(false))
{
cancellationToken.ThrowIfCancellationRequested();
SymbolTreeInfo info;
if (s_metadataIdToInfo.TryGetValue(metadata.Id, out info))
{
return info;
}
info = await LoadOrCreateMetadataSymbolTreeInfoAsync(
solution, reference, loadOnly, cancellationToken: cancellationToken).ConfigureAwait(false);
if (info == null && loadOnly)
{
return null;
}
return s_metadataIdToInfo.GetValue(metadata.Id, _ => info);
}
}
开发者ID:swaroop-sridhar,项目名称:roslyn,代码行数:38,代码来源:SymbolTreeInfo_Metadata.cs
示例3: PluginList
public PluginList()
{
InitializeComponent();
_logger = new Logger();
_dte = Package.GetGlobalService(typeof(DTE)) as DTE;
if (_dte == null)
return;
_solution = _dte.Solution;
if (_solution == null)
return;
_events = _dte.Events;
var windowEvents = _events.WindowEvents;
windowEvents.WindowActivated += WindowEventsOnWindowActivated;
_solutionEvents = _events.SolutionEvents;
_solutionEvents.BeforeClosing += BeforeSolutionClosing;
_solutionEvents.BeforeClosing += SolutionBeforeClosing;
_solutionEvents.ProjectAdded += SolutionProjectAdded;
_solutionEvents.ProjectRemoved += SolutionProjectRemoved;
_solutionEvents.ProjectRenamed += SolutionProjectRenamed;
SelectedAssemblyItem.PropertyChanged += SelectedAssemblyItem_PropertyChanged;
}
开发者ID:modulexcite,项目名称:CRMDeveloperExtensions,代码行数:26,代码来源:PluginList.xaml.cs
示例4: NewSolutionSnapshotAsync
public override Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancellationToken)
{
// check whether we are good to report total symbol numbers
if (_symbolCountByProjectMap == null || _symbolCountByProjectMap.Count < solution.ProjectIds.Count || string.IsNullOrEmpty(solution.FilePath))
{
return SpecializedTasks.EmptyTask;
}
if (_solutionId != null && _solutionId != solution.Id)
{
ReportCount();
return SpecializedTasks.EmptyTask;
}
_solutionId = solution.Id;
foreach (var projectId in solution.ProjectIds)
{
if (!_symbolCountByProjectMap.ContainsKey(projectId))
{
return SpecializedTasks.EmptyTask;
}
}
ReportCount();
return SpecializedTasks.EmptyTask;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:26,代码来源:SymbolTreeInfoIncrementalAnalyzerProvider.cs
示例5: SymbolLocationNavigableItem
public SymbolLocationNavigableItem(
Solution solution,
ISymbol symbol,
Location location)
{
_solution = solution;
_symbol = symbol;
_location = location;
_lazyDisplayName = new Lazy<string>(() =>
{
var symbolDisplayService = this.Document.Project.LanguageServices.GetService<ISymbolDisplayService>();
switch (symbol.Kind)
{
case SymbolKind.NamedType:
return symbolDisplayService.ToDisplayString(_symbol, s_shortFormatWithModifiers);
case SymbolKind.Method:
return _symbol.IsStaticConstructor()
? symbolDisplayService.ToDisplayString(_symbol, s_shortFormatWithModifiers)
: symbolDisplayService.ToDisplayString(_symbol, s_shortFormat);
default:
return symbolDisplayService.ToDisplayString(_symbol, s_shortFormat);
}
});
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:28,代码来源:NavigableItemFactory.SymbolLocationNavigableItem.cs
示例6: FindReferencesInServiceProcessAsync
private static async Task FindReferencesInServiceProcessAsync(
SymbolAndProjectId symbolAndProjectId,
Solution solution,
IStreamingFindReferencesProgress progress,
IImmutableSet<Document> documents,
CancellationToken cancellationToken)
{
var client = await solution.Workspace.GetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (client == null)
{
await FindReferencesInCurrentProcessAsync(
symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false);
return;
}
// Create a callback that we can pass to the server process to hear about the
// results as it finds them. When we hear about results we'll forward them to
// the 'progress' parameter which will then upate the UI.
var serverCallback = new ServerCallback(solution, progress, cancellationToken);
using (var session = await client.CreateCodeAnalysisServiceSessionAsync(
solution, serverCallback, cancellationToken).ConfigureAwait(false))
{
await session.InvokeAsync(
nameof(IRemoteSymbolFinder.FindReferencesAsync),
SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId),
documents?.Select(SerializableDocumentId.Dehydrate).ToArray()).ConfigureAwait(false);
}
}
开发者ID:jkotas,项目名称:roslyn,代码行数:29,代码来源:SymbolFinder_Remote.cs
示例7: TestMethod
public void TestMethod(string ratingsString, string candyString)
{
var ratings = JsonConvert.DeserializeObject<int[]>(ratingsString);
var expectedResult = JsonConvert.DeserializeObject<int[]>(candyString).Sum();
var result = new Solution().Candy(ratings);
Assert.AreEqual(expectedResult, result);
}
开发者ID:alexguo88,项目名称:LeetCode,代码行数:7,代码来源:135.Candy.Test.cs
示例8: SolutionPackageRepository2
public SolutionPackageRepository2 (Solution solution)
: this (
solution,
new SharpDevelopPackageRepositoryFactory (),
PackageManagementServices.Options)
{
}
开发者ID:modulexcite,项目名称:monodevelop-nuget-extensions,代码行数:7,代码来源:SolutionPackageRepository.cs
示例9: Main
static void Main(string[] args)
{
Solution s = new Solution();
int[] TestCase = new int[6] {1,3,6,4,1,2};
Console.WriteLine(s.solution(TestCase));
}
开发者ID:stanchow,项目名称:Codility-DemoCode,代码行数:7,代码来源:Lesson2-3.cs
示例10: TestMethod
public void TestMethod(string s, string wordDictString, string expectedResultsString)
{
var wordDict = new HashSet<string>(wordDictString.Split());
var expectedResults = expectedResultsString.Split('|').OrderBy(str => str).ToArray();
var results = new Solution().WordBreak(s, wordDict).OrderBy(str => str).ToArray();
Assert.AreEqual(string.Join("|", expectedResults), string.Join("|", results));
}
开发者ID:alexguo88,项目名称:LeetCode,代码行数:7,代码来源:140.WordBreakII.Test.cs
示例11: DoMutation
public void DoMutation(double probability, Solution solution)
{
XReal x = new XReal(solution);
for (int var = 0; var < solution.DecisionVariables.Length; var++)
{
if (PseudoRandom.Instance().NextDouble() < probability)
{
double rand = PseudoRandom.Instance().NextDouble();
double tmp = (rand - 0.5)*_perturbation;
tmp += x.GetValue(var);
if (tmp < x.GetLowerBound(var))
{
tmp = x.GetLowerBound(var);
}
else if (tmp > x.GetUpperBound(var))
{
tmp = x.GetUpperBound(var);
}
x.SetValue(var, tmp);
}
}
}
开发者ID:CRIAAC,项目名称:CSharpMetal,代码行数:26,代码来源:UniformMutation.cs
示例12: MergeAndResolveDependencies
public IList<Dependency> MergeAndResolveDependencies(Solution soln, Project proj)
{
try {
var wishes = new List<Wish>();
wishes.AddRange(soln.GetAllWishes());
wishes.AddRange(proj.GetAllWishes());
if (Log.IsTraceEnabled()) {
Log.Trace("merged wishes=\n" + String.Join("\n",wishes));
}
ValidateAll(wishes);
//now the fun begins. Resolve transitive deps, find closest versions
//TODO:resolve for all but pick only what the current project needs
//TODO:keep the calculated cache for how long? how to decide when to recalc all?
var resolver = new WishDependencyResolver(DepsCache);
var deps = resolver.Resolve(wishes);
var projWishes = proj.GetAllWishes();
//TODO:now line up with deps? to get copy to and additional info added?
return deps;
} catch (Exception e) {
throw new ResolverException("Error trying to resolve dependencies for project " + proj + " and solution " + soln, e);
}
}
开发者ID:NRequire,项目名称:nrequire,代码行数:26,代码来源:ProjectDependencyResolver.cs
示例13: TestMethod
public void TestMethod(string input, string expectedResultString)
{
var expectedResult = JsonConvert.DeserializeObject<List<int>>(expectedResultString);
expectedResult.Sort();
var result = new Solution().DiffWaysToCompute(input).OrderBy(x => x);
Assert.AreEqual(JsonConvert.SerializeObject(expectedResult), JsonConvert.SerializeObject(result));
}
开发者ID:alexguo88,项目名称:LeetCode,代码行数:7,代码来源:241.DifferentWaysToAddParentheses.Test.cs
示例14: RestoreAndCheckForUpdatesAction
public RestoreAndCheckForUpdatesAction (Solution solution)
{
this.solution = solution;
packageManagementEvents = PackageManagementServices.PackageManagementEvents;
solutionManager = PackageManagementServices.Workspace.GetSolutionManager (solution);
nugetProjects = solutionManager.GetNuGetProjects ().ToList ();
if (AnyProjectsUsingPackagesConfig ()) {
restoreManager = new PackageRestoreManager (
solutionManager.CreateSourceRepositoryProvider (),
solutionManager.Settings,
solutionManager
);
}
if (AnyProjectsUsingProjectJson ()) {
buildIntegratedRestorer = new MonoDevelopBuildIntegratedRestorer (
solutionManager.CreateSourceRepositoryProvider (),
solutionManager.Settings);
}
if (AnyNuGetAwareProjects ()) {
nugetAwareRestorer = new NuGetAwareProjectPackageRestoreManager (solutionManager);
}
}
开发者ID:PlayScriptRedux,项目名称:monodevelop,代码行数:26,代码来源:RestoreAndCheckForUpdatesAction.cs
示例15: TemporaryWorkspace
public TemporaryWorkspace(Solution solution)
: base(RoslynServices.HostServices, workspaceKind: TemporaryWorkspace.WorkspaceKind_TemporaryWorkspace)
{
Options = Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0);
this.SetCurrentSolution(solution);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:TemporaryWorkspace.cs
示例16: ProcessReferencedSymbol
private void ProcessReferencedSymbol(
Solution solution,
ReferencedSymbol referencedSymbol,
ArrayBuilder<DefinitionItem> definitions,
ArrayBuilder<SourceReferenceItem> references,
bool includeHiddenLocations,
HashSet<DocumentSpan> uniqueSpans)
{
// See if this is a symbol we even want to present to the user. If not,
// ignore it entirely (including all its reference locations).
if (!referencedSymbol.ShouldShow())
{
return;
}
var definitionItem = referencedSymbol.Definition.ToDefinitionItem(
solution, includeHiddenLocations, uniqueSpans);
definitions.Add(definitionItem);
// Now, create the SourceReferenceItems for all the reference locations
// for this definition.
CreateReferences(
referencedSymbol, references, definitionItem,
includeHiddenLocations, uniqueSpans);
// Finally, see if there are any third parties that want to add their
// own result to our collection.
var thirdPartyItem = GetThirdPartyDefinitionItem(solution, referencedSymbol.Definition);
if (thirdPartyItem != null)
{
definitions.Add(thirdPartyItem);
}
}
开发者ID:panopticoncentral,项目名称:roslyn,代码行数:33,代码来源:IDefinitionsAndReferencesFactory.cs
示例17: LinqGenerator
public LinqGenerator(Solution.Solution solution, SchemaFactory dbInfo)
: base(solution, dbInfo)
{
LinqDirectory = Path.Combine(Solution.BaseDirectory, "LINQ");
if (!Directory.Exists(LinqDirectory))
Directory.CreateDirectory(LinqDirectory);
}
开发者ID:CDHDeveloper,项目名称:CDHLinqDBSchema,代码行数:7,代码来源:LinqGenerator.cs
示例18: Projects
public static IList<Project> Projects(Solution solution)
{
Projects projects = solution.Projects;
List<Project> list = new List<Project>();
var item = projects.GetEnumerator();
while (item.MoveNext())
{
var project = item.Current as Project;
if (project == null)
{
continue;
}
if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder)
{
list.AddRange(GetSolutionFolderProjects(project));
}
else
{
list.Add(project);
}
}
return list;
}
开发者ID:techl,项目名称:MonoRemoteDebugger,代码行数:25,代码来源:MonoVisualStudioExtension.cs
示例19: FindReferencesAsync
/// <summary>
/// Finds all references to a symbol throughout a solution
/// </summary>
/// <param name="symbol">The symbol to find references to.</param>
/// <param name="solution">The solution to find references within.</param>
/// <param name="cancellationToken">A cancellation token.</param>
public static Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync(
ISymbol symbol,
Solution solution,
CancellationToken cancellationToken = default(CancellationToken))
{
return FindReferencesAsync(symbol, solution, progress: null, documents: null, cancellationToken: cancellationToken);
}
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:13,代码来源:SymbolFinder_References.cs
示例20: Main
static void Main()
{
var s = new Solution();
Console.WriteLine(s.solution(
new[] { 5, 1, 3, 1, 1 },
new[] { 1, 1, 0, 0, 0 }));
Console.WriteLine(s.solution(
new[] { 1, 2, 1, 1, 1 },
new[] { 0, 1, 0, 0, 0 }));
Console.WriteLine(s.solution(
new[] { 1, 2, 4, 3, 5 },
new[] { 0, 1, 0, 1, 0 }));
Console.WriteLine(s.solution(
new[] { 1, 2, 1, 3, 1 },
new[] { 0, 1, 0, 1, 0 }));
Console.WriteLine(s.solution(
new[] { 1, 4, 2, 3, 5 },
new[] { 0, 1, 0, 1, 0 }));
Console.WriteLine(s.solution(
new[] { 1, 1, 3, 1, 1 },
new[] { 0, 1, 0, 0, 0 }));
Console.WriteLine(s.solution(new[] { 1 }, new[] { 0 }));
Console.WriteLine(s.solution(new[] { 1 }, new[] { 1 }));
var A = new int[100000];
for (int i = 0; i < 100000; i++)
{
A[i] = 1000000000 - i;
}
var B = new int[100000];
B[0] = 1;
Console.WriteLine(s.solution(A, B));
}
开发者ID:VictorNS,项目名称:Codility,代码行数:34,代码来源:Program.cs
注:本文中的Solution类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论