Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Morten Nielsen dotMorten

:octocat:
View GitHub Profile
@dotMorten
dotMorten / AsyncTaskExtensions.cs
Created Dec 12, 2012
Silverlight/WPF/WP7 Async tasks - for ESRI.ArcGIS.Client
View AsyncTaskExtensions.cs
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using ESRI.ArcGIS.Client.Tasks;
namespace ESRI.Samples.Async.Tasks
{
public static partial class Extensions
{
@dotMorten
dotMorten / GpsCoordinateSimulator.cs
Created Dec 12, 2012
GeoPositionWatcher for more accurately simulating a GPS device, including change in accuracy, heading, and speed. This code is compatible with WPF, Windows Phone 7 and Windows Phone 8
View GpsCoordinateSimulator.cs
// GpsCoordinateSimulator.cs:
// WPF: Requires reference to System.Device.dll
using System;
using System.Device.Location;
using System.Windows;
using System.Windows.Threading;
namespace GpsSimulator
{
/// <summary>
@dotMorten
dotMorten / SharpGIS.Bing.ElevationServiceClient.cs
Created Jan 16, 2013
Bing Maps Elevation Service for Windows 8/RT
View SharpGIS.Bing.ElevationServiceClient.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
@dotMorten
dotMorten / HttpGZipClientHandler.cs
Last active May 8, 2018
GZip support for PCL HttpClient. Create HttpClient using: HttpClient client = new HttpClient(new HttpGZipClientHandler());
View HttpGZipClientHandler.cs
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
namespace SharpGIS.Http
{
public class HttpGZipClientHandler : HttpClientHandler
{
@dotMorten
dotMorten / TestMessageHandler.cs
Created Mar 24, 2013
Custom Http message handler used for mocking web responses in UnitTests relying on HttpClient. Add a resource file named "TestResponses.resw" and add your responses in this, and you can simply use TestMessageHandler.FromResourceResponse(key) and use this handler in you HttpClient.
View TestMessageHandler.cs
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources;
namespace TestHarness
{
/// <summary>
/// A message handler for simulating web requests
@dotMorten
dotMorten / PointAnimator.cs
Created Mar 24, 2013
Code for animating a MapPoint to a new location
View PointAnimator.cs
using ESRI.ArcGIS.Runtime;
using System;
using Windows.UI.Xaml.Media;
namespace GeometryUtils
{
public class PointAnimator
{
public PointAnimator(MapPoint point, MapPoint to, TimeSpan duration)
{
@dotMorten
dotMorten / NamingGuidelinesTest.cs
Last active Dec 21, 2015
Unit test that checks that Task-returning methods are postfixed 'Async"
View NamingGuidelinesTest.cs
[TestMethod]
[TestCategory("Naming guidelines")]
public void TasksReturningMethodsArePostfixedAsync()
{
var asm = typeof(SomeTypeInMyAssembly).Assembly;
StringBuilder sb = new StringBuilder();
foreach (var type in asm.GetExportedTypes())
{
foreach (var mi in type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static |
@dotMorten
dotMorten / XamlMarkerSymbol.cs
Created Nov 1, 2013
A XAML based PictureMarkerSymbol for the ArcGIS Runtime .NET SDK
View XamlMarkerSymbol.cs
using Esri.ArcGISRuntime.Symbology;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
#if NETFX_CORE
using Windows.UI.Xaml.Markup;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.Foundation;
@dotMorten
dotMorten / RandomLocationProvider.cs
Last active Dec 27, 2015
A custom location provider that randomly accelerates and changes heading for simple in-house testing of location
View RandomLocationProvider.cs
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Location;
using System;
using System.Linq;
using System.Threading.Tasks;
#if NETFX_CORE
using Windows.Foundation;
using Windows.UI.Xaml;
#else
using System.Windows.Threading;
@dotMorten
dotMorten / Frameworks.xml
Last active Aug 29, 2015
Modified frameworks file for Sandcastle to add support for phone 8.1
View Frameworks.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- This file defines the assemblies that make up the various versions of the .NET Framework. -->
<Frameworks>
<!-- This element defines a framework. The Platform attribute defines the platform and should be
".NETFramework" for standard frameworks, ".NETPortable" for portable library frameworks,
"Silverlight" for Silverlight frameworks, or ".NETCore" for Windows Store Apps frameworks. The Version
attribute should be set to the corresponding version of the framework. The Title element defines a
friendly name that can be used in development tools. The optional Redirect element allows you to specify
an alternate framework version to use if this version is not available on the system. Redirection will
continue until a version is found or a framework without a redirection is encountered. -->