Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

C# library added #423

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 15 additions & 0 deletions lib/csharp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Emojione utility for C#


### How to use

This utility provides a method to convert from shortname to unicode characters.


### How to re-generate mapping

```
cd lib/csharp/generator
npm install
node generate.js
```
1 change: 1 addition & 0 deletions lib/csharp/generator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions lib/csharp/generator/Emojione.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;

public class Emojione {

public static string ShortnameToUnicode(string shortname)
{
string unicode = null;
unicodeMap.TryGetValue(shortname, out unicode);
return unicode;
}

private static Dictionary<string, string> unicodeMap = new Dictionary<string, string>(){
<%= mapping %>
};

}
23 changes: 23 additions & 0 deletions lib/csharp/generator/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var util = require("util"),
fs = require("fs"),
_ = require("underscore");


// Load emojis
var emojis = require("../../../emoji_strategy.json");

// Generate C# mapping
var mapping = _(emojis).map(function(data, shortname) {
// Get chars
return '{"' + shortname + '", "' + data.unicode + '"},';
}).join("\n ");

// Generate C# class from template
var input = fs.readFileSync("./Emojione.cs");
var output = _(input.toString()).template()({ mapping: mapping });

// Write C# class to file
var output_path = "../src/Emojione.cs";
fs.writeFileSync(output_path, output);

console.log("Generated " + output_path);
7 changes: 7 additions & 0 deletions lib/csharp/generator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "emojione-csharp",
"version": "0.1.0",
"dependencies": {
"underscore": "^1.7.0"
}
}
Loading