AndroMDA使用“墨盒”一词(例如,指开箱即用的NHibernate支持)。据我所知,它需要一个API/组件,封装它,从不添加新特性,简化它,常常去掉“完全的功能”,但在大多数情况下都很好。
我的问题:
例如:下面的Base64助手是用于Base64转换的墨盒吗?您为性能调优提供了所有的能力,但是如果您只想解码一个简单的(而且很小)的字符串,那么它可以很好地工作:
用法:
Base64StringCartridge.Decode(input);实现
public static string Decode(string data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = System.Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
catch
{
return "";
}
}发布于 2009-03-29 16:37:29
这叫立面图案。想必AndroMDA的人是老电子游戏机器的大粉丝.
https://stackoverflow.com/questions/694898
复制相似问题