Exemplo n.º 1
0
 static JGDBGameProfile()
 {
     Info1         = new JGDBGameProfile();
     Info1.m_Login = "******";
     Info1.m_Pwd   = "admin";
     Info2         = new JGDBGameProfile();
     Info2.m_Login = "******";
     Info2.m_Pwd   = "sample";
 }
Exemplo n.º 2
0
        internal static JGDBGameProfile CreateNewProfile(Dictionary <string, string> t)
        {
            JGDBGameProfile v_t    = new JGDBGameProfile();
            Type            v_type = v_t.GetType();

            foreach (var item in t)
            {
                FieldInfo     f       = v_type.GetField("m_" + item.Key, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                TypeConverter v_convt = TypeDescriptor.GetConverter(f.FieldType);
                f.SetValue(
                    v_t, v_convt.ConvertFromString(item.Value));
            }
            return(v_t);
        }
Exemplo n.º 3
0
        static JGDB()
        {
            sm_profile = new Dictionary <string, JGDBGameProfile>();
            if (File.Exists(JGConstant.DB_FILE))
            {
                XmlReader xreader = XmlReader.Create("jgdb.xml");
                try
                {
                    while (xreader.Read())
                    {
                        switch (xreader.NodeType)
                        {
                        case XmlNodeType.Element:
                            if (xreader.Name == "profile")
                            {
                                JGDBGameProfile p = LoadProfile(xreader.ReadSubtree());
                                if (!string.IsNullOrEmpty(p.Login) && !sm_profile.ContainsKey(p.Login))
                                {
                                    sm_profile.Add(p.Login, p);
                                }
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    xreader.Close();
                }
            }
            if (sm_profile.Count == 0)
            {
                sm_profile.Add("*****@*****.**", JGDBGameProfile.Info1);
                sm_profile.Add("*****@*****.**", JGDBGameProfile.Info2);
            }
        }
Exemplo n.º 4
0
        private static JGDBGameProfile LoadProfile(XmlReader xmlReader)
        {
            Dictionary <string, string> t = new Dictionary <string, string> ();

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (xmlReader.Name != "profile")
                    {
                        if (!t.ContainsKey(xmlReader.Name))
                        {
                            t.Add(xmlReader.Name, xmlReader.ReadInnerXml());
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            return(JGDBGameProfile.CreateNewProfile(t));
        }