示例#1
0
        public void CheckSerilizingAndDeserializeingOfVersionObject()
        {
            var versionObject = VersionObject.GetVersionObject();

            versionObject.Clear();
            versionObject.VersionData.VersionName        = "aaa";
            versionObject.VersionData.VersionDescription = "bbb";
            versionObject.VersionData.VersionChanges.Add("c1");
            versionObject.VersionData.VersionChanges.Add("c2");
            var file = File.Create("aa.txt");

            file.Close();
            versionObject.ListOfFiles.Add(new FileInformation("aa.txt"));

            Update.MoveWithReplaceInNaroCad("Version.XML", "Version1.XML");

            Program.SerializeToXml(versionObject);
            versionObject.Clear();

            versionObject = UpdateLogic.DeserializeFromXml("Version.XML");
            Assert.IsTrue(versionObject.VersionData.VersionName == "aaa", "Version name not correct.");
            Assert.IsTrue(versionObject.VersionData.VersionDescription == "bbb", "Version description not correct.");
            Assert.IsTrue(versionObject.VersionData.VersionChanges[0] == "c1", "Version Change 1 not correct.");
            Assert.IsTrue(versionObject.VersionData.VersionChanges[1] == "c2", "Version Change 2 not correct.");
            Assert.IsTrue(versionObject.ListOfFiles[0].SourcePath == "aa.txt", "Source path not correct.");

            Update.MoveWithReplaceInNaroCad("Version1.XML", "Version.XML");
            File.Delete("aa.txt");
        }
        public void _0003_Version()
        {
            VersionObject Version = new VersionObject();

            Version.Parse("VERSION \"12\"");
            Assert.AreEqual("12", Version.Value);
        }
示例#3
0
 private void ChangeFileVersion(PropertyGroup propertyGroup, Action <VersionObject> versionOperate)
 {
     try
     {
         var version = VersionHelper.GetVersionObject(propertyGroup.Version);
         versionOperate(version);
         propertyGroup.Version = version.ToString();
     }
     catch (Exception ex)
     {
         //some projects many not have a invalid verion number.
         SenparcTrace.SendCustomLog("version not changed", ex.Message);
     }
     finally
     {
         VersionObject version = null;
         try
         {
             version = VersionHelper.GetVersionObject(SelectedFile.Version);
         }
         catch
         {
             version = new VersionObject();
         }
         txtVersion.Dispatcher.Invoke(() => txtVersion.Text     = SelectedFile.Version);
         txtQualifier.Dispatcher.Invoke(() => txtQualifier.Text = version.QualifierVersion);
     }
 }
示例#4
0
        public static void SerializeToXml(VersionObject versionInstance)
        {
            var        serializer = new XmlSerializer(typeof(VersionObject));
            TextWriter textWriter = new StreamWriter(UpdateLogic.VersionFileName);

            serializer.Serialize(textWriter, versionInstance);
            textWriter.Close();
        }
示例#5
0
文件: Update.cs 项目: Soju06/NUMC
        public static byte Compare(VersionObject <Release> release)
        {
            if (release == null || release.Version == null)
            {
                return(127);
            }

            if (!Version.TryParse(Constant.Verison, out Version currentVersion))
            {
                return(255);
            }

            return((byte)(release.Version > currentVersion ? 1 : 0));
        }
示例#6
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();

            try
            {
                VersionObject vObject = new VersionObject();
                vObject.version        = AddInHost.Current.MediaCenterEnvironment.Version.ToString();
                opResult.StatusCode    = OpStatusCode.Success;
                opResult.ContentObject = vObject;
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return(opResult);
        }
示例#7
0
 private static void CreateXmlVersionFile(string versionName)
 {
     VersionObject.GetVersionObject().Initialize(versionName);
     SerializeToXml(VersionObject.GetVersionObject());
 }
示例#8
0
        /// <summary>
        ///     Parses deserialised json data.
        /// </summary>
        private void ParseJsonData(Dictionary<string, object> data)
        {
            // Check that the data supplied exists.
            if (data == null)
            {
                return;
            }

            // Iterate through each element in the json data.
            foreach (string key in data.Keys)
            {
                switch (key.ToLowerInvariant())
                {
                    // Add-on display name.
                    case "name":
                        Name = data[key] as string;
                        break;

                    // URL that is used to fetch the remote add-on information.
                    case "url":
                        Url = data[key] as string;
                        break;

                    // Download URL where the player can obtain the latest version of the add-on.
                    case "download":
                        Download = data[key] as string;
                        break;

                    // Change log content that's stored in the add-on information.
                    case "change_log":
                        ChangeLog = data[key] as string;
                        break;

                    // URL where a plain text change log can be fetched.
                    case "change_log_url":
                        ChangeLogUrl = data[key] as string;
                        break;

                    // The add-on version.
                    case "version":
                        Version = new VersionObject(data[key]);
                        break;

                    // Game version which the add-on was built for.
                    case "ksp_version":
                        Compatibility.Version = new VersionObject(data[key]);
                        break;

                    // Minimum game version the add-on officially supports.
                    case "ksp_version_min":
                        Compatibility.VersionMin = new VersionObject(data[key]);
                        break;

                    // Maximum game version the add-on officially supports.
                    case "ksp_version_max":
                        Compatibility.VersionMax = new VersionObject(data[key]);
                        break;

                    // Assembly name for dynamically fetching the add-on version.
                    case "assembly":
                        Version = Utils.GetAssemblyVersion(data[key] as string);
                        break;

                    case "github":
                        break;
                }
            }
        }
示例#9
0
		public override void OnVersion(VersionObject pData)
		{
			m_versions.Add(pData);
		}
示例#10
0
		public override void OnVersion(VersionObject version)
		{
			foreach(DocumentVisitor observer in m_observers)
				observer.OnVersion(version);
		}
    public void registerModelObjects()
    {
        _versionObject = new VersionObject();

        _selfUserObject = new UserObject();
        _leftUserObject = new UserObject();
        _rightUserObject = new UserObject();

        _roomObject = new RoomObject();
        _deskObject = new DeskObject();

        _userLoginObject = new UserLoginObject();
        _userEditProfileObject = new UserEditProfileObject();

        _userSitOnDeskObject = new UserSitOnDeskObject();
        _deskJiaoDiZhuObject = new DeskJiaoDiZhuObject();

        _deskCardsPromptObject = new DeskCardsPromptObject();
        _deskChuPaiObject = new DeskChuPaiObject();
        _deskCardsValidateObject = new DeskCardsValidateObject();
        _userCheckResumePlayObject = new UserCheckResumePlayObject();
    }
示例#12
0
        /// <summary>
        ///     Parses deserialised json data.
        /// </summary>
        private void ParseJsonData(Dictionary <string, object> data)
        {
            // Check that the data supplied exists.
            if (data == null)
            {
                return;
            }

            // Iterate through each element in the json data.
            foreach (string key in data.Keys)
            {
                switch (key.ToLowerInvariant())
                {
                // Add-on display name.
                case "name":
                    Name = data[key] as string;
                    break;

                // URL that is used to fetch the remote add-on information.
                case "url":
                    Url = data[key] as string;
                    break;

                // Download URL where the player can obtain the latest version of the add-on.
                case "download":
                    Download = data[key] as string;
                    break;

                // Change log content that's stored in the add-on information.
                case "change_log":
                    ChangeLog = data[key] as string;
                    break;

                // URL where a plain text change log can be fetched.
                case "change_log_url":
                    ChangeLogUrl = data[key] as string;
                    break;

                // The add-on version.
                case "version":
                    Version = new VersionObject(data[key]);
                    break;

                // Game version which the add-on was built for.
                case "ksp_version":
                    Compatibility.Version = new VersionObject(data[key]);
                    break;

                // Minimum game version the add-on officially supports.
                case "ksp_version_min":
                    Compatibility.VersionMin = new VersionObject(data[key]);
                    break;

                // Maximum game version the add-on officially supports.
                case "ksp_version_max":
                    Compatibility.VersionMax = new VersionObject(data[key]);
                    break;

                // Assembly name for dynamically fetching the add-on version.
                case "assembly":
                    Version = Utils.GetAssemblyVersion(data[key] as string);
                    break;

                case "github":
                    break;
                }
            }
        }
示例#13
0
        public static VersionObject GetVersionObject(string versionString)
        {
            //var systemVersion = Version.Parse(versionString);
            var versionArr    = versionString.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
            var versionObject = new VersionObject();

            for (int i = 0; i < versionArr.Length; i++)
            {
                var currentVersion = versionArr[i];
                int versionNumber;
                if (!int.TryParse(currentVersion, out versionNumber))
                {
                    //may contains QualifierVersion

                    var regex = Regex.Match(currentVersion, @"(\d+)([_\-\+]{0,1})([\S\w]*)");
                    if (regex.Success)
                    {
                        if (!int.TryParse(regex.Groups[1].Value, out versionNumber))
                        {
                            throw new Exception($"invalid version format: {currentVersion} / {regex.Groups[1].Value}");
                        }

                        if (!regex.Groups[2].Value.IsNullOrEmpty() /*like: "-" */ && !regex.Groups[3].Value.IsNullOrEmpty() /* like: "preview3" */)
                        {
                            versionObject.QualifierVersion = regex.Groups[2].Value + regex.Groups[3].Value;//like: "-preview3"
                        }
                    }
                    else
                    {
                        throw new Exception("invalid version format: " + currentVersion);
                    }
                }

                switch (i)
                {
                case 0:
                    versionObject.MajorVersion = versionNumber;
                    break;

                case 1:
                    versionObject.MinorVersion = versionNumber;
                    break;

                case 2:
                    versionObject.RevisionVersion = versionNumber;
                    break;

                case 3:
                    versionObject.BuildNumberVersion = versionNumber;
                    break;

                default:
                    break;
                }
            }


            //ver version = new VersionObject(versionMatch)

            return(versionObject);
        }