📄 contactinfoitem!1.cs
字号:
namespace Imps.Client.Core
{
using Imps.Utils;
using System;
public class ContactInfoItem<T> : IDataCanProposed
{
private T _contactSet;
private UserSetData<T> _userSet;
public ContactInfoItem() : this(ReflectionHelper.GetDefaultValue<T>())
{
}
public ContactInfoItem(T contactSet)
{
this._contactSet = contactSet;
this._userSet = null;
}
public ContactInfoItem(T contactSet, T userSetValue)
{
this._contactSet = contactSet;
this._userSet = new UserSetData<T>(contactSet, userSetValue);
}
public ContactInfoItem(T contactSet, UserSetData<T> userSet)
{
this._contactSet = contactSet;
this._userSet = userSet;
}
public void AcceptUserSetData()
{
if (this._userSet != null)
{
this._userSet.ContactSetValue = this._contactSet;
}
}
public ContactInfoItem<T> CloneWithContactSetValue(T value)
{
return new ContactInfoItem<T>(value, this._userSet);
}
public ContactInfoItem<T> CloneWithNoUserSetValue()
{
return new ContactInfoItem<T>(this._contactSet);
}
public ContactInfoItem<T> CloneWithUserSetValue(T value)
{
return new ContactInfoItem<T>(this._contactSet, value);
}
public ContactInfoItem<T> CloneWithUserSetValue(T value, T defVal)
{
if (object.Equals(value, defVal))
{
return new ContactInfoItem<T>(this._contactSet);
}
return new ContactInfoItem<T>(this._contactSet, value);
}
public bool Equals(ContactInfoItem<T> val)
{
if ((val != null) && object.Equals(this._contactSet, val._contactSet))
{
return object.Equals(this._userSet, val._userSet);
}
return false;
}
public override bool Equals(object other)
{
if (other is ContactInfoItem<T>)
{
return this.Equals((ContactInfoItem<T>) other);
}
if (other is T)
{
return object.Equals(this.Value, (T) other);
}
return false;
}
public override int GetHashCode()
{
int hashCode = this._contactSet.GetHashCode();
if (this._userSet != null)
{
hashCode &= this._userSet.GetHashCode();
}
return hashCode;
}
public void ModifyProposedUserSetData(T val)
{
this.UserSetData.ProposedValue = val;
}
public void ModifyUserSetData(T val)
{
this._userSet = new UserSetData<T>(this._contactSet, val);
}
public static explicit operator ContactInfoItem<T>(T value)
{
return new ContactInfoItem<T>(value);
}
public static implicit operator T(ContactInfoItem<T> value)
{
return value.Value;
}
public void OverrideUserSetData()
{
this._userSet = null;
}
public void RemoveProposedValue()
{
if (this._userSet != null)
{
this._userSet.RemoveProposedValue();
}
}
public override string ToString()
{
if (object.Equals(null, this.Value))
{
return string.Empty;
}
return this.Value.ToString();
}
public T ContactSetData
{
get
{
return this._contactSet;
}
}
public bool HasProposedValue
{
get
{
if (this._userSet != null)
{
return this._userSet.HasProposedValue;
}
return false;
}
}
public bool HasUserSetData
{
get
{
return (null != this._userSet);
}
}
public object ProposedValue
{
get
{
if ((this._userSet != null) && (this._userSet != null))
{
return this._userSet.ProposedValue;
}
return null;
}
}
public bool ShouldPrompt
{
get
{
if (this._userSet != null)
{
return !object.Equals(this._userSet.ContactSetValue, this._contactSet);
}
return false;
}
}
internal UserSetData<T> UserSetData
{
get
{
return this._userSet;
}
}
public T UserSetDataProposedValue
{
get
{
if (this._userSet != null)
{
return this._userSet.Value;
}
return ReflectionHelper.GetDefaultValue<T>();
}
set
{
if (this._userSet == null)
{
this._userSet = new UserSetData<T>(this._contactSet, ReflectionHelper.GetDefaultValue<T>());
}
this._userSet.ProposedValue = value;
}
}
public T Value
{
get
{
if (this._userSet != null)
{
return this._userSet.Value;
}
return this._contactSet;
}
set
{
this.UserSetData.ProposedValue = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -