当前位置: 首页>>代码示例>>C#>>正文


C# Helpers.Add方法代码示例

本文整理汇总了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;
 }
开发者ID:kblc,项目名称:Personnel.old,代码行数:7,代码来源:BaseService.cs

示例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;
                }
        }
开发者ID:kblc,项目名称:Royalty,代码行数:29,代码来源:FileService.cs

示例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;
                }
        }
开发者ID:kblc,项目名称:Royalty,代码行数:41,代码来源:FileService.cs


注:本文中的Helpers.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。