Пример #1
0
        public List <SentimentPhrase> GetSentimentPhrases(string configId = null)
        {
            AuthResponse           authResponse = this.Get <SentimentPhrase>(configId);
            List <SentimentPhrase> obj          = new List <SentimentPhrase>();

            switch (_format)
            {
            case "json":
            {
                List <SentimentPhrase> result = this.ProcessGetResponse <List <SentimentPhrase> >(authResponse);
                if (result != null)
                {
                    obj = result;
                }
            }
            break;

            case "xml":
            {
                SentimentPhrases result = this.ProcessGetResponse <SentimentPhrases>(authResponse);
                if (result != null)
                {
                    obj = result.Data;
                }
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(obj);
        }
Пример #2
0
        private object GetStub <T>(List <T> items)
        {
            object data = null;

            if (typeof(T).Equals(typeof(Configuration)))
            {
                data = new Configurations(items as List <Configuration>);
            }
            else if (typeof(T).Equals(typeof(Category)))
            {
                data = new Categories(items as List <Category>);
            }
            else if (typeof(T).Equals(typeof(String)))
            {
                data = new Blacklists(items as List <string>);
            }
            else if (typeof(T).Equals(typeof(Query)))
            {
                data = new Queries(items as List <Query>);
            }
            else if (typeof(T).Equals(typeof(UserEntity)))
            {
                data = new UserEntities(items as List <UserEntity>);
            }
            else if (typeof(T).Equals(typeof(SentimentPhrase)))
            {
                data = new SentimentPhrases(items as List <SentimentPhrase>);
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }

            return(data);
        }
Пример #3
0
        private List<SentimentPhrase> RequestSentimentPhrases(string url)
        {
            AuthResponse authResponse = this.RunRequest(QueryMethod.GET, url, null);
            List<SentimentPhrase> obj = new List<SentimentPhrase>();

            switch (_format)
            {
                case "json":
                    {
                        List<SentimentPhrase> result = ProcessGetResponse<List<SentimentPhrase>>(authResponse);
                        if (result != null) obj = result;
                    }
                    break;
                case "xml":
                    {
                        SentimentPhrases result = ProcessGetResponse<SentimentPhrases>(authResponse);
                        if (result != null) obj = result.Data;
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return obj;
        }