-
-
Save lgolubyev/68ec59d200bb7608f06881baf2670601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class AdapterBase | |
{ | |
protected string Name; | |
public string GetName() | |
{ | |
return Name; | |
} | |
} | |
class AjaxAdapter : AdapterBase | |
{ | |
public AjaxAdapter() | |
{ | |
Name = "ajaxAdapter"; | |
} | |
} | |
class NodeAdapter : AdapterBase | |
{ | |
public NodeAdapter() | |
{ | |
Name = "nodeAdapter"; | |
} | |
} | |
class HttpRequester : AdapterBase | |
{ | |
private readonly AdapterBase Adapter; | |
public HttpRequester(AdapterBase adapter) | |
{ | |
Adapter = adapter; | |
} | |
public bool Fetch(string url) | |
{ | |
var adapterName = Adapter.GetName(); | |
if (adapterName == "ajaxAdapter") | |
{ | |
return MakeAjaxCall(url); | |
} | |
else if (adapterName == "httpNodeAdapter") | |
{ | |
return MakeHttpCall(url); | |
} | |
} | |
private bool MakeAjaxCall(string url) | |
{ | |
// request and return promise | |
} | |
private bool MakeHttpCall(string url) | |
{ | |
// request and return promise | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment