public override void Extract()
            {
                int sizeOfFixedSizeProperty = PropertyTag.GetSizeOfFixedSizeProperty(base.PropertyTag.Type);

                if (sizeOfFixedSizeProperty > 0)
                {
                    byte[] array = base.StreamExtractor.ReadBytes(sizeOfFixedSizeProperty);
                    if (base.PropertyTag.Type == PropertyTag.PropertyType.Boolean)
                    {
                        array = new byte[]
                        {
                            array[0]
                        };
                    }
                    if (base.PropertyValueProcessor != null)
                    {
                        array = (byte[])base.PropertyValueProcessor(array);
                    }
                    if (array != null)
                    {
                        IProperty       property       = base.PropertyBag.AddProperty(base.PropertyTag.Value);
                        IPropertyWriter propertyWriter = property.OpenStreamWriter();
                        propertyWriter.Write(array);
                        propertyWriter.Close();
                    }
                }
            }
        protected override IFolder CreateFolder(IPST targetSession, IFolder parentFolder, string folderName)
        {
            List <uint> subFolderIds = parentFolder.SubFolderIds;

            if (subFolderIds != null)
            {
                foreach (uint num in subFolderIds)
                {
                    IFolder folder = targetSession.ReadFolder(num);
                    Dictionary <ushort, IProperty> properties = folder.PropertyBag.Properties;
                    IProperty property = null;
                    if (properties.TryGetValue(PropertyTag.DisplayName.Id, out property))
                    {
                        IPropertyReader propertyReader = property.OpenStreamReader();
                        string          @string        = Encoding.Unicode.GetString(propertyReader.Read());
                        if (@string == folderName)
                        {
                            return(folder);
                        }
                        propertyReader.Close();
                    }
                }
            }
            IFolder         folder2        = parentFolder.AddFolder();
            IProperty       property2      = folder2.PropertyBag.AddProperty(PropertyTag.DisplayName.Value);
            IPropertyWriter propertyWriter = property2.OpenStreamWriter();

            propertyWriter.Write(Encoding.Unicode.GetBytes(folderName));
            propertyWriter.Close();
            folder2.Save();
            return(folder2);
        }
 private void AddRecipientDisplayProperty(PropertyTag propertyTag, StringBuilder displayString)
 {
     if (displayString.Length > 0)
     {
         IProperty       property       = this.PropertyBag.AddProperty(propertyTag.NormalizedValueForPst);
         IPropertyWriter propertyWriter = property.OpenStreamWriter();
         propertyWriter.Write(Encoding.Unicode.GetBytes(displayString.ToString(0, displayString.Length - 1)));
         propertyWriter.Close();
     }
 }
            public override IMessage AddEmbeddedMessage()
            {
                IMessage        message        = this.attachment.AddMessageAttachment();
                IProperty       property       = this.attachment.PropertyBag.AddProperty(922812429U);
                IPropertyWriter propertyWriter = property.OpenStreamWriter();

                propertyWriter.Write(BitConverter.GetBytes((ulong)message.Id));
                propertyWriter.Close();
                return(message);
            }
Exemple #5
0
 public PlantUmlTypeWriter(
     IQueryType queryType,
     ITypeNameWriter typeNameWriter,
     ITypeNameWriter escapedTypeNameWriter,
     IEventWriter eventWriter,
     IMethodWriter methodWriter,
     IFieldWriter fieldWriter,
     IPropertyWriter propertyWriter)
 {
     _queryType             = queryType;
     _typeNameWriter        = typeNameWriter;
     _escapedTypeNameWriter = escapedTypeNameWriter;
     _eventWriter           = eventWriter;
     _methodWriter          = methodWriter;
     _fieldWriter           = fieldWriter;
     _propertyWriter        = propertyWriter;
 }
Exemple #6
0
 public SimpleTypeWriter(
     ITypeQueryFactory typeQueryFactory,
     ITypeNameWriter typeNameWriter,
     ITypeNameConverter typeNameConverter,
     IEventWriter eventWriter,
     IMethodWriter methodWriter,
     IFieldWriter fieldWriter,
     IPropertyWriter propertyWriter)
 {
     _typeQueryFactory  = typeQueryFactory;
     _typeNameWriter    = typeNameWriter;
     _typeNameConverter = typeNameConverter;
     _eventWriter       = eventWriter;
     _methodWriter      = methodWriter;
     _fieldWriter       = fieldWriter;
     _propertyWriter    = propertyWriter;
 }
            public override void Extract()
            {
                byte[] value = base.StreamExtractor.ReadBytes(4);
                int    size  = BitConverter.ToInt32(value, 0);

                byte[] array = base.StreamExtractor.ReadBytes(size);
                if (base.PropertyValueProcessor != null)
                {
                    array = (byte[])base.PropertyValueProcessor(array);
                }
                if (array != null)
                {
                    IProperty       property       = base.PropertyBag.AddProperty(base.PropertyTag.NormalizedValueForPst);
                    IPropertyWriter propertyWriter = property.OpenStreamWriter();
                    propertyWriter.Write(FastTransferStreamExtractor.PropertyExtractor.TrimStringEnd(base.PropertyTag.Type, array));
                    propertyWriter.Close();
                }
            }
Exemple #8
0
            static ITypeWriter CreatePlantUmlTypeWriter()
            {
                bool writeMembers = true;

                var queryType = new QueryType(new TypeQueryOptions());
                var normalTypeNameConverter   = new SimpleTypeNameConverter();
                var escapingTypeNameConverter = new EscapingTypenameConverter();

                var             normalTypeNameWriter  = new SimpleTypeNameWriter(normalTypeNameConverter);
                var             escapedTypeNameWriter = new SimpleTypeNameWriter(escapingTypeNameConverter);
                IPropertyWriter propertyWriter        = writeMembers ? new PropertyWriter(normalTypeNameWriter) : new EmptyPropertyWriter();
                IMethodWriter   methodWriter          = writeMembers ? new MethodWriter(normalTypeNameConverter, normalTypeNameWriter) : new EmptyMethodWriter();
                IFieldWriter    fieldWriter           = writeMembers ? new FieldWriter(normalTypeNameWriter) : new EmptyFieldWriter();
                IEventWriter    eventWriter           = writeMembers ? new EventWriter(normalTypeNameWriter) : new EmptyEventWriter();

                return(new PlantUmlTypeWriter(
                           queryType,
                           normalTypeNameWriter,
                           escapedTypeNameWriter,
                           eventWriter,
                           methodWriter,
                           fieldWriter,
                           propertyWriter));
            }
Exemple #9
0
        /// <inheritdoc />
        public void Serialize(object instance, IPropertyWriter writer)
        {
            var value = GetValue(instance);

            _serializer.Write(writer, this, value);
        }
Exemple #10
0
 /// <inheritdoc />
 void IValueSerializer <byte[]> .Write(IPropertyWriter writer, IPropertyDescriptor descriptor, byte[] value)
 => writer.Write(descriptor, value);
Exemple #11
0
 /// <inheritdoc />
 void IValueSerializer <string> .Write(IPropertyWriter writer, IPropertyDescriptor descriptor, string value)
 => writer.Write(descriptor, value);
Exemple #12
0
 /// <inheritdoc />
 void IValueSerializer <double> .Write(IPropertyWriter writer, IPropertyDescriptor descriptor, double value)
 => writer.Write(descriptor, value);
Exemple #13
0
 /// <inheritdoc />
 void IValueSerializer <int> .Write(IPropertyWriter writer, IPropertyDescriptor descriptor, int value)
 => writer.Write(descriptor, value);
Exemple #14
0
        public virtual void SetProperty(PropertyValue propertyValue)
        {
            if (!this.iPstPropertyBag.IsWritable || PSTPropertyBag.propertiesToSkip.Contains((ushort)propertyValue.PropertyTag.PropertyId))
            {
                this.values[propertyValue.PropertyTag] = propertyValue.Value;
                return;
            }
            IProperty property;

            if (!this.iPstPropertyBag.Properties.TryGetValue((ushort)propertyValue.PropertyTag.PropertyId, out property))
            {
                property = this.iPstPropertyBag.AddProperty(propertyValue.PropertyTag);
            }
            if (property == null)
            {
                throw new NullReferenceException("Cannot SetProperty on a null pstProperty");
            }
            if (property.PropTag != propertyValue.PropertyTag)
            {
                throw new PropertyTagsDoNotMatchPermanentException(property.PropTag, propertyValue.PropertyTag);
            }
            try
            {
                if (propertyValue.PropertyTag.IsMultiValuedProperty)
                {
                    List <List <byte> > list = new List <List <byte> >(((Array)propertyValue.Value).Length);
                    int i = 0;
                    while (i < ((Array)propertyValue.Value).Length)
                    {
                        PropertyType propertyType = propertyValue.PropertyTag.PropertyType;
                        byte[]       source;
                        if (propertyType <= PropertyType.MultiValueUnicode)
                        {
                            switch (propertyType)
                            {
                            case PropertyType.MultiValueInt16:
                                source = BitConverter.GetBytes(((short[])propertyValue.Value)[i]);
                                goto IL_27D;

                            case PropertyType.MultiValueInt32:
                                source = BitConverter.GetBytes(((int[])propertyValue.Value)[i]);
                                goto IL_27D;

                            case PropertyType.MultiValueFloat:
                                source = BitConverter.GetBytes(((float[])propertyValue.Value)[i]);
                                goto IL_27D;

                            case PropertyType.MultiValueDouble:
                            case PropertyType.MultiValueAppTime:
                                source = BitConverter.GetBytes(((double[])propertyValue.Value)[i]);
                                goto IL_27D;

                            case PropertyType.MultiValueCurrency:
                                break;

                            default:
                                if (propertyType != PropertyType.MultiValueInt64)
                                {
                                    switch (propertyType)
                                    {
                                    case PropertyType.MultiValueString8:
                                        source = Encoding.ASCII.GetBytes(((string[])propertyValue.Value)[i]);
                                        goto IL_27D;

                                    case PropertyType.MultiValueUnicode:
                                        source = Encoding.Unicode.GetBytes(((string[])propertyValue.Value)[i]);
                                        goto IL_27D;

                                    default:
                                        goto IL_289;
                                    }
                                }
                                break;
                            }
                            source = BitConverter.GetBytes(((long[])propertyValue.Value)[i]);
                            goto IL_27D;
                        }
                        if (propertyType == PropertyType.MultiValueSysTime)
                        {
                            long value;
                            try
                            {
                                value = ((ExDateTime[])propertyValue.Value)[i].ToFileTimeUtc();
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                value = 0L;
                            }
                            source = BitConverter.GetBytes(value);
                            goto IL_27D;
                        }
                        if (propertyType == PropertyType.MultiValueGuid)
                        {
                            source = ((Guid[])propertyValue.Value)[i].ToByteArray();
                            goto IL_27D;
                        }
                        if (propertyType == PropertyType.MultiValueBinary)
                        {
                            source = ((byte[][])propertyValue.Value)[i];
                            goto IL_27D;
                        }
IL_289:
                        i++;
                        continue;
IL_27D:
                        list.Add(source.ToList <byte>());
                        goto IL_289;
                    }
                    property.WriteMultiValueData(list);
                }
                else
                {
                    IPropertyWriter propertyWriter = property.OpenStreamWriter();
                    PropertyType    propertyType2  = propertyValue.PropertyTag.PropertyType;
                    if (propertyType2 <= PropertyType.Unicode)
                    {
                        switch (propertyType2)
                        {
                        case PropertyType.Int16:
                            propertyWriter.Write(BitConverter.GetBytes((short)propertyValue.Value));
                            goto IL_4B4;

                        case PropertyType.Int32:
                            propertyWriter.Write(BitConverter.GetBytes((int)propertyValue.Value));
                            goto IL_4B4;

                        case PropertyType.Float:
                            propertyWriter.Write(BitConverter.GetBytes((float)propertyValue.Value));
                            goto IL_4B4;

                        case PropertyType.Double:
                        case PropertyType.AppTime:
                            propertyWriter.Write(BitConverter.GetBytes((double)propertyValue.Value));
                            goto IL_4B4;

                        case PropertyType.Currency:
                            break;

                        case (PropertyType)8:
                        case (PropertyType)9:
                        case PropertyType.Error:
                        case (PropertyType)12:
                            goto IL_4B2;

                        case PropertyType.Bool:
                            propertyWriter.Write(BitConverter.GetBytes((bool)propertyValue.Value));
                            goto IL_4B4;

                        case PropertyType.Object:
                            goto IL_49D;

                        default:
                            if (propertyType2 != PropertyType.Int64)
                            {
                                switch (propertyType2)
                                {
                                case PropertyType.String8:
                                    propertyWriter.Write(Encoding.ASCII.GetBytes((string)propertyValue.Value));
                                    goto IL_4B4;

                                case PropertyType.Unicode:
                                    propertyWriter.Write(Encoding.Unicode.GetBytes((string)propertyValue.Value));
                                    goto IL_4B4;

                                default:
                                    goto IL_4B2;
                                }
                            }
                            break;
                        }
                        propertyWriter.Write(BitConverter.GetBytes((long)propertyValue.Value));
                        goto IL_4B4;
                    }
                    if (propertyType2 <= PropertyType.Guid)
                    {
                        if (propertyType2 == PropertyType.SysTime)
                        {
                            long value2;
                            try
                            {
                                value2 = ((ExDateTime)propertyValue.Value).ToFileTimeUtc();
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                value2 = 0L;
                            }
                            propertyWriter.Write(BitConverter.GetBytes(value2));
                            goto IL_4B4;
                        }
                        if (propertyType2 != PropertyType.Guid)
                        {
                            goto IL_4B2;
                        }
                        propertyWriter.Write(((Guid)propertyValue.Value).ToByteArray());
                        goto IL_4B4;
                    }
                    else if (propertyType2 != PropertyType.ServerId && propertyType2 != PropertyType.Binary)
                    {
                        goto IL_4B2;
                    }
IL_49D:
                    propertyWriter.Write((byte[])propertyValue.Value);
                    goto IL_4B4;
IL_4B2:
                    return;

IL_4B4:
                    propertyWriter.Close();
                }
            }
            catch (PSTExceptionBase innerException)
            {
                throw new MailboxReplicationPermanentException(new LocalizedString(((PSTSession)this.session).PstMailbox.IPst.FileName), innerException);
            }
        }
Exemple #15
0
 public StronkConfig To(IPropertyWriter writer)
 {
     _writers.Add(writer);
     return(_configRoot);
 }
 public PropertyWritingEntityAdapter(IPropertyWriter <O, I, C> propertyWriter)
 {
     this.propertyWriter = propertyWriter;
 }