예제 #1
0
        private static void SharedConnectionTest(string connectionString)
        {
            var config = new ConfigurationProvider {
                ConnectionString = connectionString
            };
            var host = new DatabaseHost(config);

            var userRepo = new UserRepository(host);

            var newUser = userRepo.RegisterUser("John", "Doe");

            userRepo.AddUserToGroup(newUser.UserId, 1);

            var users = userRepo.GetUsersByGroup(1);

            foreach (var user in users)
            {
                Console.WriteLine(user.Name);
            }

            Console.ReadKey();

            var users2 = userRepo.GetUsersByGroup(2);

            foreach (var user in users2)
            {
                Console.WriteLine(user.Name);
            }
        }
예제 #2
0
        public static void Start()
        {
            DatabaseHost.Connect("mongodb://localhost");

            WebServer  = new WebServerHost();
            GameServer = new GameServerHost();

            WebServer.Start();
            GameServer.Start();

            Thread.Sleep(-1);
        }
예제 #3
0
        /// <summary>
        /// 生成一个表
        /// </summary>
        /// <param name="dataBaseObj">数据库对象</param>
        /// <param name="templateItem">模板列表</param>
        /// <param name="savedFileName">保存到的文件名</param>
        /// <param name="paramData">参数数据</param>
        private String BuildTable(SODatabase dataBaseObj, TemplateInfo templateItem, out String savedFileName)
        {
            //生成代码文件
            DatabaseHost host = new DatabaseHost(dataBaseObj, this.NameRuleConfig, this.TypeMapConfigList);

            host.TemplateFile = templateItem.FilePath;

            // 额外参数追加
            if (this.ParamList != null && this.ParamList.Count > 0)
            {
                foreach (var item in this.ParamList)
                {
                    host.SetValue(item.ParamName, item.ParamValue);
                }
            }

            Engine engine          = new Engine();
            string templateContent = File.ReadAllText(templateItem.FilePath);
            var    outputContent   = engine.ProcessTemplate(templateContent, host);

            savedFileName = Path.Combine(this.SavePath, string.Format("{0}{1}", templateItem.TemplateName, host.FileExtention));
            if (String.IsNullOrWhiteSpace(host.OutputFileName) == false)
            {
                savedFileName = Path.Combine(this.SavePath, host.OutputFileName);
            }

            StringBuilder sb = new StringBuilder();

            if (host.ErrorCollection != null && host.ErrorCollection.HasErrors)
            {
                foreach (CompilerError err in host.ErrorCollection)
                {
                    sb.AppendLine(err.ToString());
                }

                return(sb.ToString());
            }

            if (Directory.Exists(this.SavePath) == false)
            {
                Directory.CreateDirectory(this.SavePath);
            }

            File.WriteAllText(savedFileName, outputContent, host.FileEncoding);

            return(String.Empty);
        }
예제 #4
0
파일: Class1.cs 프로젝트: KrzyskowK/Outgo
 public void Setup()
 {
     _databaseConnection = new object();
     _sut = new DatabaseHost(_databaseConnection);
 }