Ejemplo n.º 1
0
            public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context)
            {
                object obj = contact.TryGetProperty(this.prop);

                if (obj is string)
                {
                    writer.WriteProperty(this.propName, obj as string);
                    return;
                }
                if (PropertyError.IsPropertyValueTooBig(obj))
                {
                    writer.StartProperty(this.propName);
                    using (Stream stream = contact.OpenPropertyStream(this.prop, PropertyOpenMode.ReadOnly))
                    {
                        using (Stream stream2 = new ConverterStream(stream, new TextToText
                        {
                            InputEncoding = Encoding.Unicode,
                            OutputEncoding = context.Encoding
                        }, ConverterStreamAccess.Read))
                        {
                            writer.WritePropertyValue(stream2);
                        }
                    }
                }
            }
Ejemplo n.º 2
0
 public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context)
 {
     writer.WriteProperty(PropertyId.Profile, "VCARD");
     writer.WriteProperty(PropertyId.Version, "3.0");
     writer.WriteProperty(PropertyId.Mailer, "Microsoft Exchange");
     writer.WriteProperty(PropertyId.ProductId, "Microsoft Exchange");
 }
Ejemplo n.º 3
0
            public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context)
            {
                Sensitivity?sensitivity = contact.TryGetProperty(InternalSchema.Sensitivity) as Sensitivity?;

                if (sensitivity != null)
                {
                    switch (sensitivity.Value)
                    {
                    case Sensitivity.Normal:
                        writer.WriteProperty(PropertyId.Class, "PUBLIC");
                        break;

                    case Sensitivity.Personal:
                    case Sensitivity.Private:
                        writer.WriteProperty(PropertyId.Class, "PRIVATE");
                        return;

                    case Sensitivity.CompanyConfidential:
                        writer.WriteProperty(PropertyId.Class, "CONFIDENTIAL");
                        return;

                    default:
                        return;
                    }
                }
            }
Ejemplo n.º 4
0
 public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context)
 {
     byte[][] array = contact.TryGetProperty(InternalSchema.UserX509Certificates) as byte[][];
     if (array != null)
     {
         foreach (byte[] array3 in array)
         {
             if (array3 != null)
             {
                 writer.StartProperty(PropertyId.Key);
                 writer.WriteParameter(ParameterId.Type, "X509");
                 writer.WriteParameter(ParameterId.Encoding, "B");
                 using (MemoryStream memoryStream = new MemoryStream())
                 {
                     using (Stream stream = new EncoderStream(new StreamWrapper(memoryStream, false), new Base64Encoder(0), EncoderStreamAccess.Write))
                     {
                         stream.Write(array3, 0, array3.Length);
                     }
                     memoryStream.Position = 0L;
                     writer.WritePropertyValue(memoryStream);
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
            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);
            }
Ejemplo n.º 7
0
            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());
                }
            }
Ejemplo n.º 8
0
 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);
         }
     }
 }
Ejemplo n.º 9
0
 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);
         }
     }
 }
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
            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);
            }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
            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);
                }
            }
Ejemplo n.º 14
0
 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;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 15
0
            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);
                }
            }
Ejemplo n.º 16
0
 public abstract void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context);