Hola amigos de AMSSpecialist.info, quiero presentaros la primera DLL que he creado es una dll muy simple y limitada pero bueno es lo que diríamos practicas con Visual Studio. Como el nombre bien describe esta dll es para convertir BBCode en HTML, y bueno no están todos los comando pero bueno la cuestión era crear mi primera dll y que funcionara bien.
C#:
Lua:
He puesto el "str" en code por que en lua me da algunos errores....
Decarga:
C#:
using System;
using System.Collections.Generic;
using System.Text;
using RGiesecke.DllExport;
using System.Text.RegularExpressions;
namespace ConvertBBCodeToHTML
{
internal static class UnmanagedExports
{
[DllExport("ConvertBBCodeToHTML", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string ConvertBBCodeToHTML(string str)
{
Regex exp;
// format the bold tags:
// becomes: <strong></strong>
exp = new Regex(@"\[b\](.+?)\[/b\]");
str = exp.Replace(str, "<strong>$1</strong>");
// format the italic tags:
// becomes: <em></em>
exp = new Regex(@"\[i\](.+?)\[/i\]");
str = exp.Replace(str, "<em>$1</em>");
// format the underline tags:
// becomes: <u></u>
exp = new Regex(@"\[u\](.+?)\[/u\]");
str = exp.Replace(str, "<u>$1</u>");
// format the strike tags: [s][/s]
// becomes: <strike></strike>
exp = new Regex(@"\[s\](.+?)\[/s\]");
str = exp.Replace(str, "<strike>$1</strike>");
// format the url tags: my site
// becomes: <a href="www.website.com">my site</a>
exp = new Regex(@"\[url\=([^\]]+)\]([^\]]+)\[/url\]");
str = exp.Replace(str, "<a href=\"$1\">$2</a>");
// format the img tags:
// becomes: <img src="www.website.com/img/image.jpeg" />
exp = new Regex(@"\[img\]([^\]]+)\[/img\]");
str = exp.Replace(str, "<img src=\"$1\" />");
// format img tags with alt:
// becomes: <img src="www.website.com/img/image.jpeg" alt="this is the alt text" />
exp = new Regex(@"\[img\=([^\]]+)\]([^\]]+)\[/img\]");
str = exp.Replace(str, "<img src=\"$1\" alt=\"$2\" />");
//format the colour tags:
// becomes: <font color="red"></font>
// supports UK English and US English spelling of colour/color
exp = new Regex(@"\[color\=([^\]]+)\]([^\]]+)\[/color\]");
str = exp.Replace(str, "<font color=\"$1\">$2</font>");
exp = new Regex(@"\[colour\=([^\]]+)\]([^\]]+)\[/colour\]");
str = exp.Replace(str, "<font color=\"$1\">$2</font>");
// format the size tags:
// becomes: <font size="+3"></font>
exp = new Regex(@"\[size\=([^\]]+)\]([^\]]+)\[/size\]");
str = exp.Replace(str, "<font size=\"+$1\">$2</font>");
// lastly, replace any new line characters with <br />
str = str.Replace("\r\n", "<br />\r\n");
return str;
}
}
}
Lua:
Código: Seleccionar todo
str = [[
[b]negrita[/b]
[i]cursiva[/i]
[u]subrayado[/u]
[s]tachado[/s]
]]
result = DLL.CallFunction("AutoPlay\\Docs\\ConvertBBCodeToHTML.dll", "ConvertBBCodeToHTML", "\"" .. str .. "\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
Dialog.Message("", result);
Decarga: