/// <summary> /// Initializes a new instance of the <see cref="RespondWithAProvider"/> class. /// </summary> /// <param name="registrationCallback">The registration callback.</param> /// <param name="requestMatcher">The request matcher.</param> /// <param name="settings">The WireMockServerSettings.</param> /// <param name="saveToFile">Optional boolean to indicate if this mapping should be saved as static mapping file.</param> public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher, IWireMockServerSettings settings, bool saveToFile = false) { _registrationCallback = registrationCallback; _requestMatcher = requestMatcher; _settings = settings; _saveToFile = saveToFile; }
/// <summary> /// Initializes a new instance of the <see cref="RespondWithAProvider"/> class. /// </summary> /// <param name="registrationCallback">The registration callback.</param> /// <param name="requestMatcher">The request matcher.</param> /// <param name="fileSystemHandler">The fileSystemHandler.</param> /// <param name="saveToFile">Optional boolean to indicate if this mapping should be saved as static mapping file.</param> public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher, IFileSystemHandler fileSystemHandler, bool saveToFile = false) { _registrationCallback = registrationCallback; _requestMatcher = requestMatcher; _fileSystemHandler = fileSystemHandler; _saveToFile = saveToFile; }
public void ModifyRoomConfig(Jid room, RegistrationCallback callback) { RequestForm form = RequestRoomConfigForm(room); SubmitForm submit = callback.Invoke(form); SubmitRoomConfigForm(room, submit); }
public Data() { RaceLapCount = 0; BackgroundTexture = ""; Components = new List <IComponent>(); RegisterComponent = null; UnregisterComponent = null; }
public void Register(RegistrationCallback callback) { callback.ThrowIfNull <RegistrationCallback>("callback"); Iq errorIq = base.im.IqRequest(IqType.Get, null, null, Xml.Element("query", "jabber:iq:register"), null, -1, ""); if (errorIq.Type == IqType.Error) { throw new NotSupportedException("The XMPP server does not support the 'In-Band Registration' extension."); } XmlElement query = errorIq.Data["query"]; if ((query == null) || (query.NamespaceURI != "jabber:iq:register")) { throw new XmppException("Erroneous server response: " + errorIq); } if (query["registered"] != null) { throw new XmppException("The XMPP entity is already registered."); } XmlElement element2 = query["data"]; if ((element2 != null) && (element2.NamespaceURI == "urn:xmpp:bob")) { BobData bob = BobData.Parse(element2); this.bob.Add(bob); } RequestForm form = null; bool flag = query["x"] != null; if (flag) { form = DataFormFactory.Create(query["x"]) as RequestForm; } else { form = this.CreateDataForm(query); } SubmitForm form2 = callback(form); XmlElement e = Xml.Element("query", "jabber:iq:register"); if (flag) { e.Child(form2.ToXmlElement()); } else { foreach (DataField field in form2.Fields) { e.Child(Xml.Element(field.Name, null).Text(field.Values.FirstOrDefault <string>())); } } errorIq = base.im.IqRequest(IqType.Set, null, null, e, null, -1, ""); if (errorIq.Type == IqType.Error) { throw Util.ExceptionFromError(errorIq, "The registration could not be completed."); } }
/// <summary> /// Registers a new XMPP account on the connected XMPP server. /// </summary> /// <param name="callback">A callback method invoked during the registration /// process to gather user information.</param> /// <exception cref="ArgumentNullException">The callback parameter is /// null.</exception> /// <exception cref="NotSupportedException">The XMPP entity with /// the specified JID does not support the 'In-Band Registration' XMPP /// extension.</exception> /// <exception cref="XmppErrorException">The server returned an XMPP error code. /// Use the Error property of the XmppErrorException to obtain the specific /// error condition.</exception> /// <exception cref="XmppException">The server returned invalid data or another /// unspecified XMPP error occurred.</exception> public void Register(RegistrationCallback callback) { callback.ThrowIfNull("callback"); Iq iq = IM.IqRequest(IqType.Get, null, null, Xml.Element("query", "jabber:iq:register")); if (iq.Type == IqType.Error) throw new NotSupportedException("The XMPP server does not support the " + "'In-Band Registration' extension."); var query = iq.Data["query"]; if (query == null || query.NamespaceURI != "jabber:iq:register") throw new XmppException("Erroneous server response: " + iq); if (query["registered"] != null) throw new XmppException("The XMPP entity is already registered."); // If the IQ contains binary data, cache it. var data = query["data"]; if (data != null && data.NamespaceURI == "urn:xmpp:bob") { BobData bobData = BobData.Parse(data); bob.Add(bobData); } RequestForm form = null; bool xdata = query["x"] != null; if (xdata) form = DataFormFactory.Create(query["x"]) as RequestForm; // "Traditional" registration, create a data-form off the provided fields. else form = CreateDataForm(query); // Hand the data-form to the caller to have it filled-out. var submit = callback.Invoke(form); // Construct the response element. var xml = Xml.Element("query", "jabber:iq:register"); // Convert the data-form back to traditional fields if needed. if (xdata) xml.Child(submit.ToXmlElement()); else { foreach (var field in submit.Fields) { xml.Child(Xml.Element(field.Name).Text( field.Values.FirstOrDefault())); } } iq = IM.IqRequest(IqType.Set, null, null, xml); if (iq.Type == IqType.Error) throw Util.ExceptionFromError(iq, "The registration could not be " + "completed."); // Reconnect. }
public void AuthenticateUser( string userName, string password, RegistrationCallback registrationCallback, AuthenticationCallback authenticationCallback) { new RegistrationRequest(). SetUserName(userName). SetPassword(password). SetDisplayName(userName). Send((registrationResposnse) => { if (!registrationResposnse.HasErrors) { Debug.Log("Registration Successful"); registrationCallback(registrationResposnse); } else { if (registrationResposnse.NewPlayer == false) { new AuthenticationRequest().SetUserName(userName).SetPassword(password).Send( (authenticationResponse) => { if (!authenticationResponse.HasErrors) { Debug.Log("Authentication Successful"); authenticationCallback(authenticationResponse); } else { Debug.Log("Authentication Error " + authenticationResponse.Errors.JSON); } }); } else { Debug.Log("Authentication Error " + registrationResposnse.Errors.JSON); } } }); }
public void SetUp() { _realContainer = new ServiceCollection(); _containerMock = new Mock <IServiceCollection>(); _registered = new List <RegisterEvent>(); var setup = _containerMock .Setup(c => c.Add(It.IsAny <ServiceDescriptor>())); var callback = new RegistrationCallback((serviceDescriptor) => { _registered.Add(new RegisterEvent(serviceDescriptor)); _realContainer.Add(serviceDescriptor); }); setup.Callback(callback); _container = _containerMock.Object; }
public void SetUp() { _realContainer = new UnityContainer(); _containerMock = new Mock <IUnityContainer>(); _registered = new List <RegisterEvent>(); var setup = _containerMock .Setup(c => c.RegisterType(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <string>(), It.IsAny <LifetimeManager>())); var callback = new RegistrationCallback((from, to, name, lifetime, ips) => { _registered.Add(new RegisterEvent(from, to, name, lifetime)); _realContainer.RegisterType(from, to, name, lifetime); }); // Using reflection, because current version of Moq doesn't support callbacks with more than 4 arguments setup .GetType() .GetMethod("SetCallbackWithArguments", BindingFlags.NonPublic | BindingFlags.Instance) .Invoke(setup, new object[] { callback }); _container = _containerMock.Object; }
public void SetUp() { this.realContainer = new UnityContainer(); this.containerMock = new Mock<IUnityContainer>(); this.registered = new List<RegisterEvent>(); var setup = this.containerMock .Setup(c => c.RegisterType(It.IsAny<Type>(), It.IsAny<Type>(), It.IsAny<string>(), It.IsAny<LifetimeManager>())); var callback = new RegistrationCallback((from, to, name, lifetime, ips) => { this.registered.Add(new RegisterEvent(from, to, name, lifetime)); this.realContainer.RegisterType(from, to, name, lifetime); }); // Using reflection, because current version of Moq doesn't support callbacks with more than 4 arguments setup .GetType() .GetMethod("SetCallbackWithArguments", BindingFlags.NonPublic | BindingFlags.Instance) .Invoke(setup, new object[] { callback }); this.container = this.containerMock.Object; }
private static IServiceCollection AddToServiceCollectionWithCallback( this IServiceCollection serviceCollection, IEnumerable <ServicesScannerResult> services, RegistrationCallback registration, RegistrationCallback multipleInterfacesRegistration = null) { foreach (var s in services) { var ifaces = s.ImplementingInterfaces.ToList(); var multipleMode = ifaces.Count > 1 && multipleInterfacesRegistration != null; foreach (var iFace in ifaces) { var ifFaceToAdd = iFace; var impl = s.ImplementationType; if (iFace.IsGenericType && iFace.GetGenericArguments().All(c => c.IsGenericParameter)) { ifFaceToAdd = ifFaceToAdd.GetGenericTypeDefinition(); } if (s.ImplementationType.IsGenericType && s.ImplementationType.GetGenericArguments().All(c => c.IsGenericParameter)) { impl = impl.GetGenericTypeDefinition(); } if (!multipleMode) { registration(serviceCollection, ifFaceToAdd, impl); } else { multipleInterfacesRegistration(serviceCollection, ifFaceToAdd, impl); } } } return(serviceCollection); }
/// <summary> /// Registers a new XMPP account on the connected XMPP server. /// </summary> /// <param name="callback">A callback method invoked during the registration /// process to gather user information.</param> /// <exception cref="ArgumentNullException">The callback parameter is /// null.</exception> /// <exception cref="NotSupportedException">The XMPP entity with /// the specified JID does not support the 'In-Band Registration' XMPP /// extension.</exception> /// <exception cref="XmppErrorException">The server returned an XMPP error code. /// Use the Error property of the XmppErrorException to obtain the specific /// error condition.</exception> /// <exception cref="XmppException">The server returned invalid data or another /// unspecified XMPP error occurred.</exception> public void Register(RegistrationCallback callback) { callback.ThrowIfNull("callback"); Iq iq = im.IqRequest(IqType.Get, null, null, Xml.Element("query", "jabber:iq:register")); if (iq.Type == IqType.Error) { throw new NotSupportedException("The XMPP server does not support the " + "'In-Band Registration' extension."); } var query = iq.Data["query"]; if (query == null || query.NamespaceURI != "jabber:iq:register") { throw new XmppException("Erroneous server response: " + iq); } if (query["registered"] != null) { throw new XmppException("The XMPP entity is already registered."); } // If the IQ contains binary data, cache it. var data = query["data"]; if (data != null && data.NamespaceURI == "urn:xmpp:bob") { BobData bobData = BobData.Parse(data); bob.Add(bobData); } RequestForm form = null; bool xdata = query["x"] != null; if (xdata) { form = DataFormFactory.Create(query["x"]) as RequestForm; } // "Traditional" registration, create a data-form off the provided fields. else { form = CreateDataForm(query); } // Hand the data-form to the caller to have it filled-out. var submit = callback.Invoke(form); // Construct the response element. var xml = Xml.Element("query", "jabber:iq:register"); // Convert the data-form back to traditional fields if needed. if (xdata) { xml.Child(submit.ToXmlElement()); } else { foreach (var field in submit.Fields) { xml.Child(Xml.Element(field.Name).Text( field.Values.FirstOrDefault())); } } iq = im.IqRequest(IqType.Set, null, null, xml); if (iq.Type == IqType.Error) { throw Util.ExceptionFromError(iq, "The registration could not be " + "completed."); } // Reconnect. }
/// <summary> /// Initializes a new instance of the <see cref="RespondWithAProvider"/> class. /// </summary> /// <param name="registrationCallback">The registration callback.</param> /// <param name="requestMatcher">The request matcher.</param> public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher) { _registrationCallback = registrationCallback; _requestMatcher = requestMatcher; }
/// <summary> /// Initiates in-band registration with the XMPP server in order to register /// a new XMPP account. /// </summary> /// <param name="callback">A callback method invoked to let the user /// enter any information required by the server in order to complete the /// registration.</param> /// <exception cref="ArgumentNullException">The callback parameter is /// null.</exception> /// <exception cref="NotSupportedException">The XMPP server with does not /// support the 'In-Band Registration' XMPP extension.</exception> /// <exception cref="XmppErrorException">The server returned an XMPP error code. /// Use the Error property of the XmppErrorException to obtain the specific /// error condition.</exception> /// <exception cref="XmppException">The server returned invalid data or another /// unspecified XMPP error occurred.</exception> /// <remarks> /// See the "Howto: Register an account" guide for a walkthrough on how to /// register an XMPP account through the in-band registration process. /// </remarks> public void Register(RegistrationCallback callback) { callback.ThrowIfNull("callback"); inBandRegistration.Register(callback); }
public RespondWithAProvider(RegistrationCallback registrationCallback, ISpecifyRequests requestSpec) { _registrationCallback = registrationCallback; _requestSpec = requestSpec; }
public void Register(RegistrationCallback callback) { callback.ThrowIfNull <RegistrationCallback>("callback"); this.inBandRegistration.Register(callback); }