Table of Contents

Class ModelItem

Namespace
C4.Net
Assembly
C4.Net.Core.dll

Provides common metadata shared by elements and relationships in the model.

[DataContract]
public abstract class ModelItem
Inheritance
ModelItem
Derived
Inherited Members

Properties

Id

The ID of this item in the model.

[DataMember(Name = "id", EmitDefaultValue = false)]
public string Id { get; }

Property Value

string

Perspectives

The set of perspectives associated with this element.

[DataMember(Name = "perspectives", EmitDefaultValue = false)]
public ISet<Perspective> Perspectives { get; }

Property Value

ISet<Perspective>

Properties

The collection of name-value property pairs associated with this element, as a Dictionary.

[DataMember(Name = "properties", EmitDefaultValue = false)]
public Dictionary<string, string> Properties { get; }

Property Value

Dictionary<string, string>

Tags

The comma-separated tag list stored with this model item.

[DataMember(Name = "tags", EmitDefaultValue = false)]
public string Tags { get; set; }

Property Value

string

Methods

AddPerspective(string, string)

Adds a perspective to this model item.

public Perspective AddPerspective(string name, string description)

Parameters

name string

the name of the perspective (e.g. "Security", must be unique)

description string

The narrative associated with the perspective.

Returns

Perspective

The created Perspective.

Exceptions

ArgumentException

Thrown when the name or description is blank, or when a perspective with the same name already exists.

AddProperty(string, string)

Adds a name-value pair property to this element.

public void AddProperty(string name, string value)

Parameters

name string

the name of the property

value string

the value of the property

Exceptions

ArgumentException

Thrown when name or value is null, empty, or whitespace.

AddTags(params string[])

Adds one or more user-defined tags to this model item.

public void AddTags(params string[] tags)

Parameters

tags string[]

The tags to add.

GetAllTags()

Returns the full tag list, including required built-in tags and user-specified tags.

public IEnumerable<string> GetAllTags()

Returns

IEnumerable<string>

The complete set of tags as individual values.

GetRequiredTags()

Returns the built-in tags that must always be present for this model item.

public abstract List<string> GetRequiredTags()

Returns

List<string>

The required tags.

GetTagsAsSet()

Returns the full tag list as a set without duplicates.

public ISet<string> GetTagsAsSet()

Returns

ISet<string>

A set containing required and user-specified tags.

RemoveTag(string)

Removes a user-defined tag from this model item.

public virtual void RemoveTag(string tag)

Parameters

tag string

The tag to remove.