コード例 #1
0
        /// <summary>
        /// Creates an instance of the CommonSubscriptionData class and sets the notification channel and the
        /// shared key information.
        /// </summary>
        /// 
        /// <param name="notificationChannel">The channel to use for notifications.</param>
        /// <param name="sharedKeyInfo">The shared key to use for authentication.</param>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="notificationChannel"/> parameter is <b>null</b>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="sharedKeyInfo"/> parameter is <b>null</b>.
        /// </exception>
        public CommonSubscriptionData(
                NotificationChannel notificationChannel, 
                NotificationAuthenticationSharedKeyInfo sharedKeyInfo)
        {
            Validator.ThrowIfArgumentNull(notificationChannel, "notificationChannel", "NotificationChannelNull");
            Validator.ThrowIfArgumentNull(sharedKeyInfo, "sharedKeyInfo", "ArgumentNull");

            _notificationChannel = notificationChannel;
            _sharedKeyInfo = sharedKeyInfo;
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of the CommonSubscriptionData class and sets the notification channel, the shared
        /// key information and the unique identifier for the subscription.
        /// </summary>
        /// 
        /// <param name="notificationChannel">The channel to use for notifications.</param>
        /// <param name="sharedKeyInfo">The shared key to use for authentication.</param>
        /// <param name="id">The id of the subscription.</param>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="notificationChannel"/> parameter is <b>null</b>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="sharedKeyInfo"/> parameter is <b>null</b>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The <paramref name="id"/> parameter is an empty GUID.
        /// </exception>
        public CommonSubscriptionData(
                NotificationChannel notificationChannel, 
                NotificationAuthenticationSharedKeyInfo sharedKeyInfo, 
            Guid id)
            : this(notificationChannel, sharedKeyInfo)
        {
            Validator.ThrowArgumentExceptionIf(id == Guid.Empty, "id", "EmptyGuid");

            _id = id;
        }
コード例 #3
0
        /// <summary>
        /// Populate the CommonSubscriptionData instance from XML.
        /// </summary>
        /// <param name="navigator">The XPathNavigator.</param>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="navigator"/> parameter is <b>null</b>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The <paramref name="navigator"/> parameter does not contain a "common" node.
        /// </exception>
        public void ParseXml(XPathNavigator navigator)
        {
            Validator.ThrowIfNavigatorNull(navigator);

            XPathNavigator commonNav = navigator.SelectSingleNode("common");
            Validator.ThrowArgumentExceptionIf(commonNav == null, "navigator", "MissingCommonNode");

            XPathNavigator idNav = commonNav.SelectSingleNode("id");
            if (idNav != null)
            {
                _id = new Guid(idNav.Value);
            }

            XPathNavigator notificationAuthNode = commonNav.SelectSingleNode("notification-authentication-info");
            if (notificationAuthNode != null)
            {
                XPathNavigator sharedKeyNav = notificationAuthNode.SelectSingleNode("hv-eventing-shared-key");

                _sharedKeyInfo = new NotificationAuthenticationSharedKeyInfo();
                _sharedKeyInfo.ParseXml(sharedKeyNav);
            }

            XPathNavigator channelNav = commonNav.SelectSingleNode("notification-channel");
            if (channelNav != null)
            {
                XPathNodeIterator children = channelNav.SelectChildren(XPathNodeType.Element);
                XPathNavigator child = children.Current;
                _notificationChannel = NotificationChannel.Deserialize(child);
            }
        }