当前位置: 首页>>代码示例>>C#>>正文


C# ISerializable.Serialize方法代码示例

本文整理汇总了C#中ISerializable.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# ISerializable.Serialize方法的具体用法?C# ISerializable.Serialize怎么用?C# ISerializable.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISerializable的用法示例。


在下文中一共展示了ISerializable.Serialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeObject

        public void SerializeObject(string name, ISerializable serObject)
        {
            XElement subElem = new XElement(name);
            serObject.Serialize(new XmlSerializer(subElem));

            elem.Add(subElem);
        }
开发者ID:doanhtdpl,项目名称:boom-game,代码行数:7,代码来源:XmlSerializer.cs

示例2: DoRopCall

        /// <summary>
        /// Send ROP request with single operation.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <param name="insideObjHandle">Server object handle in request.</param>
        /// <param name="response">ROP response objects.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="getPropertiesFlag">The flag indicate the test cases expect to get which object type's properties(message's properties or attachment's properties).</param>
        /// <param name="returnValue">An unsigned integer value indicates the return value of call EcDoRpcExt2 method.</param>
        /// <returns>Server objects handles in response.</returns>
        public List<List<uint>> DoRopCall(ISerializable ropRequest, uint insideObjHandle, ref object response, ref byte[] rawData, GetPropertiesFlags getPropertiesFlag, out uint returnValue)
        {
            List<ISerializable> requestRops = new List<ISerializable>
            {
                ropRequest
            };

            List<uint> requestSOH = new List<uint>
            {
                insideObjHandle
            };

            if (Common.IsOutputHandleInRopRequest(ropRequest))
            {
                // Add an element for server output object handle, set default value to 0xFFFFFFFF
                requestSOH.Add(DefaultOutputHandle);
            }
            
            List<IDeserializable> responseRops = new List<IDeserializable>();
            List<List<uint>> responseSOHs = new List<List<uint>>();

            // 0x10008 specifies the maximum size of the rgbOut buffer to place in Response.
            uint ret = this.oxcropsClient.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, 0x10008);
            returnValue = ret;
            if (ret == OxcRpcErrorCode.ECRpcFormat)
            {
                this.Site.Assert.Fail("Error RPC Format");
            }

            if (ret != 0)
            {
                return responseSOHs;
            }

            if (responseRops != null)
            {
                if (responseRops.Count > 0)
                {
                    response = responseRops[0];
                }
            }
            else
            {
                response = null;
            }

            if (ropRequest.GetType() == typeof(RopReleaseRequest))
            {
                return responseSOHs;
            }

            byte ropId = (byte)BitConverter.ToInt16(ropRequest.Serialize(), 0);

            List<PropertyObj> pts = null;
            switch (ropId)
            {
                case (byte)RopId.RopOpenMessage:
                    RopOpenMessageResponse openMessageResponse = (RopOpenMessageResponse)response;

                    // This check is for the open specification expectation for a particular request with some valid input parameters.
                    if (openMessageResponse.ReturnValue == 0x00000000)
                    {
                        this.VerifyRopOpenMessageResponse(openMessageResponse);
                    }

                    break;

                case (byte)RopId.RopGetPropertiesSpecific:
                    // RopGetPropertiesSpecificRequest
                    pts = PropertyHelper.GetPropertyObjFromBuffer(((RopGetPropertiesSpecificRequest)ropRequest).PropertyTags, (RopGetPropertiesSpecificResponse)response);

                    foreach (PropertyObj pitem in pts)
                    {
                        // Verify capture code for MS-OXCMSG. 
                        this.VerifyMessageSyntaxDataType(pitem);
                    }

                    PropertyObj propertyObjPidTagSubjectPrefix = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagSubjectPrefix);
                    PropertyObj propertyObjPidTagNormalizedSubject = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagNormalizedSubject);

                    // Verify the message of PidTagSubjectPrefixAndPidTagNormalizedSubject
                    if (PropertyHelper.IsPropertyValid(propertyObjPidTagSubjectPrefix) || PropertyHelper.IsPropertyValid(propertyObjPidTagNormalizedSubject))
                    {
                        this.VerifyMessageSyntaxPidTagSubjectPrefixAndPidTagNormalizedSubject(propertyObjPidTagSubjectPrefix, propertyObjPidTagNormalizedSubject);
                    }

                    // Verify the requirements of PidTagAttachmentLinkId and PidTagAttachmentFlags.
                    PropertyObj pidTagAttachmentLinkId = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAttachmentLinkId);
                    if (PropertyHelper.IsPropertyValid(pidTagAttachmentLinkId))
                    {
//.........这里部分代码省略.........
开发者ID:OfficeDev,项目名称:Interop-TestSuites,代码行数:101,代码来源:MS-OXCMSGAdapter.cs

示例3: Write

 public void Write(ISerializable structure)
 {
     structure.Serialize(this);
 }
开发者ID:oxykidz,项目名称:RiceEmu,代码行数:4,代码来源:PacketIO.cs

示例4: IsInvalidInputHandleNeeded

        /// <summary>
        /// Check whether the default invalid handle is needed.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <param name="expectedRopResponseType">The expected ROP response type.</param>
        /// <returns>Return true if the default handle is needed in the request, otherwise return false.</returns>
        private bool IsInvalidInputHandleNeeded(ISerializable ropRequest, RopResponseType expectedRopResponseType)
        {
            if (!Common.IsOutputHandleInRopRequest(ropRequest) && expectedRopResponseType == RopResponseType.FailureResponse)
            {
                byte[] request = ropRequest.Serialize();

                // The default handle is also needed by some cases to verify the failure response caused by an invalid input handle.
                // The input handle index is the third byte and its value is 1 in this test suite for this situation.
                byte inputHandleIndex = request[2];
                if (inputHandleIndex == 1)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:23,代码来源:MS-OXCROPSAdapter.cs

示例5: IsOutputHandleInRopRequest

        /// <summary>
        /// Identify whether the Rop request contains more than one server object handle. Refers to [MS-OXCROPS] for more details.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <returns>Return true if the Rop request contains more than one server object handle, otherwise return false.</returns>
        public static bool IsOutputHandleInRopRequest(ISerializable ropRequest)
        {
            byte ropId = (byte)BitConverter.ToInt16(ropRequest.Serialize(), 0);

            switch (ropId)
            {
                case 0x01: // RopRelease ROP
                case 0x07: // RopGetPropertiesSpecific ROP
                case 0x08: // RopGetPropertiesAll ROP
                case 0x09: // RopGetPropertiesList ROP
                case 0x0A: // RopSetProperties ROP
                case 0x0B: // RopDeleteProperties ROP
                case 0x0D: // RopRemoveAllRecipients ROP
                case 0x0E: // RopModifyRecipients ROP
                case 0x0F: // RopReadRecipients ROP
                case 0x10: // RopReloadCachedInformation ROP
                case 0x12: // RopSetColumns ROP
                case 0x13: // RopSortTable ROP
                case 0x14: // RopRestrict ROP
                case 0x15: // RopQueryRows ROP
                case 0x16: // RopGetStatus ROP
                case 0x17: // RopQueryPosition ROP
                case 0x18: // RopSeekRow ROP
                case 0x19: // RopSeekRowBookmark ROP
                case 0x1A: // RopSeekRowFractional ROP
                case 0x1B: // RopCreateBookmark ROP
                case 0x1D: // RopDeleteFolder ROP
                case 0x1E: // RopDeleteMessages ROP
                case 0x1F: // RopGetMessageStatus ROP
                case 0x20: // RopSetMessageStatus ROP
                case 0x24: // RopDeleteAttachment ROP
                case 0x26: // RopSetReceiveFolder ROP
                case 0x27: // RopGetReceiveFolder ROP
                case 0x2A: // RopNotify ROP
                case 0x2C: // RopReadStream ROP
                case 0x2D: // RopWriteStream ROP
                case 0x2E: // RopSeekStream ROP
                case 0x2F: // RopSetStreamSize ROP
                case 0x30: // RopSetSearchCriteria ROP
                case 0x31: // RopGetSearchCriteria ROP
                case 0x32: // RopSubmitMessage ROP
                case 0x34: // RopAbortSubmit ROP
                case 0x37: // RopQueryColumnsAll ROP
                case 0x38: // RopAbort ROP
                case 0x40: // RopModifyPermissions ROP
                case 0x41: // RopModifyRules ROP
                case 0x42: // RopGetOwningServers ROP
                case 0x43: // RopLongTermIdFromId ROP
                case 0x44: // RopIdFromLongTermId ROP
                case 0x45: // RopPublicFolderIsGhosted ROP
                case 0x47: // RopSetSpooler ROP
                case 0x48: // RopSpoolerLockMessage ROP
                case 0x49: // RopGetAddressTypes ROP
                case 0x4A: // RopTransportSend ROP
                case 0x4E: // RopFastTransferSourceGetBuffer ROP
                case 0x4F: // RopFindRow ROP
                case 0x50: // RopProgress ROP
                case 0x51: // RopTransportNewMail ROP
                case 0x52: // RopGetValidAttachments ROP
                case 0x54: // RopFastTransferDestinationPutBuffer ROP
                case 0x55: // RopGetNamesFromPropertyIds ROP
                case 0x56: // RopGetPropertyIdsFromNames ROP
                case 0x57: // RopUpdateDeferredActionMessages ROP
                case 0x58: // RopEmptyFolder ROP
                case 0x59: // RopExpandRow ROP
                case 0x5A: // RopCollapseRow ROP
                case 0x5B: // RopLockRegionStream ROP
                case 0x5C: // RopUnlockRegionStream ROP
                case 0x5D: // RopCommitStream ROP
                case 0x5E: // RopGetStreamSize ROP
                case 0x5F: // RopQueryNamedProperties ROP
                case 0x60: // RopGetPerUserLongTermIds ROP
                case 0x61: // RopGetPerUserGuid ROP
                case 0x63: // RopReadPerUserInformation ROP
                case 0x64: // RopWritePerUserInformation ROP
                case 0x66: // RopSetReadFlags ROP
                case 0x68: // RopGetReceiveFolderTable ROP
                case 0x6B: // RopGetCollapseState ROP
                case 0x6C: // RopSetCollapseState ROP
                case 0x6D: // RopGetTransportFolder ROP
                case 0x6E: // RopPending ROP
                case 0x6F: // RopOptionsData ROP
                case 0x73: // RopSynchronizationImportHierarchyChange ROP
                case 0x74: // RopSynchronizationImportDeletes ROP
                case 0x75: // RopSynchronizationUploadStateStreamBegin ROP
                case 0x76: // RopSynchronizationUploadStateStreamContinue ROP
                case 0x77: // RopSynchronizationUploadStateStreamEnd ROP
                case 0x78: // RopSynchronizationImportMessageMove ROP
                case 0x79: // RopSetPropertiesNoReplicate ROP
                case 0x7A: // RopDeletePropertiesNoReplicate ROP
                case 0x7B: // RopGetStoreState ROP
                case 0x7F: // RopGetLocalReplicaIds ROP
                case 0x80: // RopSynchronizationImportReadStateChanges ROP
                case 0x81: // RopResetTable ROP
                case 0x86: // RopTellVersion ROP
//.........这里部分代码省略.........
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:101,代码来源:Common.cs


注:本文中的ISerializable.Serialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。