Esempio n. 1
0
        /// <summary>
        /// Returns a string that represents the current object.
        /// </summary>
        /// <param name="version">vCard version</param>
        /// <returns>A string that represents the current object.</returns>
        public string ToString(vCardVersion version)
        {
            var clone = this;

            clone.Version = version;
            return(Serializer.Serialize(this));
        }
Esempio n. 2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="vCard"/> class.
        /// </summary>
        public vCard()
        {

            // Per Microsoft best practices, string properties should
            // never return null.  String properties should always
            // return String.Empty.

            this.additionalNames = string.Empty;
            this.department = string.Empty;
            this.displayName = string.Empty;
            this.familyName = string.Empty;
            this.formattedName = string.Empty;
            this.givenName = string.Empty;
            this.mailer = string.Empty;
            this.namePrefix = string.Empty;
            this.nameSuffix = string.Empty;
            this.office = string.Empty;
            this.organization = string.Empty;
            this.productId = string.Empty;
            this.role = string.Empty;
            this.timeZone = string.Empty;
            this.title = string.Empty;
            this.uniqueId = string.Empty;
            this.version = vCardVersion.Version2;
            this.categories = new StringCollection();
            this.certificates = new vCardCertificateCollection();
            this.deliveryAddresses = new vCardDeliveryAddressCollection();
            this.deliveryLabels = new vCardDeliveryLabelCollection();
            this.emailAddresses = new vCardEmailAddressCollection();
            this.socialProfiles = new vCardSocialProfileCollection();
            this.nicknames = new StringCollection();
            this.notes = new vCardNoteCollection();
            this.phones = new vCardPhoneCollection();
            this.photos = new vCardPhotoCollection();
            this.sources = new vCardSourceCollection();
            this.websites = new vCardWebsiteCollection();
        }
        /// <summary>
        ///     Writes a collection of vCard properties to an output text writer.
        /// </summary>
        public void Write(vCardPropertyCollection properties, vCardVersion vCardVersion, TextWriter output)
        {
            this.version = vCardVersion;
            if (properties == null)
                throw new ArgumentNullException("properties");

            if (output == null)
                throw new ArgumentNullException("output");

            foreach (vCardProperty property in properties)
            {
                output.WriteLine(EncodeProperty(property));
            }

        }
        /// <summary>
        ///     Writes a vCard to an output text writer.
        /// </summary>
        public override void Write(vCard card, TextWriter output)
        {
            this.version = card.Version;
            if (card == null)
                throw new ArgumentNullException("card");

            if (output == null)
                throw new ArgumentNullException("output");

            // Get the properties of the vCard.

            vCardPropertyCollection properties =
                BuildProperties(card);

            Write(properties, output);

        }