예제 #1
0
        public static MultiValuedProperty <Page> BlobToPageCollection(byte[] blob, MAPIPropertiesDictionary propertiesDictionary)
        {
            MultiValuedProperty <Page> multiValuedProperty = new MultiValuedProperty <Page>();

            try
            {
                uint intFrom4bytes = DetailsTemplateAdapter.GetIntFrom4bytes(blob, 4);
                int  num           = 8;
                int  num2          = 0;
                while ((long)num2 < (long)((ulong)intFrom4bytes))
                {
                    uint[] array = new uint[9];
                    for (int i = 0; i < 9; i++)
                    {
                        array[i] = DetailsTemplateAdapter.GetIntFrom4bytes(blob, num);
                        num     += 4;
                    }
                    DetailsTemplateAdapter.AddControl(array, blob, multiValuedProperty, propertiesDictionary);
                    num2++;
                }
            }
            catch (ArgumentException ex)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Pages", ex.Message), DetailsTemplateSchema.Pages, blob), ex);
            }
            catch (InvalidOperationException ex2)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Pages", ex2.Message), DetailsTemplateSchema.Pages, blob), ex2);
            }
            catch (ParsingException ex3)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Pages", ex3.Message), DetailsTemplateSchema.Pages, blob), ex3);
            }
            return(multiValuedProperty);
        }
예제 #2
0
        private static uint GetMAPIPropTag(DetailsTemplateControl control, MAPIPropertiesDictionary propertiesDictionary)
        {
            if (control.GetControlType() == DetailsTemplateControl.ControlTypes.Button)
            {
                return(ButtonControl.MapiInt);
            }
            string attributeName = control.m_AttributeName;

            if (attributeName == null)
            {
                return(0U);
            }
            AttributeInfo attributeInfo = propertiesDictionary[attributeName];

            if (attributeInfo == null)
            {
                return(0U);
            }
            uint mapiID = (uint)attributeInfo.MapiID;

            return((uint)(control.GetMapiPrefix() | (DetailsTemplateControl.MapiPrefix)(mapiID << 16)));
        }
 public DetailsTemplateTypeService(string templateType, MAPIPropertiesDictionary propertiesDictionary)
 {
     this.TemplateType             = templateType;
     this.MAPIPropertiesDictionary = propertiesDictionary;
 }
예제 #4
0
 internal override bool ValidateAttribute(MAPIPropertiesDictionary propertiesDictionary)
 {
     return(base.ValidateAttributeHelper(propertiesDictionary));
 }
예제 #5
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);
 }
예제 #6
0
        private static void AddControl(uint[] data, byte[] blob, MultiValuedProperty <Page> pages, MAPIPropertiesDictionary propertiesDictionary)
        {
            int  x         = (int)data[0];
            int  y         = (int)data[2];
            int  width     = (int)data[1];
            int  height    = (int)data[3];
            int  num       = (int)data[8];
            int  maxLength = (int)data[7];
            uint num2      = data[6];

            DetailsTemplateControl.ControlFlags controlFlags = (DetailsTemplateControl.ControlFlags)data[5];
            string attributeName = propertiesDictionary[(int)(num2 >> 16 & 65535U)] ?? string.Empty;
            string @string       = Encoding.Unicode.GetString(blob, num, DetailsTemplateAdapter.GetNullTerminatedStringLength(blob, num));
            DetailsTemplateControl detailsTemplateControl = null;

            switch (data[4])
            {
            case 0U:
                detailsTemplateControl = new LabelControl();
                break;

            case 1U:
                detailsTemplateControl = new EditControl(controlFlags);
                break;

            case 2U:
                detailsTemplateControl = new ListboxControl(controlFlags);
                break;

            case 5U:
                detailsTemplateControl = new CheckboxControl();
                break;

            case 6U:
                detailsTemplateControl = new GroupboxControl();
                break;

            case 7U:
                detailsTemplateControl = new ButtonControl();
                break;

            case 8U:
                pages.Add(new Page
                {
                    Text        = @string,
                    HelpContext = (int)controlFlags
                });
                break;

            case 11U:
                detailsTemplateControl = new MultiValuedListboxControl();
                break;

            case 12U:
                detailsTemplateControl = new MultiValuedDropdownControl();
                break;
            }
            if (detailsTemplateControl != null)
            {
                if (pages.Count == 0)
                {
                    throw new ParsingException(DirectoryStrings.NoPagesSpecified);
                }
                detailsTemplateControl.X               = x;
                detailsTemplateControl.Y               = y;
                detailsTemplateControl.Width           = width;
                detailsTemplateControl.Height          = height;
                detailsTemplateControl.m_MaxLength     = maxLength;
                detailsTemplateControl.m_AttributeName = attributeName;
                detailsTemplateControl.m_Text          = @string;
                detailsTemplateControl.OriginalFlags   = controlFlags;
                pages[pages.Count - 1].Controls.Add(detailsTemplateControl);
            }
        }
예제 #7
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;
 }
 internal bool ValidateAttributeHelper(MAPIPropertiesDictionary propertiesDictionary)
 {
     return(!string.IsNullOrEmpty(this.m_AttributeName) && propertiesDictionary != null && propertiesDictionary[this.m_AttributeName] != null && (propertiesDictionary[this.m_AttributeName].ControlType & this.GetAttributeControlType()) != DetailsTemplateControl.AttributeControlTypes.None);
 }
 internal virtual bool ValidateAttribute(MAPIPropertiesDictionary propertiesDictionary)
 {
     return(true);
 }