Gordon Pedersen
7c84fbc4c5
There's a lot of rubbish in here, but I don't want to lose anything, so I'm going to commit it all before getting rid of some of the trash.
208 lines
9.2 KiB
C#
208 lines
9.2 KiB
C#
using KristofferStrube.ActivityStreams;
|
|
using KristofferStrube.ActivityStreams.JsonConverters;
|
|
using KristofferStrube.ActivityStreams.JsonLD;
|
|
using OneOf;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace ActivityPub;
|
|
public class BaseActivity : OneOfBase<Activity, IntransitiveActiviy>, IObject {
|
|
|
|
protected BaseActivity(OneOf<Activity, IntransitiveActiviy> _) : base(_) { }
|
|
|
|
public static implicit operator BaseActivity(Activity _) => new BaseActivity(_);
|
|
public static implicit operator BaseActivity(IntransitiveActiviy _) => new BaseActivity(_);
|
|
|
|
public static explicit operator Activity(BaseActivity _) => _.Match(a => a, ia => throw new InvalidCastException());
|
|
public static explicit operator IntransitiveActiviy(BaseActivity _) => _.Match(a => throw new InvalidCastException(), ia => ia);
|
|
|
|
public bool IsIntransitive { get => IsT1; }
|
|
|
|
/// <summary>
|
|
/// Describes one or more entities that either performed or are expected to perform the activity. Any single activity can have multiple actors. The actor may be specified using an indirect Link.
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Actor {
|
|
get => Match(a => a.Actor, ia => ia.Actor);
|
|
set => Switch(a => a.Actor = value, ia => ia.Actor = value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Describes an object of any kind. The Object type serves as the base type for most of the other kinds of objects defined in the Activity Vocabulary, including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection.
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Object {
|
|
get => Match(a => a.Object, ia => throw new InvalidOperationException("Activity is Intransitive"));
|
|
set => Switch(a => a.Object = value, ia => throw new InvalidOperationException("Activity is Intransitive"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent on the type of action being described but will often be the object of the English preposition "to". For instance, in the activity "John added a movie to his wishlist", the target of the activity is John's wishlist. An activity can have more than one target.
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Target {
|
|
get => Match(a => a.Target, ia => ia.Target);
|
|
set => Switch(a => a.Target = value, ia => ia.Target = value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Describes the result of the activity. For instance, if a particular action results in the creation of a new resource, the result property can be used to describe that new resource.
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Result {
|
|
get => Match(a => a.Result, ia => ia.Result);
|
|
set => Switch(a => a.Result = value, ia => ia.Result = value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Describes an indirect object of the activity from which the activity is directed. The precise meaning of the origin is the object of the English preposition "from". For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Origin {
|
|
get => Match(a => a.Origin, ia => ia.Origin);
|
|
set => Switch(a => a.Origin = value, ia => ia.Origin = value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Identifies one or more objects used (or to be used) in the completion of an Activity.
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Instrument {
|
|
get => Match(a => a.Instrument, ia => ia.Instrument);
|
|
set => Switch(a => a.Instrument = value, ia => ia.Instrument = value);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public IEnumerable<IObjectOrLink>? Attachment {
|
|
get => Match(a => a.Attachment, ia => ia.Attachment);
|
|
set => Switch(a => a.Attachment = value, ia => ia.Attachment = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? AttributedTo {
|
|
get => Match(a => a.AttributedTo, ia => ia.AttributedTo);
|
|
set => Switch(a => a.AttributedTo = value, ia => ia.AttributedTo = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Audience {
|
|
get => Match(a => a.Audience, ia => ia.Audience);
|
|
set => Switch(a => a.Audience = value, ia => ia.Audience = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Bcc {
|
|
get => Match(a => a.Bcc, ia => ia.Bcc);
|
|
set => Switch(a => a.Bcc = value, ia => ia.Bcc = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Bto {
|
|
get => Match(a => a.Bto, ia => ia.Bto);
|
|
set => Switch(a => a.Bto = value, ia => ia.Bto = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Cc {
|
|
get => Match(a => a.Cc, ia => ia.Cc);
|
|
set => Switch(a => a.Cc = value, ia => ia.Cc = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Context {
|
|
get => Match(a => a.Context, ia => ia.Context);
|
|
set => Switch(a => a.Context = value, ia => ia.Context = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Generator {
|
|
get => Match(a => a.Generator, ia => ia.Generator);
|
|
set => Switch(a => a.Generator = value, ia => ia.Generator = value);
|
|
}
|
|
public IEnumerable<IImageOrLink>? Icon {
|
|
get => Match(a => a.Icon, ia => ia.Icon);
|
|
set => Switch(a => a.Icon = value, ia => ia.Icon = value);
|
|
}
|
|
public IEnumerable<IImageOrLink>? Image {
|
|
get => Match(a => a.Image, ia => ia.Image);
|
|
set => Switch(a => a.Image = value, ia => ia.Image = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? InReplyTo {
|
|
get => Match(a => a.InReplyTo, ia => ia.InReplyTo);
|
|
set => Switch(a => a.InReplyTo = value, ia => ia.InReplyTo = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Location {
|
|
get => Match(a => a.Location, ia => ia.Location);
|
|
set => Switch(a => a.Location = value, ia => ia.Location = value);
|
|
}
|
|
public Collection? Replies {
|
|
get => Match(a => a.Replies, ia => ia.Replies);
|
|
set => Switch(a => a.Replies = value, ia => ia.Replies = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Tag {
|
|
get => Match(a => a.Tag, ia => ia.Tag);
|
|
set => Switch(a => a.Tag = value, ia => ia.Tag = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? To {
|
|
get => Match(a => a.To, ia => ia.To);
|
|
set => Switch(a => a.To = value, ia => ia.To = value);
|
|
}
|
|
public IEnumerable<ILink>? Url {
|
|
get => Match(a => a.Url, ia => ia.Url);
|
|
set => Switch(a => a.Url = value, ia => ia.Url = value);
|
|
}
|
|
public IEnumerable<string>? Content {
|
|
get => Match(a => a.Content, ia => ia.Content);
|
|
set => Switch(a => a.Content = value, ia => ia.Content = value);
|
|
}
|
|
public IEnumerable<IDictionary<string, string>>? ContentMap {
|
|
get => Match(a => a.ContentMap, ia => ia.ContentMap);
|
|
set => Switch(a => a.ContentMap = value, ia => ia.ContentMap = value);
|
|
}
|
|
public IEnumerable<IDictionary<string, string>>? NameMap {
|
|
get => Match(a => a.NameMap, ia => ia.NameMap);
|
|
set => Switch(a => a.NameMap = value, ia => ia.NameMap = value);
|
|
}
|
|
public TimeSpan? Duration {
|
|
get => Match(a => a.Duration, ia => ia.Duration);
|
|
set => Switch(a => a.Duration = value, ia => ia.Duration = value);
|
|
}
|
|
public DateTime? EndTime {
|
|
get => Match(a => a.EndTime, ia => ia.EndTime);
|
|
set => Switch(a => a.EndTime = value, ia => ia.EndTime = value);
|
|
}
|
|
public DateTime? Published {
|
|
get => Match(a => a.Published, ia => ia.Published);
|
|
set => Switch(a => a.Published = value, ia => ia.Published = value);
|
|
}
|
|
public DateTime? StartTime {
|
|
get => Match(a => a.Published, ia => ia.Published);
|
|
set => Switch(a => a.Published = value, ia => ia.Published = value);
|
|
}
|
|
public IEnumerable<string>? Summary {
|
|
get => Match(a => a.Summary, ia => ia.Summary);
|
|
set => Switch(a => a.Summary = value, ia => ia.Summary = value);
|
|
}
|
|
public IEnumerable<IDictionary<string, string>>? SummaryMap {
|
|
get => Match(a => a.SummaryMap, ia => ia.SummaryMap);
|
|
set => Switch(a => a.SummaryMap = value, ia => ia.SummaryMap = value);
|
|
}
|
|
public DateTime? Updated {
|
|
get => Match(a => a.Updated, ia => ia.Updated);
|
|
set => Switch(a => a.Updated = value, ia => ia.Updated = value);
|
|
}
|
|
public Source? Source {
|
|
get => Match(a => a.Source, ia => ia.Source);
|
|
set => Switch(a => a.Source = value, ia => ia.Source = value);
|
|
}
|
|
public Dictionary<string, JsonElement>? ExtensionData {
|
|
get => Match(a => a.ExtensionData, ia => ia.ExtensionData);
|
|
set => Switch(a => a.ExtensionData = value, ia => ia.ExtensionData = value);
|
|
}
|
|
public string? Id {
|
|
get => Match(a => a.Id, ia => ia.Id);
|
|
set => Switch(a => a.Id = value, ia => ia.Id = value);
|
|
}
|
|
public IEnumerable<ITermDefinition>? JsonLDContext {
|
|
get => Match(a => a.JsonLDContext, ia => ia.JsonLDContext);
|
|
set => Switch(a => a.JsonLDContext = value, ia => ia.JsonLDContext = value);
|
|
}
|
|
public IEnumerable<string>? Type {
|
|
get => Match(a => a.Type, ia => ia.Type);
|
|
set => Switch(a => a.Type = value, ia => ia.Type = value);
|
|
}
|
|
public string? MediaType {
|
|
get => Match(a => a.MediaType, ia => ia.MediaType);
|
|
set => Switch(a => a.MediaType = value, ia => ia.MediaType = value);
|
|
}
|
|
public IEnumerable<string>? Name {
|
|
get => Match(a => a.Name, ia => ia.Name);
|
|
set => Switch(a => a.Name = value, ia => ia.Name = value);
|
|
}
|
|
public IEnumerable<IObjectOrLink>? Preview {
|
|
get => Match(a => a.Preview, ia => ia.Preview);
|
|
set => Switch(a => a.Preview = value, ia => ia.Preview = value);
|
|
}
|
|
}
|