AddRule 클래스
개체 모델에 추가 될 때 호출 되는 규칙을 나타냅니다.
상속 계층 구조
System.Object
Microsoft.VisualStudio.Modeling.Rule
Microsoft.VisualStudio.Modeling.AddRule
Microsoft.VisualStudio.Modeling.Diagrams.CommentShapeAddRule
Microsoft.VisualStudio.Modeling.Diagrams.NodeShape.ExpandCollapseNodeShapeWhenAddedToDiagramRule
Microsoft.VisualStudio.Modeling.Diagrams.ParentShapeContainsNestedChildShapesAddRule
Microsoft.VisualStudio.Modeling.Diagrams.ParentShapeHasRelativeChildShapesAddRule
Microsoft.VisualStudio.Modeling.Diagrams.ShapeElementAddRule
Microsoft.VisualStudio.Modeling.ElementDeserializedRule
네임스페이스: Microsoft.VisualStudio.Modeling
어셈블리: Microsoft.VisualStudio.Modeling.Sdk.11.0(Microsoft.VisualStudio.Modeling.Sdk.11.0.dll)
구문
‘선언
Public MustInherit Class AddRule _
Inherits Rule
public abstract class AddRule : Rule
AddRule 형식에서는 다음과 같은 멤버를 노출합니다.
생성자
이름 | 설명 | |
---|---|---|
AddRule | AddRule 클래스의 인스턴스를 초기화합니다. |
위쪽
속성
이름 | 설명 | |
---|---|---|
FireBefore | true 변경 하기 전에이 규칙 실행 되는 경우 발생 합니다. (Rule에서 상속됨) | |
FireImmediately | true 이 규칙의 변경 사항도 즉시 실행 하는 경우에 발생 합니다. (Rule에서 상속됨) | |
FireOnLocalCommit | true 때이 규칙을 실행 하면 현재 트랜잭션이 커밋합니다. (Rule에서 상속됨) | |
FireOnTopLevelCommit | true 때이 규칙을 실행 하는 경우 상위 수준의 트랜잭션이 커밋합니다. (Rule에서 상속됨) | |
FireTime | 규칙을 실행 해야 하는 경우를 나타내는 값을 가져오거나 설정 합니다.일반적으로 RuleOn 특성으로 설정 합니다. (Rule에서 상속됨) | |
IsEnabled | 규칙의 활성화 여부를 나타내는 값을 가져오거나 설정 합니다.기본적으로 일반적으로 true 있지만 RuleOn 특성을 false로 초기화 합니다. (Rule에서 상속됨) | |
Priority | 규칙에 할당 된 우선 순위를 가져옵니다.트랜잭션이 끝날 때 실행 되는 규칙의 순서를 결정 하는 데 도움이 됩니다. (Rule에서 상속됨) |
위쪽
메서드
이름 | 설명 | |
---|---|---|
CompareTo(Object) | 규칙에 다른 개체를 비교합니다. (Rule에서 상속됨) | |
CompareTo(Rule) | 규칙을 다른 규칙에 의해 해당 Id 비교합니다. (Rule에서 상속됨) | |
ElementAdded | 규칙 사용 된 수신기를 알려 줍니다. | |
Equals(Object) | 규칙에 다른 개체와 같은지 여부를 확인 합니다. (Rule에서 상속됨) | |
Equals(Rule) | 규칙을 다른 규칙 같은지 여부를 확인 합니다. (Rule에서 상속됨) | |
Finalize | 가비지 수집에서 회수하기 전에 개체에서 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다. (Object에서 상속됨) | |
GetHashCode | 규칙에 대 한 해시 코드를 가져옵니다. (Rule에서 상속됨) | |
GetType | 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨) | |
MemberwiseClone | 현재 Object의 단순 복사본을 만듭니다. (Object에서 상속됨) | |
ToString | 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨) |
위쪽
설명
이 형식의 규칙 요소, 관계, 도형, 연결선 또는 다이어그램 모델에 추가 될 때 트리거됩니다.
A RuleOnAttribute 특성 클래스에 배치를 나타내는 규칙 종류의 개체에 적용 하 고 합니다 규칙을 때 발생 합니다.
지정 된 형식의 개체를 모델에 추가 될 때 UI 또는 프로그래밍 방식으로 추가 되었는지 여부는 규칙 이라고 합니다.
규칙 또한 요소가 파일에서 로드 될 때 발생 합니다.이 문제가 발생 하면 컴퓨터가 응답 하지 발생 하지 않도록 하려면이 코드를 Elementadded에 포함 됩니다.
// Ignore this call if we're currently loading a model:
if (e.ModelElement.Store.TransactionManager
.CurrentTransaction.IsSerializing)
return;
자세한 내용과 예제를 보려면 규칙으로 모델 내부의 변경 내용 전파을 참조하십시오.
예제
다음 예제에서는 파생 규칙 정의 AddRule.이 규칙을 다이어그램에 추가할 때 도형의 위치를 설정 합니다.
RuleOn 특성 지정 합니다. 상위 수준의 트랜잭션을 커밋할 때 규칙 발생 합니다.
[RuleOn(typeof(ParentShapeContainsNestedChildShapes), FireTime = TimeToFire.TopLevelCommit)]
public class ShapeAddedToDiagramRule : AddRule
{
private double offset = 0.25;
private PointD location = new PointD(0.25, 0.25);
public override void ElementAdded(ElementAddedEventArgs e)
{
Shape shape = null;
ParentShapeContainsNestedChildShapes nestedLink = e.ModelElement as ParentShapeContainsNestedChildShapes;
if (nestedLink != null)
{
shape = nestedLink.NestedChildShapes as Shape;
}
if (shape != null && shape.Diagram != null)
{
// Expand the shape and move it to its new position
shape.IsExpanded = true;
shape.Location = new PointD(location.X, location.Y + offset);
// Adjust the height offset for the size of the shape
// (I'm assuming that the DefaultContainerMargin
// provides for a decent spacing between the shapes)
offset += shape.Size.Height + shape.Diagram.DefaultContainerMargin.Height;
}
}
}
스레드로부터의 안전성
이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.
참고 항목
참조
Microsoft.VisualStudio.Modeling 네임스페이스