mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-26 13:38:06 +03:00
WebApi doesn't belong here (moving to different repo)
This commit is contained in:
parent
74ef4d49ad
commit
9f3ecfd66e
@ -100,9 +100,6 @@
|
|||||||
<Compile Include="Server\Inventory.cs" />
|
<Compile Include="Server\Inventory.cs" />
|
||||||
<Compile Include="Server\Server.cs" />
|
<Compile Include="Server\Server.cs" />
|
||||||
<Compile Include="Server\Stats.cs" />
|
<Compile Include="Server\Stats.cs" />
|
||||||
<Compile Include="Web\IWorkshopService.cs" />
|
|
||||||
<Compile Include="Web\ISteamEconomy.cs" />
|
|
||||||
<Compile Include="Web\ISteamApps.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Facepunch.Steamworks\Facepunch.Steamworks.csproj">
|
<ProjectReference Include="..\Facepunch.Steamworks\Facepunch.Steamworks.csproj">
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public partial class ISteamApps
|
|
||||||
{
|
|
||||||
[TestInitialize]
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// For the sake of tests, we store our Key in an environment variable
|
|
||||||
// (so we don't end up shipping it to github and exposing it to everyone)
|
|
||||||
//
|
|
||||||
Facepunch.SteamApi.Config.Key = Environment.GetEnvironmentVariable( "SteamWebApi", EnvironmentVariableTarget.User );
|
|
||||||
|
|
||||||
//
|
|
||||||
// We're going to be using Newtonsoft to deserialize our json
|
|
||||||
//
|
|
||||||
Facepunch.SteamApi.Config.DeserializeJson = ( str, type ) =>
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.DeserializeObject( str, type );
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void GetAppBetas()
|
|
||||||
{
|
|
||||||
foreach ( var beta in Facepunch.SteamApi.ISteamApps.GetAppBetas( 252490 ).betas )
|
|
||||||
{
|
|
||||||
Console.WriteLine( beta.Key );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void GetAppBuilds()
|
|
||||||
{
|
|
||||||
foreach ( var build in Facepunch.SteamApi.ISteamApps.GetAppBuilds( 252490, 10 ).builds )
|
|
||||||
{
|
|
||||||
Console.WriteLine( build.Key );
|
|
||||||
Console.WriteLine( " Desc: " + build.Value.Description );
|
|
||||||
Console.WriteLine( " Accnt:" + build.Value.AccountIDCreator );
|
|
||||||
|
|
||||||
foreach ( var depot in build.Value.depots )
|
|
||||||
{
|
|
||||||
Console.WriteLine( " Depot" + depot.Value.DepotId + ":" );
|
|
||||||
Console.WriteLine( " GID: " + depot.Value.DepotVersionGID );
|
|
||||||
Console.WriteLine( " Bytes: " + depot.Value.TotalOriginalBytes );
|
|
||||||
Console.WriteLine( " Compressed: " + depot.Value.TotalCompressedBytes );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public partial class ISteamEconomy
|
|
||||||
{
|
|
||||||
[TestInitialize]
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// For the sake of tests, we store our Key in an environment variable
|
|
||||||
// (so we don't end up shipping it to github and exposing it to everyone)
|
|
||||||
//
|
|
||||||
Facepunch.SteamApi.Config.Key = Environment.GetEnvironmentVariable( "SteamWebApi", EnvironmentVariableTarget.User );
|
|
||||||
|
|
||||||
//
|
|
||||||
// We're going to be using Newtonsoft to deserialize our json
|
|
||||||
//
|
|
||||||
Facepunch.SteamApi.Config.DeserializeJson = ( str, type ) =>
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.DeserializeObject( str, type );
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void GetMarketPrices()
|
|
||||||
{
|
|
||||||
var response = Facepunch.SteamApi.ISteamEconomy.GetMarketPrices( 252490 );
|
|
||||||
|
|
||||||
var items = response.groups.OrderByDescending( x => x.sell_listings );
|
|
||||||
|
|
||||||
foreach ( var i in items )
|
|
||||||
{
|
|
||||||
Console.WriteLine( i.sell_listings + " " + i.name );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public partial class IWorkshopService
|
|
||||||
{
|
|
||||||
[TestInitialize]
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// For the sake of tests, we store our Key in an environment variable
|
|
||||||
// (so we don't end up shipping it to github and exposing it to everyone)
|
|
||||||
//
|
|
||||||
Facepunch.SteamApi.Config.Key = Environment.GetEnvironmentVariable( "SteamWebApi", EnvironmentVariableTarget.User );
|
|
||||||
|
|
||||||
//
|
|
||||||
// We're going to be using Newtonsoft to deserialize our json
|
|
||||||
//
|
|
||||||
Facepunch.SteamApi.Config.DeserializeJson = ( str, type ) =>
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.DeserializeObject( str, type );
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void GetItemDailyRevenue()
|
|
||||||
{
|
|
||||||
var response = SteamApi.IWorkshopService.GetItemDailyRevenue( 252490, 20006, DateTime.Now.Subtract( TimeSpan.FromDays( 30 ) ), DateTime.Now.AddDays( 1 ) );
|
|
||||||
|
|
||||||
Console.WriteLine( "Item Sold " + response.TotalUnitsSold + " worldwide" );
|
|
||||||
Console.WriteLine( "Item Generated $" + response.TotalRevenue + " worldwide" );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -144,10 +144,6 @@
|
|||||||
<Compile Include="Server\Auth.cs" />
|
<Compile Include="Server\Auth.cs" />
|
||||||
<Compile Include="Server\Query.cs" />
|
<Compile Include="Server\Query.cs" />
|
||||||
<Compile Include="Server\Stats.cs" />
|
<Compile Include="Server\Stats.cs" />
|
||||||
<Compile Include="SteamNative\SteamApi.cs" />
|
|
||||||
<Compile Include="SteamNative\SteamApi.Config.cs" />
|
|
||||||
<Compile Include="SteamNative\SteamApi.Response.cs" />
|
|
||||||
<Compile Include="SteamNative\SteamApi.Utility.cs" />
|
|
||||||
<Compile Include="SteamNative\SteamNative.Helpers.cs" />
|
<Compile Include="SteamNative\SteamNative.Helpers.cs" />
|
||||||
<Compile Include="SteamNative\SteamNative.Constants.cs" />
|
<Compile Include="SteamNative\SteamNative.Constants.cs" />
|
||||||
<Compile Include="SteamNative\SteamNative.Enums.cs" />
|
<Compile Include="SteamNative\SteamNative.Enums.cs" />
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Facepunch
|
|
||||||
{
|
|
||||||
namespace SteamApi
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Static class to configure SteamApi
|
|
||||||
/// </summary>
|
|
||||||
public static class Config
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Your Steam Api Key is secret.
|
|
||||||
/// Don't ship it with your game.
|
|
||||||
/// Treat it like a password.
|
|
||||||
/// </summary>
|
|
||||||
public static string Key;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Plug your json deserializer in here. We don't force one on you, this is left
|
|
||||||
/// up to the implementation. We've only tested Newtonsoft.Json though. Here's an example of
|
|
||||||
/// how to set it up.
|
|
||||||
/// </summary>
|
|
||||||
/// <example>
|
|
||||||
///
|
|
||||||
/// Facepunch.SteamApi.Config.DeserializeJson = ( str, type ) =>
|
|
||||||
/// {
|
|
||||||
/// return Newtonsoft.Json.JsonConvert.DeserializeObject( str, type );
|
|
||||||
/// };
|
|
||||||
///
|
|
||||||
/// </example>
|
|
||||||
public static Func<string, Type, object> DeserializeJson;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
namespace Facepunch.SteamApi
|
|
||||||
{
|
|
||||||
internal class ApiResponse<T>
|
|
||||||
{
|
|
||||||
public T Response;
|
|
||||||
public T Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class ISteamApps
|
|
||||||
{
|
|
||||||
public class GetAppBetasResponse
|
|
||||||
{
|
|
||||||
public class Beta
|
|
||||||
{
|
|
||||||
public ulong BuildId;
|
|
||||||
public string Description;
|
|
||||||
public bool ReqPassword;
|
|
||||||
public bool ReqLocalCS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Beta> betas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GetAppBuildsResponse
|
|
||||||
{
|
|
||||||
public class Build
|
|
||||||
{
|
|
||||||
public ulong BuildId;
|
|
||||||
public string Description;
|
|
||||||
public uint CreationTime;
|
|
||||||
public ulong AccountIDCreator;
|
|
||||||
|
|
||||||
public class Depot
|
|
||||||
{
|
|
||||||
public ulong DepotId;
|
|
||||||
public ulong DepotVersionGID;
|
|
||||||
public ulong TotalOriginalBytes;
|
|
||||||
public ulong TotalCompressedBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Depot> depots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Build> builds;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class ISteamEconomy
|
|
||||||
{
|
|
||||||
public class GetMarketPricesResponse
|
|
||||||
{
|
|
||||||
public int total_count;
|
|
||||||
public int start;
|
|
||||||
public int count;
|
|
||||||
|
|
||||||
public class Group
|
|
||||||
{
|
|
||||||
public string name;
|
|
||||||
public string icon_url;
|
|
||||||
public ulong sell_listings;
|
|
||||||
public ulong buy_listings;
|
|
||||||
public ulong listed_property_def_index;
|
|
||||||
|
|
||||||
public class Currency
|
|
||||||
{
|
|
||||||
public int ECurrencyCode;
|
|
||||||
public string currency;
|
|
||||||
public double sell_price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Currency[] currencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Group[] groups;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public partial class IWorkshopService
|
|
||||||
{
|
|
||||||
public class GetItemDailyRevenueResponse
|
|
||||||
{
|
|
||||||
public class Country
|
|
||||||
{
|
|
||||||
public string country_code;
|
|
||||||
public uint date;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Appears to be the dollar amount multiplied by 10000
|
|
||||||
/// Use Revenue to get the real value as a double
|
|
||||||
/// </summary>
|
|
||||||
public double revenue_usd;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Total dollar revenue, normalised
|
|
||||||
/// </summary>
|
|
||||||
public double Revenue { get { return revenue_usd / 10000.0; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of units sold
|
|
||||||
/// </summary>
|
|
||||||
public long Units;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Country[] country_revenue;
|
|
||||||
|
|
||||||
public long TotalUnitsSold { get { return country_revenue.Sum( x => x.Units ); } }
|
|
||||||
public double TotalRevenue { get { return country_revenue.Sum( x => x.Revenue ); } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
namespace Facepunch.SteamApi
|
|
||||||
{
|
|
||||||
public class Utility
|
|
||||||
{
|
|
||||||
public static T WebGet<T>( string url )
|
|
||||||
{
|
|
||||||
var www = new System.Net.WebClient();
|
|
||||||
var data = www.DownloadString( url );
|
|
||||||
www.Dispose();
|
|
||||||
|
|
||||||
if ( typeof( T ) == typeof( string ) )
|
|
||||||
return (T)(object)data;
|
|
||||||
|
|
||||||
var response = DeserializeJson<ApiResponse<T>>( data );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( response.Response == null )
|
|
||||||
return response.Result;
|
|
||||||
|
|
||||||
return response.Response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T WebPost<T>( string url, System.Collections.Generic.Dictionary<string, object> variables )
|
|
||||||
{
|
|
||||||
var www = new System.Net.WebClient();
|
|
||||||
|
|
||||||
var nvc = new NameValueCollection();
|
|
||||||
|
|
||||||
if ( Config.Key != null )
|
|
||||||
variables.Add( "key", Config.Key );
|
|
||||||
|
|
||||||
foreach ( var v in variables )
|
|
||||||
{
|
|
||||||
nvc.Add( v.Key, v.Value.ToString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
var bytes = www.UploadValues( url, "POST", nvc );
|
|
||||||
var data = System.Text.Encoding.UTF8.GetString( bytes );
|
|
||||||
|
|
||||||
www.Dispose();
|
|
||||||
|
|
||||||
if ( typeof( T ) == typeof( string ) )
|
|
||||||
return (T)(object)data;
|
|
||||||
|
|
||||||
var response = DeserializeJson<ApiResponse<T>>( data );
|
|
||||||
|
|
||||||
if ( response.Response == null )
|
|
||||||
return response.Result;
|
|
||||||
|
|
||||||
return response.Response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static T DeserializeJson<T>( string data )
|
|
||||||
{
|
|
||||||
return (T)Facepunch.SteamApi.Config.DeserializeJson( data, typeof( T ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -11,13 +11,10 @@ namespace Generator
|
|||||||
public partial class CodeWriter
|
public partial class CodeWriter
|
||||||
{
|
{
|
||||||
private SteamApiDefinition def;
|
private SteamApiDefinition def;
|
||||||
private WebApiDefinition webdef;
|
|
||||||
|
|
||||||
public CodeWriter( SteamApiDefinition def, WebApiDefinition webdef )
|
public CodeWriter( SteamApiDefinition def )
|
||||||
{
|
{
|
||||||
this.def = def;
|
this.def = def;
|
||||||
this.webdef = webdef;
|
|
||||||
|
|
||||||
WorkoutTypes();
|
WorkoutTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +103,6 @@ namespace Generator
|
|||||||
{
|
{
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
Header( "Facepunch.SteamApi" );
|
Header( "Facepunch.SteamApi" );
|
||||||
WebApi();
|
|
||||||
Footer();
|
Footer();
|
||||||
System.IO.File.WriteAllText( $"{folder}SteamApi.cs", sb.ToString() );
|
System.IO.File.WriteAllText( $"{folder}SteamApi.cs", sb.ToString() );
|
||||||
}
|
}
|
||||||
|
@ -1,150 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Generator
|
|
||||||
{
|
|
||||||
public partial class CodeWriter
|
|
||||||
{
|
|
||||||
public static string[] HasReturnTypes = new string[]
|
|
||||||
{
|
|
||||||
"ISteamApps.GetAppBetas",
|
|
||||||
"ISteamApps.GetAppBuilds",
|
|
||||||
|
|
||||||
"ISteamEconomy.GetMarketPrices",
|
|
||||||
|
|
||||||
"IWorkshopService.GetItemDailyRevenue"
|
|
||||||
};
|
|
||||||
|
|
||||||
private void WebApi()
|
|
||||||
{
|
|
||||||
foreach ( var o in webdef.apilist.interfaces )
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Skip any that end in numbers
|
|
||||||
if ( char.IsNumber( o.name.Last() ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
WriteLine( $"/// <summary>" );
|
|
||||||
WriteLine( $"/// {o.name}" );
|
|
||||||
WriteLine( $"/// </summary>" );
|
|
||||||
StartBlock( $"public partial class {o.name}" );
|
|
||||||
{
|
|
||||||
WriteLine( $"private const string Url = \"http://api.steampowered.com/{o.name}/\";" );
|
|
||||||
WriteLine();
|
|
||||||
|
|
||||||
|
|
||||||
foreach ( var m in o.methods.OrderBy( x => x.name ) )
|
|
||||||
{
|
|
||||||
var LatestVersion = o.methods
|
|
||||||
.Where( x => x.name == m.name )
|
|
||||||
.Max( x => x.version );
|
|
||||||
|
|
||||||
// Skip this method if it's not the latest
|
|
||||||
if ( LatestVersion != m.version )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
WebApiMethod( o.name, m );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EndBlock();
|
|
||||||
WriteLine();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WebApiMethod( string parent, WebApiDefinition.ApiList.Interface.Method m )
|
|
||||||
{
|
|
||||||
BeforeLines = new List<string>();
|
|
||||||
|
|
||||||
var pars = m.parameters.Where ( x => x.name != "key" );
|
|
||||||
|
|
||||||
var parameters = string.Join( ", ", pars.Select( x => FormatParameter( x ) ).Where( x => x != null ) );
|
|
||||||
|
|
||||||
foreach ( var p in pars )
|
|
||||||
{
|
|
||||||
var name = p.name;
|
|
||||||
if ( p.type == "uint32" && p.name.Contains( "date" ) )
|
|
||||||
{
|
|
||||||
name += "_dt";
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteLine( $"/// <param name=\"{name.Replace( "[0]", "[]" ) }\">({p.type}){p.description}</param>" );
|
|
||||||
}
|
|
||||||
|
|
||||||
var returnType = "string";
|
|
||||||
|
|
||||||
if ( HasReturnTypes.Contains( $"{parent}.{m.name}" ) )
|
|
||||||
{
|
|
||||||
returnType = m.name + "Response";
|
|
||||||
}
|
|
||||||
|
|
||||||
StartBlock( $"public static {returnType} {m.name}({parameters})" );
|
|
||||||
{
|
|
||||||
if ( BeforeLines.Count > 0 )
|
|
||||||
{
|
|
||||||
WriteLines( BeforeLines );
|
|
||||||
WriteLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m.httpmethod == "GET" )
|
|
||||||
{
|
|
||||||
var getParameters = string.Join( "&", pars.Select( x => FormatGetParameter( x ) ).Where( x => x != null ) );
|
|
||||||
WriteLine( $"return Utility.WebGet<{returnType}>( $\"{{Url}}{m.name}/v{m.version.ToString( "0000" )}/?key={{Facepunch.SteamApi.Config.Key}}&format=json&{getParameters}\" );" );
|
|
||||||
}
|
|
||||||
else if ( m.httpmethod == "POST" )
|
|
||||||
{
|
|
||||||
StartBlock( $"var headers = new System.Collections.Generic.Dictionary<string, object>()" );
|
|
||||||
{
|
|
||||||
foreach ( var p in pars )
|
|
||||||
{
|
|
||||||
WriteLine( $"{{ \"{p.name}\", {p.name} }}," );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EndBlock( ";" );
|
|
||||||
WriteLine();
|
|
||||||
|
|
||||||
WriteLine( $"return Utility.WebPost<{returnType}>( $\"{{Url}}/{m.name}/v{m.version.ToString( "0000" )}/\", headers );" );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
EndBlock();
|
|
||||||
WriteLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
private object FormatGetParameter( WebApiDefinition.ApiList.Interface.Method.Parameter x )
|
|
||||||
{
|
|
||||||
return $"{x.name}={{{x.name}}}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private object FormatParameter( WebApiDefinition.ApiList.Interface.Method.Parameter x )
|
|
||||||
{
|
|
||||||
var name = x.name;
|
|
||||||
|
|
||||||
var type = ToManagedType( x.type );
|
|
||||||
|
|
||||||
if ( type == "{message}" ) type = "string";
|
|
||||||
if ( type == "rawbinary" ) type = "byte[]";
|
|
||||||
|
|
||||||
if ( name.EndsWith( "[0]" ) )
|
|
||||||
{
|
|
||||||
name = name.Replace( "[0]", "" );
|
|
||||||
type += "[]";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( type == "uint" && name.Contains( "date" ) )
|
|
||||||
{
|
|
||||||
BeforeLines.Add( $"uint {name} = Facepunch.Steamworks.Utility.Epoch.FromDateTime( {name}_dt );" );
|
|
||||||
|
|
||||||
type = "DateTime";
|
|
||||||
name += "_dt";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $"{type} {name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -51,7 +51,6 @@
|
|||||||
<Compile Include="CodeParser\CodeParser.cs" />
|
<Compile Include="CodeParser\CodeParser.cs" />
|
||||||
<Compile Include="CodeWriter\Class.cs" />
|
<Compile Include="CodeWriter\Class.cs" />
|
||||||
<Compile Include="CodeWriter\Constants.cs" />
|
<Compile Include="CodeWriter\Constants.cs" />
|
||||||
<Compile Include="CodeWriter\WebApi.cs" />
|
|
||||||
<Compile Include="CodeWriter\Writing.cs" />
|
<Compile Include="CodeWriter\Writing.cs" />
|
||||||
<Compile Include="CodeWriter\CodeWriter.cs" />
|
<Compile Include="CodeWriter\CodeWriter.cs" />
|
||||||
<Compile Include="CodeWriter\Enums.cs" />
|
<Compile Include="CodeWriter\Enums.cs" />
|
||||||
@ -61,7 +60,6 @@
|
|||||||
<Compile Include="CodeWriter\Interface.cs" />
|
<Compile Include="CodeWriter\Interface.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="WebApiDefinition.cs" />
|
|
||||||
<Compile Include="SteamApiDefinition.cs" />
|
<Compile Include="SteamApiDefinition.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -14,16 +14,13 @@ namespace Generator
|
|||||||
var content = System.IO.File.ReadAllText( "steam_sdk/steam_api.json" );
|
var content = System.IO.File.ReadAllText( "steam_sdk/steam_api.json" );
|
||||||
var def = Newtonsoft.Json.JsonConvert.DeserializeObject<SteamApiDefinition>( content );
|
var def = Newtonsoft.Json.JsonConvert.DeserializeObject<SteamApiDefinition>( content );
|
||||||
|
|
||||||
var webcontent = System.IO.File.ReadAllText( "steam_sdk/web_api.json" );
|
|
||||||
var webdef = Newtonsoft.Json.JsonConvert.DeserializeObject<WebApiDefinition>( webcontent );
|
|
||||||
|
|
||||||
AddExtras( def );
|
AddExtras( def );
|
||||||
|
|
||||||
var parser = new CodeParser( @"steam_sdk" );
|
var parser = new CodeParser( @"steam_sdk" );
|
||||||
|
|
||||||
parser.ExtendDefinition( def );
|
parser.ExtendDefinition( def );
|
||||||
|
|
||||||
var generator = new CodeWriter( def, webdef );
|
var generator = new CodeWriter( def );
|
||||||
|
|
||||||
generator.ToFolder( "../Facepunch.Steamworks/SteamNative/" );
|
generator.ToFolder( "../Facepunch.Steamworks/SteamNative/" );
|
||||||
}
|
}
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Generator
|
|
||||||
{
|
|
||||||
public class WebApiDefinition
|
|
||||||
{
|
|
||||||
public class ApiList
|
|
||||||
{
|
|
||||||
public Interface[] interfaces { get; set; }
|
|
||||||
|
|
||||||
public class Interface
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
|
|
||||||
public Method[] methods { get; set; }
|
|
||||||
|
|
||||||
public class Method
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public int version { get; set; }
|
|
||||||
public string httpmethod { get; set; }
|
|
||||||
|
|
||||||
public Parameter[] parameters { get; set; }
|
|
||||||
|
|
||||||
public class Parameter
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public string type { get; set; }
|
|
||||||
public bool optional { get; set; }
|
|
||||||
public string description { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApiList apilist { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user