Back

Module instead static class

The C# code:

public static partial class TableExtensions
{
public static File Find(this ITable<File> table, int ID)
{
return table.FirstOrDefault(t =>
t.ID == ID);
}

public static FileHash Find(this ITable<FileHash> table, int IDFile, int Hash)
{
return table.FirstOrDefault(t =>
t.IDFile == IDFile &&
t.Hash == Hash);
}

public static Group Find(this ITable<Group> table, int ID)
{
return table.FirstOrDefault(t =>
t.ID == ID);
}
}

should be converted to:

Partial Public Module TableExtensions
<System.Runtime.CompilerServices.Extension>
Public Function Find(table As ITable(Of File), ID As Integer) As File
Return table.FirstOrDefault(Function(t) t.ID = ID)
End Function

<System.Runtime.CompilerServices.Extension>
Public Function Find(table As ITable(Of FileHash), IDFile As Integer, Hash As Integer) As FileHash
Return table.FirstOrDefault(Function(t) t.IDFile = IDFile AndAlso t.Hash = Hash)
End Function

<System.Runtime.CompilerServices.Extension>
Public Function Find(table As ITable(Of Group), ID As Integer) As Group
Return table.FirstOrDefault(Function(t) t.ID = ID)
End Function
End Module

instead of:

Public NotInheritable Partial Class TableExtensions
Private Sub New()
End Sub
<System.Runtime.CompilerServices.Extension> _
Public Shared Function Find(table As ITable(Of File), ID As Integer) As File
Return table.FirstOrDefault(Function(t) t.ID = ID)
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function Find(table As ITable(Of FileHash), IDFile As Integer, Hash As Integer) As FileHash
Return table.FirstOrDefault(Function(t) t.IDFile = IDFile AndAlso t.Hash = Hash)
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function Find(table As ITable(Of Group), ID As Integer) As Group
Return table.FirstOrDefault(Function(t) t.ID = ID)
End Function
End Class

Best regards,
Filippo.
» Post Comment

Comments (0)

 
No comments, yet. Be the first!

Post Comment

Your Comment :
Commenting is disabled when the portal is unlicensed.
Select...