1
0
mirror of https://github.com/SirLecram/HospitalServerManager synced 2024-07-17 02:20:30 +02:00
admissionManager/ViewModel/Validators/InterfaceImplementValidator.cs
Marcel Grześ 069f0612da Basic function development
A few models has been improved;
New pages has been added; NewRecordDialog has been added;
ViewNavigator was created; A type providers has been added; new interfaces has been added; New validator, which checks if interface is implemented has been added;
The application can read data and add new record by API now.
2018-12-29 11:58:25 +01:00

38 lines
1.2 KiB
C#

using HospitalServerManager.InterfacesAndEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalServerManager.ViewModel.Validators
{
class InterfaceImplementValidator : IValidateIfInterfaceIsImplemented
{
public IProvideType TypeProvider { protected get; set; }
public InterfaceImplementValidator() { }
public InterfaceImplementValidator(IProvideType typeProvider) { TypeProvider = typeProvider; }
public bool ValidateIfTypeImplementInterface(Type typeToCheck, string interfaceNameToCheck)
{
Type returnedType = typeToCheck.GetInterface(interfaceNameToCheck);
if (returnedType == null)
return false;
return true;
}
public bool ValidateIfTypeImplementInterface(string typeName, string interfaceNameToCheck)
{
Type typeFromString = TypeProvider.GetTypeFromString(typeName);
return ValidateIfTypeImplementInterface(typeFromString, interfaceNameToCheck);
}
public bool ValidateIfTypeImplementInterface(Type typeToCheck, Type interfaceToCheck)
{
string interfaceName = interfaceToCheck.Name;
return ValidateIfTypeImplementInterface(typeToCheck, interfaceName);
}
}
}