Skip to content

Instantly share code, notes, and snippets.

View jamesmontemagno's full-sized avatar
🐒

James Montemagno jamesmontemagno

🐒
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout
android:layout_width="fill_parent"
<?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="ImageSearch.Shared.View.DetailsPage"
Title="{Binding SelectedImage.Title}">
<ContentPage.Content>
<ScrollView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout Padding="10">
<Image
HeightRequest="200"
public static string GetIPAddressQuick()
{
var interfaces = NetworkInterface.NetworkInterfaces;
IPAddress ipAddr;
try
{
bool hasMore = true;
int count = 0;
while (hasMore)
Device.OnPlatform(
iOS: () => MainPage.BackgroundColor = Color.Black,
Android: () => MainPage.BackgroundColor = Color.Red,
WinPhone: () => MainPage.BackgroundColor = Color.Orange,
Default: () => MainPage.BackgroundColor = Color.Transparent);
<!--Old XAML On Platform-->
<StackLayout>
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness"
Android="0, 0, 0, 0"
WinPhone="0, 0, 0, 0"
iOS="0, 20, 0, 0"/>
</StackLayout.Padding>
</StackLayout>
if(Device.RuntimePlatform == Device.iOS)
{
//iOS stuff
}
else if(Device.RuntimePlatform == Device.Android)
{
}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Plugin.Connectivity.Abstractions;
namespace UnitTestProject.Tests.Mock
{
public class MockConnectivity : IConnectivity
{
public bool IsConnected => true;
public class MyClass
{
public int Math(int x, int y)
{
if (!Connectivity.Instance.IsConnected)
return x + y + x;
return x + y;
}
}
public static class Connectivity
{
static IConnectivity connectivity;
public static IConnectivity Instance
{
get
{
return connectivity ?? (connectivity = CrossConnectivity.Current);
}
set
public static class Settings
{
ISettings AppSettings
{
get
{
return CrossSettings.Current;
}
}