Click here to Skip to main content
15,887,361 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I deserialize/Load Different XML files? Pin
Richard MacCutchan14-Jun-18 21:31
mveRichard MacCutchan14-Jun-18 21:31 
GeneralRe: How can I deserialize/Load Different XML files? Pin
SebGM201814-Jun-18 10:52
SebGM201814-Jun-18 10:52 
QuestionUsing Email Retrieval (EAGetMail) in Unity Pin
Member 1387162013-Jun-18 8:53
Member 1387162013-Jun-18 8:53 
AnswerRe: Using Email Retrieval (EAGetMail) in Unity Pin
Gerry Schmitz13-Jun-18 10:34
mveGerry Schmitz13-Jun-18 10:34 
QuestionMoving File to corresponding folders Pin
SanjaV 13-Jun-18 8:16
SanjaV 13-Jun-18 8:16 
AnswerRe: Moving File to corresponding folders Pin
BillWoodruff13-Jun-18 22:41
professionalBillWoodruff13-Jun-18 22:41 
AnswerRe: Moving File to corresponding folders Pin
User 418025414-Jun-18 7:02
User 418025414-Jun-18 7:02 
Questionthe code c# below that does not compile Pin
Member 1366398513-Jun-18 6:06
Member 1366398513-Jun-18 6:06 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using HtmlAgilityPack;
using System.Net;
using System.IO;

namespace DocumentosSubsidios.Infrastructure.RobotBase
{
    public abstract class BaseRoboAddress
    {
        public enum EncodingEnum
        {
            Default,
            UTF8,
            ASCII,
            ISO_8859_1, 
            ANSICodePage

        }

        public BaseRoboAddress() { }

        public BaseRoboBaseRoboAddress(WebClientSession webClientSession)
        {
            this._webClientSession = webClientSession;
        }

        public delegate void MyMethodInvoker<T>(T t);
        public event MyMethodInvoker<string> ResultRequest;

        #region [Membros Privados]

        private CredentialCache _credentialCache;
        private WebClientSession _webClientSession;

        private CookieCollection _cookies = null;
        private HtmlNodeCollection _inputs = null;

        #endregion

        #region [Propriedades]

        public WebClientSession WebClientSession
        {
            get
            {
                if (_webClientSession == null) _webClientSession = new WebClientSession();
                return _webClientSession;
            }
            set
            {
                _webClientSession = value;
            }
        }
        private CredentialCache mCredentialCache
        {
            get
            {
                if (_credentialCache == null) _credentialCache = new CredentialCache();
                return _credentialCache;
            }
            set
            {
                _credentialCache = value;
            }
        }

        public CookieCollection Cookies
        {
            get
            {
                if (_cookies == null)
                    _cookies = new CookieCollection();

                return _cookies;
            }
            set { _cookies = value; }
        }
        public HtmlNodeCollection Inputs
        {
            get
            {
                if (_inputs == null)
                    _inputs = new HtmlNodeCollection(null);

                return _inputs;
            }
            set { _inputs = value; }
        }

        #endregion

        #region [Métodos Publicos]

        public virtual HtmlDocument Get(string url)
        {
            return this.Get(url, false, EncodingEnum.UTF8);
        }

        public HtmlDocument Get(string url, EncodingEnum encoding)
        {
            return this.Get(url, false, encoding);
        }

        public HtmlDocument Get(string url, bool fire, EncodingEnum encoding)
        {
            HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            byte[] pagina = this.WebClientSession.DownloadData(url);

            switch (encoding)
            {
                case EncodingEnum.UTF8:
                    htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
                    break;

                case EncodingEnum.ASCII:
                    htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
                    break;

                case EncodingEnum.Default:
                    htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
                    break;

                case EncodingEnum.ISO_8859_1:
                    htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
                    break;
            }

            return htmlDocument;
        }

        public HtmlDocument Post(string url, NameValueCollection parametros, bool fire)
        {
            return this.Post(url, parametros, fire, EncodingEnum.UTF8);
        }

        public HtmlDocument Post(string url, NameValueCollection parametros, EncodingEnum encoding)
        {
            return this.Post(url, parametros, true, encoding);
        }

        public HtmlDocument Post(string url, NameValueCollection parametros)
        {
            return this.Post(url, parametros, true);
        }

        public HtmlDocument Post(string url, NameValueCollection parametros, bool fire, EncodingEnum encoding)
        {
            HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            byte[] pagina = this.WebClientSession.UploadValues(url, parametros);

            switch (encoding)
            {
                case EncodingEnum.Default:
                    htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
                    break;
                case EncodingEnum.UTF8:
                    htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
                    break;
                case EncodingEnum.ASCII:
                    htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
                    break;

                case EncodingEnum.ISO_8859_1:
                    htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
                    break;
            }

            return htmlDocument;
        }

        public byte[] PostBinario(string url, NameValueCollection parametros)
        {
            HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            return this.WebClientSession.UploadValues(url, parametros);
        }

        public HtmlDocument PostData(string url, IEnumerable<byte> IBody, bool fire)
        {
            lock (this)
            {

                HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
                byte[] pagina = this.WebClientSession.UploadData(url, "POST", IBody.ToArray());
                htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
                return htmlDocument;
            }
        }

        public HtmlDocument PostData(string url, IEnumerable<byte> IBody)
        {
            return this.PostData(url, IBody, true);
        }

        public HtmlDocument PostData(string url, IEnumerable<byte> IBody, EncodingEnum encoding)
        {
            lock (this)
            {
                byte[] pagina = this.WebClientSession.UploadData(url, "POST", IBody.ToArray());
                HtmlDocument htmlDocument = LoadHtmlDocument(encoding, pagina);
                return htmlDocument;
            }
        }

        private HtmlDocument LoadHtmlDocument(EncodingEnum encoding, byte[] pagina)
        {
            HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            switch (encoding)
            {
                case EncodingEnum.Default:
                    htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
                    break;
                case EncodingEnum.UTF8:
                    htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
                    break;
                case EncodingEnum.ASCII:
                    htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
                    break;

                case EncodingEnum.ISO_8859_1:
                    htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
                    break;
            }
            return htmlDocument;
        }

AnswerRe: the code c# below that does not compile Pin
OriginalGriff13-Jun-18 6:19
mveOriginalGriff13-Jun-18 6:19 
GeneralRe: the code c# below that does not compile Pin
Member 1366398513-Jun-18 16:10
Member 1366398513-Jun-18 16:10 
GeneralRe: the code c# below that does not compile Pin
OriginalGriff13-Jun-18 21:32
mveOriginalGriff13-Jun-18 21:32 
AnswerRe: the code c# below that does not compile Pin
Gerry Schmitz13-Jun-18 7:48
mveGerry Schmitz13-Jun-18 7:48 
GeneralRe: the code c# below that does not compile Pin
Member 1366398513-Jun-18 16:16
Member 1366398513-Jun-18 16:16 
QuestionHow to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha11-Jun-18 22:13
Mohammad Abdullaha11-Jun-18 22:13 
AnswerRe: How to make an android phone does calls to people using vc#.net Pin
OriginalGriff11-Jun-18 23:03
mveOriginalGriff11-Jun-18 23:03 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha12-Jun-18 3:58
Mohammad Abdullaha12-Jun-18 3:58 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
OriginalGriff12-Jun-18 4:37
mveOriginalGriff12-Jun-18 4:37 
AnswerRe: How to make an android phone does calls to people using vc#.net Pin
Pete O'Hanlon11-Jun-18 23:14
mvePete O'Hanlon11-Jun-18 23:14 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha12-Jun-18 3:53
Mohammad Abdullaha12-Jun-18 3:53 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Richard MacCutchan12-Jun-18 9:05
mveRichard MacCutchan12-Jun-18 9:05 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Richard Andrew x6412-Jun-18 12:10
professionalRichard Andrew x6412-Jun-18 12:10 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Richard MacCutchan12-Jun-18 21:13
mveRichard MacCutchan12-Jun-18 21:13 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Pete O'Hanlon12-Jun-18 21:26
mvePete O'Hanlon12-Jun-18 21:26 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha13-Jun-18 5:29
Mohammad Abdullaha13-Jun-18 5:29 
AnswerRe: How to make an android phone does calls to people using vc#.net Pin
Gerry Schmitz13-Jun-18 7:42
mveGerry Schmitz13-Jun-18 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.