示例#1
0
 public static SDKManager getInstance()
 {
     if (instance == null)
     {
         instance = new SDKManager();
     }
     return(instance);
 }
示例#2
0
        public void readGameConfig(String xmlfile)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(xmlfile);
            XmlNode root  = xml.SelectSingleNode("xml");
            XmlNode games = root.SelectSingleNode("channels");

            ChannelList.Clear();

            foreach (XmlNode game in games.ChildNodes)
            {
                Channel c = new Channel();
                foreach (XmlNode p in game.ChildNodes)
                {
                    if (p.Name == "param")
                    {
                        if (p.Attributes["name"] != null)
                        {
                            Param pm = c.Params[p.Attributes["name"].Value as String];
                            if (pm != null)
                            {
                                pm.value.value = p.Attributes["value"].Value as String;
                            }
                            else
                            {
                                Console.WriteLine(p.Attributes["name"].Value as String);
                            }
                        }
                    }
                }
                XmlNode sdkparams = game.SelectSingleNode("sdk-params");
                if (sdkparams != null)
                {
                    foreach (XmlNode l in sdkparams.ChildNodes)
                    {
                        if (l.Attributes["name"] != null)
                        {
                            String key   = l.Attributes["name"].Value as String;
                            String value = "";
                            String desc  = "";
                            if (l.Attributes["value"] != null)
                            {
                                value = l.Attributes["value"].Value as String;
                            }
                            if (l.Attributes["desc"] != null)
                            {
                                desc = l.Attributes["desc"].Value as String;
                            }

                            Param pm = new Param(key, value, desc);
                            c.SDKParams.Add(key, pm);
                        }
                    }
                }
                c.sdk = SDKManager.getInstance().SDKList[c.Params["sdk"].value.value];
                if (c.sdk != null)
                {
                    foreach (KeyValuePair <String, Param> key in c.sdk.Params)
                    {
                        Param p = key.Value;
                        if (p.require == true)
                        {
                            if (!c.SDKParams.ContainsKey(p.name.value))
                            {
                                c.SDKParams.Add(p.name.value, p.Clone());
                            }
                            else
                            {
                                c.SDKParams[p.name.value].desc.value = key.Value.desc.value;
                            }
                        }
                    }
                }
                ChannelList.Add(c);
            }
            xml.Save(xmlfile);
        }