Initial Commit
This commit is contained in:
parent
8e178cbb7b
commit
63ed43f4af
368 changed files with 7968 additions and 20433 deletions
|
|
@ -1,210 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Observatory.Framework;
|
||||
|
||||
namespace Observatory.Framework
|
||||
#region Setting property attributes
|
||||
|
||||
/// <summary>
|
||||
/// Specifies text to display as the name of the setting in the UI instead of the property name.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingDisplayName : Attribute
|
||||
{
|
||||
|
||||
#region Settings class attributes
|
||||
/// <summary>
|
||||
/// Specifies the width of a settings column in the settings view. There are two columns.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public class SettingSuggestedColumnWidth : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the width of a settings column in the settings view. There are two columns.
|
||||
/// </summary>
|
||||
/// <param name="width">Provides a hint of the width of a settings column.</param>
|
||||
public SettingSuggestedColumnWidth(int width)
|
||||
{
|
||||
Width = width;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a hint of the width of a settings column.
|
||||
/// </summary>
|
||||
public int Width { get; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Setting property attributes
|
||||
private string name;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies text to display as the name of the setting in the UI instead of the property name.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingDisplayName : Attribute
|
||||
/// <param name="name">Name to display</param>
|
||||
public SettingDisplayName(string name)
|
||||
{
|
||||
private string name;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies text to display as the name of the setting in the UI instead of the property name.
|
||||
/// </summary>
|
||||
/// <param name="name">Name to display</param>
|
||||
public SettingDisplayName(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accessor to get/set displayed name.
|
||||
/// </summary>
|
||||
public string DisplayName
|
||||
{
|
||||
get => name;
|
||||
set => name = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a new visual group of settings beginning with the current setting with an optional label.
|
||||
/// Accessor to get/set displayed name.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingNewGroup : Attribute
|
||||
public string DisplayName
|
||||
{
|
||||
/// <summary>
|
||||
/// Starts a new visual group of settings beginning with the current setting with an optional label.
|
||||
/// </summary>
|
||||
/// <param name="label">An optional label describing the group.</param>
|
||||
public SettingNewGroup(string label = "")
|
||||
{
|
||||
Label = label;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An optional label describing the group.
|
||||
/// </summary>
|
||||
public string Label { get; }
|
||||
get => name;
|
||||
set => name = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the property should not be displayed to the user in the UI.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingIgnore : Attribute
|
||||
{ }
|
||||
/// <summary>
|
||||
/// Indicates numeric properly should use a slider control instead of a numeric textbox with roller.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingNumericUseSlider : Attribute
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates numeric properly should use a slider control instead of a numeric textbox with roller.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingNumericUseSlider : Attribute
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Specify backing value used by Dictionary<string, object> to indicate selected option.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingBackingValue : Attribute
|
||||
{
|
||||
private string property;
|
||||
|
||||
/// <summary>
|
||||
/// Specify backing value used by Dictionary<string, object> to indicate selected option.
|
||||
/// </summary>
|
||||
/// <param name="property">Property name for backing value.</param>
|
||||
public SettingBackingValue(string property)
|
||||
{
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accessor to get/set backing value property name.
|
||||
/// </summary>
|
||||
public string BackingProperty
|
||||
{
|
||||
get => property;
|
||||
set => property = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Specify bounds for numeric inputs.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingNumericBounds : Attribute
|
||||
{
|
||||
private double minimum;
|
||||
private double maximum;
|
||||
private double increment;
|
||||
private int precision;
|
||||
|
||||
/// <summary>
|
||||
/// Specify bounds for numeric inputs.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class SettingNumericBounds : Attribute
|
||||
/// <param name="minimum">Minimum allowed value.</param>
|
||||
/// <param name="maximum">Maximum allowed value.</param>
|
||||
/// <param name="increment">Increment between allowed values in slider/roller inputs.</param>
|
||||
/// <param name="precision">The number of digits to display for non integer values.</param>
|
||||
public SettingNumericBounds(double minimum, double maximum, double increment = 1.0, int precision = 1)
|
||||
{
|
||||
private double minimum;
|
||||
private double maximum;
|
||||
private double increment;
|
||||
private int precision;
|
||||
|
||||
/// <summary>
|
||||
/// Specify bounds for numeric inputs.
|
||||
/// </summary>
|
||||
/// <param name="minimum">Minimum allowed value.</param>
|
||||
/// <param name="maximum">Maximum allowed value.</param>
|
||||
/// <param name="increment">Increment between allowed values in slider/roller inputs.</param>
|
||||
/// <param name="precision">The number of digits to display for non integer values.</param>
|
||||
public SettingNumericBounds(double minimum, double maximum, double increment = 1.0, int precision = 1)
|
||||
{
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
this.increment = increment;
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimum allowed value.
|
||||
/// </summary>
|
||||
public double Minimum
|
||||
{
|
||||
get => minimum;
|
||||
set => minimum = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum allowed value.
|
||||
/// </summary>
|
||||
public double Maximum
|
||||
{
|
||||
get => maximum;
|
||||
set => maximum = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment between allowed values in slider/roller inputs.
|
||||
/// </summary>
|
||||
public double Increment
|
||||
{
|
||||
get => increment;
|
||||
set => increment = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of digits to display for non integer values.
|
||||
/// </summary>
|
||||
public int Precision
|
||||
{
|
||||
get => precision;
|
||||
set => precision = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BasicUI attributes
|
||||
/// <summary>
|
||||
/// Suggests default column width when building basic plugin grid UI.
|
||||
/// Minimum allowed value.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public class ColumnSuggestedWidth : Attribute
|
||||
public double Minimum
|
||||
{
|
||||
/// <summary>
|
||||
/// Suggests default column width when building basic plugin grid UI.
|
||||
/// </summary>
|
||||
/// <param name="width">The suggested width of the annotated column.</param>
|
||||
public ColumnSuggestedWidth(int width)
|
||||
{
|
||||
Width = width;
|
||||
}
|
||||
get => minimum;
|
||||
set => minimum = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The suggested width of the annotated column.
|
||||
/// </summary>
|
||||
public int Width { get; }
|
||||
/// <summary>
|
||||
/// Maximum allowed value.
|
||||
/// </summary>
|
||||
public double Maximum
|
||||
{
|
||||
get => maximum;
|
||||
set => maximum = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment between allowed values in slider/roller inputs.
|
||||
/// </summary>
|
||||
public double Increment
|
||||
{
|
||||
get => increment;
|
||||
set => increment = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of digits to display for non integer values.
|
||||
/// </summary>
|
||||
public int Precision
|
||||
{
|
||||
get => precision;
|
||||
set => precision = value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -1,172 +1,169 @@
|
|||
using System;
|
||||
namespace Observatory.Framework;
|
||||
|
||||
namespace Observatory.Framework
|
||||
/// <summary>
|
||||
/// Provides data for Elite Dangerous journal events.
|
||||
/// </summary>
|
||||
public class JournalEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for Elite Dangerous journal events.
|
||||
/// <para>Type of journal entry that triggered event.</para>
|
||||
/// <para>Will be a class from the Observatory.Framework.Files.Journal namespace derived from JournalBase, or JournalBase itself in the case of an unhandled journal event type.</para>
|
||||
/// </summary>
|
||||
public class JournalEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Type of journal entry that triggered event.</para>
|
||||
/// <para>Will be a class from the Observatory.Framework.Files.Journal namespace derived from JournalBase, or JournalBase itself in the case of an unhandled journal event type.</para>
|
||||
/// </summary>
|
||||
public Type journalType;
|
||||
/// <summary>
|
||||
/// <para>Elite Dangerous journal event, deserialized into a .NET object of the type specified by JournalEventArgs.journalType.</para>
|
||||
/// <para>Unhandled json values within a journal entry type will be contained in member property:<br/>Dictionary<string, object> AdditionalProperties.</para>
|
||||
/// </summary>
|
||||
public object journalEvent;
|
||||
}
|
||||
|
||||
public Type journalType;
|
||||
/// <summary>
|
||||
/// Provides values used as arguments for Observatory notification events.
|
||||
/// <para>Elite Dangerous journal event, deserialized into a .NET object of the type specified by JournalEventArgs.journalType.</para>
|
||||
/// <para>Unhandled json values within a journal entry type will be contained in member property:<br/>Dictionary<string, object> AdditionalProperties.</para>
|
||||
/// </summary>
|
||||
public class NotificationArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Text typically displayed as header content.
|
||||
/// </summary>
|
||||
public string Title;
|
||||
/// <summary>
|
||||
/// SSML representation of Title text.<br/>
|
||||
/// This value is optional, if omitted the value of <c>NotificationArgs.Title</c> will be used for voice synthesis without markup.
|
||||
/// </summary>
|
||||
public string TitleSsml;
|
||||
/// <summary>
|
||||
/// Text typically displayed as body content.
|
||||
/// </summary>
|
||||
public string Detail;
|
||||
/// <summary>
|
||||
/// SSML representation of Detail text.<br/>
|
||||
/// This value is optional, if omitted the value of <c>NotificationArgs.Detail</c> will be used for voice synthesis without markup.
|
||||
/// </summary>
|
||||
public string DetailSsml;
|
||||
/// <summary>
|
||||
/// Specify window timeout in ms (overrides Core setting). Specify 0 timeout to persist until removed via IObservatoryCore.CancelNotification. Default -1 (use Core setting).
|
||||
/// </summary>
|
||||
public int Timeout = -1;
|
||||
/// <summary>
|
||||
/// Specify window X position as a percentage from upper left corner (overrides Core setting). Default -1.0 (use Core setting).
|
||||
/// </summary>
|
||||
public double XPos = -1.0;
|
||||
/// <summary>
|
||||
/// Specify window Y position as a percentage from upper left corner (overrides Core setting). Default -1.0 (use Core setting).
|
||||
/// </summary>
|
||||
public double YPos = -1.0;
|
||||
/// <summary>
|
||||
/// Specifies the desired renderings of the notification. Defaults to <see cref="NotificationRendering.All"/>.
|
||||
/// </summary>
|
||||
public NotificationRendering Rendering = NotificationRendering.All;
|
||||
/// <summary>
|
||||
/// Specifies if some part of the notification should be suppressed. Not supported by all notifiers. Defaults to <see cref="NotificationSuppression.None"/>.
|
||||
/// </summary>
|
||||
public NotificationSuppression Suppression = NotificationSuppression.None;
|
||||
/// <summary>
|
||||
/// The plugin sending this notification.
|
||||
/// </summary>
|
||||
public string Sender = "";
|
||||
/// <summary>
|
||||
/// Additional notification detailed (generally not rendered by voice or popup; potentially used by aggregating/logging plugins).
|
||||
/// </summary>
|
||||
public string ExtendedDetails;
|
||||
/// <summary>
|
||||
/// A value which allows grouping of notifications together. For example, values >= 0 <= 1000 could be system body IDs, -1 is the system, anything else is arbitrary.
|
||||
/// </summary>
|
||||
public int? CoalescingId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines constants for suppression of title or detail announcement in a notification.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum NotificationSuppression
|
||||
{
|
||||
/// <summary>
|
||||
/// No suppression.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Suppress title.
|
||||
/// </summary>
|
||||
Title = 1,
|
||||
/// <summary>
|
||||
/// Suppress detail.
|
||||
/// </summary>
|
||||
Detail = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines constants for controlling notification routing to plugins or native notification handlers.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum NotificationRendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Send notification to native visual popup notificaiton handler.
|
||||
/// </summary>
|
||||
NativeVisual = 1,
|
||||
/// <summary>
|
||||
/// Send notification to native speech notification handler.
|
||||
/// </summary>
|
||||
NativeVocal = 2,
|
||||
/// <summary>
|
||||
/// Send notification to all installed notifier plugins.
|
||||
/// </summary>
|
||||
PluginNotifier = 4,
|
||||
/// <summary>
|
||||
/// Send notification to all available handlers.
|
||||
/// </summary>
|
||||
All = (NativeVisual | NativeVocal | PluginNotifier)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flags indicating current state of journal monitoring.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum LogMonitorState : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Monitoring is stopped.
|
||||
/// </summary>
|
||||
Idle = 0,
|
||||
/// <summary>
|
||||
/// Real-time monitoring is active.
|
||||
/// </summary>
|
||||
Realtime = 1,
|
||||
/// <summary>
|
||||
/// Batch read of historical journals is in progress.
|
||||
/// </summary>
|
||||
Batch = 2,
|
||||
/// <summary>
|
||||
/// Batch read of recent journals is in progress to establish current player state.
|
||||
/// </summary>
|
||||
PreRead = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides information about a LogMonitor state transition.
|
||||
/// </summary>
|
||||
public class LogMonitorStateChangedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The previous LogMonitor state.
|
||||
/// </summary>
|
||||
public LogMonitorState PreviousState;
|
||||
|
||||
/// <summary>
|
||||
/// The new, current LogMonitor state.
|
||||
/// </summary>
|
||||
public LogMonitorState NewState;
|
||||
|
||||
/// <summary>
|
||||
/// Determins if the given state is a batch read of any form.
|
||||
/// </summary>
|
||||
/// <param name="state">The state to evaluate</param>
|
||||
/// <returns>A boolean; True iff the state provided represents a batch-mode read.</returns>
|
||||
public static bool IsBatchRead(LogMonitorState state)
|
||||
{
|
||||
return state.HasFlag(LogMonitorState.Batch) || state.HasFlag(LogMonitorState.PreRead);
|
||||
}
|
||||
}
|
||||
public object journalEvent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides values used as arguments for Observatory notification events.
|
||||
/// </summary>
|
||||
public class NotificationArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Text typically displayed as header content.
|
||||
/// </summary>
|
||||
public string Title;
|
||||
/// <summary>
|
||||
/// SSML representation of Title text.<br/>
|
||||
/// This value is optional, if omitted the value of <c>NotificationArgs.Title</c> will be used for voice synthesis without markup.
|
||||
/// </summary>
|
||||
public string TitleSsml;
|
||||
/// <summary>
|
||||
/// Text typically displayed as body content.
|
||||
/// </summary>
|
||||
public string Detail;
|
||||
/// <summary>
|
||||
/// SSML representation of Detail text.<br/>
|
||||
/// This value is optional, if omitted the value of <c>NotificationArgs.Detail</c> will be used for voice synthesis without markup.
|
||||
/// </summary>
|
||||
public string DetailSsml;
|
||||
/// <summary>
|
||||
/// Specify window timeout in ms (overrides Core setting). Specify 0 timeout to persist until removed via IObservatoryCore.CancelNotification. Default -1 (use Core setting).
|
||||
/// </summary>
|
||||
public int Timeout = -1;
|
||||
/// <summary>
|
||||
/// Specify window X position as a percentage from upper left corner (overrides Core setting). Default -1.0 (use Core setting).
|
||||
/// </summary>
|
||||
public double XPos = -1.0;
|
||||
/// <summary>
|
||||
/// Specify window Y position as a percentage from upper left corner (overrides Core setting). Default -1.0 (use Core setting).
|
||||
/// </summary>
|
||||
public double YPos = -1.0;
|
||||
/// <summary>
|
||||
/// Specifies the desired renderings of the notification. Defaults to <see cref="NotificationRendering.All"/>.
|
||||
/// </summary>
|
||||
public NotificationRendering Rendering = NotificationRendering.All;
|
||||
/// <summary>
|
||||
/// Specifies if some part of the notification should be suppressed. Not supported by all notifiers. Defaults to <see cref="NotificationSuppression.None"/>.
|
||||
/// </summary>
|
||||
public NotificationSuppression Suppression = NotificationSuppression.None;
|
||||
/// <summary>
|
||||
/// The plugin sending this notification.
|
||||
/// </summary>
|
||||
public string Sender = "";
|
||||
/// <summary>
|
||||
/// Additional notification detailed (generally not rendered by voice or popup; potentially used by aggregating/logging plugins).
|
||||
/// </summary>
|
||||
public string ExtendedDetails;
|
||||
/// <summary>
|
||||
/// A value which allows grouping of notifications together. For example, values >= 0 <= 1000 could be system body IDs, -1 is the system, anything else is arbitrary.
|
||||
/// </summary>
|
||||
public int? CoalescingId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines constants for suppression of title or detail announcement in a notification.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum NotificationSuppression
|
||||
{
|
||||
/// <summary>
|
||||
/// No suppression.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Suppress title.
|
||||
/// </summary>
|
||||
Title = 1,
|
||||
/// <summary>
|
||||
/// Suppress detail.
|
||||
/// </summary>
|
||||
Detail = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines constants for controlling notification routing to plugins or native notification handlers.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum NotificationRendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Send notification to native visual popup notificaiton handler.
|
||||
/// </summary>
|
||||
NativeVisual = 1,
|
||||
/// <summary>
|
||||
/// Send notification to native speech notification handler.
|
||||
/// </summary>
|
||||
NativeVocal = 2,
|
||||
/// <summary>
|
||||
/// Send notification to all installed notifier plugins.
|
||||
/// </summary>
|
||||
PluginNotifier = 4,
|
||||
/// <summary>
|
||||
/// Send notification to all available handlers.
|
||||
/// </summary>
|
||||
All = (NativeVisual | NativeVocal | PluginNotifier)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flags indicating current state of journal monitoring.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum LogMonitorState : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Monitoring is stopped.
|
||||
/// </summary>
|
||||
Idle = 0,
|
||||
/// <summary>
|
||||
/// Real-time monitoring is active.
|
||||
/// </summary>
|
||||
Realtime = 1,
|
||||
/// <summary>
|
||||
/// Batch read of historical journals is in progress.
|
||||
/// </summary>
|
||||
Batch = 2,
|
||||
/// <summary>
|
||||
/// Batch read of recent journals is in progress to establish current player state.
|
||||
/// </summary>
|
||||
PreRead = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides information about a LogMonitor state transition.
|
||||
/// </summary>
|
||||
public class LogMonitorStateChangedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The previous LogMonitor state.
|
||||
/// </summary>
|
||||
public LogMonitorState PreviousState;
|
||||
|
||||
/// <summary>
|
||||
/// The new, current LogMonitor state.
|
||||
/// </summary>
|
||||
public LogMonitorState NewState;
|
||||
|
||||
/// <summary>
|
||||
/// Determins if the given state is a batch read of any form.
|
||||
/// </summary>
|
||||
/// <param name="state">The state to evaluate</param>
|
||||
/// <returns>A boolean; True iff the state provided represents a batch-mode read.</returns>
|
||||
public static bool IsBatchRead(LogMonitorState state)
|
||||
{
|
||||
return state.HasFlag(LogMonitorState.Batch) || state.HasFlag(LogMonitorState.PreRead);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +1,31 @@
|
|||
using System;
|
||||
namespace Observatory.Framework;
|
||||
|
||||
namespace Observatory.Framework
|
||||
/// <summary>
|
||||
/// Container for exceptions within plugins which cannot be gracefully handled in context,
|
||||
/// but benefit from having a context-specific user message.
|
||||
/// </summary>
|
||||
public class PluginException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Container for exceptions within plugins which cannot be gracefully handled in context,
|
||||
/// but benefit from having a context-specific user message.
|
||||
/// Initialze new PluginException with details of the originating plugin and a specific user-facing message for display.
|
||||
/// </summary>
|
||||
public class PluginException : Exception
|
||||
/// <param name="pluginName"></param>
|
||||
/// <param name="userMessage"></param>
|
||||
/// <param name="innerException"></param>
|
||||
public PluginException(string pluginName, string userMessage, Exception innerException) : base(innerException.Message, innerException)
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialze new PluginException with details of the originating plugin and a specific user-facing message for display.
|
||||
/// </summary>
|
||||
/// <param name="pluginName"></param>
|
||||
/// <param name="userMessage"></param>
|
||||
/// <param name="innerException"></param>
|
||||
public PluginException(string pluginName, string userMessage, Exception innerException) : base(innerException.Message, innerException)
|
||||
{
|
||||
PluginName = pluginName;
|
||||
UserMessage = userMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of plugin from which the exception was thrown.
|
||||
/// </summary>
|
||||
public string PluginName { get; }
|
||||
/// <summary>
|
||||
/// Name of plugin from which the exception was thrown.
|
||||
/// </summary>
|
||||
public string PluginName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Message to be displayed to user.
|
||||
/// </summary>
|
||||
public string UserMessage { get; }
|
||||
/// <summary>
|
||||
/// Message to be displayed to user.
|
||||
/// </summary>
|
||||
public string UserMessage { get; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +1,28 @@
|
|||
using Observatory.Framework.Files.ParameterTypes;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Immutable;
|
||||
using Observatory.Framework.Files.Journal;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Journal
|
||||
namespace Observatory.Framework.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Elite Dangerous backpack.json file. Describes all the items currently carried by the player.
|
||||
/// </summary>
|
||||
public class BackpackFile : JournalBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Elite Dangerous backpack.json file. Describes all the items currently carried by the player.
|
||||
/// List of all items carried.
|
||||
/// </summary>
|
||||
public class BackpackFile : JournalBase
|
||||
{
|
||||
/// <summary>
|
||||
/// List of all items carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Items { get; init; }
|
||||
/// <summary>
|
||||
/// List of all components carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Components { get; init; }
|
||||
/// <summary>
|
||||
/// List of player consumable items carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Consumables { get; init; }
|
||||
/// <summary>
|
||||
/// List of all data currently stored by the player.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Data { get; init; }
|
||||
}
|
||||
}
|
||||
public ImmutableList<BackpackItem> Items { get; init; }
|
||||
/// <summary>
|
||||
/// List of all components carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Components { get; init; }
|
||||
/// <summary>
|
||||
/// List of player consumable items carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Consumables { get; init; }
|
||||
/// <summary>
|
||||
/// List of all data currently stored by the player.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Data { get; init; }
|
||||
}
|
||||
|
|
@ -1,24 +1,24 @@
|
|||
using Observatory.Framework.Files.ParameterTypes;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Immutable;
|
||||
using Observatory.Framework.Files.Journal;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files
|
||||
namespace Observatory.Framework.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Elite Dangerous cargo.json file. Describes the current cargo carried above the player's ship.
|
||||
/// </summary>
|
||||
public class CargoFile : JournalBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Elite Dangerous cargo.json file. Describes the current cargo carried above the player's ship.
|
||||
/// Type of vehicle currently being reported. "Ship" or "SRV".
|
||||
/// </summary>
|
||||
public class CargoFile : Journal.JournalBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of vehicle currently being reported. "Ship" or "SRV".
|
||||
/// </summary>
|
||||
public string Vessel { get; init; }
|
||||
/// <summary>
|
||||
/// Number of different types of cargo carried(?)
|
||||
/// </summary>
|
||||
public int Count { get; init; }
|
||||
/// <summary>
|
||||
/// List of full cargo details.
|
||||
/// </summary>
|
||||
public ImmutableList<CargoType> Inventory { get; init; }
|
||||
}
|
||||
}
|
||||
public string Vessel { get; init; }
|
||||
/// <summary>
|
||||
/// Number of different types of cargo carried(?)
|
||||
/// </summary>
|
||||
public int Count { get; init; }
|
||||
/// <summary>
|
||||
/// List of full cargo details.
|
||||
/// </summary>
|
||||
public ImmutableList<CargoType> Inventory { get; init; }
|
||||
}
|
||||
|
|
@ -1,24 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
class FleetCarrierTravelConverter : JsonConverter<float>
|
||||
{
|
||||
class FleetCarrierTravelConverter : JsonConverter<float>
|
||||
public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
return Single.Parse(reader.GetString().Split(' ')[0]);
|
||||
else
|
||||
return reader.GetSingle();
|
||||
return float.Parse(reader.GetString().Split(' ')[0]);
|
||||
return reader.GetSingle();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,17 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public class IntBoolConverter : JsonConverter<bool>
|
||||
{
|
||||
|
||||
public class IntBoolConverter : JsonConverter<bool>
|
||||
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return reader.GetInt16() == 1;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteNumberValue(value ? 1 : 0);
|
||||
}
|
||||
return reader.GetInt16() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteNumberValue(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,19 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public class IntBoolFlexConverter : JsonConverter<bool>
|
||||
{
|
||||
public class IntBoolFlexConverter : JsonConverter<bool>
|
||||
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
return reader.GetInt16() == 1;
|
||||
else
|
||||
return reader.GetBoolean();
|
||||
return reader.GetBoolean();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteBooleanValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +1,26 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
{
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Faction changed from a simple string to an object with additional state information. If we find a string convert it to an object with null state.
|
||||
/// </summary>
|
||||
public class LegacyFactionConverter<TFaction> : JsonConverter<TFaction> where TFaction : Faction, new()
|
||||
/// <summary>
|
||||
/// Faction changed from a simple string to an object with additional state information. If we find a string convert it to an object with null state.
|
||||
/// </summary>
|
||||
public class LegacyFactionConverter<TFaction> : JsonConverter<TFaction> where TFaction : Faction, new()
|
||||
{
|
||||
public override TFaction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override TFaction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
return new TFaction { Name = reader.GetString(), FactionState = null };
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonSerializer.Deserialize<TFaction>(ref reader);
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<TFaction>(ref reader);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, TFaction value, JsonSerializerOptions options)
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, TFaction value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// The format used for materials changed from an object with a key for each material to an array of objects containing "name" and "percent".
|
||||
/// Need to handle both if we're going to read historical data. This reads the old format into a class reflecting the new structure.
|
||||
/// </summary>
|
||||
public class MaterialCompositionConverter : JsonConverter<ImmutableList<MaterialComposition>>
|
||||
{
|
||||
/// <summary>
|
||||
/// The format used for materials changed from an object with a key for each material to an array of objects containing "name" and "percent".
|
||||
/// Need to handle both if we're going to read historical data. This reads the old format into a class reflecting the new structure.
|
||||
/// </summary>
|
||||
public class MaterialCompositionConverter : JsonConverter<ImmutableList<MaterialComposition>>
|
||||
public override ImmutableList<MaterialComposition> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override ImmutableList<MaterialComposition> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
if (reader.TokenType == JsonTokenType.StartObject)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.StartObject)
|
||||
var materialComposition = new List<MaterialComposition>();
|
||||
while (reader.Read())
|
||||
{
|
||||
var materialComposition = new List<MaterialComposition>();
|
||||
while (reader.Read())
|
||||
if (reader.TokenType != JsonTokenType.EndObject)
|
||||
{
|
||||
if (reader.TokenType != JsonTokenType.EndObject)
|
||||
if (reader.TokenType == JsonTokenType.PropertyName)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.PropertyName)
|
||||
var name = reader.GetString();
|
||||
reader.Read();
|
||||
var percent = reader.GetSingle();
|
||||
var material = new MaterialComposition
|
||||
{
|
||||
string name = reader.GetString();
|
||||
reader.Read();
|
||||
float percent = reader.GetSingle();
|
||||
var material = new MaterialComposition
|
||||
{
|
||||
Name = name,
|
||||
Percent = percent
|
||||
};
|
||||
materialComposition.Add(material);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
Name = name,
|
||||
Percent = percent
|
||||
};
|
||||
materialComposition.Add(material);
|
||||
}
|
||||
}
|
||||
return materialComposition.ToImmutableList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ImmutableList<MaterialComposition>)JsonSerializer.Deserialize(ref reader, typeof(ImmutableList<MaterialComposition>));
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return materialComposition.ToImmutableList();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ImmutableList<MaterialComposition> value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return (ImmutableList<MaterialComposition>)JsonSerializer.Deserialize(ref reader, typeof(ImmutableList<MaterialComposition>));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ImmutableList<MaterialComposition> value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// The format used for materials changed from an object with a key for each material to an array of objects containing "name" and "percent".
|
||||
/// Need to handle both if we're going to read historical data. This reads the old format into a class reflecting the new structure.
|
||||
/// </summary>
|
||||
public class MaterialConverter : JsonConverter<ImmutableList<Material>>
|
||||
{
|
||||
/// <summary>
|
||||
/// The format used for materials changed from an object with a key for each material to an array of objects containing "name" and "percent".
|
||||
/// Need to handle both if we're going to read historical data. This reads the old format into a class reflecting the new structure.
|
||||
/// </summary>
|
||||
public class MaterialConverter : JsonConverter<ImmutableList<Material>>
|
||||
public override ImmutableList<Material> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override ImmutableList<Material> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.StartObject)
|
||||
{
|
||||
var materialComposition = new List<Material>();
|
||||
|
|
@ -24,9 +22,9 @@ namespace Observatory.Framework.Files.Converters
|
|||
{
|
||||
if (reader.TokenType == JsonTokenType.PropertyName)
|
||||
{
|
||||
string name = reader.GetString();
|
||||
var name = reader.GetString();
|
||||
reader.Read();
|
||||
int count = reader.GetInt32();
|
||||
var count = reader.GetInt32();
|
||||
var material = new Material
|
||||
{
|
||||
Name = name,
|
||||
|
|
@ -43,15 +41,12 @@ namespace Observatory.Framework.Files.Converters
|
|||
}
|
||||
return materialComposition.ToImmutableList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ImmutableList<Material>)JsonSerializer.Deserialize(ref reader, typeof(ImmutableList<Material>));
|
||||
}
|
||||
|
||||
return (ImmutableList<Material>)JsonSerializer.Deserialize(ref reader, typeof(ImmutableList<Material>));
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ImmutableList<Material> value, JsonSerializerOptions options)
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, ImmutableList<Material> value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,37 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public class MissionEffectConverter : JsonConverter<MissionEffect>
|
||||
{
|
||||
public class MissionEffectConverter : JsonConverter<MissionEffect>
|
||||
public override MissionEffect Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override MissionEffect Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
var effect = reader.GetString();
|
||||
//TODO: Find out all possible values
|
||||
switch (effect)
|
||||
{
|
||||
string effect = reader.GetString();
|
||||
//TODO: Find out all possible values
|
||||
switch (effect)
|
||||
{
|
||||
case "+":
|
||||
effect = "Low";
|
||||
break;
|
||||
case "++":
|
||||
effect = "Med";
|
||||
break;
|
||||
case "+++":
|
||||
case "++++":
|
||||
case "+++++":
|
||||
effect = "High";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
MissionEffect missionEffect = (MissionEffect)Enum.Parse(typeof(MissionEffect), effect, true);
|
||||
|
||||
return missionEffect;
|
||||
case "+":
|
||||
effect = "Low";
|
||||
break;
|
||||
case "++":
|
||||
effect = "Med";
|
||||
break;
|
||||
case "+++":
|
||||
case "++++":
|
||||
case "+++++":
|
||||
effect = "High";
|
||||
break;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, MissionEffect value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
var missionEffect = (MissionEffect)Enum.Parse(typeof(MissionEffect), effect, true);
|
||||
|
||||
return missionEffect;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, MissionEffect value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
{
|
||||
class MutableStringDoubleConverter : JsonConverter<object>
|
||||
{
|
||||
public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
return reader.GetString();
|
||||
else
|
||||
return reader.GetDouble();
|
||||
}
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
class MutableStringDoubleConverter : JsonConverter<object>
|
||||
{
|
||||
public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
return reader.GetString();
|
||||
return reader.GetDouble();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,19 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
class PipConverter : JsonConverter<(int Sys, int Eng, int Wep)>
|
||||
{
|
||||
class PipConverter : JsonConverter<(int Sys, int Eng, int Wep)>
|
||||
public override (int Sys, int Eng, int Wep) Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override (int Sys, int Eng, int Wep) Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
int[] values = (int[])JsonSerializer.Deserialize(ref reader, typeof(int[]));
|
||||
var values = (int[])JsonSerializer.Deserialize(ref reader, typeof(int[]));
|
||||
|
||||
return (Sys: values[0], Eng: values[1], Wep: values[2]);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, (int Sys, int Eng, int Wep) value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return (Sys: values[0], Eng: values[1], Wep: values[2]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, (int Sys, int Eng, int Wep) value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
{
|
||||
public class RepInfConverter : JsonConverter<int>
|
||||
{
|
||||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return reader.GetString().Trim().Length;
|
||||
}
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public class RepInfConverter : JsonConverter<int>
|
||||
{
|
||||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return reader.GetString().Trim().Length;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,22 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Converting the ordered array of coordinates from the journal to a named tuple for clarity.
|
||||
/// </summary>
|
||||
public class StarPosConverter : JsonConverter<(double x, double y, double z)>
|
||||
{
|
||||
/// <summary>
|
||||
/// Converting the ordered array of coordinates from the journal to a named tuple for clarity.
|
||||
/// </summary>
|
||||
public class StarPosConverter : JsonConverter<(double x, double y, double z)>
|
||||
public override (double x, double y, double z) Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override (double x, double y, double z) Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
double[] values = (double[])JsonSerializer.Deserialize(ref reader, typeof(double[]));
|
||||
var values = (double[])JsonSerializer.Deserialize(ref reader, typeof(double[]));
|
||||
|
||||
return (x: values[0], y: values[1], z: values[2]);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, (double x, double y, double z) value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return (x: values[0], y: values[1], z: values[2]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, (double x, double y, double z) value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +1,26 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public class StationServiceConverter : JsonConverter<StationService>
|
||||
{
|
||||
public class StationServiceConverter : JsonConverter<StationService>
|
||||
public override StationService Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override StationService Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
var services = StationService.None;
|
||||
|
||||
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
|
||||
{
|
||||
StationService services = StationService.None;
|
||||
|
||||
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
|
||||
{
|
||||
services |= (StationService)Enum.Parse(typeof(StationService), reader.GetString(), true);
|
||||
}
|
||||
|
||||
return services;
|
||||
|
||||
services |= (StationService)Enum.Parse(typeof(StationService), reader.GetString(), true);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, StationService value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return services;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, StationService value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
{
|
||||
class StringIntConverter : JsonConverter<int>
|
||||
{
|
||||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
return Int32.Parse(reader.GetString());
|
||||
else
|
||||
return reader.GetInt32();
|
||||
}
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
class StringIntConverter : JsonConverter<int>
|
||||
{
|
||||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
return int.Parse(reader.GetString());
|
||||
return reader.GetInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
class ThargoidWarRemainingTimeConverter : JsonConverter<int>
|
||||
{
|
||||
class ThargoidWarRemainingTimeConverter : JsonConverter<int>
|
||||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
string value = reader.GetString();
|
||||
var value = reader.GetString();
|
||||
|
||||
int dayCount = Int32.TryParse(value.Split(' ')[0], out int days)
|
||||
var dayCount = int.TryParse(value.Split(' ')[0], out var days)
|
||||
? days
|
||||
: 0;
|
||||
|
||||
return dayCount;
|
||||
}
|
||||
else
|
||||
return reader.GetInt32();
|
||||
}
|
||||
|
||||
return reader.GetInt32();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString() + " Days");
|
||||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value + " Days");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +1,25 @@
|
|||
using Observatory.Framework.Files.ParameterTypes;
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
class VoucherTypeConverter : JsonConverter<VoucherType>
|
||||
{
|
||||
class VoucherTypeConverter : JsonConverter<VoucherType>
|
||||
public override VoucherType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override VoucherType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
string voucher = reader.GetString();
|
||||
var voucher = reader.GetString();
|
||||
|
||||
if (voucher.Length == 0)
|
||||
voucher = "None";
|
||||
|
||||
VoucherType missionEffect = (VoucherType)Enum.Parse(typeof(VoucherType), voucher, true);
|
||||
var missionEffect = (VoucherType)Enum.Parse(typeof(VoucherType), voucher, true);
|
||||
|
||||
return missionEffect;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, VoucherType value, JsonSerializerOptions options)
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, VoucherType value, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue