本文整理汇总了C#中Log.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Log.GetType方法的具体用法?C# Log.GetType怎么用?C# Log.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogListener
/// <summary>
/// Initialize a new LogListener instance registered to receive Log Events from a
/// specific log. By default, all log events are received.
/// </summary>
/// <param name="log">Log instance to register this listener with</param>
public LogListener(Log log)
{
if ((log != null) && (log.GetType() != typeof(NullLog)))
{
log.OnLogMessageReceived += new LogEventHandler(OnLogMessageReceived);
subscribedLog = log;
}
}
示例2: Serialize
public static void Serialize(string file, Log logSimulacion)
{
System.Xml.Serialization.XmlSerializer xs
= new System.Xml.Serialization.XmlSerializer(logSimulacion.GetType());
StreamWriter writer = File.CreateText(file);
xs.Serialize(writer, logSimulacion);
writer.Flush();
writer.Close();
}
示例3: ClassToXML
/// <summary>
/// 构造日志xml项
/// </summary>
/// <param name="doc">XmlDocument</param>
/// <param name="log">日志对象</param>
/// <returns>xmlnode</returns>
private XmlNode ClassToXML(XmlDocument doc, Log log)
{
XmlElement elementnode = doc.CreateElement("log");
PropertyInfo[] pinfo = log.GetType().GetProperties();
for (int i = 0; i < pinfo.Length; i++)
{
XmlNode ele = doc.CreateElement(pinfo[i].Name);
ele.InnerText = pinfo[i].GetValue(log, null).ToString();
elementnode.AppendChild(ele);
}
return elementnode;
}
示例4: GetLog
public string GetLog(DateTime firstdt, DateTime lastdt, Log log)
{
StringBuilder sb = new StringBuilder();
sb.Append("select * from log where timeline between '");
sb.Append(firstdt);
sb.Append("' and '");
sb.Append(lastdt);
sb.Append("'");
foreach (var prop in log.GetType().GetProperties())
{
//시간 프로퍼티 중복 회피 위해
if (prop.Name == "timeline")
{
continue;
}
sb.Append(" and ");
sb.Append(prop.Name);
if (prop.PropertyType == typeof(string))
{
sb.Append(" like '%");
sb.Append(GetEscapedString(log[prop.Name].ToString(),true));
sb.Append("%'");
sb.Append(" escape '#'");
}
else
{
sb.Append(" = ");
sb.Append(log[prop.Name]);
}
}
return sb.ToString();
}