📄 personalgroupcollection.cs
字号:
namespace Imps.Client.Core
{
using Imps.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
public class PersonalGroupCollection : UserItemBase, ICollection<PersonalGroup>, IEnumerable<PersonalGroup>, IEnumerable
{
private List<PersonalGroup> _col;
private PersonalGroupLoadStatus _groupLoadStatus;
private object _syncObj;
private string _version;
public event EventHandler GroupLoadStatusChanged;
internal PersonalGroupCollection(User owner) : base(owner)
{
this._col = new List<PersonalGroup>();
this._syncObj = new object();
}
public void Add(PersonalGroup item)
{
lock (this._syncObj)
{
this._col.Add(item);
}
}
public void Clear()
{
this._col.Clear();
}
public bool Contains(PersonalGroup item)
{
return this._col.Contains(item);
}
public IEnumerator<PersonalGroup> GetEnumerator()
{
return this._col.GetEnumerator();
}
internal void OnMemberLoadStatusChanged(EventArgs e)
{
if (this.GroupLoadStatusChanged != null)
{
FuncDispatcher.InvokeEventHandlerInUiThread(this, this.GroupLoadStatusChanged, e);
}
}
public bool Remove(PersonalGroup item)
{
lock (this._syncObj)
{
if (this.Contains(item))
{
this._col.Remove(item);
return true;
}
return false;
}
}
public void Sort()
{
this._col.Sort();
}
void ICollection<PersonalGroup>.CopyTo(PersonalGroup[] array, int arrayIndex)
{
throw new NotSupportedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
public int Count
{
get
{
return this._col.get_Count();
}
}
public int CountButNotSuperManager
{
get
{
return (this.Count - this.CountSuperManager);
}
}
public int CountSuperManager
{
get
{
lock (this.SyncRoot)
{
int num = 0;
List<PersonalGroup>.Enumerator enumerator = this._col.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
if (((UserIdentity) enumerator.get_Current().UserInfo.GroupUserIdentity.Value) == UserIdentity.SuperManager)
{
num++;
}
}
}
finally
{
enumerator.Dispose();
}
return num;
}
}
}
public PersonalGroupLoadStatus GroupLoadStatus
{
get
{
return this._groupLoadStatus;
}
internal set
{
if (this._groupLoadStatus != value)
{
this._groupLoadStatus = value;
if (value != PersonalGroupLoadStatus.Loading)
{
this.OnMemberLoadStatusChanged(EventArgs.Empty);
}
}
}
}
public PersonalGroup this[int i]
{
get
{
return this._col.get_Item(i);
}
}
public PersonalGroup this[string uri]
{
get
{
lock (this._syncObj)
{
List<PersonalGroup>.Enumerator enumerator = this._col.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
PersonalGroup group = enumerator.get_Current();
if (group.Uri.Raw == uri)
{
return group;
}
}
}
finally
{
enumerator.Dispose();
}
return null;
}
}
}
public PersonalGroup this[IicUri uri]
{
get
{
return this[uri.Raw];
}
}
public object SyncRoot
{
get
{
return this._syncObj;
}
}
bool ICollection<PersonalGroup>.IsReadOnly
{
get
{
return this._col.get_IsReadOnly();
}
}
internal string Version
{
get
{
return this._version;
}
set
{
this._version = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -