Skip to content

Instantly share code, notes, and snippets.

View guntidheerajkumar's full-sized avatar
💭
Happy

Dheeraj Kumar Gunti guntidheerajkumar

💭
Happy
View GitHub Profile
public class CountriesViewModel
{
const string url = "http://country.io/names.json";
public async Task<Dictionary<string, string>> GetCountriesData()
{
try
{
var httpClient = new HttpClient();
var countries = await httpClient.GetStringAsync(url);
public class Countries
{
public string CountryCode { get; set; }
public string CountryName { get; set; }
}
public enum Countries
{
[EnumDescription(Text="India")]
India,
[EnumDescription(Text = "South Africa")]
SouthAfrica,
}
public static class EnumsHelper
{
public static T GetAttributeOfType<T>(this Enum enumVal) where T : Attribute
{
var typeInfo = enumVal.GetType().GetTypeInfo();
var v = typeInfo.DeclaredMembers.First(x => x.Name == enumVal.ToString());
return v.GetCustomAttribute<T>();
}
public static string GetDescription(this Enum enumVal)
public class EnumDescriptionAttribute : Attribute
{
public virtual string DisplayName { get; set; }
}
ItemsTableView.Source = new TableSource (Names);
searchBar.SearchButtonClicked += (sender, e) => {
var listItems = Utilities.Names.Where (m => m.ToString ().StartsWith (searchBar.Text.Trim ())).ToList ();
ItemsTableView.Source = new TableSource (listItems);
ItemsTableView.ReloadData ();
searchBar.ResignFirstResponder ();
};
searchBar.TextChanged += (sender, e) => {
var listItems = Utilities.Names.Where (m => m.ToString ().StartsWith (searchBar.Text.Trim ())).ToList ();
ItemsTableView.Source = new TableSource (listItems);
ItemsTableView.ReloadData ();
public class TableSource : UITableViewSource
{
List<string> tableItems;
string cellIdentifier = "TableCell";
public TableSource (List<string> items)
{
tableItems = items;
}
public override nint RowsInSection (UITableView tableview, nint section)
{
public static void RegisterGlobalFilter(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
[HandleError(View = "ErrorView")]
public ActionResult Index()
{
try
{
//Logic
}
catch (Exception ex)
{
throw ex;