本文整理汇总了C#中Helpers.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Helpers.Add方法的具体用法?C# Helpers.Add怎么用?C# Helpers.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewRepository
protected virtual Repository.Logic.Repository GetNewRepository(Helpers.Log.SessionInfo logSession)
{
var rep = new Repository.Logic.Repository();
rep.SqlLog += (s, e) => RaiseSqlLog(e);
rep.Log += (s, e) => logSession.Add(e, "[REPOSITORY]");
return rep;
}
示例2: SetOutputResponseHeaders
/// <summary>
/// Set some header for output response stream
/// </summary>
/// <param name="mime">File mime type</param>
/// <param name="encoding">File encoding</param>
/// <param name="fileName">File name</param>
private void SetOutputResponseHeaders(string mime, Encoding encoding, string fileName, Helpers.Log.SessionInfo upperLogSession)
{
if (upperLogSession == null)
throw new ArgumentNullException(nameof(upperLogSession));
using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, ss => ss.ToList().ForEach(s => upperLogSession.Add(s))))
try
{
var webContext = System.ServiceModel.Web.WebOperationContext.Current;
if (webContext != null)
{
webContext.OutgoingResponse.ContentType = new string[] { mime, encoding?.WebName }.Where(s => !string.IsNullOrWhiteSpace(s)).Concat(s => s, "; ");
if (!string.IsNullOrWhiteSpace(fileName))
webContext.OutgoingResponse.Headers.Add("Content-Disposition", $"attachment; filename={fileName}");
}
}
catch (Exception ex)
{
logSession.Add(ex);
logSession.Enabled = true;
upperLogSession.Enabled = true;
}
}
示例3: GetInputRequestHeaders
/// <summary>
/// Get parameters from input request stream
/// </summary>
/// <param name="mime">File mime type</param>
/// <param name="encoding">File encoding</param>
/// <param name="fileName">File name</param>
private void GetInputRequestHeaders(out string mime, out Encoding encoding, out string fileName, Helpers.Log.SessionInfo upperLogSession)
{
if (upperLogSession == null)
throw new ArgumentNullException(nameof(upperLogSession));
mime = null;
encoding = null;
fileName = null;
using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, ss => ss.ToList().ForEach(s => upperLogSession.Add(s))))
try
{
var webContext = System.ServiceModel.Web.WebOperationContext.Current;
if (webContext != null)
{
var ct = webContext.IncomingRequest.ContentType.Split(new char[] { ';' }, StringSplitOptions.None).Select(i => i.Trim());
mime = ct.FirstOrDefault();
var encName = ct.Skip(1).FirstOrDefault();
if (!string.IsNullOrWhiteSpace(encName))
try { encoding = Encoding.GetEncoding(encName); } catch { }
var cd = webContext.IncomingRequest.Headers.Get("Content-Disposition");
if (!string.IsNullOrWhiteSpace(cd))
{
var fName = cd.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).FirstOrDefault(i => i.ToLower().StartsWith("filename="));
fileName = fName.Substring(fName.IndexOf("=") + 1);
}
}
}
catch (Exception ex)
{
logSession.Add(ex);
logSession.Enabled = true;
upperLogSession.Enabled = true;
}
}