Пример #1
0
        public int CompareTo(ModuleVersion other)
        {
            var comparison = MajorVersion.CompareTo(other.MajorVersion);

            if (comparison != 0)
            {
                return(comparison);
            }

            comparison = MinorVersion.CompareTo(other.MinorVersion);

            if (comparison != 0)
            {
                return(comparison);
            }

            comparison = Revision.CompareTo(other.Revision);

            if (comparison != 0)
            {
                return(comparison);
            }

            if (IsPreRelease && !other.IsPreRelease)
            {
                return(-1);
            }

            if (other.IsPreRelease && !IsPreRelease)
            {
                return(1);
            }

            return(0);
        }
Пример #2
0
        public Migrator(
            MigrationConfigurationBase configuration,
            ServerStore serverStore,
            CancellationToken cancellationToken)
        {
            var hasCredentials =
                string.IsNullOrWhiteSpace(configuration.UserName) == false &&
                string.IsNullOrWhiteSpace(configuration.Password) == false;

            var httpClientHandler = new HttpClientHandler
            {
                UseDefaultCredentials = hasCredentials == false,
            };

            if (hasCredentials)
            {
                httpClientHandler.Credentials = new NetworkCredential(
                    configuration.UserName,
                    configuration.Password,
                    configuration.Domain);
            }

            _client = new HttpClient(httpClientHandler);

            _serverUrl = configuration.ServerUrl.TrimEnd('/');

            _serverStore       = serverStore;
            _version           = configuration.MajorVersion;
            _cancellationToken = cancellationToken;
        }
Пример #3
0
        public override string Serialize()
        {
            StringBuilder msg = new StringBuilder("$ID");

            msg.Append(From);
            msg.Append(DELIMITER);
            msg.Append(To);
            msg.Append(DELIMITER);
            msg.Append(ClientID.ToString("x4"));
            msg.Append(DELIMITER);
            msg.Append(ClientName);
            msg.Append(DELIMITER);
            msg.Append(MajorVersion.ToString());
            msg.Append(DELIMITER);
            msg.Append(MinorVersion.ToString());
            msg.Append(DELIMITER);
            msg.Append(CID);
            msg.Append(DELIMITER);
            msg.Append(SysUID);
            if (!string.IsNullOrEmpty(InitialChallenge))
            {
                msg.Append(DELIMITER);
                msg.Append(InitialChallenge);
            }
            return(msg.ToString());
        }
Пример #4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (FontTextProps?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)NextAvailableId;
         hashCode = (hashCode * 397) ^ (BooleanProperties?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)BorderStyle;
         hashCode = (hashCode * 397) ^ (int)MousePointer;
         hashCode = (hashCode * 397) ^ (ScrollBars?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ GroupCount;
         hashCode = (hashCode * 397) ^ (int)Cycle;
         hashCode = (hashCode * 397) ^ (int)SpecialEffect;
         hashCode = (hashCode * 397) ^ (BorderColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)Zoom;
         hashCode = (hashCode * 397) ^ (int)PictureAlignment;
         hashCode = (hashCode * 397) ^ (int)PictureSizeMode;
         hashCode = (hashCode * 397) ^ (int)ShapeCookie;
         hashCode = (hashCode * 397) ^ (int)DrawBuffer;
         hashCode = (hashCode * 397) ^ (DisplayedSize?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (LogicalSize?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ScrollPosition?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ FontIsStdFont.GetHashCode();
         hashCode = (hashCode * 397) ^ (FontStdFont?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Пример #5
0
        public Migrator(MigrationConfigurationBase configuration, ServerStore serverStore)
        {
            _serverUrl         = UrlHelper.TryGetLeftPart(configuration.ServerUrl);
            _serverStore       = serverStore;
            _buildMajorVersion = configuration.BuildMajorVersion;
            _buildVersion      = configuration.BuildVersion;

            //because of backward compatibility useCompression == false here
            var httpClientHandler = RequestExecutor.CreateHttpMessageHandler(_serverStore.Server.Certificate.Certificate, setSslProtocols: false, useCompression: false);

            httpClientHandler.UseDefaultCredentials = false;

            if (string.IsNullOrWhiteSpace(configuration.ApiKey) == false)
            {
                Authenticator.GetApiKeyParts(configuration.ApiKey); // will throw if not in correct format
                _apiKey = configuration.ApiKey;
                _enableBasicAuthenticationOverUnsecuredHttp = configuration.EnableBasicAuthenticationOverUnsecuredHttp;
            }
            else if (string.IsNullOrWhiteSpace(configuration.UserName) == false &&
                     string.IsNullOrWhiteSpace(configuration.Password) == false)
            {
                var domain = string.IsNullOrWhiteSpace(configuration.Domain) ? "\\" : configuration.Domain;
                httpClientHandler.Credentials = new NetworkCredential(
                    configuration.UserName,
                    configuration.Password,
                    domain);
            }

            _httpClient = new HttpClient(httpClientHandler);
        }
Пример #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Accelerators.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Items.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ ListIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (MouseIcon?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MousePointer.GetHashCode();
         hashCode = (hashCode * 397) ^ PropMask.GetHashCode();
         hashCode = (hashCode * 397) ^ Remainder.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ Size.GetHashCode();
         hashCode = (hashCode * 397) ^ TabData.GetHashCode();
         hashCode = (hashCode * 397) ^ TabFixedHeight.GetHashCode();
         hashCode = (hashCode * 397) ^ TabFixedWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ TabNames.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ TabOrientation.GetHashCode();
         hashCode = (hashCode * 397) ^ TabsAllocated.GetHashCode();
         hashCode = (hashCode * 397) ^ TabStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ Tags.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ TextProps.GetHashCode();
         hashCode = (hashCode * 397) ^ TipStrings.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ VariousPropertyBits.GetHashCode();
         return(hashCode);
     }
 }
Пример #7
0
        /// <summary>
        ///     Compares the current instance with another object of the same type and returns an integer that indicates
        ///     whether the current instance precedes, follows, or occurs in the same position in the sort order as the
        ///     <paramref name="comparison" /> object.
        /// </summary>
        /// <remarks>
        ///     <para>
        ///         Semantic Versions have a very specific and somewhat counterintuitive order of precedence. Comparison
        ///         begins with the major version and proceeds to the minor version, patch, prerelease tag and build
        ///         metadata tag. The order of precedence is always returned as soon as it can be determined.
        ///     </para>
        ///     <para>
        ///         If order cannot be determined from the major, minor and patch versions, then comparison proceeds to
        ///         the prerelease tag and then the build metadata tag. These fields can contain multiple segments
        ///         separated by the '.' character. each dot-separated segment is considered separately and where
        ///         possible is converted to an integer, so that <c>beta.9</c> sorts before <c>beta.10</c>.
        ///     </para>
        ///     <para>
        ///         Note that any version with a prerelease tag sorts lower than the same version without a prerelease
        ///         tag. Put another way: a release version is greater than a prerelease version.
        ///     </para>
        ///     <para>
        ///         The specification states that build metadata should be ignored when determining precedence. That
        ///         doesn't seem like a very sensible approach to us, since builds have to appear in some sort of order
        ///         and 'random' didn't strike us as an amazingly useful outcome. Therefore we have chosen to deviate
        ///         from the specification and include it as the last item in the list of comparisons when determining
        ///         the collation sequence. We treat the build metadata in a similar way to the prerelease tag, giving
        ///         it the lowest precedence but nonetheless yielding a more deterministic result when comparing and
        ///         sorting semantic versions.
        ///     </para>
        /// </remarks>
        /// <param name="comparison">An object to compare with this instance.</param>
        /// <returns>
        ///     A value that indicates the relative order of the objects being compared.
        /// </returns>
        public int CompareTo(SemanticVersion comparison)
        {
            if (comparison == null)
            {
                throw new ArgumentNullException(nameof(comparison));
            }
            if (ReferenceEquals(this, comparison))
            {
                return(0);
            }
            int result = MajorVersion.CompareTo(comparison.MajorVersion);

            if (result != 0)
            {
                return(result);
            }
            result = MinorVersion.CompareTo(comparison.MinorVersion);
            if (result != 0)
            {
                return(result);
            }
            result = PatchVersion.CompareTo(comparison.PatchVersion);
            if (result != 0)
            {
                return(result);
            }
            result = ComparePrereleaseVersions(PrereleaseVersion, comparison.PrereleaseVersion);
            if (result != 0)
            {
                return(result);
            }
            return(CompareBuildVersions(BuildVersion, comparison.BuildVersion));
        }
Пример #8
0
        protected override void Execute(NativeActivityContext context)
        {
            var pModel = new PackageModel();

            pModel.Id          = PackageId.Get(context);
            pModel.Description = Description.Get(context);
            pModel.Version     = Models.PackageModel.CreateFullVersionFromMajorMinor(MajorVersion.Get(context), MinorVersion.Get(context));
            pModel.Authors     = Authors.Get(context);
            pModel.Owners      = Owners.Get(context);
            pModel.LicenseUrl  = LicenseUrl.Get(context);
            pModel.ProjectUrl  = ProjectUrl.Get(context);
            pModel.IconUrl     = IconUrl.Get(context);
            pModel.RequireLicenseAcceptance = RequireLicenseAcceptance.Get(context);
            pModel.ReleaseNotes             = ReleaseNotes.Get(context);
            pModel.Copyright              = Copyright.Get(context);
            pModel.Tags                   = Tags.Get(context);
            pModel.DirectorySet           = DirectorySet.Get(context);
            pModel.ModelsAssemblyGuid     = ModelsAssemblyGuid.Get(context) ?? Guid.NewGuid().ToString();
            pModel.ActivitiesAssemblyGuid = ActivitiesAssemblyGuid.Get(context) ?? Guid.NewGuid().ToString();

            this.PackageModel.Set(context, pModel);

            context.Properties.Add("PackageModel", pModel);

            context.ScheduleActivity(this.Body);
        }
Пример #9
0
 public RavenVersionAttribute()
 {
     MajorVersion       = _assemblyVersion.Major;
     MajorVersionAsChar = char.Parse(MajorVersion.ToInvariantString());
     MinorVersion       = _assemblyVersion.Minor;
     PatchVersion       = _assemblyVersion.Build;
 }
Пример #10
0
 public override int GetHashCode()
 {
     return(MajorVersion.GetHashCode() ^
            MinorVersion.GetHashCode() ^
            Revision.GetHashCode() ^
            IsPreRelease.GetHashCode());
 }
Пример #11
0
 public override void DumpBody(XmlWriter writer)
 {
     writer.WriteElementString("url", Url);
     writer.WriteElementString("major-version", MajorVersion.ToString());
     writer.WriteElementString("minor-version", MinorVersion.ToString());
     Assets.DumpXml(writer);
 }
Пример #12
0
 public override void DumpBody(XmlWriter writer)
 {
     writer.WriteElementString("product-id", ProductId.ToString());
     writer.WriteElementString("edition", Edition.ToString());
     writer.WriteElementString("major-version", MajorVersion.ToString());
     writer.WriteElementString("minor-version", MinorVersion.ToString());
     writer.WriteElementString("build-number", BuildNumber.ToString());
     writer.WriteElementString("build-date", BuildDate.ToString());
 }
Пример #13
0
        public virtual void WriteXml(XmlDictionaryWriter writer,
                                     SamlSerializer samlSerializer,
                                     SecurityTokenSerializer keyInfoTokenSerializer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (Issuer == null || Issuer.Length == 0)
            {
                throw new SecurityTokenException("Issuer must not be null or empty.");
            }
            if (Statements.Count == 0)
            {
                throw new SecurityTokenException("At least one assertion statement is required.");
            }

            if (samlSerializer == null)
            {
                throw new ArgumentNullException("samlSerializer");
            }
            CultureInfo invariant = CultureInfo.InvariantCulture;

            writer.WriteStartElement("saml", "Assertion", SamlConstants.Namespace);
            writer.WriteAttributeString("MajorVersion", MajorVersion.ToString(invariant));
            writer.WriteAttributeString("MinorVersion", MinorVersion.ToString(invariant));
            writer.WriteAttributeString("AssertionID", AssertionId);
            writer.WriteAttributeString("Issuer", Issuer);
            writer.WriteAttributeString("IssueInstant", IssueInstant.ToString(SamlConstants.DateFormat, invariant));

            try
            {
                if (Conditions != null)
                {
                    Conditions.WriteXml(writer, samlSerializer, keyInfoTokenSerializer);
                }
                if (Advice != null)
                {
                    Advice.WriteXml(writer, samlSerializer, keyInfoTokenSerializer);
                }
                foreach (SamlStatement statement in Statements)
                {
                    statement.WriteXml(writer, samlSerializer, keyInfoTokenSerializer);
                }
            }
            catch (NotImplementedException)
            {
                throw;
            }
            catch (Exception ex) // bad catch, eh?
            {
                throw new InvalidOperationException("There is an error on writing assertion statements.", ex);
            }
            writer.WriteEndElement();
        }
Пример #14
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MinorVersion.GetHashCode();
         return(hashCode);
     }
 }
Пример #15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ Revision.GetHashCode();
         return(hashCode);
     }
 }
Пример #16
0
 public override void WriteMetadata(StringBuilder builder)
 {
     builder.Append(Encoding.ASCII.GetString(HttpMethodBytes.GetBytes(Method)));
     builder.Append(" ");
     builder.Append(Path);
     builder.Append(" HTTP/");
     builder.Append(MajorVersion.ToString(CultureInfo.InvariantCulture));
     builder.Append(".");
     builder.Append(MinorVersion.ToString(CultureInfo.InvariantCulture));
     builder.Append("\r\n");
     Headers.Write(builder, null, Encoding.ASCII);
 }
Пример #17
0
        protected override BaseBlock ConvertToBaseBlock(bool reverseByteOrder, Action <Exception> ActionOnException)
        {
            List <byte> body = new List <byte>();

            body.AddRange(BitConverter.GetBytes(((uint)MagicNumber).ReverseByteOrder(reverseByteOrder)));
            body.AddRange(BitConverter.GetBytes(MajorVersion.ReverseByteOrder(reverseByteOrder)));
            body.AddRange(BitConverter.GetBytes(MinorVersion.ReverseByteOrder(reverseByteOrder)));
            body.AddRange(BitConverter.GetBytes(SectionLength.ReverseByteOrder(reverseByteOrder)));
            body.AddRange(Options.ConvertToByte(reverseByteOrder, ActionOnException));
            BaseBlock baseBlock = new BaseBlock(this.BlockType, body.ToArray(), reverseByteOrder, 0);

            return(baseBlock);
        }
Пример #18
0
        /// <summary>
        /// Provide an XML version of the extension
        /// </summary>
        /// <returns>XML encoding of the extension</returns>
        /// <remarks>Sample OSCA XML description of the CertTemplateInfo extension:
        /// <code>
        ///  &lt;Extension&gt;
        ///    &lt;name description="Certificate Template Information"&gt;CertTemplateInfo&lt;/name&gt;
        ///    &lt;critical&gt;false&lt;/critical&gt;
        ///    &lt;value&gt;
        ///        &lt;template&gt;1.2.3.4.5.6&lt;/template&gt;
        ///        &lt;majorVersion&gt;1&lt;/majorVersion&gt;
        ///        &lt;minorVersion&gt;4&lt;/minorVersion&gt;
        ///    &lt;/value&gt;
        ///  &lt;/Extension&gt;
        /// </code>
        /// </remarks>
        public override XNode ToXml()
        {
            // Build generic
            XElement extension = (XElement)base.ToXml();

            // Create the parameter list
            XElement entry = extension.Element("value");

            entry.Add(new XElement("template", Template));
            entry.Add(new XElement("majorVersion", MajorVersion.ToString()));
            entry.Add(new XElement("minorVersion", MinorVersion.ToString()));
            return(extension);
        }
Пример #19
0
        public async Task UpdateSourceServerVersion()
        {
            var buildInfo = await GetBuildInfo();

            _buildVersion = buildInfo.BuildVersion;
            _version      = buildInfo.MajorVersion;
            _fullVersion  = buildInfo.FullVersion;

            if (_version == MajorVersion.Unknown)
            {
                throw new InvalidOperationException($"Unknown build version: {buildInfo.BuildVersion}, " +
                                                    $"product version: {buildInfo.ProductVersion}");
            }
        }
Пример #20
0
        public byte[] ConvertToByte()
        {
            List <byte> ret = new List <byte>();
            bool        reverseByteOrder = this.ReverseByteOrder;

            ret.AddRange(BitConverter.GetBytes((uint)MagicNumber));
            ret.AddRange(BitConverter.GetBytes(MajorVersion.ReverseByteOrder(reverseByteOrder)));
            ret.AddRange(BitConverter.GetBytes(MinorVersion.ReverseByteOrder(reverseByteOrder)));
            ret.AddRange(BitConverter.GetBytes(TimezoneOffset.ReverseByteOrder(reverseByteOrder)));
            ret.AddRange(BitConverter.GetBytes(SignificantFigures.ReverseByteOrder(reverseByteOrder)));
            ret.AddRange(BitConverter.GetBytes(MaximumCaptureLength.ReverseByteOrder(reverseByteOrder)));
            ret.AddRange(BitConverter.GetBytes(((uint)LinkType).ReverseByteOrder(reverseByteOrder)));
            return(ret.ToArray());
        }
Пример #21
0
        /// <summary>
        /// Compares two tags based on their version details.
        /// </summary>
        /// <param name="other">The tag instance to compare against.</param>
        /// <returns>TODO:</returns>
        public int CompareTo(Id3Tag other)
        {
            if (other == null)
            {
                return(1);
            }
            int majorComparison = MajorVersion.CompareTo(other.MajorVersion);
            int minorComparison = MinorVersion.CompareTo(other.MinorVersion);

            if (majorComparison == 0 && minorComparison == 0)
            {
                return(0);
            }
            return(majorComparison != 0 ? majorComparison : minorComparison);
        }
Пример #22
0
        public async Task <List <string> > GetFileSystemNames(MajorVersion buildMajorVersion)
        {
            if (buildMajorVersion != MajorVersion.V30 && buildMajorVersion != MajorVersion.V35)
            {
                return(new List <string>());
            }

            try
            {
                return(await AbstractLegacyMigrator.GetResourcesToMigrate(_serverUrl, _httpClient, true, _apiKey, _enableBasicAuthenticationOverUnsecuredHttp, _skipServerCertificateValidation, null, _serverStore.ServerShutdown));
            }
            catch (Exception e) when(e is UnauthorizedAccessException || e is AuthorizationException)
            {
                return(new List <string>());
            }
        }
Пример #23
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)FontEffects;
         hashCode = (hashCode * 397) ^ (int)FontHeight;
         hashCode = (hashCode * 397) ^ FontCharSet.GetHashCode();
         hashCode = (hashCode * 397) ^ FontPitchAndFamily.GetHashCode();
         hashCode = (hashCode * 397) ^ ParagraphAlign.GetHashCode();
         hashCode = (hashCode * 397) ^ FontWeight.GetHashCode();
         hashCode = (hashCode * 397) ^ (FontName?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Пример #24
0
        public async Task <List <string> > GetFileSystemNames(MajorVersion builMajorVersion)
        {
            if (builMajorVersion != MajorVersion.V30 && builMajorVersion != MajorVersion.V35)
            {
                return(new List <string>());
            }

            try
            {
                return(await AbstractLegacyMigrator.GetResourcesToMigrate(_serverUrl, _httpClient, true, _serverStore.ServerShutdown));
            }
            catch (UnauthorizedAccessException)
            {
                return(new List <string>());
            }
        }
Пример #25
0
 public Migrator_V3(
     string serverUrl,
     string databaseName,
     SmugglerResult result,
     Action <IOperationProgress> onProgress,
     DocumentDatabase database,
     HttpClient client,
     string migrationStateKey,
     MajorVersion marjorVersion,
     OperationCancelToken cancelToken)
     : base(serverUrl, databaseName, result, onProgress, database, cancelToken)
 {
     _client            = client;
     _migrationStateKey = migrationStateKey;
     _majorVersion      = marjorVersion;
 }
Пример #26
0
        public async Task UpdateBuildInfoIfNeeded()
        {
            if (_buildMajorVersion != MajorVersion.Unknown)
            {
                return;
            }

            var buildInfo = await GetBuildInfo();

            this._buildMajorVersion = buildInfo.MajorVersion;

            if (buildInfo.MajorVersion == MajorVersion.Unknown)
            {
                throw new InvalidOperationException($"Unknown build version: {buildInfo.BuildVersion}, " +
                                                    $"product version: {buildInfo.ProductVersion}");
            }
        }
Пример #27
0
            /// <summary>
            /// Returns negative integer if <see cref="MajorVersion"/> is behind to <see cref="secondMajorVerion"/>
            /// otherwise returns 0 if both are equal or positive integer if <see cref="MajorVersion"/> is ahead of <see cref="secondMajorVerion"/>
            /// </summary>
            /// <param name="secondMajorVerion">secondMajorVerion</param>
            /// <returns>substraction of <see cref="MajorVersion"/> and <see cref="secondMajorVerion"/></returns>
            public int CompareMajorVersion(float secondMajorVerion)
            {
                float  x;
                double xTruncate;

                if (BitConverter.GetBytes(decimal.GetBits((decimal)MajorVersion)[3])[2] == 1)
                {
                    var temp   = MajorVersion.ToString(System.Globalization.CultureInfo.InvariantCulture).Split('.');
                    var joined = $"{temp[0]}.0{temp[1]}";
                    x = Convert.ToSingle(joined);

                    xTruncate = Math.Truncate(x);
                }
                else
                {
                    x         = MajorVersion;
                    xTruncate = Math.Truncate(MajorVersion);
                }

                float  y;
                double yTruncate;

                if (BitConverter.GetBytes(decimal.GetBits((decimal)secondMajorVerion)[3])[2] == 1)
                {
                    var temp   = secondMajorVerion.ToString(System.Globalization.CultureInfo.InvariantCulture).Split('.');
                    var joined = $"{temp[0]}.0{temp[1]}";
                    y = Convert.ToSingle(joined);

                    yTruncate = Math.Truncate(y);
                }
                else
                {
                    y         = secondMajorVerion;
                    yTruncate = Math.Truncate(secondMajorVerion);
                }

                var xDecimalPart = x - xTruncate;
                var yDecimalPart = y - yTruncate;

                var result = Math.Round(xDecimalPart - yDecimalPart, 2) * 100 + (xTruncate - yTruncate);

                return((int)result);
            }
Пример #28
0
        public int CompareTo(EventReader other)
        {
            if (other is null)
            {
                return(1);
            }

            if (Equals(other))
            {
                return(0);
            }

            if (MajorVersion == other.MajorVersion)
            {
                return(MinorVersion.CompareTo(other.MinorVersion));
            }

            return(MajorVersion.CompareTo(other.MajorVersion));
        }
Пример #29
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)VariousPropertyBits;
         hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)PicturePosition;
         hashCode = (hashCode * 397) ^ (int)MousePointer;
         hashCode = (hashCode * 397) ^ (Accelerator?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Size?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Picture?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MouseIcon?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (TextProps?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)MaxLength;
         hashCode = (hashCode * 397) ^ (int)BorderStyle;
         hashCode = (hashCode * 397) ^ (ScrollBars?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ DisplayStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ (PasswordChar?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)ListWidth;
         hashCode = (hashCode * 397) ^ BoundColumn.GetHashCode();
         hashCode = (hashCode * 397) ^ TextColumn.GetHashCode();
         hashCode = (hashCode * 397) ^ ColumnCount.GetHashCode();
         hashCode = (hashCode * 397) ^ ListRows.GetHashCode();
         hashCode = (hashCode * 397) ^ ColumnInfoCount.GetHashCode();
         hashCode = (hashCode * 397) ^ MatchEntry.GetHashCode();
         hashCode = (hashCode * 397) ^ ListStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ ShowDropButtonWhen.GetHashCode();
         hashCode = (hashCode * 397) ^ DropButtonStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ MultiSelect.GetHashCode();
         hashCode = (hashCode * 397) ^ (BorderColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)SpecialEffect;
         hashCode = (hashCode * 397) ^ (Value?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (GroupName?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Remainder?.Length.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Пример #30
0
            internal void RestoreLayout(Dock dock, DockableContextContentCreator contentCreator)
            {
                Dictionary <int, DockableCollection> dockableCollections = new Dictionary <int, DockableCollection>();

                if (MajorVersion != MetadataMajorVersion || MinorVersion > MetadataMinorVersion)
                {
                    throw new InvalidDataException("Saved layout version (" + MajorVersion.ToString() + "." + MinorVersion.ToString() +
                                                   " is not compatible with the expected version " + MetadataMajorVersion.ToString() + "." + MetadataMinorVersion.ToString());
                }

                //  First, create the collections and associate them with the dock

                foreach (DockableCollectionDescriptor desc in DockedCollections)
                {
                    DockableCollection newCollection = desc.Create(dock, contentCreator);
                    dockableCollections.Add(desc.InternalId, newCollection);
                }


                //  Next, resolve their peer associations

                foreach (DockableCollectionDescriptor desc in DockedCollections)
                {
                    DockableCollection dockableCollection = dockableCollections[desc.InternalId];
                    desc.ResolvePeerRelationships(dockableCollections, dockableCollection);
                }

                dock.InvalidatePhysical();

                if (dock.ActualWidth != DockSize.Width || dock.ActualHeight != DockSize.Height)
                {
                    dock.InvalidatePositioning(LayoutContext.PositionClasses.EveryCollection | LayoutContext.PositionClasses.All | LayoutContext.PositionClasses.Resize);
                }

                foreach (DockDescriptor desc in FloatingDocks)
                {
                    dock.CreateFloatingDock(desc.Position, desc.DockSize, (DockWindow dockWindow) =>
                    {
                        desc.RestoreLayout(dockWindow.Dock, contentCreator);
                    });
                }
            }