Esempio n. 1
0
        public void Super(string behavior)
        {
            if (next == null)
            {
                throw new InvalidOperationException($"Super behavior can only be specified while behavior configuration is in progress. " +
                                                    $"Current: {Current}, Offending: {behavior}");
            }

            if (next.Includes(behavior))
            {
                throw new InvalidOperationException("Detected cyclic declaration of super behaviors. " +
                                                    $"'{behavior}' is already within super chain of {next.Name}");
            }

            var existent = current.FindSuper(behavior);

            if (existent != null)
            {
                next.Super(existent);
                return;
            }

            var prev = next;

            next = new CustomBehavior(behavior);

            prev.Super(next);
            var action = RegisteredAction(behavior);

            action(actor);

            next = prev;
        }
Esempio n. 2
0
 bool IncludedIn(CustomBehavior behavior) =>
 behavior?.FindSuper(Name) != null;
Esempio n. 3
0
 public CustomBehavior FindSuper(string name) =>
 Name == name ? this : super?.FindSuper(name);