using System; using System.Collections.Generic; using System.Linq; namespace RosettaUI { public static partial class UICustom { public static void RegisterPropertyOrFields(params string[] names) { TypeUtility.RegisterUITargetPropertyOrFields(typeof(T), names); } public static void UnregisterPropertyOrFields(params string[] names) { TypeUtility.UnregisterUITargetPropertyOrFields(typeof(T), names); } /// removed field name public static IEnumerable UnregisterPropertyOrFieldAll() { return TypeUtility.UnregisterUITargetPropertyOrFieldAll(typeof(T)); } #region Scope public readonly ref struct PropertyOrFieldsScope { private readonly IEnumerable _removedFieldNames; public PropertyOrFieldsScope(params string[] propertyOrFieldNames) { _removedFieldNames = UnregisterPropertyOrFieldAll(); RegisterPropertyOrFields(propertyOrFieldNames); } public void Dispose() { RegisterPropertyOrFields(_removedFieldNames.ToArray()); } } #endregion } }