CompareMetadata() статический приватный Метод

Compares two metadata collections together
static private CompareMetadata ( object>.IEnumerable leftMetadata, object>.IEnumerable rightMetadata, bool &same ) : ObservableCollection
leftMetadata object>.IEnumerable Metadata list from the first file to use in comparison
rightMetadata object>.IEnumerable Metadata list from the second file to use in comparison
same bool True if the metadata keys and values were identical between both files, false otherwise
Результат ObservableCollection
Пример #1
0
        /// <summary>
        /// Initializes a new instance of the CompareFileData class and sets properties based on the FileData provided
        /// </summary>
        /// <param name="leftFile">First set of FileData to use in comparison</param>
        /// <param name="rightFile">Second set of FileData to use in comparison</param>
        public CompareFileData(FileData leftFile, FileData rightFile)
        {
            if (leftFile == null)
            {
                throw new ArgumentNullException("leftFile");
            }

            if (rightFile == null)
            {
                throw new ArgumentNullException("rightFile");
            }

            this.LeftFileData    = leftFile;
            this.RightFileData   = rightFile;
            this.FileCompareText = string.Format(Strings.CompareFilesHeader, Path.GetFileName(leftFile.FileName), Path.GetFileName(rightFile.FileName));
            bool samePublicMetadata   = true;
            bool samePersonalMetadata = true;

            this.PublicMetadata   = CompareFileData.CompareMetadata(leftFile.PublicMetadata, rightFile.PublicMetadata, out samePublicMetadata);
            this.PersonalMetadata = CompareFileData.CompareMetadata(leftFile.PersonalMetadata, rightFile.PersonalMetadata, out samePersonalMetadata);
            this.Streams          = CompareFileData.CompareStreams(leftFile.Streams, rightFile.Streams);

            if (leftFile.PublicMetadata.Count == 0 && rightFile.PublicMetadata.Count == 0)
            {
                this.PublicMetadataCompareText = string.Format(Strings.PublicMetadataHeader, Strings.None);
            }
            else
            {
                this.PublicMetadataCompareText = string.Format(Strings.PublicMetadataHeader, samePublicMetadata ? Strings.Same : Strings.Different);
            }

            if (leftFile.PersonalMetadata.Count == 0 && rightFile.PersonalMetadata.Count == 0)
            {
                this.PersonalMetadataCompareText = string.Format(Strings.PersonalMetadataHeader, Strings.None);
            }
            else
            {
                this.PersonalMetadataCompareText = string.Format(Strings.PersonalMetadataHeader, samePersonalMetadata ? Strings.Same : Strings.Different);
            }

            if (leftFile.Streams.Count == 0 && rightFile.Streams.Count == 0)
            {
                this.StreamsCompareText = string.Format(Strings.StreamsHeader, Strings.None);
            }
            else
            {
                bool sameStreamData = this.Streams.All(data => data.Same);
                this.StreamsCompareText = string.Format(Strings.StreamsHeader, sameStreamData ? Strings.Same : Strings.Different);
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the CompareStreamData class and sets all properties based on the StreamData provided
        /// </summary>
        /// <param name="leftStream">First StreamData object to use for comparison</param>
        /// <param name="rightStream">Second StreamData object to use for comparison</param>
        public CompareStreamData(StreamData leftStream, StreamData rightStream)
        {
            if (leftStream == null && rightStream == null)
            {
                throw new InvalidOperationException(Strings.ErrorNoStreams);
            }

            this.StreamName = Strings.Unknown;
            this.LeftPublicMetadataCount    = 0;
            this.RightPublicMetadataCount   = 0;
            this.LeftPersonalMetadataCount  = 0;
            this.RightPersonalMetadataCount = 0;
            string          dataTypeIdKey         = Strings.DataTypeIdHeader;
            string          semanticIdKey         = Strings.SemanticIdHeader;
            string          eventCountKey         = Strings.EventCountHeader;
            string          startTimeKey          = Strings.StreamStartTimeHeader;
            string          endTimeKey            = Strings.StreamEndTimeHeader;
            string          leftSemanticId        = string.Empty;
            string          rightSemanticId       = string.Empty;
            string          leftEventCount        = string.Empty;
            string          rightEventCount       = string.Empty;
            string          leftStartTime         = string.Empty;
            string          rightStartTime        = string.Empty;
            string          leftEndTime           = string.Empty;
            string          rightEndTime          = string.Empty;
            string          leftDataTypeId        = string.Empty;
            string          rightDataTypeId       = string.Empty;
            KStudioMetadata leftPublicMetadata    = null;
            KStudioMetadata rightPublicMetadata   = null;
            KStudioMetadata leftPersonalMetadata  = null;
            KStudioMetadata rightPersonalMetadata = null;

            if (leftStream != null)
            {
                this.StreamName                = leftStream.EventStream.DataTypeName;
                leftSemanticId                 = leftStream.EventStream.SemanticId.ToString();
                leftEventCount                 = leftStream.EventHeaders.Count.ToString();
                leftStartTime                  = leftStream.StartTime.ToString();
                leftEndTime                    = leftStream.EndTime.ToString();
                leftDataTypeId                 = leftStream.EventStream.DataTypeId.ToString();
                leftPublicMetadata             = leftStream.PublicMetadata;
                leftPersonalMetadata           = leftStream.PersonalMetadata;
                this.LeftPublicMetadataCount   = leftStream.PublicMetadata.Count;
                this.LeftPersonalMetadataCount = leftStream.PersonalMetadata.Count;
            }

            if (rightStream != null)
            {
                if (leftStream == null)
                {
                    this.StreamName = rightStream.EventStream.DataTypeName;
                }

                rightSemanticId                 = rightStream.EventStream.SemanticId.ToString();
                rightEventCount                 = rightStream.EventHeaders.Count.ToString();
                rightStartTime                  = rightStream.StartTime.ToString();
                rightEndTime                    = rightStream.EndTime.ToString();
                rightDataTypeId                 = rightStream.EventStream.DataTypeId.ToString();
                rightPublicMetadata             = rightStream.PublicMetadata;
                rightPersonalMetadata           = rightStream.PersonalMetadata;
                this.RightPublicMetadataCount   = rightStream.PublicMetadata.Count;
                this.RightPersonalMetadataCount = rightStream.PersonalMetadata.Count;
            }

            // compare stream metadata
            bool samePublicMetadata   = true;
            bool samePersonalMetadata = true;

            this.PublicMetadata   = CompareFileData.CompareMetadata(leftPublicMetadata, rightPublicMetadata, out samePublicMetadata);
            this.PersonalMetadata = CompareFileData.CompareMetadata(leftPersonalMetadata, rightPersonalMetadata, out samePersonalMetadata);

            if (this.LeftPublicMetadataCount == 0 && this.RightPublicMetadataCount == 0)
            {
                this.StreamPublicMetadataCompareText = string.Format(Strings.PublicMetadataHeader, Strings.None);
            }
            else
            {
                this.StreamPublicMetadataCompareText = string.Format(Strings.PublicMetadataHeader, samePublicMetadata ? Strings.Same : Strings.Different);
            }

            if (this.LeftPersonalMetadataCount == 0 && this.RightPersonalMetadataCount == 0)
            {
                this.StreamPersonalMetadataCompareText = string.Format(Strings.PersonalMetadataHeader, Strings.None);
            }
            else
            {
                this.StreamPersonalMetadataCompareText = string.Format(Strings.PersonalMetadataHeader, samePersonalMetadata ? Strings.Same : Strings.Different);
            }

            // compare stream details
            this.StreamDetails = new ObservableCollection <CompareData>();
            this.StreamDetails.Add(new CompareData(dataTypeIdKey, leftDataTypeId, rightDataTypeId));
            this.StreamDetails.Add(new CompareData(semanticIdKey, leftSemanticId, rightSemanticId));
            this.StreamDetails.Add(new CompareData(eventCountKey, leftEventCount, rightEventCount));
            this.StreamDetails.Add(new CompareData(startTimeKey, leftStartTime, rightStartTime));
            this.StreamDetails.Add(new CompareData(endTimeKey, leftEndTime, rightEndTime));

            bool sameDetails = this.StreamDetails.All(data => data.Same);

            this.StreamDetailsCompareText = string.Format(Strings.StreamDetailsHeader, sameDetails ? Strings.Same : Strings.Different);

            this.Same = (samePublicMetadata && samePersonalMetadata && sameDetails) ? true : false;
        }