Open sandboxFocus
  • TOC

Post­Sharp Documentation

Introduction

Deployment and Configuration

Adding Aspects to Code

Logging

Contracts

INotify­Property­Changed

Weak Event

XAML

Parent/Child, Visitor and Disposable

Undo/Redo

Caching

Multithreading

Developing Custom Aspects

Validating Architecture

Testing and Debugging

Miscellaneous

API Reference

Post­Sharp

Post­Sharp.​Aspects

Post­Sharp.​Aspects.​Advices

Post­Sharp.​Aspects.​Configuration

Post­Sharp.​Aspects.​Dependencies

Post­Sharp.​Aspects.​Internals

Post­Sharp.​Aspects.​Serialization

Post­Sharp.​Collections

Post­Sharp.​Constraints

Post­Sharp.​Extensibility

Post­Sharp.​Extensibility.​Build­Time­Logging

Post­Sharp.​Patterns

Post­Sharp.​Patterns.​Caching

Post­Sharp.​Patterns.​Caching.​Backends

Post­Sharp.​Patterns.​Caching.​Backends.​Azure

Post­Sharp.​Patterns.​Caching.​Backends.​Redis

Post­Sharp.​Patterns.​Caching.​Dependencies

Post­Sharp.​Patterns.​Caching.​Formatters

Post­Sharp.​Patterns.​Caching.​Implementation

Post­Sharp.​Patterns.​Caching.​Locking

Post­Sharp.​Patterns.​Caching.​Serializers

Post­Sharp.​Patterns.​Caching.​Value­Adapters

Post­Sharp.​Patterns.​Collections

Post­Sharp.​Patterns.​Collections.​Advices

Post­Sharp.​Patterns.​Contracts

Post­Sharp.​Patterns.​Diagnostics

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Core

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Framework

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Diagnostic­Source

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Http­Client

Post­Sharp.​Patterns.​Diagnostics.​Audit

Post­Sharp.​Patterns.​Diagnostics.​Backends

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Application­Insights

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Audit

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Common­Logging

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Console

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Event­Source

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Log4Net

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Microsoft

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Multiplexer

Post­Sharp.​Patterns.​Diagnostics.​Backends.​NLog

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Null

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Serilog

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Trace

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Trace­Source

Post­Sharp.​Patterns.​Diagnostics.​Contexts

Post­Sharp.​Patterns.​Diagnostics.​Correlation

Post­Sharp.​Patterns.​Diagnostics.​Custom

Post­Sharp.​Patterns.​Diagnostics.​Custom.​Messages

Post­Sharp.​Patterns.​Diagnostics.​Formatters

Post­Sharp.​Patterns.​Diagnostics.​Record­Builders

Post­Sharp.​Patterns.​Diagnostics.​Threading­Instrumentation

Post­Sharp.​Patterns.​Diagnostics.​Transactions

Post­Sharp.​Patterns.​Diagnostics.​Transactions.​Model

Post­Sharp.​Patterns.​Dynamic­Advising

Post­Sharp.​Patterns.​Formatters

Post­Sharp.​Patterns.​Model

Post­Sharp.​Patterns.​Model.​Controls

Post­Sharp.​Patterns.​Model.​Type­Adapters

Post­Sharp.​Patterns.​Recording

Post­Sharp.​Patterns.​Recording.​Operations

Post­Sharp.​Patterns.​Threading

Post­Sharp.​Patterns.​Threading.​Models

Post­Sharp.​Patterns.​Utilities

Post­Sharp.​Patterns.​Xaml

Post­Sharp.​Reflection

Post­Sharp.​Reflection.​Method­Body

Post­Sharp.​Serialization

  • Article

Class AdvisableHashSet<T>

A collection type similar to HashSet<T> into which advices can be injected dynamically.

Inheritance
AdvisableHashSet<T>
Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common.dll
Syntax
public class AdvisableHashSet<T> : DynamicallyAdvisableObject, ISerializable, IDeserializationCallback, ISet<T>, ICollection<T>, IEnumerable<T>, IDynamicallyAdvisableHashSet, IDynamicallyAdvisable, IQueryInterface, ICollection, IEnumerable
Type Parameters
Name Description
T

The type of elements in the collection

Remarks

The API of this class is compatible with the HashSet<T> class. It provides some additions but preserves the same design and naming conventions.

Classes that derive from HashSet<T> can add functionalities by overriding protected methods or by defining new public methods. New public methods wrap their logic in a call of the ExecuteWithAdvices<TResult, TAction>(ObjectAccessLevel, ref TAction) method, which applies boundary aspects. Public methods can access the data structure thanks to protected methods, which have a name ending in Item, for instance AddItem(T). Public methods should not use other public methods of the class, as it may cause inconsistent invocation of advises and performance issues.

Constructors

Name Description
AdvisableHashSet()

Initializes a new instance of the AdvisableHashSet<T> class that is empty and uses the default equality comparer for the set type.

AdvisableHashSet(IEnumerable<T>)

Initializes a new instance of the AdvisableHashSet<T> class that uses the default equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

AdvisableHashSet(IEnumerable<T>, IEqualityComparer<T>)

Initializes a new instance of the AdvisableHashSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

AdvisableHashSet(IEqualityComparer<T>)

Initializes a new instance of the AdvisableHashSet<T> class that is empty and uses the specified equality comparer for the set type.

Properties

Name Description
Comparer

Gets the IEqualityComparer<T> object that is used to determine equality for the values in the set.

Count

Methods

Name Description
Add(T)
AddItem(T)

Inserts an element into the underlying set.

ChangeManyItems(IList<T>, IList<T>)

Modifies the underlying set by adding and removing the specified items.

Clear()
ClearItems()

Removes all elements from the underlying set.

Contains(T)
CopyTo(T[])

Copies the elements of an AdvisableHashSet<T> object to an array.

CopyTo(T[], int)
CopyTo(T[], int, int)

Copies the specified number of elements of an AdvisableHashSet<T> object to an array, starting at the specified array index.

CreateSetComparer()

Returns an IEqualityComparer object that can be used for equality testing of a AdvisableHashSet<T> object.

ExceptWith(IEnumerable<T>)
GetAdviceEnumerator()

Gets an AdviceEnumerator<T> for the ICollectionDynamicAdvice<T> interface.

GetEnumerator()

Returns an enumerator that iterates through the AdvisableHashSet<T>.

GetObjectData(SerializationInfo, StreamingContext)
IntersectWith(IEnumerable<T>)
IsProperSubsetOf(IEnumerable<T>)
IsProperSupersetOf(IEnumerable<T>)
IsSubsetOf(IEnumerable<T>)
IsSupersetOf(IEnumerable<T>)
OnDeserialization(object)
Overlaps(IEnumerable<T>)
Remove(T)
RemoveItem(T)

Removes an element from the underlying collection.

RemoveWhere(Predicate<T>)

Removes all elements that match the conditions defined by the specified predicate from a HashSet<T> collection.

SetEquals(IEnumerable<T>)
SymmetricExceptWith(IEnumerable<T>)
TrimExcess()

Sets the capacity of a AdvisableHashSet<T> object to the actual number of elements it contains, rounded up to a nearby, implementation-specific value.

UnionWith(IEnumerable<T>)

Extension Methods