Exemplo n.º 1
0
        /// <summary>
        /// For Unit Testing, allowing mocking of the LevelUpHttpRestfulService.  Note
        /// that the AssemblyInfo.cs file enables internals to be visible to the unit
        /// test project.
        /// </summary>
        internal static T Create <T>(AgentIdentifier identifier, LevelUpEnvironment enviornment, IRestfulService restService)
            where T : ILevelUpClientModule
        {
            var client = new LevelUpClient(GetDefaultLevelUpRequestEngine(identifier, enviornment, restService));

            return((T)(object)client);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a LevelUp client interface with a custom request engine
        /// </summary>
        /// <remarks>
        /// Use this only if you need to override certain behaviors in the way that
        /// the SDK makes calls into the levelup platform.  Otherwise, use the
        /// standard Create<T> overload, which will use the default LevelUp
        /// implementation classes.
        /// </remarks>
        /// <typeparam name="T">The type of LevelUp client interface to generate.</typeparam>
        /// <param name="engine">An IRequestVisitor that can make calls to the
        /// LevelUp API for each type of request object.</param>
        /// <returns>The LevelUp client interface of the specified type T.</returns>
        public static T Create <T>(IRequestVisitor <IResponse> engine)
            where T : ILevelUpClientModule
        {
            var client = new LevelUpClient(engine);

            return((T)(object)client);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a composed interface, containing a collection of the more fine-grained
        /// LevelUp client interfaces.
        /// </summary>
        /// <typeparam name="T">The type of composed interface to generate.</typeparam>
        /// <param name="identifier">An object that retains data about the caller
        /// (company name, etc.) as an informational and diagnostic tool for the
        /// LevelUp backend.</param>
        /// <param name="enviornment">The target enviornment (sandbox, production, etc.)</param>
        /// <returns>The LevelUp client interface of the specified type T.</returns>
        public static T CreateComposedInterface <T>(AgentIdentifier identifier, LevelUpEnvironment enviornment)
            where T : IComposedInterface
        {
            IRestfulService httpRestService = new LevelUpHttpRestfulService();
            var             client          = new LevelUpClient(GetDefaultLevelUpRequestEngine(identifier, enviornment, httpRestService));

            return((T)(object)client);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a LevelUp client interface with a set timeout value
        /// </summary>
        /// <typeparam name="T">The type of LevelUp client interface to generate.</typeparam>
        /// <param name="identifier">An object that retains data about the caller
        /// (company name, etc.) as an informational and diagnostic tool for the
        /// LevelUp backend.</param>
        /// <param name="enviornment">The target enviornment (sandbox, production, etc.)</param>
        /// <param name="timeoutInMs">Time out value in milliseconds</param>
        /// <returns>The LevelUp client interface of the specified type T.</returns>
        public static T Create <T>(AgentIdentifier identifier, LevelUpEnvironment enviornment, int timeoutInMs)
            where T : ILevelUpClientModule
        {
            IRestfulService httpRestService = new LevelUpHttpRestfulService(timeoutInMs);
            var             client          = new LevelUpClient(httpRestService, identifier, enviornment);

            return((T)(object)client);
        }