// ---------------- Functions ---------------- /// <summary> /// Converts an XML node to a config object. /// </summary> /// <param name="rng"> /// Leave this null to use the default RNG, otherwise pass this in if you want to use your own (e.g. with a different seed) /// </param> public static void Deserialize( this MessageHandlerConfig msgConfig, XmlNode handlerNode, IIrcConfig ircConfig, Random rng = null ) { IReadOnlyList <string> responses = DeserializeBase(msgConfig, handlerNode); // I can not for the life of me figure out how to make this generic between this and // action... maybe we can't? MessageHandlerAction action = delegate(MessageHandlerArgs args) { HandleResponse(args, responses, ircConfig, rng); }; msgConfig.LineAction = action; }
/// <summary> /// Fetches a message handler object filled with all the properties for a specific entry identified with the ObjectId /// of the user that owns it /// CUPI returns it as a list even though it's a single entry so we have to treat it as though we're fetching a list of /// objects. /// </summary> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public WebCallResult GetMessageHandler() { string strUrl = string.Format("{0}users/{1}/messagehandlers", HomeServer.BaseUrl, SubscriberObjectId); List <MessageHandler> oTemp = new List <MessageHandler>(); var res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, null); if (!res.Success) { return(res); } if (res.TotalObjectCount != 1) { res.Success = false; res.ErrorText = "Object count returned from messageHandler fetch not equal to 1"; return(res); } oTemp = HomeServer.GetObjectsFromJson <MessageHandler>(res.ResponseText); if (oTemp.Count != 1) { res.Success = false; res.ErrorText = "Objects returned from JSON parse of messageHandler fetch not equal to 1"; return(res); } var oItem = oTemp.First(); this.DeliveryReceiptAction = oItem.DeliveryReceiptAction; this.EmailAction = oItem.EmailAction; this.FaxAction = oItem.FaxAction; this.ObjectId = oItem.ObjectId; this.RelayAddress = oItem.RelayAddress; this.VoicemailAction = oItem.VoicemailAction; ClearPendingChanges(); return(res); }
internal MessageHandler(object?target, MessageHandlerAction?handlerAction) { Target = target ?? throw new ArgumentNullException(nameof(target)); _action = handlerAction ?? throw new ArgumentNullException(nameof(handlerAction)); }