PeerCastStation.UI.HTTP.APIHost.APIContext.AddYellowPage C# (CSharp) Method

AddYellowPage() private method

private AddYellowPage ( string protocol, string name, string uri = null, string announceUri = null, string channelsUri = null ) : Newtonsoft.Json.Linq.JObject
protocol string
name string
uri string
announceUri string
channelsUri string
return Newtonsoft.Json.Linq.JObject
      private JObject AddYellowPage(string protocol, string name, string uri=null, string announceUri=null, string channelsUri=null)
      {
        var factory = PeerCast.YellowPageFactories.FirstOrDefault(p => protocol==p.Protocol);
        if (factory==null) throw new RPCError(RPCErrorCode.InvalidParams, "protocol Not Found");
        if (name==null) throw new RPCError(RPCErrorCode.InvalidParams, "name must be String");
				Uri announce_uri = null;
				try {
					if (String.IsNullOrEmpty(uri)) uri = announceUri;
					if (!String.IsNullOrEmpty(uri)) {
						announce_uri = new Uri(uri, UriKind.Absolute);
						if (!factory.CheckURI(announce_uri)) {
							throw new RPCError(RPCErrorCode.InvalidParams, String.Format("Not suitable uri for {0}", protocol));
						}
					}
				}
				catch (ArgumentNullException) {
					throw new RPCError(RPCErrorCode.InvalidParams, "uri must be String");
				}
				catch (UriFormatException) {
					throw new RPCError(RPCErrorCode.InvalidParams, "Invalid uri");
				}
				Uri channels_uri = null;
				try {
					if (!String.IsNullOrEmpty(channelsUri)) {
						channels_uri = new Uri(channelsUri, UriKind.Absolute);
					}
				}
				catch (ArgumentNullException) {
					throw new RPCError(RPCErrorCode.InvalidParams, "uri must be String");
				}
				catch (UriFormatException) {
					throw new RPCError(RPCErrorCode.InvalidParams, "Invalid uri");
				}
        var yp = PeerCast.AddYellowPage(factory.Protocol, name, announce_uri, channels_uri);
        owner.Application.SaveSettings();
        var res = new JObject();
        res["yellowPageId"] = GetObjectId(yp);
        res["name"]         = yp.Name;
        res["uri"]          = yp.AnnounceUri==null ? null : yp.AnnounceUri.ToString();
        res["announceUri"]  = yp.AnnounceUri==null ? null : yp.AnnounceUri.ToString();
        res["channelsUri"]  = yp.ChannelsUri==null ? null : yp.ChannelsUri.ToString();
        res["protocol"]     = yp.Protocol;
        return res;
      }