コード例 #1
0
        /// <summary>
        /// Initiates a new instance of the <see cref="SpecializedSessionManagementMethodBase"/> class.
        /// </summary>
        /// <param name="sessionManagementMethod">The generic session management method.</param>
        /// <param name="supportedMethodName">The method name this specialized class supports.</param>
        protected SpecializedSessionManagementMethodBase(SessionManagementMethod sessionManagementMethod, string supportedMethodName)
        {
            if (sessionManagementMethod == null)
            {
                throw new ArgumentNullException(nameof(sessionManagementMethod));
            }
            if (sessionManagementMethod.MethodName != supportedMethodName)
            {
                throw new InvalidOperationException(Resources.InvalidSessionManagementMethodSupplied);
            }

            BaseSessionManagementMethod = sessionManagementMethod;
            SupportedMethodName         = supportedMethodName;

            base.MethodName = supportedMethodName;
        }
コード例 #2
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                var sessionManagementMethodObject = JObject.Load(reader);
                var sessionManagementMethod       = new SessionManagementMethod
                {
                    MethodName = sessionManagementMethodObject.Value <string>(NamePropertyName)
                };

                var parameterProperties = sessionManagementMethodObject.Properties()
                                          .Where(p => p.Name != NamePropertyName);

                foreach (var parameterProperty in parameterProperties)
                {
                    sessionManagementMethod.Parameters.Add(parameterProperty.Name, parameterProperty.Value.ToString());
                }

                return(sessionManagementMethod);
            }