Exemplo n.º 1
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            // Overflow is fine, just wrap.
            unchecked
            {
                int hash = 17;

                hash *= 23 + ApplicationName.GetHashCode();
                hash *= 23 + ApplicationSystemId.GetHashCode();
                hash *= 23 + ApplicationVersion.GetHashCode();
                hash *= 23 + ContentDescription.GetHashCode();
                hash *= 23 + Copyright.GetHashCode();
                hash *= 23 + Corporation.GetHashCode();
                hash *= 23 + CorporationAddress.GetHashCode();
                hash *= 23 + Filename.GetHashCode();
                hash *= 23 + Language.GetHashCode();
                hash *= 23 + SourceCopyright.GetHashCode();
                hash *= 23 + SourceDate.GetHashCode();
                hash *= 23 + SourceName.GetHashCode();
                hash *= 23 + TransmissionDate.GetHashCode();

                return(hash);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Output GEDCOM format for this instance.
        /// </summary>
        /// <param name="sw">Where to output the data to.</param>
        public override void Output(TextWriter sw)
        {
            sw.Write("0 HEAD");

            sw.Write(Environment.NewLine);
            sw.Write("1 SOUR {0}", ApplicationSystemId);

            if (!string.IsNullOrEmpty(ApplicationName))
            {
                sw.Write(Environment.NewLine);
                sw.Write("2 NAME {0}", ApplicationName);
            }

            if (!string.IsNullOrEmpty(ApplicationVersion))
            {
                sw.Write(Environment.NewLine);
                sw.Write("2 VERS {0}", ApplicationVersion);
            }

            if (!string.IsNullOrEmpty(Corporation))
            {
                sw.Write(Environment.NewLine);
                sw.Write("2 CORP {0}", Corporation);
            }

            if (CorporationAddress != null)
            {
                CorporationAddress.Output(sw, 3);
            }

            if (!string.IsNullOrEmpty(SourceName) ||
                !string.IsNullOrEmpty(SourceCopyright) ||
                SourceDate != null)
            {
                sw.Write(Environment.NewLine);
                sw.Write("2 DATA");
                if (!string.IsNullOrEmpty(SourceName))
                {
                    sw.Write(" ");
                    sw.Write(SourceName);
                }

                if (!string.IsNullOrEmpty(SourceCopyright))
                {
                    sw.Write(Environment.NewLine);
                    sw.Write("3 COPR ");
                    sw.Write(SourceCopyright);
                }

                if (SourceDate != null)
                {
                    SourceDate.Output(sw);
                }
            }

            if (TransmissionDate != null)
            {
                TransmissionDate.Output(sw);
            }

            sw.Write(Environment.NewLine);
            sw.Write("1 FILE {0}", Filename);

            if (ContentDescription != null)
            {
                ContentDescription.Output(sw);
            }

            sw.Write(Environment.NewLine);
            sw.Write("1 GEDC");

            sw.Write(Environment.NewLine);
            sw.Write("2 VERS 5.5.1");

            sw.Write(Environment.NewLine);
            sw.Write("2 FORM LINEAGE-LINKED");

            sw.Write(Environment.NewLine);
            sw.Write("1 CHAR UTF-8");

            sw.Write(Environment.NewLine);
            if (!string.IsNullOrWhiteSpace(Language))
            {
                sw.Write($"1 LANG {Language}");
            }

            bool hasSubmitter = !string.IsNullOrEmpty(submitterXRefID);

            if (hasSubmitter)
            {
                sw.Write(Environment.NewLine);
                sw.Write($"1 SUBM @{submitterXRefID}@");
            }
        }