/// <summary> /// Create a new unique identifier from a list of tags. /// </summary> /// <param name="type"> /// The type of object that the identifier is for. /// </param> /// <param name="tags"> /// A list of Tag objects and nulls, where null specifies the delimiter /// between agent tags in the case of a multiagent. /// </param> public UniqueIdentifier(IdentityType type, Tag[] tags) { this.type = type; int totalSize = tags.Sum(x => (x==null) ? 0 : x.Data.Count) + tags.Length - 1; this.genome = new Resource[totalSize]; int i = 0; bool isFirst = true; foreach (var tag in tags) { // Pad with a null for every new tag after the first if (isFirst) { isFirst = false; } else { this.genome[i++] = null; } if (tag != null) { Array.Copy(tag.Data.ToArray(), 0, this.genome, i, tag.Data.Count); i += tag.Data.Count; } } }