Beispiel #1
0
		public static MyData[] ConcatDistinct(this MyData[] source, MyData e)
		{
			if (source.Contains(e.Name))
				return source;

			return source.Concat(e);
		}
Beispiel #2
0
		public static MyData[] Concat(this MyData[] source, MyData e)
		{
			var a = new MyData[source.Length + 1];

			Array.Copy(source, a, source.Length);

			a[source.Length] = e;

			return a;
		}
Beispiel #3
0
		public static MyData[] Parse(string source)
		{
			var a = new ArrayList();

			JSONDocument.ParseMatrix(source,
				delegate
				{
					var n = new MyData();

					a.Add(n);

					return new JSONDocument.ParseArguments[] 
							{
								(JSONDocument.StringAction)(Name => n.Name = Name),
								(JSONDocument.StringAction)(Target => n.Target = Target)
							};
				}
			);

			return (MyData[])a.ToArray(typeof(MyData));
		}
Beispiel #4
0
		public static string ToString(MyData[] a)
		{
			return JSONDocument.ToString(
				delegate
				{
					var i = -1;

					return delegate
					{
						i++;

						if (i < a.Length)
						{
							var c = a[i];

							return new[] { c.Name, c.Target };
						}

						return null;
					};
				}
			);
		}
Beispiel #5
0
		private void SendCommandFindName(MyData t, string name)
		{
			Action Try =
				delegate
				{
					AppendTextLine("asking from " + t.Target);

					var ip_host = t.Target.GetLocalAddressByConnecting();

					if (ip_host == "")
					{
						this.AppendTextLine(t.Target + " seems to be offline!");
						return;
					}

					var ip = ip_host + ":" + PortTextbox.Text.ToInt32Array()[0];

					this.outgoingMessages1.SendCommand(t.Target,
						new findname
						{
							myip = ip,
							name = name,
						}
					);
				};

			Try.TryInvokeInBackground();
		}