验证循环组织单元
我有一个对象组织单位,并且在同一个对象中对它有一个自引用
public class OrganizationUnit: IOrganizationUnit {
private string fName;
public string Name {
get { return fName; }
set { SetPropertyValue("Name", ref fName, (string) value); }
}
private OrganizationUnit fManagedBy;
public IOrganizationUnit ManagedBy {
get { return fManagedBy; }
set {
SetPropertyValue("ManagedBy", ref fManagedBy, (OrganizationUnit)value);
}
}
}
我需要一个方法,如果发现第三级中的子组织单位正在引用父组织单位,或者说循环父组织。
- A 是主要 B 由 AC 管理,不能由 A 管理
I have a object Organization Unit and I have a self reference to it in the same object
public class OrganizationUnit: IOrganizationUnit {
private string fName;
public string Name {
get { return fName; }
set { SetPropertyValue("Name", ref fName, (string) value); }
}
private OrganizationUnit fManagedBy;
public IOrganizationUnit ManagedBy {
get { return fManagedBy; }
set {
SetPropertyValue("ManagedBy", ref fManagedBy, (OrganizationUnit)value);
}
}
}
I need a method that will throw an exception if it finds a child organization unit in the third level is referencing a parent Organization unit, or to say cyclic parent organization.
- A is main B managed by A C cannot be managed by A
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遍历图表并保留访问过的节点的历史记录。如果你再次访问一个节点,你就检测到了一个循环:
Walk the graph and keep a history of visited nodes. If you visit a node again, you've detected a cycle: