本文整理汇总了C#中Thought.vCards.vCard类的典型用法代码示例。如果您正苦于以下问题:C# vCard类的具体用法?C# vCard怎么用?C# vCard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
vCard类属于Thought.vCards命名空间,在下文中一共展示了vCard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: StringEmpty_Mailer
public void StringEmpty_Mailer()
{
vCard card = new vCard();
Assert.IsEmpty(
card.Mailer,
"Mailer is not string.Empty.");
card.Mailer = null;
Assert.IsEmpty(
card.Mailer,
"Mailer is not string.Empty after being assigned null.");
}
开发者ID:drlongnecker,项目名称:Thought.vCards,代码行数:16,代码来源:vCardTests.cs
示例17: ParseUnicodeSimple
public void ParseUnicodeSimple()
{
vCard card = new vCard(
new StreamReader(new MemoryStream(SampleCards.UnicodeNameSample)));
Assert.IsNotNull(card);
//Assert.AreEqual("³ÂÀö¾ý", card.GivenName);
}
开发者ID:bobeverland,项目名称:Thought.vCards,代码行数:8,代码来源:OutlookTests.cs
示例18: StringEmpty_NameSuffix
public void StringEmpty_NameSuffix()
{
vCard card = new vCard();
Assert.IsEmpty(
card.NameSuffix,
"NameSuffix is not string.Empty.");
card.NameSuffix = null;
Assert.IsEmpty(
card.NameSuffix,
"NameSuffix is not string.Empty after being assigned null.");
}
开发者ID:drlongnecker,项目名称:Thought.vCards,代码行数:16,代码来源:vCardTests.cs
示例19: ParseOutlookSimple
public void ParseOutlookSimple()
{
// 01 BEGIN:VCARD
// 02 VERSION:2.1
// 03 N:Pinch;David;John
// 04 FN:David John Pinch
// 05 NICKNAME:Dave
// 06 ORG:Thought Project
// 07 TITLE:Dictator
// 08 TEL;WORK;VOICE:800-929-5805
// 09 TEL;HOME;VOICE:612-269-6017
// 10 ADR;HOME:;;129 15th Street #3;Minneapolis;MN;55403;United States of America
// 11 LABEL;HOME;ENCODING=QUOTED-PRINTABLE:129 15th Street #3=0D=0AMinneapolis, MN 55403=0D=0AUnited States of America
// 12 URL;WORK:http://www.thoughtproject.com
// 13 EMAIL;PREF;INTERNET:[email protected]
// 14 REV:20061130T234000Z
// 15 END:VCARD
vCard card = new vCard(
new StreamReader(new MemoryStream(SampleCards.OutlookSimple)));
// 03 N:Pinch;David;John
Assert.AreEqual(
"Pinch",
card.FamilyName,
"N at line 3 has a different family name.");
Assert.AreEqual(
"David",
card.GivenName,
"N at line 3 has a different given name.");
Assert.AreEqual(
"John",
card.AdditionalNames,
"N at line 3 has a different middle name.");
// 04 FN:David John Pinch
Assert.AreEqual(
"David John Pinch",
card.FormattedName,
"FN at line 4 has a different formatted name.");
// 05 NICKNAME:Dave
Assert.AreEqual(
1,
card.Nicknames.Count,
"Exactly one nickname is located at line 5.");
Assert.AreEqual(
"Dave",
card.Nicknames[0],
"NICKNAME at line 5 has a different value.");
// 06 ORG:Thought Project
Assert.AreEqual(
"Thought Project",
card.Organization,
"ORG at line 6 has a different value.");
// 07 TITLE:Dictator
Assert.AreEqual(
"Dictator",
card.Title,
"TITLE at line 7 has a different value.");
// 08 TEL;WORK;VOICE:800-929-5805
// 09 TEL;HOME;VOICE:612-269-6017
Assert.AreEqual(
2,
card.Phones.Count,
"Two telephone numbers are defined at lines 8 and 9.");
Assert.IsTrue(
card.Phones[0].IsWork,
"TEL at line 8 is a work number.");
Assert.IsTrue(
card.Phones[0].IsVoice,
"TEL at line 8 is a voice number.");
Assert.AreEqual(
"800-929-5805",
card.Phones[0].FullNumber,
"TEL at line 8 has a different value.");
// 09 TEL;HOME;VOICE:612-269-6017
Assert.IsTrue(
card.Phones[1].IsHome,
"TEL at line 9 is a home number.");
Assert.IsTrue(
//.........这里部分代码省略.........
开发者ID:bobeverland,项目名称:Thought.vCards,代码行数:101,代码来源:OutlookTests.cs
示例20: _parseCard1
private void _parseCard1(vCard card)
{
// 01 BEGIN:vCard
// 02 VERSION:3.0
// 03 FN:Frank Dawson
// 04 ORG:Lotus Development Corporation
// 05 ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive
// 06 ;Raleigh;NC;27613-3502;U.S.A.
// 07 TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
// 08 TEL;TYPE=FAX,WORK:+1-919-676-9564
// 09 EMAIL;TYPE=INTERNET,PREF:[email protected]
// 10 EMAIL;TYPE=INTERNET:[email protected]
// 11 URL:http://home.earthlink.net/~fdawson
// 12 END:vCard
Assert.AreEqual(
"Frank Dawson",
card.FormattedName,
"FN on line 3 is different.");
Assert.AreEqual(
"Lotus Development Corporation",
card.Organization,
"ORG on line 4 is different.");
Assert.AreEqual(
1,
card.DeliveryAddresses.Count,
"One address expected in card 1 at line 5.");
// 05 ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive
// 06 ;Raleigh;NC;27613-3502;U.S.A.
Assert.IsTrue(
card.DeliveryAddresses[0].IsWork,
"ADR on lines 5-6 is a work address.");
Assert.IsTrue(
card.DeliveryAddresses[0].IsPostal,
"ADR on lines 5-6 is a postal address.");
Assert.IsTrue(
card.DeliveryAddresses[0].IsParcel,
"ADR on lines 5-6 is a parcel address.");
Assert.AreEqual(
"6544 Battleford Drive",
card.DeliveryAddresses[0].Street,
"ADR on lines 5-6 has a different street address.");
Assert.AreEqual(
"Raleigh",
card.DeliveryAddresses[0].City,
"ADR on lines 5-6 has a different city.");
Assert.AreEqual(
"27613-3502",
card.DeliveryAddresses[0].PostalCode,
"ADR on lines 5-6 has a different postal code.");
Assert.AreEqual(
"U.S.A.",
card.DeliveryAddresses[0].Country,
"ADR on lines 5-6 has a different country.");
// 07 TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
// 08 TEL;TYPE=FAX,WORK:+1-919-676-9564
Assert.AreEqual(
2,
card.Phones.Count,
"Two phones are expected at lines 7-8.");
Assert.IsTrue(
card.Phones[0].IsVoice,
"TEL at line 7 is a voice number.");
Assert.IsTrue(
card.Phones[0].IsMessagingService,
"TEL at line 7 is a messaging service.");
Assert.IsTrue(
card.Phones[0].IsWork,
"TEL at line 7 is a work number.");
Assert.AreEqual(
"+1-919-676-9515",
card.Phones[0].FullNumber,
"TEL at line 7 has a different number.");
// 08 TEL;TYPE=FAX,WORK:+1-919-676-9564
Assert.IsTrue(
card.Phones[1].IsFax,
"TEL at line 8 is a fax number.");
Assert.IsTrue(
card.Phones[1].IsWork,
"TEL at line 8 is a work number.");
//.........这里部分代码省略.........
开发者ID:richardsalt,项目名称:Thought.vCards,代码行数:101,代码来源:RfcAuthorTests.cs
注:本文中的Thought.vCards.vCard类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论