예제 #1
0
        private string Subscribe(ConnectionInfo connectioninfo, string query)
        {
            var credentialType = connectioninfo.SupportsActiveSubscriptions ? "None" : _subscriptionListener.GetCredentialTypeForBinding(connectioninfo.Binding);

            PropertyBag propertyBag = new PropertyBag
            {
                { "Query", query },
                { "EndpointAddress", connectioninfo.SupportsActiveSubscriptions ? _activeSubscriberAddress : _subscriptionListener.GetAddressForBinding(connectioninfo.Binding) },
                { "Description", "SWQL Studio" },
                { "DataFormat", "Xml" },
                { "CredentialType", credentialType }
            };

            propertyBag["Binding"] = connectioninfo.Binding.Scheme.Equals("http") ? "Soap1_1" : "NetTcp";

            if (credentialType.Equals("Username"))
            {
                propertyBag.Add("Username", "subscriber");
                propertyBag.Add("Password", "subscriber");
            }

            return(ConnectionInfo.DoWithExceptionTranslation(() => connectioninfo.Proxy.Create("System.Subscription", propertyBag)));
        }