### Implement Query Example App in C# Source: https://github.com/liangxiegame/qframework/blob/master/QFramework.Unity2018+/Assets/QFramework/Toolkits/_CoreKit/Internal/Guidline/Editor/Resources/EditorGuideline/2. 架构篇:QFramework.cs/09. Query 介绍.md This snippet demonstrates the implementation of a Query example application using QFramework. It includes model definitions, architecture setup, a concrete Query class for fetching school population, and UI elements for triggering the query. ```csharp using System.Collections.Generic; using UnityEngine; namespace QFramework.Example { public class QueryExampleController : MonoBehaviour,IController { public class StudentModel : AbstractModel { public List StudentNames = new List() { "张三", "李四" }; protected override void OnInit() { } } public class TeacherModel : AbstractModel { public List TeacherNames = new List() { "王五", "赵六" }; protected override void OnInit() { } } // Architecture public class QueryExampleApp : Architecture { protected override void Init() { this.RegisterModel(new StudentModel()); this.RegisterModel(new TeacherModel()); } } /// /// 获取学校的全部人数 /// public class SchoolAllPersonCountQuery : AbstractQuery { protected override int OnDo() { return this.GetModel().StudentNames.Count + this.GetModel().TeacherNames.Count; } } private int mAllPersonCount = 0; private void OnGUI() { GUILayout.Label(mAllPersonCount.ToString()); if (GUILayout.Button("查询学校总人数")) { mAllPersonCount = this.SendQuery(new SchoolAllPersonCountQuery()); } } public IArchitecture GetArchitecture() { return QueryExampleApp.Interface; } } } ``` -------------------------------- ### QFramework.cs Architecture Example Source: https://github.com/liangxiegame/qframework/blob/master/QFramework.Unity2018+/Assets/QFramework/Toolkits/_CoreKit/Internal/Guidline/Editor/Resources/EditorGuideline/1. 介绍/01.简介.md Demonstrates a typical controller implementation using QFramework.cs for managing application state and UI interactions. It shows how to get models, find UI components, and send commands. ```csharp namespace QFramework.Exmaple { public class CounterAppController : MonoBehaviour , IController { // View private Button mBtnAdd; private Button mBtnSub; private Text mCountText; // Model private ICounterAppModel mModel; void Start() { // 获取模型 mModel = this.GetModel(); // View 组件获取 mBtnAdd = transform.Find("BtnAdd").GetComponent