Skip to content

Commit

Permalink
Move to client library as portable
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescadd committed Jun 11, 2015
1 parent c6c2e73 commit 4091144
Show file tree
Hide file tree
Showing 28 changed files with 2,100 additions and 19 deletions.
52 changes: 52 additions & 0 deletions ClientLibrary/ClientError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// *********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
//
// *********************************************************

namespace Microsoft.ProjectOxford.Face
{
using System;

/// <summary>
/// Container of ClientError and Error Entity.
/// </summary>
public class ClientError
{
/// <summary>
/// Gets or sets error code in error entity.
/// </summary>
/// <value>
/// The code of client error.
/// </value>
public string Code
{
get;
set;
}

/// <summary>
/// Gets or sets the message.
/// </summary>
/// <value>
/// The message.
/// </value>
public string Message
{
get;
set;
}

/// <summary>
/// Gets or sets the request identifier.
/// </summary>
/// <value>
/// The request identifier.
/// </value>
public Guid RequestId
{
get;
set;
}
}
}
133 changes: 133 additions & 0 deletions ClientLibrary/ClientException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// *********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
//
// *********************************************************

namespace Microsoft.ProjectOxford.Face
{
using System;
using System.Net;

/// <summary>
/// The Exception will be shown to client.
/// </summary>
public class ClientException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
public ClientException()
: base()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
/// <param name="message">The corresponding error message.</param>
public ClientException(string message)
: base(message)
{
this.Error = new ClientError()
{
Code = HttpStatusCode.InternalServerError.ToString(),
Message = message
};
}

/// <summary>
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
/// <param name="message">The corresponding error message.</param>
/// <param name="httpStatus">The Http Status code.</param>
public ClientException(string message, HttpStatusCode httpStatus)
: base(message)
{
this.HttpStatus = httpStatus;

this.Error = new ClientError()
{
Code = this.HttpStatus.ToString(),
Message = message
};
}

/// <summary>
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
/// <param name="message">The corresponding error message.</param>
/// <param name="innerException">The inner exception.</param>
public ClientException(string message, Exception innerException)
: base(message, innerException)
{
this.Error = new ClientError()
{
Code = HttpStatusCode.InternalServerError.ToString(),
Message = message
};
}

/// <summary>
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
/// <param name="message">The corresponding error message.</param>
/// <param name="errorCode">The error code.</param>
/// <param name="httpStatus">The http status.</param>
/// <param name="innerException">The inner exception.</param>
public ClientException(string message, string errorCode, HttpStatusCode httpStatus, Exception innerException)
: base(message, innerException)
{
this.HttpStatus = httpStatus;

this.Error = new ClientError()
{
Code = errorCode,
Message = message
};
}

/// <summary>
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
/// <param name="error">The error entity.</param>
/// <param name="httpStatus">The http status.</param>
public ClientException(ClientError error, HttpStatusCode httpStatus)
{
this.Error = error;
this.HttpStatus = httpStatus;
}

/// <summary>
/// Gets http status of http response.
/// </summary>
/// <value>
/// The HTTP status.
/// </value>
public HttpStatusCode HttpStatus { get; private set; }

/// <summary>
/// Gets or sets the httpError message.
/// </summary>
/// <value>
/// The error.
/// </value>
public ClientError Error { get; set; }

/// <summary>
/// Create Client Exception of Bad Request.
/// </summary>
/// <param name="message">The corresponding error message.</param>
/// <returns>Client Exception Instance.</returns>
public static ClientException BadRequest(string message)
{
return new ClientException(
new ClientError()
{
Code = ((int)HttpStatusCode.BadRequest).ToString(),
Message = message
},
HttpStatusCode.BadRequest);
}
}
}
68 changes: 68 additions & 0 deletions ClientLibrary/ClientLibrary.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{25D58BA5-660F-407B-803C-22B4547C09DC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClientLibrary</RootNamespace>
<AssemblyName>ClientLibrary</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="ClientError.cs" />
<Compile Include="ClientException.cs" />
<Compile Include="Contract\Face.cs" />
<Compile Include="Contract\FaceAttribute.cs" />
<Compile Include="Contract\HeadPose.cs" />
<Compile Include="Contract\FaceRectangle.cs" />
<Compile Include="Contract\FaceLandmarks.cs" />
<Compile Include="Contract\GroupResult.cs" />
<Compile Include="Contract\IdentifyResult.cs" />
<Compile Include="Contract\Person.cs" />
<Compile Include="Contract\Candidate.cs" />
<Compile Include="Contract\CreatePersonResult.cs" />
<Compile Include="Contract\PersonFace.cs" />
<Compile Include="Contract\PersonGroup.cs" />
<Compile Include="Contract\FeatureCoordinate.cs" />
<Compile Include="Contract\SimilarFace.cs" />
<Compile Include="Contract\TrainingStatus.cs" />
<Compile Include="Contract\VerifyResult.cs" />
<Compile Include="FaceServiceClient.cs" />
<Compile Include="IFaceServiceClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>$(SolutionDir)\packages\Newtonsoft.Json.6.0.8\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
</Project>
32 changes: 32 additions & 0 deletions ClientLibrary/Contract/Candidate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// *********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
//
// *********************************************************

namespace Microsoft.ProjectOxford.Face.Contract
{
using System;

/// <summary>
/// The identified candidate entity.
/// </summary>
public class Candidate
{
/// <summary>
/// Gets or sets the person identifier.
/// </summary>
/// <value>
/// The person identifier.
/// </value>
public Guid PersonId { get; set; }

/// <summary>
/// Gets or sets the confidence.
/// </summary>
/// <value>
/// The confidence.
/// </value>
public double Confidence { get; set; }
}
}
24 changes: 24 additions & 0 deletions ClientLibrary/Contract/CreatePersonResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// *********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
//
// *********************************************************

namespace Microsoft.ProjectOxford.Face.Contract
{
using System;

/// <summary>
/// The class for person creation result.
/// </summary>
public class CreatePersonResult
{
/// <summary>
/// Gets or sets the person identifier.
/// </summary>
/// <value>
/// The person identifier.
/// </value>
public Guid PersonId { get; set; }
}
}
50 changes: 50 additions & 0 deletions ClientLibrary/Contract/Face.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// *********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
//
// *********************************************************

namespace Microsoft.ProjectOxford.Face.Contract
{
using System;

/// <summary>
/// The detected face entity.
/// </summary>
public class Face
{
/// <summary>
/// Gets or sets the face identifier.
/// </summary>
/// <value>
/// The face identifier.
/// </value>
public Guid FaceId { get; set; }

/// <summary>
/// Gets or sets the face rectangle.
/// </summary>
/// <value>
/// The face rectangle.
/// </value>
public FaceRectangle FaceRectangle { get; set; }

/// <summary>
/// Gets or sets the face landmarks.
/// </summary>
/// <value>
/// The face landmarks.
/// </value>
public FaceLandmarks FaceLandmarks { get; set; }

/// <summary>
/// Gets or sets the attributes.
/// </summary>
/// <value>
/// The attributes.
/// </value>
public FaceAttribute Attributes { get; set; }

public object Tag { get; set; }
}
}
Loading

0 comments on commit 4091144

Please sign in to comment.