⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datamapping.cs

📁 经典游戏程序设计:visual c++ 上的杀人游戏源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DAL
{
    partial class DataMappingDataContext
    {
        private static StreamWriter sw = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), "log.txt"), true);

        /**/
        /// <summary>
        /// Try to create DataContext with log. 
        /// </summary>
        /// <param name="withLog"></param>

        public DataMappingDataContext(bool withLog)
            : this(Provider.ConnectionString)
        {
            OnCreated();
            if (withLog)
            {
                if (sw == null)
                {
                    sw = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), "log.txt"), true);
                }
                this.Log = sw;
            }
        }

        /**/
        /// <summary>
        /// try to close streamwriter
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            sw.Flush();

        }

    }

    internal static class Provider
    {
        internal static string ConnectionString
        {
            get
            {
                //string path = Directory.GetCurrentDirectory();
                //path = Path.Combine(path, "killperson.sdf");
                //return "Data Source = " + path;
                return DAL.Properties.Settings.Default.KillingGameConnectionString;
            }
        }
    }
    public partial class PlayerEntity : Player
    {
        public string IP { get; set; }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -