-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
28,873 additions
and
28,965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
namespace NetVips.Docs | ||
{ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Docfx; | ||
using Docfx.Dotnet; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Docfx; | ||
using Docfx.Dotnet; | ||
|
||
namespace NetVips.Docs; | ||
|
||
internal class Build | ||
internal class Build | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
var projectDir = | ||
Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")); | ||
var currentDirectory = Directory.GetCurrentDirectory(); | ||
var projectDir = | ||
Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")); | ||
var currentDirectory = Directory.GetCurrentDirectory(); | ||
|
||
Directory.SetCurrentDirectory(projectDir); | ||
await DotnetApiCatalog.GenerateManagedReferenceYamlFiles("docfx.json"); | ||
await Docset.Build("docfx.json"); | ||
Directory.SetCurrentDirectory(currentDirectory); | ||
} | ||
Directory.SetCurrentDirectory(projectDir); | ||
await DotnetApiCatalog.GenerateManagedReferenceYamlFiles("docfx.json"); | ||
await Docset.Build("docfx.json"); | ||
Directory.SetCurrentDirectory(currentDirectory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace NetVips | ||
namespace NetVips; | ||
|
||
public interface ISample | ||
{ | ||
public interface ISample | ||
{ | ||
string Name { get; } | ||
string Name { get; } | ||
|
||
string Category { get; } | ||
string Category { get; } | ||
|
||
void Execute(string[] args); | ||
} | ||
void Execute(string[] args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,103 @@ | ||
namespace NetVips | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace NetVips; | ||
|
||
internal class Program | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
private static readonly List<ISample> Samples = Assembly.GetExecutingAssembly().GetTypes() | ||
.Where(x => x.GetInterfaces().Contains(typeof(ISample)) && x.GetConstructor(Type.EmptyTypes) != null) | ||
.Select(x => Activator.CreateInstance(x) as ISample) | ||
.OrderBy(s => s?.Category) | ||
.ToList(); | ||
|
||
internal class Program | ||
private static void Main(string[] args) | ||
{ | ||
private static readonly List<ISample> Samples = Assembly.GetExecutingAssembly().GetTypes() | ||
.Where(x => x.GetInterfaces().Contains(typeof(ISample)) && x.GetConstructor(Type.EmptyTypes) != null) | ||
.Select(x => Activator.CreateInstance(x) as ISample) | ||
.OrderBy(s => s?.Category) | ||
.ToList(); | ||
|
||
private static void Main(string[] args) | ||
if (!ModuleInitializer.VipsInitialized) | ||
{ | ||
if (!ModuleInitializer.VipsInitialized) | ||
{ | ||
Console.WriteLine("Error: Unable to init libvips. Please check your PATH environment variable."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
Console.WriteLine("Error: Unable to init libvips. Please check your PATH environment variable."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
|
||
Console.WriteLine($"libvips {NetVips.Version(0)}.{NetVips.Version(1)}.{NetVips.Version(2)}"); | ||
Console.WriteLine($"libvips {NetVips.Version(0)}.{NetVips.Version(1)}.{NetVips.Version(2)}"); | ||
|
||
Console.WriteLine( | ||
$"Type a number (1-{Samples.Count}) to execute a sample of your choice. Press <Enter> or type 'Q' to quit."); | ||
Console.WriteLine( | ||
$"Type a number (1-{Samples.Count}) to execute a sample of your choice. Press <Enter> or type 'Q' to quit."); | ||
|
||
DisplayMenu(); | ||
DisplayMenu(); | ||
|
||
string input; | ||
do | ||
string input; | ||
do | ||
{ | ||
var sampleArgs = Array.Empty<string>(); | ||
if (args.Length > 0) | ||
{ | ||
var sampleArgs = Array.Empty<string>(); | ||
if (args.Length > 0) | ||
{ | ||
var sampleId = Samples.Select((value, index) => new { Index = index + 1, value.Name }) | ||
.FirstOrDefault(s => s.Name.Equals(args[0]))?.Index; | ||
input = sampleId != null ? $"{sampleId}" : "0"; | ||
sampleArgs = args.Skip(1).ToArray(); | ||
} | ||
else | ||
{ | ||
input = Console.ReadLine(); | ||
} | ||
var sampleId = Samples.Select((value, index) => new { Index = index + 1, value.Name }) | ||
.FirstOrDefault(s => s.Name.Equals(args[0]))?.Index; | ||
input = sampleId != null ? $"{sampleId}" : "0"; | ||
sampleArgs = args.Skip(1).ToArray(); | ||
} | ||
else | ||
{ | ||
input = Console.ReadLine(); | ||
} | ||
|
||
if (int.TryParse(input, out var userChoice)) | ||
if (int.TryParse(input, out var userChoice)) | ||
{ | ||
if (!TryGetSample(userChoice, out var sample)) | ||
{ | ||
if (!TryGetSample(userChoice, out var sample)) | ||
{ | ||
Console.WriteLine("Sample doesn't exists, try again"); | ||
continue; | ||
} | ||
|
||
Console.WriteLine($"Executing sample: {sample.Name}"); | ||
sample.Execute(sampleArgs); | ||
Console.WriteLine("Sample successfully executed!"); | ||
Console.WriteLine("Sample doesn't exists, try again"); | ||
continue; | ||
} | ||
|
||
// Clear any arguments | ||
args = Array.Empty<string>(); | ||
} while (!string.IsNullOrEmpty(input) && !string.Equals(input, "Q", StringComparison.OrdinalIgnoreCase)); | ||
} | ||
Console.WriteLine($"Executing sample: {sample.Name}"); | ||
sample.Execute(sampleArgs); | ||
Console.WriteLine("Sample successfully executed!"); | ||
} | ||
|
||
public static void DisplayMenu() | ||
{ | ||
Console.WriteLine(); | ||
Console.WriteLine("Menu:"); | ||
// Clear any arguments | ||
args = Array.Empty<string>(); | ||
} while (!string.IsNullOrEmpty(input) && !string.Equals(input, "Q", StringComparison.OrdinalIgnoreCase)); | ||
} | ||
|
||
public static void DisplayMenu() | ||
{ | ||
Console.WriteLine(); | ||
Console.WriteLine("Menu:"); | ||
|
||
string currCategory = null; | ||
var menu = Samples.Select((value, index) => new { Index = index + 1, value.Name, value.Category }) | ||
.Aggregate(new StringBuilder(), (builder, pair) => | ||
string currCategory = null; | ||
var menu = Samples.Select((value, index) => new { Index = index + 1, value.Name, value.Category }) | ||
.Aggregate(new StringBuilder(), (builder, pair) => | ||
{ | ||
if (currCategory != pair.Category) | ||
{ | ||
if (currCategory != pair.Category) | ||
if (pair.Index > 1) | ||
{ | ||
if (pair.Index > 1) | ||
{ | ||
builder.AppendLine(); | ||
} | ||
builder.AppendLine(); | ||
} | ||
|
||
builder.AppendLine($" - {pair.Category}"); | ||
builder.AppendLine($" - {pair.Category}"); | ||
|
||
currCategory = pair.Category; | ||
} | ||
currCategory = pair.Category; | ||
} | ||
|
||
builder.AppendLine($" {pair.Index}: {pair.Name}"); | ||
return builder; | ||
}); | ||
builder.AppendLine($" {pair.Index}: {pair.Name}"); | ||
return builder; | ||
}); | ||
|
||
Console.WriteLine(menu); | ||
} | ||
Console.WriteLine(menu); | ||
} | ||
|
||
public static bool TryGetSample(int id, out ISample sample) | ||
{ | ||
sample = Samples | ||
.Select((value, index) => new { Index = index + 1, Sample = value }) | ||
.FirstOrDefault(pair => pair.Index == id)?.Sample; | ||
public static bool TryGetSample(int id, out ISample sample) | ||
{ | ||
sample = Samples | ||
.Select((value, index) => new { Index = index + 1, Sample = value }) | ||
.FirstOrDefault(pair => pair.Index == id)?.Sample; | ||
|
||
return sample != null; | ||
} | ||
return sample != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,64 @@ | ||
namespace NetVips | ||
{ | ||
using System; | ||
using System.Linq; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace NetVips; | ||
|
||
public static class SampleExtensions | ||
public static class SampleExtensions | ||
{ | ||
/// <summary> | ||
/// Make first letter of a string upper case. | ||
/// </summary> | ||
/// <param name="str">The input string.</param> | ||
/// <returns>A new string with the first letter upper case.</returns> | ||
internal static string FirstLetterToUpper(this string str) | ||
{ | ||
/// <summary> | ||
/// Make first letter of a string upper case. | ||
/// </summary> | ||
/// <param name="str">The input string.</param> | ||
/// <returns>A new string with the first letter upper case.</returns> | ||
internal static string FirstLetterToUpper(this string str) | ||
if (str == null) | ||
{ | ||
if (str == null) | ||
{ | ||
return null; | ||
} | ||
|
||
if (str.Length > 1) | ||
{ | ||
return char.ToUpper(str[0]) + str[1..]; | ||
} | ||
|
||
return str.ToUpper(); | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// Make first letter of a string lower case. | ||
/// </summary> | ||
/// <param name="str">The input string.</param> | ||
/// <returns>A new string with the first letter lower case.</returns> | ||
internal static string FirstLetterToLower(this string str) | ||
if (str.Length > 1) | ||
{ | ||
if (str == null) | ||
{ | ||
return null; | ||
} | ||
|
||
if (str.Length > 1) | ||
{ | ||
return char.ToLower(str[0]) + str[1..]; | ||
} | ||
|
||
return str.ToLower(); | ||
return char.ToUpper(str[0]) + str[1..]; | ||
} | ||
|
||
/// <summary> | ||
/// Convert snake case (my_string) to camel case (MyString). | ||
/// </summary> | ||
/// <param name="str">The input string.</param> | ||
/// <returns>A new camel cased string.</returns> | ||
internal static string ToPascalCase(this string str) | ||
return str.ToUpper(); | ||
} | ||
|
||
/// <summary> | ||
/// Make first letter of a string lower case. | ||
/// </summary> | ||
/// <param name="str">The input string.</param> | ||
/// <returns>A new string with the first letter lower case.</returns> | ||
internal static string FirstLetterToLower(this string str) | ||
{ | ||
if (str == null) | ||
{ | ||
return str.Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries) | ||
.Select(s => char.ToUpperInvariant(s[0]) + s[1..]) | ||
.Aggregate(string.Empty, (s1, s2) => s1 + s2); | ||
return null; | ||
} | ||
|
||
public static double NextDouble(this Random random, double minValue, double maxValue) | ||
if (str.Length > 1) | ||
{ | ||
return random.NextDouble() * (maxValue - minValue) + minValue; | ||
return char.ToLower(str[0]) + str[1..]; | ||
} | ||
|
||
return str.ToLower(); | ||
} | ||
|
||
/// <summary> | ||
/// Convert snake case (my_string) to camel case (MyString). | ||
/// </summary> | ||
/// <param name="str">The input string.</param> | ||
/// <returns>A new camel cased string.</returns> | ||
internal static string ToPascalCase(this string str) | ||
{ | ||
return str.Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries) | ||
.Select(s => char.ToUpperInvariant(s[0]) + s[1..]) | ||
.Aggregate(string.Empty, (s1, s2) => s1 + s2); | ||
} | ||
|
||
public static double NextDouble(this Random random, double minValue, double maxValue) | ||
{ | ||
return random.NextDouble() * (maxValue - minValue) + minValue; | ||
} | ||
} |
Oops, something went wrong.