C# Generic extension method on interface

Date: 2022-07-25
public static class IMvSyncEntityExtensions
{
    public static T CheckEntityTypeAndClearFields<T>(this T item) where T : IMvSyncEntity
    {
        if (item.SavedEntityType == MultiversSyncEntityType.Unknown)
        {
            item.SavedEntityType = item.SyncEntityType;
            return item;
        }
        if (item.SavedEntityType != MultiversSyncEntityType.Creditor)
        {
            item.MVId = null;
            item.MVError = null;
            item.MVLastSynced = null;
        }

        return item;
    }
}
64070cookie-checkC# Generic extension method on interface