ArcGIS Pro 2.7 API Reference Guide
GetRules Method (TopologyDefinition)
Example 

ArcGIS.Core.Data.Topology Namespace > TopologyDefinition Class : GetRules Method
Gets the TopologyRules defined for this Topology. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Return Value

The TopologyRules defined for this Topology.
Exceptions
ExceptionDescription
A geodatabase-related exception has occurred.
Example
using (TopologyDefinition topologyDefinition = topology.GetDefinition())
{
  IReadOnlyList<TopologyRule> rules = topologyDefinition.GetRules();

  Console.WriteLine($"There are {rules.Count} topology rules defined for the topology:");
  Console.WriteLine("ID \t Origin Class \t Origin Subtype \t Destination Class \t Destination Subtype \t Rule Type");

  foreach (TopologyRule rule in rules)
  {
    Console.Write($"{rule.ID}");

    Console.Write(!String.IsNullOrEmpty(rule.OriginClass) ? $"\t{rule.OriginClass}" : "\t\"\"");

    Console.Write(rule.OriginSubtype != null ? $"\t{rule.OriginSubtype.GetName()}" : "\t\"\"");

    Console.Write(!String.IsNullOrEmpty(rule.DestinationClass) ? $"\t{rule.DestinationClass}" : "\t\"\"");

    Console.Write(rule.DestinationSubtype != null ? $"\t{rule.DestinationSubtype.GetName()}" : "\t\"\"");

    Console.Write($"\t{rule.RuleType}");

    Console.WriteLine();
  }
}
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

TopologyDefinition Class
TopologyDefinition Members