Skip to content
Permalink
Browse files

Moved the code template (should be generalized)

Added a method to control the encryption
  • Loading branch information
sidewinder94 committed Nov 16, 2019
1 parent d833488 commit c3fa7389911ca10cdfa12faa6fd8da801a86cb6a
@@ -31,7 +31,12 @@ public SpeedifyAdapter DailyDataLimit(SpeedifyAdapter adapter, long? dataUsage =
value = dataUsage.ToString();
}

return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] { Adapter._moduleName, "datalimit", "daily", adapter.AdapterId.ToString(), value });
return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] {
Adapter._moduleName,
"datalimit",
"daily",
adapter.AdapterId.ToString(),
value });
}

/// <summary>
@@ -43,7 +48,12 @@ public SpeedifyAdapter DailyDataLimit(SpeedifyAdapter adapter, long? dataUsage =
/// <returns>An updated <see cref="SpeedifyAdapter"/> object</returns>
public SpeedifyAdapter DailyDataBoost(SpeedifyAdapter adapter, long additionalData, int timeout = 60)
{
return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] { Adapter._moduleName, "datalimit", "dailyboost", adapter.AdapterId.ToString(), additionalData.ToString() });
return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] {
Adapter._moduleName,
"datalimit",
"dailyboost",
adapter.AdapterId.ToString(),
additionalData.ToString() });
}

/// <summary>
@@ -54,7 +64,7 @@ public SpeedifyAdapter DailyDataBoost(SpeedifyAdapter adapter, long additionalDa
/// <param name="dayOfReset">day of the month to reset on, 0 for last 30 days, default : 0</param>
/// <param name="timeout">Timeout for the command, default 60</param>
/// <returns>An updated <see cref="SpeedifyAdapter"/> object</returns>
public SpeedifyAdapter MonthlyDataLimit(SpeedifyAdapter adapter, long? dataUsage = null, int dayOfReset = 0,int timeout = 60)
public SpeedifyAdapter MonthlyDataLimit(SpeedifyAdapter adapter, long? dataUsage = null, int dayOfReset = 0, int timeout = 60)
{
string value = "unlimited";

@@ -63,7 +73,22 @@ public SpeedifyAdapter MonthlyDataLimit(SpeedifyAdapter adapter, long? dataUsage
value = dataUsage.ToString();
}

return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] { Adapter._moduleName, "datalimit", "monthly", adapter.AdapterId.ToString(), value, value == "unlimited" ? "" : dayOfReset.ToString() });
return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] {
Adapter._moduleName,
"datalimit",
"monthly",
adapter.AdapterId.ToString(),
value,
value == "unlimited" ? "" : dayOfReset.ToString() });
}

public SpeedifyAdapter SetEncryption(SpeedifyAdapter adapter, bool enable, int timeout = 60)
{
return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] {
Adapter._moduleName,
"encryption",
adapter.AdapterId.ToString(),
enable ? "on" : "off" });
}
}
}

This file was deleted.

@@ -0,0 +1,35 @@
/*
This file is generated by a tool, do not edit manually
*/

using System;
using System.Collections.Generic;
using SpeedifyCliWrapper.Common;

namespace SpeedifyCliWrapper.ReturnTypes
{
public partial class SpeedifyAdapter
{
public SpeedifyAdapter DailyDataLimit (SpeedifyAdapter adapter, Nullable<long> dataUsage, int timeout = 60)
{
return this._wrapper.Adapter.DailyDataLimit(adapter, dataUsage, timeout);
}

public SpeedifyAdapter DailyDataBoost (SpeedifyAdapter adapter, long additionalData, int timeout = 60)
{
return this._wrapper.Adapter.DailyDataBoost(adapter, additionalData, timeout);
}

public SpeedifyAdapter MonthlyDataLimit (SpeedifyAdapter adapter, Nullable<long> dataUsage, int dayOfReset = 0, int timeout = 60)
{
return this._wrapper.Adapter.MonthlyDataLimit(adapter, dataUsage, dayOfReset, timeout);
}

public SpeedifyAdapter SetEncryption (SpeedifyAdapter adapter, bool enable, int timeout = 60)
{
return this._wrapper.Adapter.SetEncryption(adapter, enable, timeout);
}

}
}

@@ -14,6 +14,14 @@
List<MethodInfo> methods = typeof(Adapter).GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(mi => mi.GetParameters().Any() && mi.GetParameters().First().ParameterType == typeof(SpeedifyAdapter)).ToList();
var compiler = new CSharpCodeProvider();
#>
/*
This file is generated by a tool, do not edit manually
*/

using System;
using System.Collections.Generic;
using SpeedifyCliWrapper.Common;

namespace SpeedifyCliWrapper.ReturnTypes
{
public partial class SpeedifyAdapter
@@ -23,7 +31,7 @@ namespace SpeedifyCliWrapper.ReturnTypes

var parameters = method.GetParameters().ToArray();
#>
public <#= method.ReturnType.Name#> <#= method.Name#> (<#for(int i = 0; i < parameters.Length ; i++) { #><#= compiler.GetTypeOutput(new CodeTypeReference(parameters[i].ParameterType)) #> <#= parameters[i].Name #><# if (i != parameters.Length - 1) { Write(", "); }}#>)
public <#= method.ReturnType.Name#> <#= method.Name#> (<#for(int i = 0; i < parameters.Length ; i++) { var typeName = compiler.GetTypeOutput(new CodeTypeReference(parameters[i].ParameterType)); #><#= typeName.Substring(typeName.LastIndexOf(".") + 1) #> <#= parameters[i].Name #><# if (parameters[i].HasDefaultValue && parameters[i].DefaultValue != null) { #> = <#= parameters[i].DefaultValue #><# } if (i != parameters.Length - 1) { Write(", "); }}#>)
{
return this._wrapper.Adapter.<#=method.Name#>(<#for(int i = 0; i < parameters.Length ; i++) { #><#= parameters[i].Name #><# if (i != parameters.Length - 1) { Write(", "); }}#>);
}
@@ -4,16 +4,18 @@
<TargetFrameworks>netstandard2.0;net462;net45</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.13-pre</Version>
<AssemblyVersion>1.0.13.0</AssemblyVersion>
<FileVersion>1.0.13.0</FileVersion>
<PackageReleaseNotes>Created a code generation template to generate methods in partial classes for the return types allowing to call their related modules methods without having to go thourgh the wrapper =&gt; module agin (to ganaralize)</PackageReleaseNotes>
<Version>1.0.14-pre</Version>
<AssemblyVersion>1.0.14.0</AssemblyVersion>
<FileVersion>1.0.14.0</FileVersion>
<PackageReleaseNotes>Moved the code template (should be generalized)

Added a method to control the encryption</PackageReleaseNotes>
<Authors>Antoine-Ali Zarrouk</Authors>
<Company />
</PropertyGroup>

<ItemGroup>
<None Include="Modules\Adapter.partial.cs">
<None Include="Modules\Partials\Adapter.partial.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Modules\Adapter.partial.tt</DependentUpon>
@@ -30,15 +32,15 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Modules\Adapter.partial.cs">
<Compile Update="Modules\Partials\Adapter.partial.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Adapter.partial.tt</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<None Update="Modules\Adapter.partial.tt">
<None Update="Modules\Partials\Adapter.partial.tt">
<DependentUpon>Modules\Adapter.cs</DependentUpon>
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Adapter.partial.cs</LastGenOutput>

0 comments on commit c3fa738

Please sign in to comment.
You can’t perform that action at this time.