Skip to content

Instantly share code, notes, and snippets.

try{
using (var client = new HttpClient()){
var response = await client.PostAsync("hogehoge");
var stream = await response.Content.ReadAsStreamAsync();
// ほげほげ
}
}catch{
// れいがい
}
@punio
punio / LocalizedXamlPage.xaml
Created June 12, 2014 06:42
Xamarin.Forms.Xaml Page
<?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:local="clr-namespace:LocalizeTest;assembly=LocalizeTest"
x:Class="LocalizeTest.XamlPage">
<Label Text="{local:LocalizedString Hello}" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>
@punio
punio / DefaultFormsXamlPage.xaml
Created June 12, 2014 06:36
Xamarin.Forms.Xaml Page Default
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LocalizeTest.XamlPage">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>
@punio
punio / LocalizedStringExtension.cs
Created June 12, 2014 06:29
LocalizedStringExtension
[ContentProperty("Text")]
public class LocalizedStringExtension : IMarkupExtension
{
public string Text { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
if (Text == null) return null;
return Strings.ResourceManager.GetString(Text);
}
@punio
punio / App.cs
Last active August 29, 2015 14:02
LocalizeTest Part1
public class App
{
public static Page GetMainPage()
{
return new ContentPage
{
Content = new StackLayout
{
Children = {
new Label
using(var ms = new MemoryStream())
{
using(var ds = new DeflateStream(ms, CompressionLevel.Fastest))
{
ProtoBuf.Serializer.Serialize(ds, DATA);
}
return ms.ToArray();
}
using(var ms = new MemoryStream())
using(var ds = new DeflateStream(ms, CompressionLevel.Fastest))
{
ProtoBuf.Serializer.Serialize(ds, DATA);
return ms.ToArray();
}
class Program
{
static void Main()
{
// テスト用データ
var testDataList = new List<TestData>();
var r = new Random();
for (var count = 0; count < 1000000; count++) testDataList.Add(new TestData(r.Next()));
var testDataArray = testDataList.ToArray();
public class AnimationItemsControl : ItemsControl {
private List<FrameworkElement> appendingItems = new List<FrameworkElement>();
private Duration opacityDuration = new Duration(TimeSpan.FromSeconds(0.5));
private Duration zoomDuration = new Duration(TimeSpan.FromSeconds(1));
private double itemInterval = 0.5;
protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {
base.OnItemsChanged(e);
if (e.Action == NotifyCollectionChangedAction.Reset) {