Exemplo n.º 1
0
        /// <summary>
        /// Asynchrnoneously queries this method with the provided HTTP POST data
        /// </summary>
        /// <typeparam name="T">The subtype to deserialize (the deserialized type being <see cref="APIResult{T}"/>).</typeparam>
        /// <param name="method">The method to query</param>
        /// <param name="postData">The http POST data</param>
        /// <param name="callback">The callback to invoke once the query has been completed. It will be done on the data actor (see <see cref="DataObject.CommonActor"/>).</param>
        /// <param name="transform">The XSL transform to apply, may be null.</param>
        private void QueryMethodAsync <T>(APIMethods method, HttpPostData postData, XslCompiledTransform transform, QueryCallback <T> callback)
        {
            // Check callback not null
            if (callback == null)
            {
                throw new ArgumentNullException("The callback cannot be null.", "callback");
            }

            // Lazy download
            string url = GetMethodUrl(method);

            Util.DownloadAPIResultAsync <T>(url, postData, transform, (result) =>
            {
                // On failure with a custom method, fallback to CCP
                if (ShouldRetryWithCCP(result))
                {
                    result = s_ccpProvider.QueryMethod <T>(method, postData, transform);
                }

                // If the result is a character sheet, we store the result
                if (method == APIMethods.CharacterSheet && !result.HasError)
                {
                    SerializableAPICharacter sheet = (SerializableAPICharacter)(Object)result.Result;
                    LocalXmlCache.Save(sheet.Name, result.XmlDocument);
                }

                // Invokes the callback
                callback(result);
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Imports data from the given character sheet informations
        /// </summary>
        /// <param name="serial">The serialized character sheet</param>
        protected void Import(SerializableAPICharacter serial)
        {
            Import((SerializableCharacterBase)serial);

            // Implants
            m_implants.Import(serial.Implants);

            // Clean the obsolete entries on plans.
            CleanObsoleteEntries();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Query this method with the provided HTTP POST data
        /// </summary>
        /// <typeparam name="T">The subtype to deserialize (the deserialized type being <see cref="APIResult{T}"/>).</typeparam>
        /// <param name="method">The method to query</param>
        /// <param name="postData">The http POST data</param>
        /// <param name="transform">The XSL transform to apply, may be null.</param>
        /// <returns>The deserialized object</returns>
        private APIResult <T> QueryMethod <T>(APIMethods method, HttpPostData postData, XslCompiledTransform transform)
        {
            // Download
            string url    = GetMethodUrl(method);
            var    result = Util.DownloadAPIResult <T>(url, postData, transform);

            // On failure with a custom method, fallback to CCP
            if (ShouldRetryWithCCP(result))
            {
                return(s_ccpProvider.QueryMethod <T>(method, postData, transform));
            }

            // If the result is a character sheet, we store the result
            if (method == APIMethods.CharacterSheet && !result.HasError)
            {
                SerializableAPICharacter sheet = (SerializableAPICharacter)(Object)result.Result;
                LocalXmlCache.Save(sheet.Name, result.XmlDocument);
            }

            // Returns
            return(result);
        }