示例#1
0
        public static DateTime GetBuildTimestamp()
        {
            var attribute = (dynamic)Assembly.GetExecutingAssembly()
                            .GetCustomAttributes(false)
                            .First(x => x.GetType().Name == "TimestampAttribute");

            return(UniversalDateParser.Parse((string)attribute.Timestamp));
        }
示例#2
0
        public static License Deserialize(string licenseText)
        {
            //todo: null checks and throw useful exceptions
            var license = new License();
            var doc     = new XmlDocument();

            doc.LoadXml(licenseText);

            var date = doc.SelectSingleNode("/license/@expiration");

            license.ExpirationDate = UniversalDateParser.Parse(date.Value.Split('T').First());

            var maxMessageThroughputPerSecond = doc.SelectSingleNode("/license/@MaxMessageThroughputPerSecond").Value;

            if (maxMessageThroughputPerSecond == "Max")
            {
                license.MaxThroughputPerSecond = MaxThroughputPerSecond;
            }
            else
            {
                license.MaxThroughputPerSecond = int.Parse(maxMessageThroughputPerSecond);
            }

            var allowedNumberOfWorkerNodes = doc.SelectSingleNode("/license/@AllowedNumberOfWorkerNodes").Value;

            if (allowedNumberOfWorkerNodes == "Max")
            {
                license.AllowedNumberOfWorkerNodes = MaxWorkerNodes;
            }
            else
            {
                license.AllowedNumberOfWorkerNodes = int.Parse(allowedNumberOfWorkerNodes);
            }

            var upgradeProtectionExpiration = doc.SelectSingleNode("/license/@UpgradeProtectionExpiration");

            //UpgradeProtectionExpiration will not exist for trial licenses
            if (upgradeProtectionExpiration != null)
            {
                license.UpgradeProtectionExpiration = UniversalDateParser.Parse(upgradeProtectionExpiration.Value);
            }

            return(license);
        }