当前位置: 首页>>代码示例>>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;未经允许,请勿转载。