Beispiel #1
0
 public static byte[] PageCollectionToBlob(MultiValuedProperty <Page> pageCollection, MAPIPropertiesDictionary propertiesDictionary)
 {
     byte[] result;
     try
     {
         int num  = 8;
         int num2 = 0;
         if (pageCollection == null || pageCollection.Count == 0)
         {
             throw new InvalidOperationException(DirectoryStrings.DetailsTemplateCorrupted);
         }
         foreach (Page page in pageCollection)
         {
             num2++;
             num2 += page.Controls.Count;
             if (page.Text != null)
             {
                 num += page.Text.Length * 2;
             }
             foreach (DetailsTemplateControl detailsTemplateControl in page.Controls)
             {
                 num += detailsTemplateControl.m_Text.Length * 2;
             }
         }
         num += num2 * 38;
         byte[] array = new byte[num];
         DetailsTemplateAdapter.SetBytesToByteArray(array, 0, DetailsTemplateAdapter.Get4byteFromInt(1U));
         DetailsTemplateAdapter.SetBytesToByteArray(array, 4, DetailsTemplateAdapter.Get4byteFromInt((uint)num2));
         int num3  = 8;
         int value = num2 * 9 * 4 + 8;
         foreach (Page page2 in pageCollection)
         {
             DetailsTemplateAdapter.SetBytesToByteArray(array, num3 + 16, DetailsTemplateAdapter.Get4byteFromInt(8U));
             DetailsTemplateAdapter.SetBytesToByteArray(array, num3 + 20, DetailsTemplateAdapter.Get4byteFromInt((uint)page2.HelpContext));
             DetailsTemplateAdapter.SetBytesToByteArray(array, num3 + 32, DetailsTemplateAdapter.Get4byteFromInt((uint)value));
             DetailsTemplateAdapter.SetCaptionToByteArray(array, ref value, page2.Text);
             num3 += 36;
             foreach (DetailsTemplateControl control in page2.Controls)
             {
                 DetailsTemplateAdapter.SetControlToByteArray(array, ref num3, ref value, control, propertiesDictionary);
             }
         }
         result = array;
     }
     catch (ArgumentException ex)
     {
         throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Pages", ex.Message), DetailsTemplateSchema.Pages, pageCollection), ex);
     }
     catch (InvalidOperationException ex2)
     {
         throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Pages", ex2.Message), DetailsTemplateSchema.Pages, pageCollection), ex2);
     }
     catch (ParsingException ex3)
     {
         throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Pages", ex3.Message), DetailsTemplateSchema.Pages, pageCollection), ex3);
     }
     return(result);
 }
Beispiel #2
0
 private static void SetCaptionToByteArray(byte[] target, ref int captionOffset, string caption)
 {
     byte[] array = new byte[2 * caption.Length + 2];
     DetailsTemplateAdapter.SetBytesToByteArray(array, 0, Encoding.Unicode.GetBytes(caption));
     for (int i = 0; i < 2; i++)
     {
         array[array.Length - 1 - i] = 0;
     }
     DetailsTemplateAdapter.SetBytesToByteArray(target, captionOffset, array);
     captionOffset += array.Length;
 }
Beispiel #3
0
 private static void SetControlToByteArray(byte[] target, ref int controlOffset, ref int captionOffset, DetailsTemplateControl control, MAPIPropertiesDictionary propertiesDictionary)
 {
     uint[] array = new uint[]
     {
         (uint)control.X,
         (uint)control.Width,
         (uint)control.Y,
         (uint)control.Height,
         (uint)control.GetControlType(),
         (uint)control.GetControlFlags(),
         DetailsTemplateAdapter.GetMAPIPropTag(control, propertiesDictionary),
         (uint)control.m_MaxLength
     };
     for (int i = 0; i < array.Length; i++)
     {
         DetailsTemplateAdapter.SetBytesToByteArray(target, controlOffset, DetailsTemplateAdapter.Get4byteFromInt(array[i]));
         controlOffset += 4;
     }
     DetailsTemplateAdapter.SetBytesToByteArray(target, controlOffset, DetailsTemplateAdapter.Get4byteFromInt((uint)captionOffset));
     DetailsTemplateAdapter.SetCaptionToByteArray(target, ref captionOffset, control.m_Text);
     controlOffset += 4;
 }