コード例 #1
0
        /// <summary>
        /// Adds an attachment to the CDA Package.
        /// </summary>
        /// <param name="fileName">The name of the file.</param>
        /// <param name="fileContent">The content of the file.</param>
        public void AddDocumentAttachment(
            string fileName,
            byte[] fileContent)
        {
            // Validation
            var vb = new ValidationBuilder();

            vb.ArgumentRequiredCheck("fileName", fileName);
            vb.ArgumentRequiredCheck("fileContent", fileContent);

            if (vb.Messages.Count > 0)
            {
                throw new ValidationException(vb.Messages);
            }

            var file = new CDAPackageFile();

            // Indicate that this is a document attachment
            file.CDAPackageFileType = CDAPackageFile.FileType.Attachment;

            // User specified fields
            file.FileName    = fileName;
            file.FileContent = fileContent;

            if (CDADocumentAttachments == null)
            {
                CDADocumentAttachments = new List <CDAPackageFile>();
            }

            CDADocumentAttachments.Add(file);
        }
コード例 #2
0
        /// <summary>
        /// Determines whether the specified Object is equal to the current Object.
        /// </summary>
        /// <param name="obj">The Object to compare with the current Object.</param>
        /// <returns>true if the specified Object is equal to the current Object; otherwise, false.</returns>
        public override bool Equals(object obj)
        {
            var compare = obj as CDAPackage;

            if (compare == null)
            {
                return(false);
            }

            if (CDADocumentAttachments != null)
            {
                if (compare.CDADocumentAttachments == null)
                {
                    return(false);
                }
                if (CDADocumentAttachments.Count != compare.CDADocumentAttachments.Count)
                {
                    return(false);
                }

                CDADocumentAttachments.Sort((a, b) => a.FileName.ToString().CompareTo(b.FileName.ToString()));
                compare.CDADocumentAttachments.Sort((a, b) => a.FileName.ToString().CompareTo(b.FileName.ToString()));

                for (int x = 0; x < CDADocumentAttachments.Count; x++)
                {
                    if (!Helper.EqualsCompare(CDADocumentAttachments[x], compare.CDADocumentAttachments[x]))
                    {
                        return(false);
                    }
                }
            }
            else if (compare.CDADocumentAttachments != null)
            {
                return(false);
            }

            if (!Helper.EqualsCompare(CDADocumentRoot, compare.CDADocumentRoot))
            {
                return(false);
            }
            if (!Helper.EqualsCompare(CDASignature, compare.CDASignature))
            {
                return(false);
            }

            if (SigningTime != null || compare.SigningTime != null)
            {
                if (!SigningTime.Equals(compare.SigningTime))
                {
                    return(false);
                }
            }

            if (Helper.HasNullDifference(Approver, compare.Approver))
            {
                return(false);
            }
            if (Approver != null && !Approver.Equals(compare.Approver))
            {
                return(false);
            }

            return(true);
        }