當前位置: 首頁>>代碼示例>>C#>>正文


C# vCards.vCard類代碼示例

本文整理匯總了C#中Thought.vCards.vCard的典型用法代碼示例。如果您正苦於以下問題:C# vCard類的具體用法?C# vCard怎麽用?C# vCard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


vCard類屬於Thought.vCards命名空間,在下文中一共展示了vCard類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CycleStandard21

        /// <summary>
        ///     Writes a card, then reads it back and compares fields.
        /// </summary>
        public static void CycleStandard21(vCard card)
        {

            if (card == null)
                throw new ArgumentNullException("cycle");

            // Create a memory stream to hold the contents of the card.

            MemoryStream stream = new MemoryStream();

            StreamWriter textWriter = new StreamWriter(stream);

            // Create a standard vCard writer and export the
            // card data to the stream.

            vCardStandardWriter writer = new vCardStandardWriter();
            writer.Write(card, textWriter);
            textWriter.Flush();

            // Reset the stream (back to its beginning), then
            // create a stream reader capable of reading text
            // lines from the stream.

            stream.Seek(0, SeekOrigin.Begin);
            StreamReader streamReader = new StreamReader(stream);

            vCardStandardReader standardReader = new vCardStandardReader();
            vCard reloaded = standardReader.Read(streamReader);

            Equals(card, reloaded);

        }
開發者ID:richardsalt,項目名稱:Thought.vCards,代碼行數:35,代碼來源:Helper.cs

示例2: Parse

        public ToxyBusinessCards Parse()
        {
            string path = Context.Path;
            ToxyBusinessCards tbcs = new ToxyBusinessCards();
            using (StreamReader sr = new StreamReader(path))
            {
                while (!sr.EndOfStream)
                {
                    var card = new vCard(sr);
                    ToxyBusinessCard tbc = new ToxyBusinessCard();
                    tbc.Name = new ToxyName();
                    if (!string.IsNullOrEmpty(card.FormattedName))
                        tbc.Name.FullName = card.FormattedName;

                    tbc.Name.FirstName = card.GivenName;
                    tbc.Name.MiddleName = card.AdditionalNames;
                    tbc.Name.LastName = card.FamilyName;
                    tbc.ProductID = card.ProductId;
                    foreach(var vSource in card.Sources)
                    {
                        tbc.Sources.Add(vSource.Uri.OriginalString);
                    }
                    tbc.Orgnization = card.Organization;
                    tbc.Title = card.Title;
                    tbc.Gender = card.Gender == vCardGender.Male ? GenderType.Male : GenderType.Female;
                    if (card.Nicknames.Count > 0)
                    {
                        tbc.NickName = new ToxyName();
                        tbc.NickName.FullName = card.Nicknames[0];
                    }
                    foreach (var dAddr in card.DeliveryAddresses)
                    {
                        var tAddr= new ToxyAddress();
                        tAddr.City = dAddr.City;
                        tAddr.Street = dAddr.Street;
                        tAddr.Country = dAddr.Country;
                        tAddr.Region = dAddr.Region;
                        tAddr.PostalCode = dAddr.PostalCode;
                        tbc.Addresses.Add(tAddr);
                    }

                    foreach (var vphone in card.Phones)
                    {
                        tbc.Contacts.Add(new ToxyContact(vphone.PhoneType.ToString(), vphone.FullNumber)); 
                    }
                    foreach (var vEmail in card.EmailAddresses)
                    {
                        tbc.Contacts.Add(new ToxyContact(vEmail.EmailType.ToString(), vEmail.Address)); 
                    }
                    foreach (var vWebsite in card.Websites)
                    {
                        tbc.Contacts.Add(new ToxyContact("Url-"+ vWebsite.WebsiteType.ToString(), vWebsite.Url));
                    }

                    tbcs.Cards.Add(tbc);
                }
            }
            return tbcs;
        }
開發者ID:bosstjann,項目名稱:toxy,代碼行數:59,代碼來源:VCardParser.cs

示例3: CycleXPlanWithPhoto

        public void CycleXPlanWithPhoto()
        {

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.XPalmWithPhoto)));

            Helper.CycleStandard(card);

        }
開發者ID:QMTech,項目名稱:Thought.vCards,代碼行數:9,代碼來源:XPalmWithPhotoTests.cs

示例4: CycleOutlookSimple

        public void CycleOutlookSimple()
        {

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.OutlookSimple)));

            Helper.CycleStandard(card);

        }
開發者ID:bobeverland,項目名稱:Thought.vCards,代碼行數:9,代碼來源:OutlookTests.cs

示例5: Write

        /// <summary>
        ///     Writes the vCard to the specified filename.
        /// </summary>
        public virtual void Write(vCard card, string filename)
        {
            if (card == null)
                throw new ArgumentNullException("card");

            using (StreamWriter output = new StreamWriter(filename))
            {
                Write(card, output);
            }
        }
開發者ID:burstas,項目名稱:rmps,代碼行數:13,代碼來源:vCardWriter.cs

示例6: CycleOutlookCertificate

        public void CycleOutlookCertificate()
        {

            // Load the vCard with the test certificate.

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.OutlookCertificate)));

            Helper.CycleStandard(card);

        }
開發者ID:bobeverland,項目名稱:Thought.vCards,代碼行數:11,代碼來源:OutlookTests.cs

示例7: requestVCard

		private vCard requestVCard(SID sid) {
			ensureLoggedIn();

			var getResponse = WebSession.Get(string.Format("https://intranet.avegagroup.se/templates/vcard.aspx?SID={0}&ext=.vcf", sid.Value));

			using (var stream = new StringReader(getResponse.TextContent)) {
				vCard card = new vCard(stream);
				return card;
			}

		}
開發者ID:yodiz,項目名稱:Avega.ContactSynchronizer,代碼行數:11,代碼來源:IntranetAvegaClientRepository.cs

示例8: ReadWriteProperty_Department

        public void ReadWriteProperty_Department()
        {

            vCard card = new vCard();
            card.Department = "DOD";

            Assert.AreEqual(
                "DOD",
                card.Department,
                "The Department property is not working.");

        }
開發者ID:drlongnecker,項目名稱:Thought.vCards,代碼行數:12,代碼來源:vCardTests.cs

示例9: ReadWriteProperty_AdditionalNames

        public void ReadWriteProperty_AdditionalNames()
        {

            // Make sure .AdditionalNames reads/writes

            vCard card = new vCard();
            card.AdditionalNames = "John";

            Assert.AreEqual(
                "John",
                card.AdditionalNames,
                "The AdditionalNames property is not working.");

        }
開發者ID:drlongnecker,項目名稱:Thought.vCards,代碼行數:14,代碼來源:vCardTests.cs

示例10: CycleRfcAuthors

        public void CycleRfcAuthors()
        {

            using (StreamReader reader = new StreamReader(
                new MemoryStream(SampleCards.RfcAuthors)))
            {

                vCard card1 = new vCard(reader);
                vCard card2 = new vCard(reader);

                Helper.CycleStandard(card1);
                Helper.CycleStandard(card2);

            }

        }
開發者ID:richardsalt,項目名稱:Thought.vCards,代碼行數:16,代碼來源:RfcAuthorTests.cs

示例11: ParseRfcAuthors

        public void ParseRfcAuthors()
        {

            using (StreamReader reader = new StreamReader(
                new MemoryStream(SampleCards.RfcAuthors)))
            {

                vCard card1 = new vCard(reader);
                vCard card2 = new vCard(reader);

                _parseCard1(card1);
                _parseCard2(card2);

            }


        }
開發者ID:richardsalt,項目名稱:Thought.vCards,代碼行數:17,代碼來源:RfcAuthorTests.cs

示例12: SamplevCardReadAndWriteTestWithEmailTypeFormat

        public void SamplevCardReadAndWriteTestWithEmailTypeFormat()
        {

            vCard card = new vCard();

            card.EmailAddresses.Add(new vCardEmailAddress() { Address = "[email protected]", EmailType = vCardEmailAddressType.Internet, IsPreferred = true, ItemType = ItemType.WORK });


            card.UniqueId = Guid.NewGuid().ToString("N");

            string text = card.ToString();

            vCardStandardWriter writer = new vCardStandardWriter();

            using (StringWriter sw = new StringWriter())
            {

                writer.Write(card, sw);

                sw.Flush();
                text = sw.ToString();
                sw.Close();
            }


            Assert.IsNotNull(text);


            vCardStandardReader reader = new vCardStandardReader();

            using (StringReader sr = new StringReader(text))
            {

                vCard cardFromReader = reader.Read(sr);

                Assert.AreEqual(1, cardFromReader.EmailAddresses.Count);

                var email = cardFromReader.EmailAddresses.First();
                Assert.AreEqual(true, email.IsPreferred);
                Assert.AreEqual(ItemType.WORK, email.ItemType);
                Assert.AreEqual(vCardEmailAddressType.Internet, email.EmailType);
                Assert.AreEqual("[email protected]", email.Address);
            }

        }
開發者ID:bobeverland,項目名稱:Thought.vCards,代碼行數:45,代碼來源:IntegrationTest.cs

示例13: ReadWriteProperty_BirthDate

        public void ReadWriteProperty_BirthDate()
        {

            vCard card = new vCard();
            card.BirthDate = DateTime.Parse("04/04/04");

            Assert.AreEqual(
                DateTime.Parse("04/04/04"),
                card.BirthDate.Value,
                "The BirthDate property was not set.");

            card.BirthDate = null;

            Assert.IsNull(
                card.BirthDate,
                "The BirthDate property was not set to null.");

        }
開發者ID:drlongnecker,項目名稱:Thought.vCards,代碼行數:18,代碼來源:vCardTests.cs

示例14: Run

        public override int Run(string[] remainingArguments)
        {
            using (var stream = new StreamReader(new FileStream(Filepath, FileMode.Open)))
            {
                while (!stream.EndOfStream)
                {
                    var card = new vCard(stream);
                    var select = new
                    {
                        name = card.FormattedName,
                        phones = string.Join(",", card.Phones.Select(p => p.FullNumber)),
                        email = card.EmailAddresses
                    };

                    if (string.IsNullOrEmpty(select.phones) || string.IsNullOrEmpty(select.name))
                        continue; ;

                    Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(select));
                }
            }

            return 0;
        }
開發者ID:fschwiet,項目名稱:VcfDerp,代碼行數:23,代碼來源:DumpVcfCommand.cs

示例15: ToVCard

        public vCard ToVCard()
        {
            vCard card = new vCard();
            if(this.Name!=null)
            {
            card.DisplayName = this.Name.FullName;
            card.FamilyName = this.Name.LastName;
            card.GivenName = this.Name.FirstName;
            }
            card.Gender = this.Gender== GenderType.Male?vCardGender.Male:vCardGender.Female;
            if (this.NickName != null)
                card.Nicknames.Add(this.NickName.FullName);

            card.Organization = this.Orgnization;
            if (this.Contacts != null)
            {
                foreach (var contact in this.Contacts)
                {
                    card.Phones.Add(new vCardPhone(contact.Name, vCardPhoneTypes.Cellular));
                }
            }
            return card;
        }
開發者ID:iraychen,項目名稱:toxy,代碼行數:23,代碼來源:ToxyBusinessCard.cs


注:本文中的Thought.vCards.vCard類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。