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


C# SerializationInfo.GetOrDefault方法代码示例

本文整理汇总了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);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:13,代码来源:ConnectionParameters.cs

示例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));
            }
        }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:19,代码来源:ServiceResponse.cs

示例3: DomainEventStreamCannotBeReplayedException

 protected DomainEventStreamCannotBeReplayedException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.AggregateRootId = info.GetOrDefault<object>(nameof(this.AggregateRootId), null);
 }
开发者ID:pete-restall,项目名称:Ichnaea,代码行数:5,代码来源:DomainEventStreamCannotBeReplayedException.cs

示例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));
            }
        }
开发者ID:rmc00,项目名称:gsf,代码行数:19,代码来源:ClientRequest.cs

示例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);
        }
开发者ID:rmc00,项目名称:gsf,代码行数:35,代码来源:ClientInfo.cs

示例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);
        }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:30,代码来源:ConnectionSettings.cs

示例7: AggregateRootIdPropertyNotFoundException

 protected AggregateRootIdPropertyNotFoundException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.PropertyName = info.GetOrDefault<string>(nameof(this.PropertyName), null);
 }
开发者ID:pete-restall,项目名称:Ichnaea,代码行数:5,代码来源:AggregateRootIdPropertyNotFoundException.cs

示例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);
 }
开发者ID:pete-restall,项目名称:Ichnaea,代码行数:6,代码来源:AggregateRootIdNotFoundException.cs


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