You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Proxy.Proxies
|
|
|
|
|
{
|
|
|
|
|
internal class Proxy : ISubject
|
|
|
|
|
{
|
|
|
|
|
private RealSubject _realSubject;
|
|
|
|
|
|
|
|
|
|
public Proxy(RealSubject realSubject)
|
|
|
|
|
{
|
|
|
|
|
_realSubject = realSubject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Request()
|
|
|
|
|
{
|
|
|
|
|
if (!CheckAccess())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_realSubject.Request();
|
|
|
|
|
|
|
|
|
|
LogAccess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CheckAccess()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Proxy: Checking access prior to firing a real request.");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LogAccess()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Proxy: Logging the time of request@{DateTime.Now}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|