Beispiel #1
0
        /// <summary>
        /// Gets the specified resource.
        /// </summary>
        /// <param name="uri">The URI of the resource.</param>
        /// <param name="args">The network resource arguments for the request.</param>
        /// <param name="type">The strategy type for the resource.</param>
        /// <param name="format">The serialization format for the request.</param>
        /// <returns></returns>
        public static string Get(string uri, NetworkResourceArguments args, ResourceStrategyType type, SerializationFormat format)
        {
            if (string.IsNullOrEmpty(uri))
            {
                return(string.Empty);
            }

            ResourceRequest  request  = NetworkResourceLibrary.Instance.GetResourceRequest(uri, type, args);
            ResourceResponse response = request.GetResponse(args.TimeoutMilliseconds);

            return(response.GetResponseString());
        }
Beispiel #2
0
        /// <summary>
        /// Gets a resource using the specified URI.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="uri">The URI of the resource.</param>
        /// <param name="args">The arguments for the request.</param>
        /// <param name="type">The resource strategy type.</param>
        /// <param name="format">The serialization format.</param>
        /// <param name="customSerializerType">Type of the custom serializer.</param>
        /// <returns></returns>
        public static T Get <T>(string uri, NetworkResourceArguments args, ResourceStrategyType type, SerializationFormat format, Type customSerializerType)
        {
            if (string.IsNullOrEmpty(uri))
            {
                return(default(T));
            }

            ResourceRequest  request  = NetworkResourceLibrary.Instance.GetResourceRequest(uri, type, args);
            ResourceResponse response = request.GetResponse(args.TimeoutMilliseconds);

            ISerializer <T> iSerializer = SerializerFactory.Create <T>(format, customSerializerType);
            T obj = iSerializer.DeserializeObject(response.GetResponseBytes());

            return(obj);
        }