コード例 #1
0
        static void Main(string[] args)
        {
            int               index             = 0;
            IConfiguration    configuration     = new XMLConfiguration();
            ConfigurationTest configurationTest = new ConfigurationTest(configuration, index);

            configuration.Load();


            while (true)
            {
                index++;
                (configuration as BaseConfiguration).GameProcessId = index;
                Console.ReadLine();
            }

            ;
            //var a1 = configuration as IConfiguration;

            //var a11 = configuration as BaseConfiguration;
            //a11.GameProcessId = 111;

            //var a2 = configuration as JSONConfiguration;
            //a2.GameUiTitle = "aaa";
            //var a3 = configuration as XMLConfiguration;
            //a3.GameUiTitle = "bbb";

            ;

            //JSONConfiguration configuration = new JSONConfiguration();
            ////configuration.GameProcessId = 100;
            //configuration.Load();
            //configuration.Save();

            //XMLConfiguration xMLConfiguration = new XMLConfiguration();
            //xMLConfiguration.GameProcessId = 150;
            //xMLConfiguration.Save();



            //var b = new JavaScriptSerializer().Deserialize<Configuration>(a);
            ;
            ////游戏进程ID
            //int GameProcessId=0;
            //// 游戏界面标题
            //string GameUiTitle="";
            ////游戏界面大小
            //Size GameUiSize;
            ////游戏中棋盘相对于游戏界面的左上角
            //Point GameBoardPoint;
            ////棋盘落子范围大小
            //int GameBoardInsideWidth;

            //String result = "GameProcessId:" + GameProcessId+Environment.NewLine;
            //result += "GameUiTitle:" + GameUiTitle + Environment.NewLine;

            //String Json = "{\"GameProcessId\":"+ GameProcessId + ",\"GameUiTitle\":"+ GameUiTitle +"}";
            //string xml = "";
        }
コード例 #2
0
        static void Main(string[] args)
        {
            IConfiguration configuration = new XMLConfiguration();

            ////configuration.Load();
            //configuration.SetGameProcessId(123);
            //configuration.SetGameUiTitle("测试");
            //configuration.Save();
            configuration.Load();

            var a1 = configuration as IConfiguration;

            var a11 = configuration as BaseConfiguration;

            a11.GameProcessId = 111;

            var a2 = configuration as JSONConfiguration;

            a2.GameUiTitle = "aaa";
            var a3 = configuration as XMLConfiguration;

            a3.GameUiTitle = "bbb";

            ;

            //JSONConfiguration configuration = new JSONConfiguration();
            ////configuration.GameProcessId = 100;
            //configuration.Load();
            //configuration.Save();

            //XMLConfiguration xMLConfiguration = new XMLConfiguration();
            //xMLConfiguration.GameProcessId = 150;
            //xMLConfiguration.Save();



            //var b = new JavaScriptSerializer().Deserialize<Configuration>(a);
            ;
            ////游戏进程ID
            //int GameProcessId=0;
            //// 游戏界面标题
            //string GameUiTitle="";
            ////游戏界面大小
            //Size GameUiSize;
            ////游戏中棋盘相对于游戏界面的左上角
            //Point GameBoardPoint;
            ////棋盘落子范围大小
            //int GameBoardInsideWidth;

            //String result = "GameProcessId:" + GameProcessId+Environment.NewLine;
            //result += "GameUiTitle:" + GameUiTitle + Environment.NewLine;

            //String Json = "{\"GameProcessId\":"+ GameProcessId + ",\"GameUiTitle\":"+ GameUiTitle +"}";
            //string xml = "";
        }
コード例 #3
0
        public override bool Load()
        {
            try
            {
                string xml = File.ReadAllText(SavedFileName);
                using (StringReader sr = new StringReader(xml))
                {
                    XmlSerializer    xmlSerializer = new XmlSerializer(typeof(XMLConfiguration));
                    XMLConfiguration a             = xmlSerializer.Deserialize(sr) as XMLConfiguration;

                    GameProcessId        = a.GameProcessId;
                    GameUiTitle          = a.GameUiTitle;
                    GameUiSize           = a.GameUiSize;
                    GameBoardPoint       = a.GameBoardPoint;
                    GameBoardInsideWidth = a.GameBoardInsideWidth;

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }