Пример #1
0
        /// <summary>
        /// Gets new service instance by type.
        /// </summary>
        /// <typeparam name="T">The type of the service.</typeparam>
        /// <returns>New service instance.</returns>
        public T GetService <T>() where T : WebServicesClientProtocol, new()
        {
            var serviceWse = new T
            {
                Url =
                    (string.Format("{0}/Services/{1}.asmx", Settings.Default.TargetProcessPath, typeof(T).Name))
            };

            TpPolicy.ApplyAutheticationTicket(serviceWse, Settings.Default.AdminLogin, Settings.Default.AdminPassword);

            return(serviceWse);
        }
Пример #2
0
        public static T GetService <T>() where T : WebServicesClientProtocol, new()
        {
            T service;

            if (Services.ContainsKey(typeof(T).Name))
            {
                service = (T)Services[typeof(T).Name];
            }
            else
            {
                service = new T {
                    Url = ConnectionInformation.RootServiceUrl + "/Services/" + typeof(T).Name + ".asmx"
                };
                TpPolicy.ApplyAutheticationTicket(service, ConnectionInformation.UserName, ConnectionInformation.Password);
            }
            return(service);
        }