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
using System.Windows; | |
using System.Windows.Controls; | |
namespace WpfApplication1 | |
{ | |
/// <summary> | |
/// Interaction logic for FilePicker.xaml | |
/// </summary> | |
public partial class FilePicker : UserControl | |
{ |
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
//Original Idea: http://blog.smoothfriction.nl/archive/2012/05/07/silverlight-busyindicator-in-caliburn-micro-pt-2-again.aspx | |
//A simpler solution: | |
public interface IBusy | |
{ | |
bool IsBusy { get; set; } | |
} |
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
//Usage: | |
public IEnumerable<IResult> Logout() | |
{ | |
yield return new ActionResult(completed => | |
{ | |
var operation = WebContext.Current.Authentication.Logout(false); | |
operation.Completed += (sender, args) => completed(); | |
}); | |
} |
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
/* Exemplo: | |
O método SaveChanges foi sobrescrito para verificar se irá persistir instâncias de entidades que implementam | |
a interface IAuditableEntity. | |
Para facilitar, utilizo uma class base chamada EntityBase que implementa essa interface, | |
e implementa também IValidatableObject. | |
*/ | |
public interface IAuditableEntity | |
{ |
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
/* | |
Exemplo de um C# Extension Method que verifica se qualquer IEnumerable<T> é nulo ou vazio (sem itens) | |
e retorna um IEnumerable<T> contendo no mínimo um item com o valor default | |
*/ | |
public static class CSharpExtensions | |
{ | |
public static IEnumerable<T> NotEmpty<T>(this IEnumerable<T> source, T defaultValue = default(T)) | |
{ | |
T[] array = null; |
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
public ActionResult Pesquisar() | |
{ | |
// simulando consulta | |
var resultado = new List<string>() { "texto1", "texto2" }; | |
// troque por este para simular retorno de dados | |
// var resultado = new List<string>(); | |
return PartialView("ResultadosDaPesquisa", resultado.NotEmpty(defaultValue: string.Empty)); | |
} |
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
public ActionResult JsonQuery<T>(IEnumerable<T> resultado, Func<IEnumerable<T>, PartialViewResult> partialView) | |
{ | |
if (resultado.Any()) return partialView(resultado); //instancia a PartialViewResult | |
return Json(string.Empty, JsonRequestBehavior.AllowGet); | |
} | |
//uso: | |
return JsonQuery(resultado, x => PartialView("ResultadosDaPesquisa", x)); |
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
using System; | |
using System.Linq; | |
using System.Windows.Forms; | |
using PaxSF.Dados.Models; | |
using PaxSF.Util; | |
namespace PaxSF.Formularios | |
{ | |
public partial class frmClientes : PaxSF.Formularios.frmCadastroPadrao | |
{ |
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
<UserControl x:Class="SCO.Ria.UI.Views.LoginView" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" | |
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" | |
xmlns:local="clr-namespace:Caliburn.Micro.Focus;assembly=Caliburn.Micro.Focus" | |
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" mc:Ignorable="d" | |
d:DesignHeight="154" d:DesignWidth="468"> |
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
/* REFERENCIAR o assembly System.ServiceModel.dll */ | |
using System.ServiceModel; | |
using System.ServiceModel.DomainServices.Client; | |
partial class MyDomainContext { | |
partial void OnCreated() { | |
var timeSpan = TimeSpan.FromSeconds(30); /* 30 segundos de timeout */ | |
DomainContextExtensions.ChangeWcfSendTimeout(this, timeSpan); |