本文整理汇总了C#中Plan.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# Plan.ThrowIfNull方法的具体用法?C# Plan.ThrowIfNull怎么用?C# Plan.ThrowIfNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan.ThrowIfNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadoutImportationWindow
/// <summary>
/// Constructor.
/// </summary>
/// <param name="plan">The plan.</param>
/// <exception cref="System.ArgumentNullException">plan</exception>
public LoadoutImportationWindow(Plan plan)
: this()
{
plan.ThrowIfNull(nameof(plan));
Plan = plan;
EveMonClient.CharacterUpdated += EveMonClient_CharacterUpdated;
EveMonClient.PlanChanged += EveMonClient_PlanChanged;
EveMonClient.PlanNameChanged += EveMonClient_PlanNameChanged;
}
示例2: ExportAsText
/// <summary>
/// Exports the plan under a text format.
/// </summary>
/// <param name="planToExport">The plan to export.</param>
/// <param name="settings">The settings.</param>
/// <param name="exportActions">The export actions.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">
/// planToExport
/// or
/// settings
/// </exception>
/// <exception cref="System.NotImplementedException"></exception>
/// <exception cref="System.ArgumentNullException">planToExport or settings</exception>
public static string ExportAsText(Plan planToExport, PlanExportSettings settings,
Action<StringBuilder, PlanEntry, PlanExportSettings> exportActions = null)
{
planToExport.ThrowIfNull(nameof(planToExport));
settings.ThrowIfNull(nameof(settings));
PlanScratchpad plan = new PlanScratchpad(planToExport.Character, planToExport);
plan.Sort(planToExport.SortingPreferences);
plan.UpdateStatistics();
StringBuilder builder = new StringBuilder();
Character character = (Character)plan.Character;
// Initialize constants
string lineFeed = Environment.NewLine;
string boldStart = String.Empty;
string boldEnd = String.Empty;
switch (settings.Markup)
{
case MarkupType.Forum:
boldStart = "[b]";
boldEnd = "[/b]";
break;
case MarkupType.Html:
lineFeed = $"<br />{Environment.NewLine}";
boldStart = "<b>";
boldEnd = "</b>";
break;
case MarkupType.Undefined:
case MarkupType.None:
break;
default:
throw new NotImplementedException();
}
// Header
if (settings.IncludeHeader)
{
builder.Append(boldStart)
.Append($"{(settings.ShoppingList ? "Shopping list " : "Skill plan ")} for {character.Name}")
.Append(boldEnd)
.Append(lineFeed)
.Append(lineFeed);
}
// Scroll through entries
int index = 0;
DateTime endTime = DateTime.Now;
foreach (PlanEntry entry in plan)
{
// Skip is we're only build a shopping list
bool shoppingListCandidate = !(entry.CharacterSkill.IsKnown || entry.Level != 1 || entry.CharacterSkill.IsOwned);
if (settings.ShoppingList && !shoppingListCandidate)
continue;
// Remapping point
if (!settings.ShoppingList && (entry.Remapping != null) && settings.RemappingPoints)
{
builder
.Append($"***{entry.Remapping}***")
.Append(lineFeed);
}
// Entry's index
index++;
if (settings.EntryNumber)
builder.Append($"{index}. ");
// Name
builder.Append(boldStart);
AddName(settings, entry, builder);
builder.Append(boldEnd);
// Training time
AddTrainingTime(settings, shoppingListCandidate, entry, builder);
exportActions?.Invoke(builder, entry, settings);
builder.Append(lineFeed);
// End time
endTime = entry.EndTime;
}
//.........这里部分代码省略.........
示例3: ExportAsXML
/// <summary>
/// Exports the plan under an XML format.
/// </summary>
/// <param name="plan">The plan.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">plan</exception>
public static string ExportAsXML(Plan plan)
{
plan.ThrowIfNull(nameof(plan));
// Generates a settings plan and transforms it to an output plan
SerializablePlan serial = plan.Export();
OutputPlan output = new OutputPlan { Name = serial.Name, Owner = serial.Owner, Revision = Settings.Revision };
output.Entries.AddRange(serial.Entries);
// Serializes to XML document and gets a string representation
XmlDocument doc = (XmlDocument)Util.SerializeToXmlDocument(output);
return Util.GetXmlStringRepresentation(doc);
}
示例4: ExportPlanAsync
/// <summary>
/// Displays the plan exportation window and then exports it.
/// </summary>
/// <param name="plan">The plan.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException"></exception>
public static async Task ExportPlanAsync(Plan plan)
{
plan.ThrowIfNull(nameof(plan));
await ExportPlanAsync(plan, (Character)plan.Character);
}