def _track_change()

in libraries/botbuilder-dialogs/botbuilder/dialogs/memory/dialog_state_manager.py [0:0]


    def _track_change(self, path: str, value: object) -> bool:
        has_path = False
        segments = self._object_path_cls.try_resolve_path(self, path)
        if segments:
            root = segments[1] if len(segments) > 1 else ""

            # Skip _* as first scope, i.e. _adaptive, _tracker, ...
            if not root.startswith("_"):
                # Convert to a simple path with _ between segments
                path_name = "_".join(segments)
                tracked_path = f"{self.path_tracker}.{path_name}"
                counter = None

                def update():
                    nonlocal counter
                    last_changed = self.try_get_value(tracked_path, int)
                    if last_changed:
                        if counter is not None:
                            counter = self.get_value(int, DialogPath.EVENT_COUNTER)

                        self.set_value(tracked_path, counter)

                update()
                if not self._is_primitive(type(value)):
                    # For an object we need to see if any children path are being tracked
                    def check_children(property: str, instance: object):
                        nonlocal tracked_path
                        # Add new child segment
                        tracked_path += "_" + property.lower()
                        update()
                        if not self._is_primitive(type(instance)):
                            self._object_path_cls.for_each_property(
                                property, check_children
                            )

                        # Remove added child segment
                        tracked_path = tracked_path.Substring(
                            0, tracked_path.LastIndexOf("_")
                        )

                    self._object_path_cls.for_each_property(value, check_children)

            has_path = True

        return has_path