public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { context.AddressCache.CopyDataFromItem(contact); context.AddressCache.Resolve(); this.WriteParticipant(writer, context.AddressCache.Participants[ConversionItemParticipants.ParticipantIndex.ContactEmail1], context.Options); this.WriteParticipant(writer, context.AddressCache.Participants[ConversionItemParticipants.ParticipantIndex.ContactEmail2], context.Options); this.WriteParticipant(writer, context.AddressCache.Participants[ConversionItemParticipants.ParticipantIndex.ContactEmail3], context.Options); }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { writer.StartProperty(PropertyId.Organization); string valueOrDefault = contact.GetValueOrDefault <string>(InternalSchema.CompanyName, string.Empty); writer.WritePropertyValue(valueOrDefault, ContactValueSeparators.Semicolon); valueOrDefault = contact.GetValueOrDefault <string>(InternalSchema.Department, string.Empty); writer.WritePropertyValue(valueOrDefault, ContactValueSeparators.Semicolon); }
public async Task <Unit> Handle(AddContactCommand request, CancellationToken cancellationToken) { var contactWriter = new ContactWriter(request.CreatedOn, request.Email, request.FirstName, request.LastName, request.FacebookName, request.PreferredName, request.PhoneNumber); await RaiseContactCreatedEvent(contactWriter, cancellationToken); return(new Unit()); }
public void EachNewContactHasUniqueId() { // Different IDs (and timestamps) will produce different encoded strings and // also you will get different encrypted values. Contact contact1 = CreateContact(), contact2 = CreateContact(); Assert.IsTrue(ContactWriter.ToString(contact1) != ContactWriter.ToString(contact2)); Assert.IsTrue(ContactWriter.ToString(contact1) != ContactWriter.ToString(contact1)); }
public void LoadFromFile() { using (var tempFile = new TemporaryFile()) { var contact = CreateContact(); ContactWriter.ToFile(tempFile, contact); CompareContacts(contact, ContactReader.FromFile(tempFile)); } }
public void AppendCustomBase64Text() { var contact = CreateContact(); var encodedContact = new StringBuilder(ContactWriter.ToString(contact)); encodedContact.Append('.'); encodedContact.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes("This is a test string."))); CompareContacts(contact, ContactReader.FromString(encodedContact.ToString())); }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { ExDateTime?exDateTime = contact.TryGetProperty(this.prop) as ExDateTime?; if (exDateTime != null) { writer.StartProperty(this.propName); writer.WriteValueTypeParameter(this.type); writer.WritePropertyValue((DateTime)exDateTime.Value.ToUtc()); } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { if (contact.Body.IsBodyDefined) { BodyReadConfiguration configuration = new BodyReadConfiguration(BodyFormat.TextPlain, context.Encoding.WebName); using (Stream stream = contact.Body.OpenReadStream(configuration)) { writer.StartProperty(PropertyId.Note); writer.WritePropertyValue(stream); } } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { string[] array = contact.TryGetProperty(this.prop) as string[]; if (array != null && array.Length > 0) { writer.StartProperty(this.propName); foreach (string value in array) { writer.WritePropertyValue(value, ContactValueSeparators.Comma); } } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { writer.StartProperty(PropertyId.StructuredName); for (int i = 0; i < OutboundVCardConverter.NameExporter.sourceProperties.Length; i++) { string text = contact.TryGetProperty(OutboundVCardConverter.NameExporter.sourceProperties[i]) as string; if (text == null) { text = string.Empty; } writer.WritePropertyValue(text, ContactValueSeparators.Semicolon); } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { string text = contact.TryGetProperty(ContactSchema.FullName) as string; if (text == null) { text = (contact.TryGetProperty(ItemSchema.NormalizedSubject) as string); if (text == null) { text = string.Empty; } } writer.WriteProperty(PropertyId.CommonName, text); }
internal static void Convert(Stream dataStream, Encoding encoding, Contact contact, OutboundConversionOptions options, ConversionLimitsTracker limitsTracker) { Util.ThrowOnNullArgument(options, "options"); Util.ThrowOnNullOrEmptyArgument(options.ImceaEncapsulationDomain, "options.ImceaEncapsulationDomain"); ContactWriter contactWriter = new ContactWriter(dataStream, encoding); contactWriter.StartVCard(); OutboundVCardConverter.PropertyExporter.Context context = new OutboundVCardConverter.PropertyExporter.Context(encoding, options, limitsTracker); foreach (OutboundVCardConverter.PropertyExporter propertyExporter in OutboundVCardConverter.exporters) { propertyExporter.Export(contactWriter, contact, context); } contactWriter.EndVCard(); }
private void WriteParticipant(ContactWriter writer, Participant addr, OutboundConversionOptions options) { if (addr == null) { return; } string participantSmtpAddress = ItemToMimeConverter.GetParticipantSmtpAddress(addr, options); if (!string.IsNullOrEmpty(participantSmtpAddress)) { writer.StartProperty(PropertyId.EMail); writer.WriteParameter(ParameterId.Type, "INTERNET"); writer.WritePropertyValue(participantSmtpAddress); } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { string text = contact.TryGetProperty(this.prop) as string; if (text != null) { writer.StartProperty(this.propName); if (this.types != null && this.types.Length > 0) { writer.StartParameter(ParameterId.Type); foreach (string value in this.types) { writer.WriteParameterValue(value); } } writer.WritePropertyValue(text); } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { foreach (AttachmentHandle handle in contact.AttachmentCollection) { using (Attachment attachment = contact.AttachmentCollection.Open(handle, null)) { if (attachment.IsContactPhoto) { StreamAttachment streamAttachment = attachment as StreamAttachment; if (streamAttachment != null) { string text = streamAttachment.ContentType; if (string.IsNullOrEmpty(text)) { text = streamAttachment.CalculatedContentType; } string value = null; if (!string.IsNullOrEmpty(text) && OutboundVCardConverter.PhotoExporter.contentTypeToType.TryGetValue(text, out value)) { using (Stream stream = streamAttachment.TryGetContentStream(PropertyOpenMode.ReadOnly)) { if (stream != null) { writer.StartProperty(PropertyId.Photo); writer.WriteParameter(ParameterId.Type, value); writer.WriteParameter(ParameterId.Encoding, "B"); using (Stream stream2 = new EncoderStream(stream, new Base64Encoder(0), EncoderStreamAccess.Read)) { writer.WritePropertyValue(stream2); break; } } } } } } } } }
public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context) { writer.StartProperty(PropertyId.Address); writer.StartParameter(ParameterId.Type); writer.WriteParameterValue(this.type); PhysicalAddressType valueOrDefault = contact.GetValueOrDefault <PhysicalAddressType>(ContactSchema.PostalAddressId); if (valueOrDefault == this.addrType) { writer.WriteParameterValue("PREF"); } for (int i = 0; i < this.props.Length; i++) { string text = string.Empty; if (this.props[i] != null) { text = (contact.TryGetProperty(this.props[i]) as string); if (text == null) { text = string.Empty; } } writer.WritePropertyValue(text, ContactValueSeparators.Semicolon); } string text2 = contact.TryGetProperty(this.labelProp) as string; if (text2 != null) { writer.StartProperty(PropertyId.Label); writer.StartParameter(ParameterId.Type); writer.WriteParameterValue(this.type); if (valueOrDefault == this.addrType) { writer.WriteParameterValue("PREF"); } writer.WritePropertyValue(text2); } }
private static string CreateEncodedContact() { return(ContactWriter.ToString(CreateContact())); }
private async Task RaiseContactCreatedEvent(ContactWriter contactWriter, CancellationToken cancellationToken) { var e = new ContactCreatedEvent(contactWriter); await _mediator.Publish(e, cancellationToken); }
public abstract void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context);