Show / Hide Table of Contents

Class Circuit

Represents an electronic circuit.

Inheritance
object
Circuit
Implements
IEntityCollection
ICollection<IEntity>
IEnumerable<IEntity>
IEnumerable
ICloneable<IEntityCollection>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SpiceSharp
Assembly: SpiceSharp.dll
Syntax
public class Circuit : IEntityCollection, ICollection<IEntity>, IEnumerable<IEntity>, IEnumerable, ICloneable<IEntityCollection>

Constructors

Circuit()

Initializes a new instance of the Circuit class.

Declaration
public Circuit()

Circuit(IEntityCollection)

Initializes a new instance of the Circuit class.

Declaration
public Circuit(IEntityCollection entities)
Parameters
Type Name Description
IEntityCollection entities

The entities.

Exceptions
Type Condition
ArgumentNullException

Thrown if entities is null.

Circuit(params IEntity[])

Initializes a new instance of the Circuit class.

Declaration
public Circuit(params IEntity[] entities)
Parameters
Type Name Description
IEntity[] entities

The entities describing the circuit.

Circuit(IEnumerable<IEntity>)

Initializes a new instance of the Circuit class.

Declaration
public Circuit(IEnumerable<IEntity> entities)
Parameters
Type Name Description
IEnumerable<IEntity> entities

The entities describing the circuit.

Properties

Comparer

Gets the comparer used to compare Entity names.

Declaration
public IEqualityComparer<string> Comparer { get; }
Property Value
Type Description
IEqualityComparer<string>

The comparer.

Count

Gets the number of elements contained in the ICollection<T>.

Declaration
public int Count { get; }
Property Value
Type Description
int

IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
bool

this[string]

Gets the IEntity with the specified name.

Declaration
public IEntity this[string name] { get; }
Parameters
Type Name Description
string name

The name of the entity.

Property Value
Type Description
IEntity

The IEntity.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

KeyNotFoundException

Thrown if no entity with the name name could be found.

Methods

Add(IEntity)

Adds an item to the ICollection<T>.

Declaration
public void Add(IEntity item)
Parameters
Type Name Description
IEntity item

The object to add to the ICollection<T>.

ByType<E>()

Gets all entities that are of a specified type.

Declaration
public IEnumerable<E> ByType<E>() where E : IEntity
Returns
Type Description
IEnumerable<E>

The entities.

Type Parameters
Name Description
E

The type of entity.

Clear()

Removes all items from the ICollection<T>.

Declaration
public void Clear()

Clone()

Clones the instance.

Declaration
public IEntityCollection Clone()
Returns
Type Description
IEntityCollection

The cloned instance.

Contains(IEntity)

Determines whether this instance contains the object.

Declaration
public bool Contains(IEntity item)
Parameters
Type Name Description
IEntity item

The object to locate in the ICollection<T>.

Returns
Type Description
bool

true if item is found in the ICollection<T>; otherwise, false.

Contains(string)

Determines whether this instance contains an IEntity with the specified name.

Declaration
public bool Contains(string name)
Parameters
Type Name Description
string name

The name.

Returns
Type Description
bool

true if the collection contains the entity; otherwise, false.

CopyTo(IEntity[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

Declaration
public void CopyTo(IEntity[] array, int arrayIndex)
Parameters
Type Name Description
IEntity[] array

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

int arrayIndex

The zero-based index in array at which copying begins.

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration
public IEnumerator<IEntity> GetEnumerator()
Returns
Type Description
IEnumerator<IEntity>

An enumerator that can be used to iterate through the collection.

Merge(Circuit)

Merge a circuit with this one. Entities are merged by reference!

Declaration
public void Merge(Circuit ckt)
Parameters
Type Name Description
Circuit ckt

The circuit to merge with.

Exceptions
Type Condition
ArgumentNullException

Thrown if ckt is null.

Remove(IEntity)

Removes the first occurrence of a specific object from the ICollection<T>.

Declaration
public bool Remove(IEntity item)
Parameters
Type Name Description
IEntity item

The object to remove from the ICollection<T>.

Returns
Type Description
bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Remove(string)

Removes the IEntity with specified name.

Declaration
public bool Remove(string name)
Parameters
Type Name Description
string name

The name of the entity.

Returns
Type Description
bool

true is the entity was removed succesfully; otherwise false.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

TryGetEntity(string, out IEntity)

Tries to find an Entity in the collection.

Declaration
public bool TryGetEntity(string name, out IEntity entity)
Parameters
Type Name Description
string name

The name of the entity.

IEntity entity

The entity.

Returns
Type Description
bool

True if the entity is found; otherwise false.

Implements

IEntityCollection
ICollection<T>
IEnumerable<T>
IEnumerable
ICloneable<T>

Extension Methods

Utility.ThrowIfNull<T>(T, string)
Helpers.IsValid(IEntityCollection)
Helpers.Validate(IEntityCollection)
Helpers.Validate(IEntityCollection, IRules)
Utility.ThrowIfEmpty<T>(IEnumerable<T>, string)

See Also

IEntityCollection
In this article
Back to top Generated by DocFX