本文整理汇总了C#中ISerializable类的典型用法代码示例。如果您正苦于以下问题:C# ISerializable类的具体用法?C# ISerializable怎么用?C# ISerializable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISerializable类属于命名空间,在下文中一共展示了ISerializable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SerializeObject
public static void SerializeObject(String filename, ISerializable objectToSerialize)
{
Stream stream = File.Open(filename, FileMode.Create);
var bFormatter = new BinaryFormatter();
bFormatter.Serialize(stream, objectToSerialize);
stream.Close();
}
开发者ID:r0llup,项目名称:ProjectReport,代码行数:7,代码来源:Serializer.cs
示例2: 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
示例3: LoguearObservaciones
public void LoguearObservaciones( string mensaje, ISerializable serializable )
{
if ( !string.IsNullOrEmpty( mensaje ) )
{
this.Loguear( serializable.Serializar() + "\r\n" + mensaje );
}
}
开发者ID:GonzaloFernandoA,项目名称:FacturacionElectronica,代码行数:7,代码来源:LogueadorFe.cs
示例4: Serialize
protected byte[] Serialize(ISerializable obj)
{
MemoryStream memoryStream = new MemoryStream();
this.binaryFormatter.Serialize(memoryStream, obj);
byte[] array = new byte[memoryStream.Length];
Array.Copy(memoryStream.GetBuffer(), array, memoryStream.Length);
return array;
}
开发者ID:chharam,项目名称:Capstone_IPM_RV,代码行数:8,代码来源:NamedPipeBase.cs
示例5: SendMessage
protected void SendMessage(ISerializable request)
{
byte[] array = this.Serialize(request);
LengthRecord obj = new LengthRecord(array.Length);
byte[] array2 = this.Serialize(obj);
D.Assert(array2.Length == 147);
this.WriteBuffer(array2, array2.Length);
this.WriteBuffer(array, array.Length);
}
开发者ID:chharam,项目名称:Capstone_IPM_RV,代码行数:9,代码来源:NamedPipeBase.cs
示例6: SNKeyPairDerivedClone
public SNKeyPairDerived SNKeyPairDerivedClone(ISerializable inter)
{
SerializationInfo info = new SerializationInfo(typeof(StrongNameKeyPair), new FormatterConverter());
StreamingContext context = new StreamingContext();
inter.GetObjectData(info, context);
return new SNKeyPairDerived(info, context);
}
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:StrongNameKeyPairTests.netstandard1.7.cs
示例7: QueueForIndex
public void QueueForIndex(ISerializable serializable, int size)
{
IndexInfo info;
info.size = size;
info.typeCode = serializable.TypeReference; //For guilds, this will automagically be zero.
info.serial = serializable.SerialIdentity;
this._orderedIndexInfo.Add(info);
}
开发者ID:Crome696,项目名称:ServUO,代码行数:11,代码来源:QueuedMemoryWriter.cs
示例8: Server
internal bool Server(object genericRequest, ref ISerializable reply)
{
if (genericRequest is OpenRequest)
{
OpenRequest openRequest = (OpenRequest)genericRequest;
if (this.foxitViewer != null)
{
reply = new ExceptionMessageRecord("Already open");
return true;
}
try
{
this.foxitViewer = new FoxitViewer(openRequest.filename, openRequest.pageNumber);
reply = new RectangleFRecord(this.foxitViewer.GetPageSize());
bool result = true;
return result;
}
catch (Exception ex)
{
reply = new ExceptionMessageRecord(ex.Message);
bool result = false;
return result;
}
}
if (genericRequest is RenderRequest)
{
RenderRequest renderRequest = (RenderRequest)genericRequest;
if (this.foxitViewer == null)
{
reply = new ExceptionMessageRecord("Not open");
return true;
}
try
{
reply = this.foxitViewer.RenderBytes(renderRequest.outputSize, renderRequest.topLeft, renderRequest.pageSize, renderRequest.transparentBackground);
bool result = true;
return result;
}
catch (Exception ex2)
{
reply = new ExceptionMessageRecord(ex2.Message);
bool result = true;
return result;
}
}
if (genericRequest is QuitRequest)
{
reply = new AckRecord();
return false;
}
reply = new ExceptionMessageRecord("Unrecognized request type " + genericRequest.GetType().ToString());
return true;
}
开发者ID:mikhp,项目名称:greatmaps,代码行数:53,代码来源:RemoteFoxitServer.cs
示例9: TestWrite
private void TestWrite(ISerializable serializable, Action<BinaryReader> check)
{
using (var ms = new MemoryStream())
using (var writer = new BinaryWriter(ms))
{
var serializer = new BinaryWriteSerializer();
serializer.Serialize(serializable, writer);
ms.Seek(0, SeekOrigin.Begin);
using (var reader = new BinaryReader(ms))
{
check(reader);
}
}
}
开发者ID:YAWL,项目名称:YAWL.Serialization,代码行数:16,代码来源:BinaryWriteSerializerTests.cs
示例10: SurrogateForISerializable
public SurrogateForISerializable(ISerializable serializable)
{
var serializationInfo = new SerializationInfo(serializable.GetType(), new FormatterConverter());
var streamingContext = new StreamingContext(StreamingContextStates.Clone);
serializable.GetObjectData(serializationInfo, streamingContext);
keys = new string[serializationInfo.MemberCount];
values = new object[serializationInfo.MemberCount];
var i = 0;
foreach(var entry in serializationInfo)
{
keys[i] = entry.Name;
values[i] = entry.Value;
i++;
}
assemblyQualifiedName = serializable.GetType().AssemblyQualifiedName;
}
开发者ID:rogeralsing,项目名称:Migrant,代码行数:16,代码来源:SurrogateForISerializable.cs
示例11: serializeFromISerializable
private void serializeFromISerializable(ISerializable data)
{
m_CustomData = new Dictionary<string,CustomTypedEntry>();
var info = new SerializationInfo(data.GetType(), new FormatterConverter());
StreamingContext streamingContext = new StreamingContext(StreamingContextStates.Persistence);
data.GetObjectData(info, streamingContext);
var senum = info.GetEnumerator();
while(senum.MoveNext())
{
var value = new CustomTypedEntry();
value.TypeIndex = MetaType.GetExistingOrNewMetaTypeIndex( m_Document, senum.ObjectType );
value.Data = m_Document.NativeDataToPortableData( senum.Value );
m_CustomData[senum.Name] = value;
}
}
开发者ID:vlapchenko,项目名称:nfx,代码行数:18,代码来源:CompositeCustomData.cs
示例12: RobustRPC
public object RobustRPC(ISerializable request)
{
object result;
try
{
this.Establish();
result = this.namedPipeServer.RPC(request);
}
catch (Exception)
{
this.Teardown();
this.Establish();
result = this.namedPipeServer.RPC(request);
}
this.namedPipeServer.childProcess.Refresh();
if (this.namedPipeServer.childProcess.VirtualMemorySize64 > 1073741824L || this.namedPipeServer.childProcess.HandleCount > 512)
{
this.Teardown();
}
return result;
}
开发者ID:mikhp,项目名称:greatmaps,代码行数:21,代码来源:RemoteFoxitStub.cs
示例13: SaveISerializeAbleObjectToFile
public static bool SaveISerializeAbleObjectToFile(String _File, ISerializable _ISerializableObject)
{
String var_Path = _File.Remove(_File.LastIndexOf("/"));
if (CreatePath(var_Path))
{
try
{
Utility.Serializer.SerializeObject(_File, _ISerializableObject);
return true;
}
catch
{
// Error!
}
}
else
{
// Error!
}
return false;
}
开发者ID:Gothen111,项目名称:2DWorld,代码行数:22,代码来源:IOManager.cs
示例14: GetMembers
static IObjectMemberInfo[] GetMembers(ISerializable value, Type type)
{
IObjectMemberInfo[] mis = null;
if (value == null)
{
if (serialCache.TryGetValue(type, out mis)) return mis;
// 尝试创建type的实例
value = GetDefaultObject(type) as ISerializable;
}
SerializationInfo info = new SerializationInfo(type, new FormatterConverter());
value.GetObjectData(info, DefaultStreamingContext);
List<IObjectMemberInfo> list = new List<IObjectMemberInfo>();
foreach (SerializationEntry item in info)
{
list.Add(CreateObjectMemberInfo(item.Name, item.ObjectType, item.Value));
}
mis = list.ToArray();
if (!serialCache.ContainsKey(type))
{
lock (serialCache)
{
if (!serialCache.ContainsKey(type)) serialCache.Add(type, mis);
}
}
return mis;
}
开发者ID:windygu,项目名称:asxinyunet,代码行数:32,代码来源:ObjectInfo.cs
示例15: createSIF_Request
// TODO: Implement
/*
private SIF_Request createSIF_Request( ElementDef objectType, String refId, Zone zone )
{
SIF_Request request = new SIF_Request();
request.getHeader().setSIF_MsgId( MSG_GUID );
request.getHeader().setSIF_SourceId( "foo" );
request.setSIF_MaxBufferSize("32768");
request.setSIF_Version( ADK.getSIFVersion().toString() );
Query query = new Query(objectType);
query.addCondition(SifDtd.SIF_REPORTOBJECT_REFID, Condition.EQ, refId);
SIF_Query q = SIFPrimitives.createSIF_Query(query, zone);
SIF_QueryObject sqo = new SIF_QueryObject();
sqo.setObjectName( objectType.name() );
q.setSIF_QueryObject(sqo);
request.setSIF_Query(q);
return request;
}
*/
private SIF_Response createSIF_Response(IElementDef objType, bool storeInRequestCache, ISerializable stateObject)
{
SIF_Request req = createSIF_Request(objType);
if (storeInRequestCache)
{
Query q = new Query(objType);
q.UserData = stateObject;
RequestCache.GetInstance(fAgent).StoreRequestInfo(req, q, fZone);
}
SIF_Response resp = new SIF_Response();
resp.SIF_RequestMsgId = req.Header.SIF_MsgId;
SIF_ObjectData sod = new SIF_ObjectData();
resp.SIF_ObjectData = sod;
Object responseObject = null;
try
{
responseObject = ClassFactory.CreateInstance(objType.FQClassName, false);
}
catch (Exception cfe)
{
throw new AdkException("Unable to create instance of " + objType.Name, fZone, cfe);
}
sod.AddChild((SifElement)responseObject);
return resp;
}
开发者ID:rafidzal,项目名称:OpenADK-csharp,代码行数:53,代码来源:MessageDispatcherTests.cs
示例16: Process
/// <summary>
/// Send ROP request with single operation and get ROP response.
/// </summary>
/// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
/// <param name="ropRequest">ROP request object.</param>
/// <param name="inputHandle">Server object handle in request.</param>
/// <returns>ROP response object.</returns>
private IDeserializable Process(int serverId, ISerializable ropRequest, uint inputHandle)
{
List<ISerializable> inputBuffer = new List<ISerializable>
{
ropRequest
};
List<uint> requestSOH = new List<uint>();
requestSOH.Add(inputHandle);
if (Common.IsOutputHandleInRopRequest(ropRequest))
{
requestSOH.Add(0xFFFFFFFF);
}
List<IDeserializable> responses = new List<IDeserializable>();
List<List<uint>> responseSOHTable = new List<List<uint>>();
byte[] rawData = null;
this.ropResult = this.oxcropsClient[serverId].RopCall(inputBuffer, requestSOH, ref responses, ref responseSOHTable, ref rawData, 0x10008);
if (this.ropResult == OxcRpcErrorCode.ECNone)
{
this.responseSOHs = responseSOHTable[0];
this.VerifyMAPITransport();
}
if (responses.Count > 0)
{
return responses[0];
}
else
{
return null;
}
}
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:40,代码来源:MS-OXCFXICSAdapter.cs
示例17: OnDragDataReceived
private void OnDragDataReceived(object sender, DragDataReceivedArgs e)
{
byte[] data = e.SelectionData.Data;
Int64 value = BitConverter.ToInt64(data, 0);
if (value != 0)
{
GCHandle handle = (GCHandle)new IntPtr(value);
DragDropData = (ISerializable)handle.Target;
}
}
开发者ID:hut104,项目名称:ApsimX,代码行数:10,代码来源:ExplorerView.cs
示例18: SerializableWrapper
public SerializableWrapper(ISerializable ser)
{
_ser = ser;
}
开发者ID:matthiaskaiser,项目名称:ExploitRemotingService,代码行数:4,代码来源:SerializableWrapper.cs
示例19: SerializeISerializable
private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract)
{
contract.InvokeOnSerializing(value, Serializer.Context);
SerializeStack.Add(value);
writer.WriteStartObject();
SerializationInfo serializationInfo = new SerializationInfo(contract.UnderlyingType, new FormatterConverter());
value.GetObjectData(serializationInfo, Serializer.Context);
foreach (SerializationEntry serializationEntry in serializationInfo)
{
writer.WritePropertyName(serializationEntry.Name);
SerializeValue(writer, serializationEntry.Value, GetContractSafe(serializationEntry.Value), null, null);
}
writer.WriteEndObject();
SerializeStack.RemoveAt(SerializeStack.Count - 1);
contract.InvokeOnSerialized(value, Serializer.Context);
}
开发者ID:JungWon2,项目名称:memory_book,代码行数:21,代码来源:JsonSerializerInternalWriter.cs
示例20: 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
注:本文中的ISerializable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论