public static void AddResourceLink(this ILinkedResource resources, LinkedResourceType resourceType, string routeUrl) { resources.Links ??= new Dictionary <LinkedResourceType, LinkedResource>(); resources.Links[resourceType] = new LinkedResource(routeUrl); }
/// <summary> /// Initializes a new instance of the <see cref="SimpleLink"/> class. /// </summary> /// <param name="target">A value that specifies where/how a linked resource is displayed/experienced.</param> /// <param name="resource">The resource.</param> /// <param name="formatsToApplyWhenActivated">OPTIONAL formatting to apply, in order, when the link is activated (e.g. clicked). DEFAULT is to leave the formatting unchanged.</param> public SimpleLink( LinkTarget target, ILinkedResource resource, IReadOnlyList <RegionFormatBase> formatsToApplyWhenActivated = null) { if (target == LinkTarget.Unknown) { throw new ArgumentOutOfRangeException(Invariant($"{nameof(target)} is {nameof(LinkTarget.Unknown)}.")); } if (resource == null) { throw new ArgumentNullException(nameof(resource)); } if (formatsToApplyWhenActivated != null) { if (!formatsToApplyWhenActivated.Any()) { throw new ArgumentException(Invariant($"{nameof(formatsToApplyWhenActivated)} is an empty enumerable.")); } if (formatsToApplyWhenActivated.Any(_ => _ == null)) { throw new ArgumentException(Invariant($"{nameof(formatsToApplyWhenActivated)} contains at least one null element.")); } } this.Target = target; this.Resource = resource; this.FormatsToApplyWhenActivated = formatsToApplyWhenActivated; }
public SimpleLink DeepCloneWithResource(ILinkedResource resource) { var result = new SimpleLink( this.Target.DeepClone(), resource, this.FormatsToApplyWhenActivated?.DeepClone()); return(result); }