本文整理汇总了C#中System.Runtime.Serialization.SerializationInfo.GetOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationInfo.GetOrDefault方法的具体用法?C# SerializationInfo.GetOrDefault怎么用?C# SerializationInfo.GetOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Serialization.SerializationInfo
的用法示例。
在下文中一共展示了SerializationInfo.GetOrDefault方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectionParameters
/// <summary>
/// Creates a new <see cref="ConnectionParameters"/> from serialization parameters.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
/// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
protected ConnectionParameters(SerializationInfo info, StreamingContext context)
{
// Deserialize connection parameters
m_timeOffset = info.GetOrDefault("timeOffset", Common.DefaultTimeOffset);
m_frameRate = info.GetOrDefault("frameRate", Common.DefaultFrameRate);
m_nominalFrequency = info.GetOrDefault("nominalFrequency", Common.DefaultNominalFrequency);
m_stationName = info.GetOrDefault("stationName", Common.DefaultStationName);
}
示例2: ServiceResponse
/// <summary>
/// Creates a new <see cref="ClientRequest"/> from serialization parameters.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
/// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
protected ServiceResponse(SerializationInfo info, StreamingContext context)
{
// Deserialize client request fields
m_type = info.GetOrDefault("type", "");
m_message = info.GetOrDefault("message", "");
m_attachments = new List<object>();
int attachmentCount = info.GetOrDefault("attachmentCount", 0);
for (int i = 0; i < attachmentCount; i++)
{
m_attachments.Add(info.GetOrDefault("attachment" + i, null as object));
}
}
示例3: DomainEventStreamCannotBeReplayedException
protected DomainEventStreamCannotBeReplayedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
this.AggregateRootId = info.GetOrDefault<object>(nameof(this.AggregateRootId), null);
}
示例4: ClientRequest
/// <summary>
/// Creates a new <see cref="ClientRequest"/> from serialization parameters.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
/// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
protected ClientRequest(SerializationInfo info, StreamingContext context)
{
// Deserialize client request fields
m_command = info.GetOrDefault("command", "");
m_arguments = info.GetOrDefault("arguments", new Arguments(""));
m_attachments = new List<object>();
int attachmentCount = info.GetOrDefault("attachmentCount", 0);
for (int i = 0; i < attachmentCount; i++)
{
m_attachments.Add(info.GetOrDefault("attachment" + i, null as object));
}
}
示例5: ClientInfo
/// <summary>
/// Creates a new <see cref="ClientInfo"/> from serialization parameters.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
/// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
protected ClientInfo(SerializationInfo info, StreamingContext context)
{
// Deserialize client request fields
m_clientID = info.GetOrDefault("clientID", Guid.Empty);
m_clientType = info.GetOrDefault("clientType", ApplicationType.Unknown);
m_clientName = info.GetOrDefault("clientName", "__undefined");
m_clientUserCredentials = info.GetOrDefault("clientUserCredentials", "");
string clientUserName = null;
if (!string.IsNullOrEmpty(m_clientUserCredentials))
{
string[] parts = m_clientUserCredentials.Split(':');
if (parts.Length == 2)
clientUserName = parts[0].Trim();
if (string.IsNullOrEmpty(clientUserName))
clientUserName = null;
}
// Initialize user principal.
if (m_clientType == ApplicationType.Web)
m_clientUser = new GenericPrincipal(new GenericIdentity(clientUserName ?? UserInfo.RemoteUserID), new string[] { });
else
m_clientUser = new GenericPrincipal(new GenericIdentity(clientUserName ?? UserInfo.CurrentUserID), new string[] { });
m_machineName = info.GetOrDefault("machineName", "__unknown");
m_connectedAt = info.GetOrDefault("connectedAt", DateTime.UtcNow);
}
示例6: ConnectionSettings
/// <summary>
/// Creates a new <see cref="ConnectionSettings"/> instance from serialization parameters.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
/// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
protected ConnectionSettings(SerializationInfo info, StreamingContext context)
{
// Deserialize connection settings values
if (!Enum.TryParse(info.GetOrDefault("PhasorProtocol", "IEEEC37_118V1"), true, out PhasorProtocol))
PhasorProtocol = PhasorProtocol.IEEEC37_118V1;
if (!Enum.TryParse(info.GetOrDefault("TransportProtocol", "Tcp"), true, out TransportProtocol))
TransportProtocol = TransportProtocol.Tcp;
ConnectionString = info.GetOrDefault("ConnectionString", (string)null);
if (!int.TryParse(info.GetOrDefault("PmuID", "1"), out PmuID))
PmuID = 1;
if (!int.TryParse(info.GetOrDefault("FrameRate", "30"), out FrameRate))
FrameRate = 30;
if (!(info.GetOrDefault("AutoRepeatPlayback", "false")).ParseBoolean())
AutoRepeatPlayback = false;
if (!int.TryParse(info.GetOrDefault("ByteEncodingDisplayFormat", "0"), out ByteEncodingDisplayFormat))
ByteEncodingDisplayFormat = 0;
ConnectionParameters = info.GetOrDefault("ConnectionParameters", (IConnectionParameters)null);
}
示例7: AggregateRootIdPropertyNotFoundException
protected AggregateRootIdPropertyNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
this.PropertyName = info.GetOrDefault<string>(nameof(this.PropertyName), null);
}
示例8: AggregateRootIdNotFoundException
protected AggregateRootIdNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
this.AggregateRootType = info.GetOrDefault<Type>(nameof(this.AggregateRootType), null);
this.AggregateRootIdType = info.GetOrDefault<Type>(nameof(this.AggregateRootIdType), null);
}