Skip to content

Commit

Permalink
add classes to file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
IS4Code committed Jun 4, 2023
1 parent 3d4d754 commit 389b319
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SFI.Tests/GraphTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ public async override ValueTask AddDefault()
{
mediaTypeAnalyzer.AddClasses = false;
}

if(Analyzers.OfType<ExtensionObjectAnalyzer>().FirstOrDefault() is ExtensionObjectAnalyzer extensionObjectAnalyzer)
{
extensionObjectAnalyzer.AddClasses = false;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions SFI/Analyzers/ExtensionObjectAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace IS4.SFI.Analyzers
/// </summary>
public class ExtensionObjectAnalyzer : EntityAnalyzer<ExtensionObject>
{
/// <summary>
/// Whether to add class information to the created node.
/// </summary>
public bool AddClasses { get; set; } = true;

/// <inheritdoc cref="EntityAnalyzer.EntityAnalyzer"/>
public ExtensionObjectAnalyzer()
{
Expand All @@ -25,6 +30,10 @@ public async override ValueTask<AnalysisResult> Analyze(ExtensionObject extensio
node = context.NodeFactory.Create(Vocabularies.Uris, Uri.EscapeDataString(ext));
}
node = InitNewNode(node, context);
if(AddClasses)
{
node.SetClass(Classes.Extension);
}
return new(node);
}
}
Expand Down
6 changes: 6 additions & 0 deletions SFI/Vocabulary/Classes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ public static class Classes
[Uri(Uriv, "Mimetype-Parametrized")]
public static readonly ClassUri MediaTypeParametrized;

/// <summary>
/// <c><see cref="Uriv"/>:Suffix</c>.
/// </summary>
[Uri(Uriv, "Suffix")]
public static readonly ClassUri Extension;

static Classes()
{
typeof(Classes).InitializeUris();
Expand Down

0 comments on commit 389b319

Please sign in to comment.