/// <summary>
        ///  Set common object properties in order to test whether each of them is read-only.
        /// </summary>
        /// <param name="commonProperty">The nine Common Object Properties defined in section 2.2.1</param>
        /// <param name="error">When a property is specified as "read-only for the client", the server MUST
        /// return an error and ignore any request to change the value of that property.</param>
        public void SetCommonObjectProperties(CommonObjectProperty commonProperty, out CPRPTErrorCode error)
        {
            PropertyTag[] proTag = new PropertyTag[1];

            proTag[0] = this.commonProperties[commonProperty];

            this.RopGetPropertiesSpecific(this.cprptCurrentHandle, ConstValues.PropertySizeLimitNone, ConstValues.WantUnicodeNo, proTag);

            error = CPRPTErrorCode.None;
            TaggedPropertyValue[] tags = new TaggedPropertyValue[1];
            tags[0] = new TaggedPropertyValue
            {
                PropertyTag = this.commonProperties[commonProperty]
            };

            switch ((PropertyTypeName)tags[0].PropertyTag.PropertyType)
            {
                case PropertyTypeName.PtypInteger32:
                    tags[0].Value = BitConverter.GetBytes(Convert.ToInt32(CommonValue));
                    break;
                case PropertyTypeName.PtypBinary:
                    tags[0].Value = Common.AddInt16LengthBeforeBinaryArray(Encoding.Unicode.GetBytes(CommonValue));
                    break;
                case PropertyTypeName.PtypTime:
                    tags[0].Value = new byte[ConstValues.PtypTimeSizeInByte];
                    for (int i = 0; i < ConstValues.PtypTimeSizeInByte; i++)
                    {
                        tags[0].Value[i] = (byte)i;
                    }

                    break;
                case PropertyTypeName.PtypString:
                    tags[0].Value = Encoding.Unicode.GetBytes(CommonValue + '\0');
                    break;
                default:
                    break;
            }

            RopSetPropertiesResponse setPtyRes = this.RopSetProperties(this.cprptCurrentHandle, tags, false);
            if (setPtyRes.ReturnValue != (uint)CPRPTErrorCode.None)
            {
                if (setPtyRes.ReturnValue == (uint)CPRPTErrorCode.AccessDenied)
                {
                    error = CPRPTErrorCode.AccessDenied;
                }
                else
                {
                    error = CPRPTErrorCode.Other;
                }
            }
            else
            {
                if (this.cprptCurrentType == ServerObjectType.Message)
                {
                    RopSaveChangesMessageResponse saveChangesMsgRes = this.RopSaveChangesMessage(this.cprptCurrentHandle, false);
                    if (saveChangesMsgRes.ReturnValue == (uint)CPRPTErrorCode.GeneralFailure)
                    {
                        error = CPRPTErrorCode.GeneralFailure;
                    }
                    else
                    {
                        this.RopGetPropertiesSpecific(this.cprptCurrentHandle, ConstValues.PropertySizeLimitNone, ConstValues.WantUnicodeNo, proTag);
                    }
                }
                else if (this.cprptCurrentType == ServerObjectType.Attachment)
                {
                    RopSaveChangesAttachmentResponse saveAttachmentRes = this.RopSaveChangesAttachment(this.cprptCurrentHandle, false);
                    if (saveAttachmentRes.ReturnValue == (uint)CPRPTErrorCode.GeneralFailure)
                    {
                        error = CPRPTErrorCode.GeneralFailure;
                    }
                    else
                    {
                        this.RopGetPropertiesSpecific(this.cprptCurrentHandle, ConstValues.PropertySizeLimitNone, ConstValues.WantUnicodeNo, proTag);
                    }
                }
            }
        }
示例#2
0
 public static void SetCommonObjectProperties(CommonObjectProperty commonProperty, out CPRPTErrorCode error)
 {
     error = CPRPTErrorCode.None;
 }
        /// <summary>
        ///   Get common object properties in order to test their type.
        /// </summary>
        /// <param name="commonProperty">The nine Common Object Properties defined in section 2.2.1.</param>
        public void GetCommonObjectProperties(CommonObjectProperty commonProperty)
        {
            PropertyTag[] proTag = new PropertyTag[1];

            proTag[0] = this.commonProperties[commonProperty];
            RopGetPropertiesSpecificResponse getPropertiesSecificResponse = this.RopGetPropertiesSpecific(this.cprptCurrentHandle, ConstValues.PropertySizeLimitNone, ConstValues.WantUnicodeNo, proTag);

            if (getPropertiesSecificResponse.ReturnValue == (uint)CPRPTErrorCode.None)
            {
                this.VerifyCommonProperties(proTag[0], getPropertiesSecificResponse, this.cprptCurrentType);
                this.VerifyCommonPropertiesInOXCDATA(proTag[0], getPropertiesSecificResponse);
                this.VerifyTypeOfCommonPropertiesInOXPROPS(proTag[0], getPropertiesSecificResponse);
            }
        }
示例#4
0
 public static void GetCommonObjectProperties(CommonObjectProperty commonProperty)
 {
     Condition.IsTrue(isInitialized);
 }