示例#1
0
 /// <summary>
 /// Constructor for this class.
 /// </summary>
 /// <param name="request">The request that this response is associated to.</param>
 /// <param name="responseType">The type of response.</param>
 protected Response(Request request, ResponseTypeEnum responseType)
 {
     ResponseTypeAsString = TranslateResponseType(responseType);
     RequestTypeAsString  = request.RequestTypeAsString;
     ProcessId            = request.ProcessId;
     Key = request.Key;
 }
示例#2
0
        /// <summary>
        /// Create a new instance of a PlayerResponse object.
        /// </summary>
        /// <param name="responseRequestType"></param>
        public PlayerResponse(ResponseTypeEnum responseType, double betAmount = 0)
        {
            // Set the responseRequestType
            this.ResponseType = responseType;

            // Set the BetAmount in case it is used
            this.BetAmount = betAmount;
        }
示例#3
0
 public bool Equals(ResponseTypeEnum obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value));
 }
示例#4
0
            static ResponseTypeEnum        Select(string type)
            {
                ResponseTypeEnum returnTypeEnum = null;

                return(type == null || !ResponseTypeEnum.allValues.TryGetValue(type, out returnTypeEnum)
                            ?   null
                            :   returnTypeEnum);
            }
示例#5
0
        public Uri GetAuthorizationUri(
            Uri authorizeUrl,
            string clientId,
            string scope,
            Uri redirectUri,
            string state,
            ResponseTypeEnum responseType,
            Dictionary <string, string> queryParameters)
        {
            if (authorizeUrl == null)
            {
                throw new ArgumentNullException(nameof(authorizeUrl));
            }

            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }

            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }

            if (redirectUri == null)
            {
                throw new ArgumentNullException(nameof(redirectUri));
            }

            if (string.IsNullOrEmpty(state))
            {
                throw new ArgumentNullException(nameof(state));
            }

            var builder = new UriBuilder(authorizeUrl.NonPath());

            builder.Path += authorizeUrl.AbsolutePath.TrimStart('/');

            var query = new HttpValueCollection
            {
                { OAuth2ParameterEnum.RedirectUri.EnumToString(), redirectUri.ToString() },
                { OAuth2ParameterEnum.ClientId.EnumToString(), clientId },
                { OAuth2ParameterEnum.Scope.EnumToString(), scope },
                { OAuth2ParameterEnum.State.EnumToString(), state },
                { OAuth2ParameterEnum.ResponseType.EnumToString(), responseType.EnumToString() }
            };

            foreach (var parameter in queryParameters)
            {
                query.Add(
                    parameter.Key,
                    parameter.Value);
            }

            builder.Query += query.ToString();

            return(builder.Uri);
        }
示例#6
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.VocalizationName  = binaryReader.ReadStringID();
     this.ResponseFlags     = ((Flags)(binaryReader.ReadInt16()));
     this.VocalizationIndex = binaryReader.ReadInt16();
     this.ResponseType      = ((ResponseTypeEnum)(binaryReader.ReadInt16()));
     this.DialogueIndex     = binaryReader.ReadInt16();
     return(pointerQueue);
 }
示例#7
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ResponseType = ((ResponseTypeEnum)(binaryReader.ReadInt16()));
     this.fieldpad     = binaryReader.ReadBytes(2);
     pointerQueue      = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.ScreenFlash.ReadFields(binaryReader)));
     pointerQueue      = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.Vibration.ReadFields(binaryReader)));
     pointerQueue      = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.SoundEffect.ReadFields(binaryReader)));
     return(pointerQueue);
 }
示例#8
0
        public IOAuthAuthenticationTemplate <OAuth2Credentials> BuildOAuth2Template <TResourceProvider>(
            IOAuthFacade <OAuth2Credentials> authentication,
            AuthenticationInterfaceEnum ui,
            string userId,
            string clientSecret,
            ResponseTypeEnum flow)
            where TResourceProvider : ResourceProvider
        {
            if (flow == ResponseTypeEnum.Code)
            {
                var callbackHandler = new OAuth2QueryCallbackHandler(
                    _strategy,
                    OAuth2ParameterEnum.State.EnumToString(),
                    userId);

                var authenticationUI = _oauthAuthorizerUIFactory
                                       .GetAuthorizer <TResourceProvider>(
                    ui,
                    callbackHandler);

                return(new OAuth2CodeAuthenticationTemplate(
                           authenticationUI,
                           authentication,
                           clientSecret));
            }
            else
            {
                IOAuthCallbackHandler callbackHandler = null;
                if (ui == AuthenticationInterfaceEnum.Dedicated)
                {
                    callbackHandler = new OAuth2QueryCallbackHandler(
                        _strategy,
                        OAuth2ParameterEnum.State.EnumToString(),
                        userId);
                }
                else
                {
                    callbackHandler = new OAuth2FragmentCallbackHandler(
                        _strategy,
                        OAuth2ParameterEnum.State.EnumToString(),
                        userId);
                }

                var authenticationUI = _oauthAuthorizerUIFactory
                                       .GetAuthorizer <TResourceProvider>(
                    ui,
                    callbackHandler);

                return(new OAuth2TokenAuthenticationTemplate(
                           authenticationUI,
                           authentication));
            }
        }
示例#9
0
        /// <summary>
        /// Register to register validation and confirmation URLs on M-Pesa
        /// </summary>
        /// <param name="responseType">This parameter specifies what is to happen if for any reason the validation URL is nor reachable.</param>
        /// <param name="confirmationUrl">This is the URL that receives the confirmation request from API upon payment completion.  </param>
        /// <param name="validationUrl">This is the URL that receives the validation request from API upon payment submission.</param>
        public async Task <ApiResponse <Response> > RegisterUrl(ResponseTypeEnum responseType, string confirmationUrl, string validationUrl)
        {
            var response = await PostHttp <Response>("/c2b/v1/registerurl", new Dictionary <string, string>
            {
                { "ShortCode", Options.ShortCode },
                { "ResponseType", responseType.ToString() },
                { "ConfirmationURL", confirmationUrl },
                { "ValidationURL", validationUrl }
            });

            return(response.ToApiResponse());
        }
示例#10
0
        public virtual OAuth2ResourceProvider SetFlow(
            string clientId,
            string clientSecret,
            AuthenticationInterfaceEnum @interface,
            OAuthAppTypeEnum appType)
        {
            ResponseTypeEnum flow;

            if (@interface == AuthenticationInterfaceEnum.Dedicated &&
                appType == OAuthAppTypeEnum.Desktop)
            {
                flow = clientSecret != null ?
                       ResponseTypeEnum.Code :
                       ResponseTypeEnum.Token;
            }
            else if (@interface == AuthenticationInterfaceEnum.Embedded &&
                     appType == OAuthAppTypeEnum.Desktop)
            {
                throw new NotSupportedException(
                          StringResources.EmbeddedDesktopUINotSupportedException);
            }
            else if (@interface == AuthenticationInterfaceEnum.Dedicated &&
                     appType == OAuthAppTypeEnum.Mobile)
            {
                flow = ResponseTypeEnum.Code;
            }
            else if (@interface == AuthenticationInterfaceEnum.Embedded &&
                     appType == OAuthAppTypeEnum.Mobile)
            {
                flow = clientSecret != null ?
                       ResponseTypeEnum.Code :
                       ResponseTypeEnum.Token;
            }
            else
            {
                throw new NotSupportedException();
            }

            if (!Flows.Contains(flow))
            {
                throw new InvalidGrantTypeException(
                          string.Format(
                              StringResources.GrantTypeNotSupportedException,
                              GetType().Name));
            }

            Flow = flow;

            return(this);
        }
示例#11
0
        /// <summary>
        /// Translate from <see cref="ResponseTypeEnum"/> to a string.
        /// </summary>
        /// <param name="responseType">The response type.</param>
        /// <returns>A string representation of the <paramref name="responseType"/>.</returns>
        public static string TranslateResponseType(ResponseTypeEnum responseType)
        {
            switch (responseType)
            {
            case ResponseTypeEnum.Success:
                return(Success);

            case ResponseTypeEnum.Failure:
                return(Failure);

            default:
                throw new ArgumentException(String.Format("Unknown response type: \"{0}\".", responseType));
            }
        }
示例#12
0
        public Response(IDictionary <string, object> data)
        {
            if (data == null)
            {
                return;
            }

            try
            {
                m_qualifier = (ResponseTypeEnum)Enum.Parse(typeof(ResponseTypeEnum), Utils.GetValue(data, "qualifier", ""), true);
            }
            catch
            {
                m_qualifier = ResponseTypeEnum.None;
            }

            RequestId = Utils.GetValue(data, "requestId", "");
            Error     = null;
            if (data.ContainsKey("error"))
            {
                Error = new Error(data["error"] as IDictionary <string, object>);
            }
        }
示例#13
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ResponseType                     = ((ResponseTypeEnum)(binaryReader.ReadInt16()));
     this.ConstraintDamageType             = ((ConstraintDamageTypeEnum)(binaryReader.ReadInt16()));
     this.InstantaneousDamageRepsonseFlags = ((Flags)(binaryReader.ReadInt32()));
     this.DamageThreshold                  = binaryReader.ReadSingle();
     this.TransitionEffect                 = binaryReader.ReadTagReference();
     pointerQueue                        = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.DamageEffect.ReadFields(binaryReader)));
     this.Region                         = binaryReader.ReadStringID();
     this.NewState                       = ((NewStateEnum)(binaryReader.ReadInt16()));
     this.RuntimeRegionIndex             = binaryReader.ReadInt16();
     this.EffectMarkerName               = binaryReader.ReadStringID();
     pointerQueue                        = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.DamageEffectMarker.ReadFields(binaryReader)));
     this.ResponseDelay                  = binaryReader.ReadSingle();
     this.DelayEffect                    = binaryReader.ReadTagReference();
     this.DelayEffectMarkerName          = binaryReader.ReadStringID();
     this.ConstraintgroupName            = binaryReader.ReadStringID();
     this.EjectingSeatLabel              = binaryReader.ReadStringID();
     this.SkipFraction                   = binaryReader.ReadSingle();
     this.DestroyedChildObjectMarkerName = binaryReader.ReadStringID();
     this.TotalDamageThreshold           = binaryReader.ReadSingle();
     return(pointerQueue);
 }
示例#14
0
 public Task <ApiResponse <Response> > RegisterUrl(ResponseTypeEnum responseType, string confirmationUrl, string validationUrl) =>
 api.C2BClient.RegisterUrl(responseType, confirmationUrl, validationUrl);
示例#15
0
 public Response(ResponseTypeEnum responseType, object content, ExCookieCollection cookies) : this(responseType, content)
 {
     Cookies = cookies;
 }
示例#16
0
 public Response(ResponseTypeEnum responseType, object content)
 {
     ResponseType = responseType;
     Content      = content;
 }
示例#17
0
 /// <summary>
 /// Creates response depending on response type and status code.
 /// </summary>
 /// <param name="responseType">Response type.</param>
 /// <param name="statusCode">Http status code.</param>
 /// <returns>Instance of <see cref="IActionResult"/>.</returns>
 public IResponseBuilder ExecuteCreation(ResponseTypeEnum responseType, HttpStatusCode statusCode)
 => _factories[responseType].Create(statusCode);
示例#18
0
 private Response(ResponseTypeEnum type)
 {
     Type = type;
 }
 public ResponseService(ResponseTypeEnum type)
 {
     Type           = type;
     FieldsInvalids = new List <string>();
 }
 public ResponseService(ResponseTypeEnum type, string message)
 {
     Type           = type;
     Message        = message;
     FieldsInvalids = new List <string>();
 }
 public ResponseService(ResponseTypeEnum type, string message, List <string> fieldsInvalids)
 {
     Type           = type;
     Message        = message;
     FieldsInvalids = fieldsInvalids;
 }