コード例 #1
0
 public static bool IsNeedToUpdateByComparePackages(Package Local, Package Remote)
 {
     if ((Local.Name).Equals(Remote.Name))
         if ((Local.Version).CompareTo(Remote.Version) < 0)
             return true;
     return false;
 }
コード例 #2
0
        public static List<Package> ReadXML(String filename)
        {
            List<Package> Packages = new List<Package>();

            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(filename);

            foreach (XmlNode Node_Lv1 in xmldoc.DocumentElement.ChildNodes)
            {
                switch (Node_Lv1.Name)
                {
                    // =============================
                    case "update":
                        foreach (XmlAttribute Attr in Node_Lv1.Attributes)
                        {
                            switch (Attr.Name)
                            {
                                // ---------------------
                                case "base":
                                    Package.UpdateServer = Attr.Value;
                                    break;
                                // ---------------------
                            }
                        }
                        break;
                    // =============================
                    case "package":
                        Package This = new Package();
                        foreach (XmlAttribute Attr in Node_Lv1.Attributes)
                        {
                            switch (Attr.Name)
                            {
                                // ---------------------
                                case "name":
                                    This.Name = Attr.Value;
                                    break;
                                // ---------------------
                                case "version":
                                    This.Version = Attr.Value;
                                    break;
                                // ---------------------
                            }
                        }
                        foreach (XmlNode Node_Lv2 in Node_Lv1.ChildNodes)
                        {
                            switch (Node_Lv2.Name)
                            {
                                // ---------------------
                                //case "product":
                                //    foreach (XmlAttribute Attr in Node_Lv2.Attributes)
                                //    {
                                //        switch (Attr.Name)
                                //        {
                                //            // .............
                                //            case "code":
                                //                This.ProductCode = Attr.Value;
                                //                break;
                                //            // .............
                                //        }
                                //    }
                                //    break;
                                // ---------------------
                                case "run":
                                    This.toRun = true;
                                    foreach (XmlNode Node_Lv3 in Node_Lv2.ChildNodes)
                                    {
                                        switch (Node_Lv3.Name)
                                        {
                                            // .............
                                            case "as":
                                                This.RunAs = Node_Lv3.InnerText;
                                                break;
                                            // .............
                                            case "once":
                                                This.RunOnce = true;
                                                break;
                                            // .............
                                        }
                                    }
                                    break;
                                // ---------------------
                                //case "dependent":
                                //    foreach (XmlAttribute Attr in Node_Lv2.Attributes)
                                //    {
                                //        switch (Attr.Name)
                                //        {
                                //            // .............
                                //            case "name":
                                //                This.Dependents.Add(Attr.Value);
                                //                break;
                                //            // .............
                                //        }
                                //    }
                                //    break;
                                // ---------------------
                            }
                        }
                        Packages.Add(This);
                        break;
                    // =============================
                }
            }
            return Packages;
        }