コード例 #1
0
ファイル: Network.cs プロジェクト: BenButzer/iFactr-Data
        /// <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);
        }