本文整理汇总了C#中Solution.GetConfigurations方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.GetConfigurations方法的具体用法?C# Solution.GetConfigurations怎么用?C# Solution.GetConfigurations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution.GetConfigurations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
/// <summary>
/// Load configuration information for a solution
/// </summary>
public void Load (Solution sol, SolutionItem project, SolutionItemRunConfiguration runConfig)
{
currentSolutionConfigurations.Clear ();
currentTargetPartitions.Clear ();
reducedConfigurations.Clear ();
if (sol == null)
return;
// Create a set of configuration partitions. Each partition will contain configurations
// which are implicitly selected when selecting an execution target. For example, in
// an iOS project we would have two partitions:
// 1) Debug|IPhoneSimulator, Release|IPhoneSimulator
// targets: iPhone, iPad
// 2) Debug|IPhone, Release|IPhone
// targets: device
List<TargetPartition> partitions = new List<TargetPartition> ();
if (project != null) {
foreach (var conf in project.Configurations) {
var targets = project.GetExecutionTargets (conf.Selector, runConfig);
if (!targets.Any ()) {
targets = new ExecutionTarget[] { dummyExecutionTarget };
}
var parts = partitions.Where (p => targets.Any (p.Targets.Contains)).ToArray();
if (parts.Length == 0) {
// Create a new partition for this configuration
var p = new TargetPartition ();
p.Configurations.Add (conf.Id);
p.Targets.UnionWith (targets);
partitions.Add (p);
}
else if (parts.Length == 1) {
// Register the configuration into an existing partition
parts[0].Configurations.Add (conf.Id);
parts[0].Targets.UnionWith (targets);
}
else {
// The partitions have to be merged into a single one
for (int n=1; n<parts.Length; n++) {
parts[0].Configurations.UnionWith (parts[n].Configurations);
parts[0].Targets.UnionWith (parts[n].Targets);
partitions.Remove (parts[n]);
}
}
}
// The startup project configuration partitions are used to create solution configuration partitions
foreach (var solConf in sol.Configurations) {
var pconf = solConf.GetEntryForItem (project);
if (pconf != null && pconf.Build) {
var part = partitions.FirstOrDefault (p => p.Configurations.Contains (pconf.ItemConfiguration));
if (part != null) {
part.SolutionConfigurations.Add (solConf.Id);
continue;
}
}
// The solution configuration is not bound to the startup project
// Add it to all partitions so that it can still take part of
// the solution configuration simplification process
foreach (var p in partitions)
p.SolutionConfigurations.Add (solConf.Id);
}
}
if (partitions.Count == 0) {
// There is no startup project, just use all solution configurations in this case
var p = new TargetPartition ();
p.SolutionConfigurations.AddRange (sol.GetConfigurations ());
partitions.Add (p);
}
// There can be several configurations with the same prefix and different platform but which build the same projects.
// If all configurations with the same prefix are identical, all of them can be reduced into a single configuration
// with no platform name. This loop detects such configurations
var notReducibleConfigurations = new HashSet<string> ();
foreach (var p in partitions) {
var groupedConfigs = p.SolutionConfigurations.GroupBy (sc => {
string name, plat;
ItemConfiguration.ParseConfigurationId (sc, out name, out plat);
return name;
}).ToArray ();
foreach (var confGroup in groupedConfigs) {
var configs = confGroup.ToArray ();
var baseConf = sol.Configurations[configs[0]];
if (configs.Skip (1).All (c => ConfigurationEquals (sol, baseConf, sol.Configurations[c])))
p.ReducedConfigurations.Add (confGroup.Key);
else
notReducibleConfigurations.Add (confGroup.Key);
}
}
// To really be able to use reduced configuration names, all partitions must have that reduced configuration
// Find the configurations that have been reduced in all partitions
//.........这里部分代码省略.........
示例2: MsSlnToCmbxHelper
public Solution MsSlnToCmbxHelper (string slnFileName, IProgressMonitor monitor)
{
Solution solution = new Solution();
monitor.BeginTask (GettextCatalog.GetString ("Importing solution"), 2);
try
{
// We invoke the ParseSolution
// by passing the file obtained
ParseSolution (slnFileName, monitor);
// Create all of the prjx files form the csproj files
monitor.BeginTask (null, projNameInfo.Values.Count * 2);
foreach (CsprojInfo pi in projNameInfo.Values) {
string mappedPath = MapPath (Path.GetDirectoryName (slnFileName), pi.csprojpath);
if (mappedPath == null) {
monitor.Step (2);
monitor.ReportWarning (GettextCatalog.GetString ("Project file not found: ") + pi.csprojpath);
continue;
}
SolutionEntityItem prj;
if (pi.NeedsConversion)
prj = CreatePrjxFromCsproj (mappedPath, monitor);
else
prj = (DotNetProject) Services.ProjectService.ReadSolutionItem (monitor, mappedPath);
if (prj == null)
return null;
monitor.Step (1);
solution.RootFolder.Items.Add (prj);
foreach (ItemConfiguration conf in prj.Configurations) {
if (!solution.GetConfigurations ().Contains (conf.Id))
solution.AddConfiguration (conf.Id, false);
}
monitor.Step (1);
}
monitor.EndTask ();
monitor.Step (1);
solution.SetLocation (Path.GetDirectoryName (slnFileName), Path.GetFileNameWithoutExtension(slnFileName));
monitor.Step (1);
return solution;
}
catch (Exception e)
{
monitor.ReportError (GettextCatalog.GetString ("The solution could not be imported."), e);
throw;
}
finally
{
monitor.EndTask ();
}
}