コード例 #1
0
        private static CmpSet CompareVersions(string v1, string v2, out string error)
        {
            error = null;
            int[] v1Vals = GetVersionValues(v1, out error);
            if (error != null)
            {
                return(CmpSet.ER);
            }
            int[] v2Vals = GetVersionValues(v2, out error);
            if (error != null)
            {
                return(CmpSet.ER);
            }
            CmpSet cmp = CmpSet.EQ;

            for (int i = 0; i < 4; ++i)
            {
                cmp = v1Vals[i] < v2Vals[i] ? CmpSet.LT : (v1Vals[i] > v2Vals[i] ? CmpSet.GT : CmpSet.EQ);
                if (cmp != CmpSet.EQ)
                {
                    return(cmp);
                }
            }
            return(CmpSet.EQ);
        }
コード例 #2
0
        private ValueTuple <string, bool, bool, string[]> CheckUpdates(string folder)
        {
            string        error         = null;
            List <string> updateInfoLst = GetUpdateInfo(folder, out error);

            if (updateInfoLst == null || error != null)
            {
                return(error, false, false, null);
            }

            string[] updateInfo = new string[(int)UpdtNdx.Count];
            string[] prefixes   = new string[]
            {
                "version::",
                "mdrdeskzip::",
                "dacversion::",
                "mscordacwks::"
            };

            for (int i = 0, icnt = updateInfoLst.Count; i < icnt; ++i)
            {
                var item = updateInfoLst[i];
                if (item.StartsWith(prefixes[(int)UpdtNdx.Version]))
                {
                    updateInfo[(int)UpdtNdx.Version] = item.Substring(prefixes[(int)UpdtNdx.Version].Length);
                }
                else if (item.StartsWith(prefixes[(int)UpdtNdx.MDRDeskZip]))
                {
                    updateInfo[(int)UpdtNdx.MDRDeskZip] = item.Substring(prefixes[(int)UpdtNdx.MDRDeskZip].Length);
                }
                else if (item.StartsWith(prefixes[(int)UpdtNdx.DacVersion]))
                {
                    updateInfo[(int)UpdtNdx.DacVersion] = item.Substring(prefixes[(int)UpdtNdx.DacVersion].Length);
                }
                else if (item.StartsWith(prefixes[(int)UpdtNdx.DacZip]))
                {
                    updateInfo[(int)UpdtNdx.DacZip] = item.Substring(prefixes[(int)UpdtNdx.DacZip].Length);
                }
            }
            bool   updateMdrDesk = false, updateDacs = false;
            CmpSet cmp = CompareVersions(_myVersion, updateInfo[(int)UpdtNdx.Version], out error);

            if (cmp == CmpSet.ER)
            {
                return(error, false, false, updateInfoLst.ToArray());
            }
            updateMdrDesk = cmp == CmpSet.LT;

            cmp = CompareIntVersion(_myDacVersion, updateInfo[(int)UpdtNdx.DacVersion], out error);
            if (cmp == CmpSet.ER)
            {
                return(error, false, false, updateInfoLst.ToArray());
            }
            updateDacs = cmp == CmpSet.LT;

            return(null, updateMdrDesk, updateDacs, updateInfo);
        }