Ejemplo n.º 1
0
        public static sDadosEnum[] RetornarDadosEnum <T>(this System.Web.Services.Protocols.SoapHttpClientProtocol valor)
        {
            Assembly assembly = valor.GetType().Assembly;
            Type     type     = assembly.GetType(valor.GetType().FullName);

            object        activator  = Activator.CreateInstance(type);
            List <object> parametros = new List <object>();

            parametros.Add(typeof(T).Name);

            var listaRetono1 = type.InvokeMember(
                "RetornarDadosEnum",
                BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public,
                null,
                activator,
                parametros.ToArray());

            IEnumerable <string> listaRetono = listaRetono1 as IEnumerable <string>;

            if (listaRetono.Count().Equals(0))
            {
                return(null);
            }
            else
            {
                var listaEnum = Enum.GetValues(typeof(T))
                                .OfType <Enum>()
                                .Select(s => new
                {
                    Item       = s,
                    ItemString = s.ToString()
                });

                var listaDadorEnum = listaRetono
                                     .Select(s => s.Split(new string[] { FGlobus.Util.Constantes.CARACTER_SEPARACAO }, StringSplitOptions.None))
                                     .Select(s => new
                {
                    ItemString = s.FirstOrDefault(),
                    Descricao  = s.LastOrDefault()
                });

                IEnumerable <sDadosEnum> listaDadosEnum =
                    (from a in listaEnum
                     join b in listaDadorEnum on a.ItemString equals b.ItemString into join_b
                     from b in join_b.DefaultIfEmpty()
                     select new sDadosEnum()
                {
                    Descricao = b == null ? a.Item.ToString() : b.Descricao,
                    Valor = a.Item
                });

                return(listaDadosEnum
                       .ToArray());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Impostazione dell'url del webservice
        /// </summary>
        /// <param name="module"></param>
        /// <param name="serviceInstance"></param>
        private static void SetServiceInstanceUrl(string module, System.Web.Services.Protocols.SoapHttpClientProtocol serviceInstance)
        {
            string httpBindingClassName = serviceInstance.GetType().Name;
            string serviceName          = httpBindingClassName.Remove(httpBindingClassName.IndexOf("SOAPHTTPBinding"));

            serviceInstance.Url = string.Concat(OCSConfigurations.GetServiceUrl(), string.Format("{0}/{1}SOAPHTTPPort", module, serviceName));
        }