[Ubuntu] 64位11.04中编译安装TOra并同时支持连接Oracle和Mysql
首先你需要安装Oracle客户端。我们可以从Oracle官网来下载3个我们需要的rpm分发的安装包,他们分别是:
- oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
- oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm
- oracle-instantclient11.2-devel-11.2.0.2.0.x86_64.rpm
由于Ubuntu需要的是deb结构的分发包,所以我们需要安装一个alien来转换这些rpm包,方法就不再这里说了,大家自己解决。把这3个东西安装了后。再安装以下依赖。
sudo apt-get build-dep tora sudo apt-get install libqt3-mt-dev libqt3-compat-headers libqscintilla-dev build-essential g++ gcc autoconf automake flex zlib1g-dev docbook-xsl debhelper alien libaio1 dpatch fakeroot xsltproc texi2html texinfo libqt3-mt-psql libqt3-mt-odbc config-package-dev cmake qt4-dev-tools libqscintilla2-dev postgresql-dev libmysqlclient-dev libaio-dev
然后我们开始准备一些系统环境变量,重启之。
sudo -i echo /usr/lib/oracle/11.2/client64/lib >> /etc/ld.so.conf echo ORACLE_HOME="/usr/lib/oracle/11.2/client64" >> /etc/environment echo LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib" >> /etc/environment echo TNS_ADMIN="/usr/lib/oracle/11.2/client64" >> /etc/environment reboot
重启后开始准备编译:
mkdir -p /opt/source/ cd /opt/source/ sudo apt-get source tora export CMAKE_INCLUDE_PATH=“/usr/include/oracle/11.2/client64” cd tora-2.1.3
在这里,我下到的tora代码有些小问题,少编译了一个文件,所以这里要改一下Makefile,我使用gedit,vim爱好者自便。
sudo gedit src/Makefile.am
找到“BUILT_SOURCES = \”处,在他的下面加入一行”moc_toawr.cpp \”,然后开始编译啦:
sudo ./configure --with-oracle=/usr/lib/oracle/11.2/client64 --with-oracle-includes=/usr/include/oracle/11.2/client64 --with-oracle-libraries=/usr/lib/oracle/11.2/client64/lib --with-oci-version=11G
我得到以下提示,关键是高亮的那行:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for makeinfo... ${SHELL} /home/noahv/software/deb/source/tora-2.1.3/config/missing --run makeinfo
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for unistd.h... (cached) yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking sys/mkdev.h usability... no
checking sys/mkdev.h presence... no
checking for sys/mkdev.h... no
checking sys/sysmacros.h usability... yes
checking sys/sysmacros.h presence... yes
checking for sys/sysmacros.h... yes
checking for string.h... (cached) yes
checking for memory.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking sys/ndir.h usability... no
checking sys/ndir.h presence... no
checking for sys/ndir.h... no
checking ndir.h usability... no
checking ndir.h presence... no
checking for ndir.h... no
checking alloca.h usability... yes
checking alloca.h presence... yes
checking for alloca.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking postgresql/libpq-fe.h usability... yes
checking postgresql/libpq-fe.h presence... yes
checking for postgresql/libpq-fe.h... yes
checking whether sys/types.h defines makedev... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for snprintf... yes
checking for vsnprintf... yes
checking for setenv... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct stat.st_blocks... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking whether closedir returns void... no
checking for size_t... yes
checking CXXFLAGS for gcc -fno-inline... -fno-inline
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... no
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for Qt...
libqt: -lQtCore -lQtGui -lQtGui -lQtSql -lQtNetwork -lQtXml,
libraries: /usr/lib,
headers: /usr/include/qt4
checking for lrelease... /usr/bin/lrelease-qt4
checking for lupdate... /usr/bin/lupdate-qt4
checking for moc-qt4... no
checking for moc... no
checking for moc-qt4... /usr/bin/moc-qt4
checking /usr/bin/moc-qt4 works... yes
checking for uic-qt4... no
checking for uic... no
checking for uic-qt4... /usr/bin/uic-qt4
checking /usr/bin/uic-qt4 works... yes
checking for rcc-qt4... no
checking for rcc... no
checking for rcc-qt4... no
checking for rcc... /usr/bin/rcc
checking /usr/bin/rcc works... yes
checking whether PQcancel is declared... yes
checking for teradata... no
checking for oracle... yes
checking oci version... 11G
checking for qscintilla... yes
checking lib pcre... (testing)
checking for pcre_study in -lpcre... no
checking for pcre_compile in -lpcre... no
checking lib pcre... no, (WARNING)
checking for cppunit-config... no
checking for Cppunit - version >= 1.10.2... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating utils/Makefile
config.status: creating utils/chex/Makefile
config.status: creating src/Makefile
config.status: creating test/Makefile
config.status: creating test/configuration/Makefile
config.status: creating doc/Makefile
config.status: creating doc/help/Makefile
config.status: creating rpm/tora.spec
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
这样应该就可以开始编译了
sudo make sudo make install
好了,大功告成,执行以下命令使用TOra:
cd /usr/local/tora/bin/ ./tora
Good Luck!
[Tips]64位Ubuntu 11.04安装firefox用FlashPlayer插件
首先在Abode网站下载插件包。目前64位版在此处下载。我只接命令搞定:
wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer10_2_p3_64bit_linux_111710.tar.gz
然后如下
tar xvzf flashplayer10_2_p3_64bit_linux_111710.tar.gz mkdir -p $HOME/.mozilla/plugins mv libflashplayer.so $HOME/.mozilla/plugins/
最后,重启firefox既可。
[ASP.Net Dynamic Data]为啥只有25个字符?
今天工作中发现,在VS2010里面用Dynamic Data自动生成出来的表格中,Text类型的列竟然只显示25个字符?,如下图:
其中超过25字符的部分都被”…”略去了, Google无答案,简单Code Review一下应该是Code模板的问题,可以如下修改:
1. 打开文件~\DynamicData\FieldTemplates\Text.ascx.cs
2. 修改其中变量MAX_DISPLAYLENGTH_IN_LIST为你想要的值
public partial class TextField : System.Web.DynamicData.FieldTemplateUserControl
{
private const int MAX_DISPLAYLENGTH_IN_LIST = 50;
public override string FieldValueString
{
get
{
string value = base.FieldValueString;
if (ContainerType == ContainerType.List)
{
if (value != null && value.Length > MAX_DISPLAYLENGTH_IN_LIST)
{
value = value.Substring(0, MAX_DISPLAYLENGTH_IN_LIST - 3) + "...";
}
}
return value;
}
}
public override Control DataControl
{
get
{
return Literal1;
}
}
}
好了,大功告成。
[Linq]使用扩展方法帮助CodeDom实现Dynamic Linq
在与复杂数据操作有关的项目中,我们常常需要将种种复杂的源数据归类到一个通用的数据表格上,再传给之后的程序继续处理。
.Net Framework 引入LINQ之后,我们基本上可以依赖LINQ对各类不同格式、不同来源的数据使用统一的查询语句来进行“格式化”,获取这些数据源中的数据并转换到我们想要的格式上来。
但是我们一直受到一个问题的困扰,那就是用来查询数据的LINQ语句本身是在编译前就确定下来的,这使得我们使用LINQ语句的扩展性大大降低。每当我们要使用一种新的数据源或者修改对一种数据源的查询逻辑时,我们必须更新代码并重新发布软件。
人们经常将LINQ和T/SQL查询语句做对比。T/SQL中有EXECUTE语句可以解析并执行Runtime生成的查询字符串。更有甚者,还有sp_executesql,甚至可以执行带参数的T/SQL语句块,并传入参数。如下例:
DECLARE @IntVariable int;
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);
DECLARE @max_title varchar(30);
SET @IntVariable = 197;
SET @SQLString = N'SELECT @max_titleOUT = max(Title)
FROM AdventureWorks.HumanResources.Employee
WHERE ManagerID = @level';
SET @ParmDefinition = N'@level tinyint, @max_titleOUT varchar(30) OUTPUT';
EXECUTE sp_executesql @SQLString,
@ParmDefinition,
@level = @IntVariable,
@max_titleOUT=@max_title OUTPUT;
SELECT @max_title;
通过给出@SQLString和@ParmDefinition,事实上定义了一个存储过程。再给出传入方法的参数,就可以简单的执行这个存储过程,并获取其执行结果。由此,从函数定义,函数内的逻辑到函数的参数值,都可以在Runtime给出。而其输出值,即执行结果也能方便的得到。
那么,我们能不能这样使用LINQ呢?从Scott的blog和MSDN的LINQSample我们可以看到微软官方也是有这方面的考虑的。只是最后仍然没有发布这样一个方法,可能是因为就像SQL Server一样,这种方式带来的安全性隐患层出不穷。
不过呢,基于现有的.Net Framework,我们不妨来山寨一下这样一个方法:
namespace System.Linq.Dynamic
{
public static class IEnumerableExtender
{
public static IEnumerable<object> ExecuteLinq<T>(
this IEnumerable<T> enumerableObject,
string linqString,
string parmDefinition,
params object[] parameters)
{
}
}
}
MSDN的namespace System.Linq.Dynamic是通过分析“where string”和“select string”,并借助表达式树来完成c的,虽然安全得多,但未免限制重重。我决定从其他方向入手。很快就发现了这篇CodeDom extensions and dynamic LINQ (string/script to LINQ emitting)。CodeDom,确实是一个很诱人的思路。
OK,第一步,把Igor的CodeDom extensions简单的整理一下,没有花精力去补全属性、变量,委托和内部类等相关的extensions,只有方法的,也就整了下面这个CodeDomHelper:
// $File: CodeDomHelper.cs $
// This class provides for extending the CodeDom library
// to help coding CodeDom more gracefully with .Net 3.5.
// History:
// $Author: noahwei $
// $Editor: noahwei $
// $Reviwer: noahwei $
// $LastModifyDate: [12/17/2008] $
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Linq;
using System.Text;
namespace System
{
/// <summary>
/// Extensions Method
/// </summary>
public static class ReflectionExtensions
{
/// <summary>
/// An simply way to invode an dynamic genereted method
/// </summary>
/// <param name="methodInfo">The method you are call</param>
/// <param name="parameters">The parameters which should be pass to the method</param>
/// <returns></returns>
public static object Invoke(this MethodInfo methodInfo, params object[] parameters)
{
return methodInfo.Invoke(null, parameters);
}
}
}
namespace System.CodeDom.Extender
{
/// <summary>
/// CodeDom Helper
/// </summary>
public class CodeDom
{
private List<CodeCompileUnit> listCompileUnits = new List<CodeCompileUnit>();
private List<CodeNamespace> listNamespaces = new List<CodeNamespace>();
private System.Collections.Specialized.StringCollection listReferencedAssemblies =
new System.Collections.Specialized.StringCollection() { "mscorlib.dll" };
/// <summary>
/// Code language. You can choose C# or VB.
/// </summary>
public enum Language
{
CSharp,
VB
}
private Language _language;
/// <summary>
/// Create an CodeDom class for C# code
/// I didn't expose the VB CodeDom now since I don't knwon it well.
/// </summary>
public CodeDom() : this(Language.CSharp) { }
private CodeDom(Language language)
{
_language = language;
}
/// <summary>
/// This is a static methos which can help you to get
/// an inctence of the System.CodeDom.Compiler.CodeDomProvider
/// that is ready for .Net v3.5 code.
/// </summary>
/// <param name="provider">Chosse your coding language</param>
/// <returns></returns>
public static CodeDomProvider Provider(Language provider)
{
var providerOptions =
new Dictionary<string, string>(); providerOptions.Add("CompilerVersion", "v3.5");
switch (provider)
{
case Language.VB:
return new Microsoft.VisualBasic.VBCodeProvider(providerOptions);
case Language.CSharp:
default:
return new Microsoft.CSharp.CSharpCodeProvider(providerOptions);
}
}
/// <summary>
/// Same as the following code snippet,
///
/// namespace namespaceName
/// {
/// ...
/// }
/// </summary>
/// <param name="namespaceName">The name of this namespace</param>
/// <returns></returns>
public CodeNamespace AddNamespace(string namespaceName)
{
CodeNamespace codeNamespace = new CodeNamespace(namespaceName);
listNamespaces.Add(codeNamespace);
return codeNamespace;
}
/// <summary>
/// Same as adding an reference assembly
/// </summary>
/// <param name="referencedAssembly">The reference assembly name. Such as "System.dll"</param>
/// <returns></returns>
public CodeDom AddReference(string referencedAssembly)
{
listReferencedAssemblies.Add(referencedAssembly);
return this;
}
/// <summary>
/// A helper method for creating an Class by CodeDom.
/// Same as the following code snippet,
///
/// public class ClassName
/// {
/// ...
/// }
/// </summary>
/// <param name="className">The name of the Class you are creating.</param>
/// <returns></returns>
public CodeTypeDeclaration Class(string className)
{
return new CodeTypeDeclaration(className);
}
/// <summary>
/// A helper method for creating an Method by CodeDom.
/// Same as the following code snippet,
///
/// public static returnType methodName(paramList)
/// {
/// methodBody
/// }
/// </summary>
/// <param name="returnType">The return type defination</param>
/// <param name="methodName">The method name</param>
/// <param name="paramList">The parameter list</param>
/// <param name="methodBody">The literal code fragment for the method body</param>
/// <returns></returns>
public CodeSnippetTypeMember Method(
string returnType,
string methodName,
string paramList,
string methodBody)
{
return Member(
string.Format("public static {0} {1}({2}) {{ {3} }} ",
returnType,
methodName,
paramList,
methodBody));
}
/// <summary>
/// A helper method for creating an Method by CodeDom.
/// Same as the following code snippet,
///
/// public static void methodName(paramList)
/// {
/// methodBody
/// }
/// </summary>
/// <param name="methodName">The method name</param>
/// <param name="paramList">The parameter list</param>
/// <param name="methodBody">The literal code for the method body</param>
/// <returns></returns>
public CodeSnippetTypeMember Method(
string methodName,
string paramList,
string methodBody)
{
return Method("void", methodName, paramList, methodBody);
}
/// <summary>
/// A helper method for creating an Method by CodeDom.
/// Same as the following code snippet,
///
/// public static void methodName()
/// {
/// methodBody
/// }
/// </summary>
/// <param name="methodName">The method name</param>
/// <param name="methodBody">The literal code fragment for the method body</param>
/// <returns></returns>
public CodeSnippetTypeMember Method(string methodName, string methodBody)
{
return Method("void", methodName, "", methodBody);
}
/// <summary>
/// A helper method for creating an Method by CodeDom.
/// Same as construction of class CodeSnippetTypeMember
/// </summary>
/// <param name="methodBody">The literal code fragment for the type member</param>
/// <returns></returns>
public CodeSnippetTypeMember Member(string memberBody)
{
return new CodeSnippetTypeMember(memberBody);
}
/// <summary>
/// A new CodeCompileUnit to contain the program graph.
/// </summary>
public CodeCompileUnit CompileUnit
{
get
{
// Create a new CodeCompileUnit to contain
// the program graph.
CodeCompileUnit compileUnit = new CodeCompileUnit();
foreach (var ns in listNamespaces)
compileUnit.Namespaces.Add(ns);
return compileUnit;
}
}
/// <summary>
/// Compile the code we have now to an assembly.
/// </summary>
/// <returns></returns>
public Assembly Compile()
{
return Compile(null);
}
/// <summary>
/// Compile the code we have now to an assembly.
/// </summary>
/// <param name="assemblyPath">The path where the assembly file drop to</param>
/// <returns></returns>
public Assembly Compile(string assemblyPath)
{
CompilerParameters options = new CompilerParameters();
options.IncludeDebugInformation = false;
options.GenerateExecutable = false;
options.GenerateInMemory = (assemblyPath == null);
foreach (string refAsm in listReferencedAssemblies)
options.ReferencedAssemblies.Add(refAsm);
//Add assembly which is referanced by current assembly also.
List<string[]> refAsmRefs = new List<string[]>();
try
{
refAsmRefs.AddRange(
from a in Assembly.GetEntryAssembly().GetReferencedAssemblies()
select new string[] { a.Name, a.FullName });
refAsmRefs.AddRange(
from a in Assembly.GetCallingAssembly().GetReferencedAssemblies()
select new string[] { a.Name, a.FullName });
refAsmRefs.AddRange(
from a in Assembly.GetExecutingAssembly().GetReferencedAssemblies()
select new string[] { a.Name, a.FullName });
}
catch { }
foreach (var refAsmRef in refAsmRefs)
{
string asmNameSimp = refAsmRef[0];
string asmFullName = refAsmRef[1];
if (!(options.ReferencedAssemblies.Contains(asmFullName)
|| options.ReferencedAssemblies.Contains(asmNameSimp)))
{
options.ReferencedAssemblies.Add(asmFullName);
}
}
if (assemblyPath != null)
options.OutputAssembly = assemblyPath.Replace('\\', '/');
CodeDomProvider codeProvider = Provider(_language);
CompilerResults results =
codeProvider.CompileAssemblyFromDom(options, CompileUnit);
codeProvider.Dispose();
if (results.Errors.Count == 0)
return results.CompiledAssembly;
// Process compilation errors
System.Diagnostics.Trace.WriteLine("Compilation Errors:");
foreach (string outpt in results.Output)
System.Diagnostics.Trace.WriteLine(outpt);
foreach (CompilerError err in results.Errors)
System.Diagnostics.Trace.WriteLine(err.ToString());
return null;
}
/// <summary>
/// Generate all code to a string.
/// </summary>
/// <returns></returns>
public string GenerateCode()
{
StringBuilder sb = new StringBuilder();
TextWriter tw = new IndentedTextWriter(new StringWriter(sb));
CodeDomProvider codeProvider = Provider(_language);
codeProvider.GenerateCodeFromCompileUnit(
CompileUnit,
tw,
new CodeGeneratorOptions());
codeProvider.Dispose();
tw.Close();
return sb.ToString();
}
}
/// <summary>
/// Converts from "object" general type to a concrete type
/// </summary>
/// <remarks>
/// The class is working with .Net 2.0 and above
/// </remarks>
public class Converter
{
/// <summary>
/// Returns True if the type can get Null as a value
/// (is a reference type and not a value one)
/// </summary>
public static bool IsNullable(Type t)
{
if (!t.IsGenericType) return false;
Type g = t.GetGenericTypeDefinition();
return (g.Equals(typeof(Nullable<>)));
}
/// <summary>
/// Returns a real type of a first generic argument
/// </summary>
private static Type UnderlyingTypeOf(Type t)
{
return t.GetGenericArguments()[0];
}
/// <summary>
/// Converter
/// </summary>
public static T To<T>(object value, T defaultValue)
{
if (value == DBNull.Value) return defaultValue;
Type t = typeof(T);
if (IsNullable(t))
{
if (value == null) return default(T);
t = UnderlyingTypeOf(t);
}
else
{
if ((value == null) && (t.IsValueType))
{
return defaultValue;
}
}
return (T)Convert.ChangeType(value, t);
}
}
/// <summary>
/// The extensions class for the CodeDom Helper
/// </summary>
public static class CodeDomeExtensions
{
/// <summary>
/// Add a class into this namaspace
/// </summary>
/// <param name="codeType">Type Declaration</param>
/// <returns></returns>
public static CodeNamespace AddClass(
this CodeNamespace codeNamespace,
CodeTypeDeclaration codeType)
{
codeNamespace.Types.Add(codeType);
return codeNamespace;
}
/// <summary>
/// Add a member into this class
/// </summary>
/// <param name="memberBody"></param>
/// <returns></returns>
public static CodeTypeDeclaration AddMember(
this CodeTypeDeclaration classCode,
CodeSnippetTypeMember memberBody)
{
classCode.Members.Add(memberBody);
return classCode;
}
/// <summary>
/// Add an imported namespace
/// </summary>
/// <param name="namespaceName"></param>
/// <returns></returns>
public static CodeNamespace Imports(
this CodeNamespace codeNamespace,
string namespaceName)
{
codeNamespace.Imports.Add(
new CodeNamespaceImport(namespaceName));
return codeNamespace;
}
}
}
有了它,一个简单的ExecuteLinq函数唾手可得:
// $File: DynamicLinq.cs $
// This class provides for extending the
// LINQ library to support Dynamic LINQ.
// History:
// $Author: noahwei $
// $Editor: noahwei $
// $Reviwer: noahwei $
// $LastModifyDate: [12/19/2008] $
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom.Extender;
namespace System.Linq.Dynamic
{
public static class IEnumerableExtender
{
public static IEnumerable<object> ExecuteLinq<T>(
this IEnumerable<T> enumerableObject,
string linqString,
string parmDefinition,
params object[] parameters)
{
var c = new System.CodeDom.Extender.CodeDom();
c.AddReference("mscorlib.dll")
.AddReference("System.Core.dll")
.AddReference("System.Data.dll")
.AddReference("System.Data.Linq.dll")
.AddReference("System.Xml.dll")
.AddReference("System.Xml.Linq.dll")
.AddNamespace("DynamicLinq")
.Imports("System.Collections.Generic")
.Imports("System.Linq")
.Imports("System.Data.Linq")
.Imports("System.Xml.Linq")
.AddClass(c.Class("DynamicLinqHelper")
.AddMember(c.Method("IEnumerable<object>",
"ExecuteLinq",
parmDefinition,
linqString)));
var method = c.Compile()
.GetType("DynamicLinq.DynamicLinqHelper")
.GetMethod("ExecuteLinq");
return method.Invoke(parameters) as IEnumerable<object>;
}
}
}
OK,够长了,测试分析留待下回。
Love until it hurts
Mother Teresa said:“I have found the paradox that if I love until it hurts,
then there is no hurt, but only more love.”
People are often unreasonable, illogical and self-centered;
Forgive them anyway.
If you are kind, people may accuse you of selfish, ulterior motives;
Be kind anyway.
If you are successful, you will win some false friends
And some true enemies;
Succeed anyway.
If you are honest and frank, people may cheat you;
Be honest and frank anyway.
What you spend years building,
Someone could destroy overnight;
Build anyway.
If you find serenity and happiness, they may be jealous;
Be happy anyway.
The good you do today, people will often forget tomorrow;
Be good anyway.
Give the world the best you have,
And it may never be enough;
Give the world the best you have anyway.
You see, in the final analysis, it is between you and God;
It is never between you and them anyway.
——Mother Teresa(1910-1997)
爱直至成伤
假如你爱至成伤,你会发现,伤没有了,却有更多的爱。
人们经常是不讲道理的、没有逻辑的和以自我为中心的
不管怎样,你要原谅他们
即使你是友善的,人们可能还是会说你自私和动机不良
不管怎样,你还是要友善
当你功成名就,你会有一些虚假的朋友
和一些真实的敌人
不管怎样,你还是要取得成功
即使你是诚实的和率直的,人们可能还是会欺骗你
不管怎样,你还是要诚实和率直
你多年来营造的东西
有人在一夜之间把它摧毁
不管怎样,你还是要去营造
如果你找到了平静和幸福,他人可能会嫉妒你
不管怎样,你还是要去追求幸福
你今天做的善事,人们往往明天就会忘记
不管怎样,你还是要做善事
即使把你最美好的东西给了这个世界
即使这些东西再多都还是不够
不管怎样,你还是要把你最好的东西给这个世界
你看,说到底,这是你和上帝之间的事
而决不是你和他人之间的事
——德蕾莎修女(1910-1997)
所以,人们相信上帝,是因为除了他人以外,人们需要相信还有另外一个存在,使人们的付出变得有意义。
否则,便不会有人去付出,因为付出爱,终成伤害。于是乎,便不会有人去爱。
可是,如果没有人去爱,则没有人会被爱。这世界便没有爱。
所以你相信这个世界有上帝么?或者说,你相信这个世界有爱么?
认真的生活
淡淡的思考
就像这蔚蓝的地球上附着的一个渺小而顽固的尘埃般对抗这令人疯狂而迷惘的命运
流淌
今天
我又加班了
估计
又会到12点
昨天也是
真累
我一直自恃是一个不容易丧失理智的人。但是我有时候不得不怀疑这一点。
金先生说过,练外家功夫的人都是有罩门的,打别得地方都不会破功,可是一被人找到了罩门。那一身横练的功夫都白练了。
我现在觉得自己的罩门被别人拿在了手里,还反复的捏。我每每都在丧失理智的边缘徘徊。
我google了一下,发现像我这样的情况不多,往往都是男友老是和前任会纠缠不清,女孩看上去都是忠诚的。可是,我还是要提醒天下的男人,千万不要和前任女友纠缠不清,这种做法给你身边的人带来的痛苦是无穷尽的。
因为人世间最痛苦的不是谩骂与折磨,而是这种甜蜜与痛苦的夹杂,天堂与地狱的距离,常常相隔只有几分钟。
我忍耐着。
用我已经所剩无多的理智。
来自于岁月的匆匆,我们都活的压力重重。不过这个夏季的日子,还是过的出奇的迷茫。
日子就是迷茫。岁月也是。爱也是。
盲目而迷茫。
走下车的时候是商店都关门的时候了,走进一家日本料理店,点了一桌菜,强迫自己全部都吃掉。
胃的感觉传达不到心脏
因为后者掌管的是记忆
痛
痛的我想钻到你心里
问问他你过往的谜
可是眼泪在提醒我
呕吐时别想别的
专心的吐
有泪水也给我一起吐出去



Pages
Categories
Tag Cloud
Entries RSS
Seven
City
Characters
Landscape
Nature
Shapes 