Skip to content

Add UnitsNet.WindowsRuntimeComponent nuget #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Build/UnitsNet.WindowsRuntimeComponent.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>

<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>UnitsNet.WindowsRuntimeComponent</id>
<version>3.33.0</version>
<title>Units.NET - Windows Runtime Component</title>
<authors>Andreas Gullberg Larsen</authors>
<owners>Andreas Gullberg Larsen</owners>
<licenseUrl>https://github.com/anjdreas/UnitsNet/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/anjdreas/UnitsNet</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>For C#/VB Universal Windows code (UWP), use UnitsNet instead. This is a Windows Runtime Component with reduced functionality to support all UWP languages, such as JavaScript and C++, and other runtime components.</description>
<summary>For C#/VB Universal Windows code (UWP), use UnitsNet instead.</summary>
<iconUrl>https://raw.githubusercontent.com/anjdreas/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png</iconUrl>
<releaseNotes></releaseNotes>
<copyright>Copyright © 2015 Andreas Gullberg Larsen</copyright>
<language>en-US</language>
<tags>unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component</tags>
</metadata>
<files>
<file src="Artifacts\Bin\Src\AnyCPU_Release\uap10.0\UnitsNet.*" target="lib/uap10.0" />
<file src="UnitsNet\**\*.cs" exclude="UnitsNet\**\obj\**\*.cs" target="src" />
</files>
</package>
21 changes: 11 additions & 10 deletions Build/UpdateAssemblyInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.EXAMPLE
Set new version.
powershell UpdateAssemblyInfo.ps1 1.2.3.4

.NOTES
Author: Andreas Gullberg Larsen
Date: May 2, 2014
Expand Down Expand Up @@ -40,37 +40,38 @@ function Get-VersionFromNuspec ([string] $nuspecFilePath) {
}

#-------------------------------------------------------------------------------
# Description: Sets the AssemblyVersion and AssemblyFileVersion of
# Description: Sets the AssemblyVersion and AssemblyFileVersion of
# AssemblyInfo.cs files.
#
# Author: Andreas Larsen
# Version: 1.0
#-------------------------------------------------------------------------------
function Update-AssemblyInfoFiles ([string] $libName) {
function Update-AssemblyInfoFiles ([string] $nuspecFilePath, [string] $assemblyInfoFilePath) {

[Version]$version = Get-VersionFromNuspec "$root\Build\$libName.nuspec"
[Version]$version = Get-VersionFromNuspec "$root\$nuspecFilePath"

$assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
$fileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
$assemblyVersion = 'AssemblyVersion("' + $version + '")';
$fileVersion = 'AssemblyFileVersion("' + $version + '")';
Get-ChildItem "$root\$libName\Properties" | Where { $_.PSChildName -match "^AssemblyInfo\.cs$"} | ForEach-Object {

Get-ChildItem "$root\$assemblyInfoFilePath" | ForEach-Object {
$filename = $_.Directory.ToString() + '\' + $_.Name
$filename + ' -> ' + $version

(Get-Content $filename -Encoding UTF8) | ForEach-Object {
% {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
% {$_ -replace $fileVersionPattern, $fileVersion }
} | Set-Content $filename -Encoding UTF8
}
}
}

try {
"Updating assembly info to version: $setVersion"
""
Update-AssemblyInfoFiles "UnitsNet"
Update-AssemblyInfoFiles "UnitsNet.Serialization.JsonNet"
Update-AssemblyInfoFiles "Build\UnitsNet.nuspec" "UnitsNet\Properties\AssemblyInfo.cs"
Update-AssemblyInfoFiles "Build\UnitsNet.WindowsRuntimeComponent.nuspec" "UnitsNet\Properties\AssemblyInfo.WindowsRuntimeComponent.cs"
Update-AssemblyInfoFiles "Build\UnitsNet.Serialization.JsonNet.nuspec" "UnitsNet.Serialization.JsonNet\Properties\AssemblyInfo.cs"
}
catch {
$myError = $_.Exception.ToString()
Expand Down
7 changes: 5 additions & 2 deletions Build/nuget-restore.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@echo off
SET ROOT=%~dp0..
SET NuGetExe=%ROOT%\Tools\NuGet.exe
SET SolutionFile=%ROOT%\UnitsNet.sln
%NuGetExe% restore %SolutionFile%

%NuGetExe% restore %ROOT%\UnitsNet.sln
if %errorlevel% neq 0 exit /b %errorlevel%

%NuGetExe% restore %ROOT%\UnitsNet.WindowsRuntimeComponent.sln
if %errorlevel% neq 0 exit /b %errorlevel%
13 changes: 8 additions & 5 deletions Build/pack-nuget.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
@echo off
SET ROOT=%~dp0..
SET MainLibNuspec=%ROOT%\Build\UnitsNet.nuspec
SET SerializationLibNuspec=%ROOT%\Build\UnitsNet.Serialization.JsonNet.nuspec
SET MainNuspec=%ROOT%\Build\UnitsNet.nuspec
SET UwpNuspec=%ROOT%\Build\UnitsNet.WindowsRuntimeComponent.nuspec
SET SerializationNuspec=%ROOT%\Build\UnitsNet.Serialization.JsonNet.nuspec
SET NuGetExe=%ROOT%\Tools\NuGet.exe
SET NuGetOutDir=%ROOT%\Artifacts\NuGet

mkdir "%NuGetOutDir%"

%NuGetExe% pack %MainLibNuspec% -Verbosity detailed -OutputDirectory "%NuGetOutDir%" -BasePath "%ROOT%" -Symbols
%NuGetExe% pack %MainNuspec% -Verbosity detailed -OutputDirectory "%NuGetOutDir%" -BasePath "%ROOT%" -Symbols
if %errorlevel% neq 0 exit /b %errorlevel%
%NuGetExe% pack %UwpNuspec% -Verbosity detailed -OutputDirectory "%NuGetOutDir%" -BasePath "%ROOT%" -Symbols
if %errorlevel% neq 0 exit /b %errorlevel%
%NuGetExe% pack %SerializationNuspec% -Verbosity detailed -OutputDirectory "%NuGetOutDir%" -BasePath "%ROOT%" -Symbols
if %errorlevel% neq 0 exit /b %errorlevel%
%NuGetExe% pack %SerializationLibNuspec% -Verbosity detailed -OutputDirectory "%NuGetOutDir%" -BasePath "%ROOT%" -Symbols
if %errorlevel% neq 0 exit /b %errorlevel%
7 changes: 5 additions & 2 deletions Build/run-tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ set LogDir=%ROOT%\Artifacts\Logs
set TestsBinDir=%ROOT%\Artifacts\Bin\Tests\AnyCPU_Release
mkdir %LogDir%

%ROOT%\Tools\NUnit\nunit-console.exe "%TestsBinDir%\UnitsNet.Tests.dll" /framework="net-4.0" /xml:%LogDir%\UnitsNet.Tests.xml
%ROOT%\Tools\NUnit\nunit-console.exe "%TestsBinDir%\UnitsNet.Tests.dll" /framework="net-4.5" /xml:%LogDir%\UnitsNet.Tests.xml
if %errorlevel% neq 0 exit /b %errorlevel%

%ROOT%\Tools\NUnit\nunit-console.exe "%TestsBinDir%\UnitsNet.Serialization.JsonNet.Tests.dll" /framework="net-3.5" /xml:%LogDir%\UnitsNet.Serialization.JsonNet.Tests.xml
%ROOT%\Tools\NUnit\nunit-console.exe "%TestsBinDir%\UnitsNet.WindowsRuntimeComponent.Tests.dll" /framework="net-4.5" /xml:%LogDir%\UnitsNet.WindowsRuntimeComponent.Tests.xml
if %errorlevel% neq 0 exit /b %errorlevel%

%ROOT%\Tools\NUnit\nunit-console.exe "%TestsBinDir%\UnitsNet.Serialization.JsonNet.Tests.dll" /framework="net-4.5" /xml:%LogDir%\UnitsNet.Serialization.JsonNet.Tests.xml
if %errorlevel% neq 0 exit /b %errorlevel%
1 change: 1 addition & 0 deletions Build/src.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<MSBuild Projects="
$(SrcPath)\UnitsNet.Net35.csproj;
$(SrcPath)\UnitsNet.Portable40.csproj;
$(SrcPath)\UnitsNet.WindowsRuntimeComponent.csproj;
$(SerializationSrcPath)\UnitsNet.Serialization.JsonNet.Net35.csproj"
Properties="Platform=$(Platform);Configuration=$(Configuration);VisualStudioVersion=$(VisualStudioVersion);AllowUnsafeBlocks=true;Retries=15;RetryDelayMilliseconds=5"
Targets="Build">
Expand Down
1 change: 1 addition & 0 deletions Build/tests.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<MSBuild Projects="
$(TestsSrcPath)\UnitsNet.Tests.csproj;
$(TestsSrcPath)\UnitsNet.WindowsRuntimeComponent.Tests.csproj;
$(SerializationTestsSrcPath)\UnitsNet.Serialization.JsonNet.Tests.csproj"
Properties="Platform=$(Platform);Configuration=$(Configuration);VisualStudioVersion=$(VisualStudioVersion);AllowUnsafeBlocks=true"
Targets="Build">
Expand Down
1 change: 1 addition & 0 deletions UnitsNet.TestApps.Uwp.Csharp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/project.lock.json
8 changes: 8 additions & 0 deletions UnitsNet.TestApps.Uwp.Csharp/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application
x:Class="UWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWP"
RequestedTheme="Light">

</Application>
105 changes: 105 additions & 0 deletions UnitsNet.TestApps.Uwp.Csharp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace UWP
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{

#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif

Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added UnitsNet.TestApps.Uwp.Csharp/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Page
x:Class="UWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Name="MyTextBlock" Text="REPLACE ME" FontSize="30" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</Grid>
</Page>
32 changes: 32 additions & 0 deletions UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Windows.UI.Xaml.Controls;
using UnitsNet;
using UnitsNet.Units;

namespace UWP
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
/// <summary>
/// Example of public property returning WinRT component compatible type.
/// </summary>
public Temperature MyTemperature { get; set; }

public MainPage()
{
InitializeComponent();

// Test some variations, From() constructors, Parse(), As()
string celsius = Temperature.FromDegreesCelsius(100).ToString(TemperatureUnit.DegreeCelsius);
string fahrenheit = Temperature.Parse("100 °C").ToString(TemperatureUnit.DegreeFahrenheit);
string kelvin = Temperature.FromDegreesCelsius(Temperature.Parse(fahrenheit).As(TemperatureUnit.DegreeCelsius)).ToString(TemperatureUnit.Kelvin);

// Arithmetic operators not allowed in WinRT Components, but SHOULD be allowed in UWP C# apps
// new Temperature(5) + new Temperature(6)

MyTextBlock.Text = $"{celsius} = {fahrenheit} = {kelvin}";
}
}
}
49 changes: 49 additions & 0 deletions UnitsNet.TestApps.Uwp.Csharp/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">

<Identity
Name="45616dde-b0ee-4de6-932f-5e98afa042c8"
Publisher="CN=Andreas"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="45616dde-b0ee-4de6-932f-5e98afa042c8" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>UWP</DisplayName>
<PublisherDisplayName>Andreas</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="UWP.App">
<uap:VisualElements
DisplayName="UWP"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="UWP"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
29 changes: 29 additions & 0 deletions UnitsNet.TestApps.Uwp.Csharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UWP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UWP")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
Loading