Skip to content

Instantly share code, notes, and snippets.

View ricardoprestes's full-sized avatar

Ricardo Prestes ricardoprestes

View GitHub Profile
private async Task MethodAsync()
{
}
private string _name;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
<CodeTemplates version="3.0">
<CodeTemplate version="2.0">
<Header>
<_Group>Xml</_Group>
<Version />
<MimeType>application/xml</MimeType>
<Shortcut>stl</Shortcut>
<_Description>StackLayout Template</_Description>
<TemplateType>Expansion, SurroundsWith</TemplateType>
</Header>
var list = new List<string> { "item 1", "item 2", "item 3" };
var newList = list.ToObservableCollection<string>();
//um tom de azul
var backgroundColor = "##50C7F3";
var textColor = backgroundColor.GetContrastColor();
//textColor = #000000
var str = "Água";
str = str.RemoveAccents();
//str = agua
str = "Próximo";
str = str.IgnoreCaseSensitiveAndAccents();
//proximo
using(new TimerMonitor("Tag name")
{
for (int i = 0; i < 500; i++)
{
var x = i;
}
}
//Console
$"Tag name" time elapsed: 100ms
public class FileHelper
{
public string GetLocalFilePath(string filename)
=> DependencyService.Get<IFileHelper>().GetLocalFilePath(filename);
}
[assembly: Dependency(typeof(FileHelperiOS))]
namespace NugetMultiSample.Helpers
{
public class FileHelperiOS : IFileHelper
{
public string GetLocalFilePath(string filename)
{
string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string libFolder = Path.Combine(docFolder, "..", "Library", "Databases");
if (!Directory.Exists(libFolder))
[assembly: Dependency(typeof(FileHelperAndroid))]
namespace NugetMultiSample.Helpers
{
public class FileHelperAndroid : IFileHelper
{
public string GetLocalFilePath(string filename)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
return Path.Combine(path, filename);
}