This file contains hidden or 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
| public interface ICacheProvider | |
| { | |
| object Get(string key); | |
| void Put(string key, object value, int duration); | |
| bool Contains(string key); | |
| } | |
| public class MemoryCacheProvider : ICacheProvider |
This file contains hidden or 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
| public class CacheResultAttribute : Attribute | |
| { | |
| public int Duration { get; set; } | |
| } |
This file contains hidden or 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
| public class CacheResultInterceptor : IInterceptor | |
| { | |
| private readonly ICacheProvider _cache; | |
| public CacheResultInterceptor(ICacheProvider cache) | |
| { | |
| _cache = cache; | |
| } | |
| public CacheResultAttribute GetCacheResultAttribute(IInvocation invocation) |
This file contains hidden or 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
| public class MyModule : Module | |
| { | |
| protected override void Load(ContainerBuilder builder) | |
| { | |
| builder.RegisterType<MemoryCacheProvider>() | |
| .As<ICacheProvider>() | |
| .SingleInstance(); | |
| builder.RegisterType<CacheResultInterceptor>() | |
| .SingleInstance(); |
This file contains hidden or 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
| public class HomeViewModel : ViewModelBase | |
| { | |
| public ObservableCollection<PersonViewModel> People { get; set; } | |
| public RelayCommand<PersonViewModel> SayHelloCommand { get; set; } | |
| public HomeViewModel() | |
| { | |
| People = new ObservableCollection<PersonViewModel> | |
| { |
This file contains hidden or 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
| public class ItemTappedEventArgsConverter : IValueConverter | |
| { | |
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
| { | |
| var eventArgs = value as ItemTappedEventArgs; | |
| if (eventArgs == null) | |
| throw new ArgumentException("Expected TappedEventArgs as value", "value"); | |
| return eventArgs.Item; | |
| } |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8" ?> | |
| <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:b="clr-namespace:HelloEventToCommand.Behaviors;assembly=HelloEventToCommand" xmlns:c="clr-namespace:HelloEventToCommand.Converters;assembly=HelloEventToCommand" x:Class="HelloEventToCommand.Views.HomeView"> | |
| <ContentPage.Resources> | |
| <ResourceDictionary> | |
| <c:ItemTappedEventArgsConverter x:Key="ItemTappedConverter" /> | |
| </ResourceDictionary> | |
| </ContentPage.Resources> | |
| <ListView ItemsSource="{Binding People}"> | |
| <ListView.Behaviors> |
This file contains hidden or 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
| public class EventToCommandBehavior : BindableBehavior<View> | |
| { | |
| public static readonly BindableProperty EventNameProperty = BindableProperty.Create<EventToCommandBehavior, string>(p => p.EventName, null); | |
| public static readonly BindableProperty CommandProperty = BindableProperty.Create<EventToCommandBehavior, ICommand>(p => p.Command, null); | |
| public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create<EventToCommandBehavior, object>(p => p.CommandParameter, null); | |
| public static readonly BindableProperty EventArgsConverterProperty = BindableProperty.Create<EventToCommandBehavior, IValueConverter>(p => p.EventArgsConverter, null); | |
| public static readonly BindableProperty EventArgsConverterParameterProperty = BindableProperty.Create<EventToCommandBehavior, object>(p => p.EventArgsConverterParameter, null); | |
| private Delegate _handler; | |
| private EventInfo _eventInfo; |
This file contains hidden or 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
| public class BindableBehavior<T> : Behavior<T> where T : BindableObject | |
| { | |
| public T AssociatedObject { get; private set; } | |
| protected override void OnAttachedTo(T visualElement) | |
| { | |
| base.OnAttachedTo(visualElement); | |
| AssociatedObject = visualElement; |
This file contains hidden or 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
| server { | |
| # Port and domain | |
| listen 80; | |
| server_name aspnet.local; | |
| # Path to the wwwroot folder | |
| root /home/developer/projects/WebApplicationBasic/wwwroot; | |
| # Static content | |
| location ~ \.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm|woff2|svg)$ { |