本文整理汇总了C#中UserInfo.Set方法的典型用法代码示例。如果您正苦于以下问题:C# UserInfo.Set方法的具体用法?C# UserInfo.Set怎么用?C# UserInfo.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserInfo
的用法示例。
在下文中一共展示了UserInfo.Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: get_and_set
public void get_and_set()
{
var foo = new Foo {Name = "Scooby"};
var bar = new Bar {Level = 33};
var user = new UserInfo();
user.Set(foo);
user.Set(bar);
user.Get<Foo>().ShouldBeTheSameAs(foo);
user.Get<Bar>().ShouldBeTheSameAs(bar);
}
示例2: ActOnInMessage
public void ActOnInMessage(IConMessage comMsg)
{
HubMessage message = (HubMessage)comMsg;
if (message is MainChat)
{
MainChat main = (MainChat)message;
MainMessage msg = new MainMessage(main.From, main.Content);
Update(hub, new FmdcEventArgs(Actions.MainMessage, msg));
}
else if (message is To)
{
To to = (To)message;
PrivateMessage pm = new PrivateMessage(to.To, to.From, to.Content);
Update(hub, new FmdcEventArgs(Actions.PrivateMessage, pm));
}
else if (message is SR)
{
SR searchResult = (SR)message;
SearchResultInfo srinfo = new SearchResultInfo(searchResult.Info, searchResult.From);
Update(hub, new FmdcEventArgs(Actions.SearchResult, srinfo));
}
else if (message is Search)
{
Search search = (Search)message;
if (hub.Share == null)
return;
int maxReturns = 5;
bool active = false;
if (search.Address != null)
{
maxReturns = 10;
active = true;
}
System.Collections.Generic.List<ContentInfo> ret = new System.Collections.Generic.List<ContentInfo>(maxReturns);
// TODO : This lookup can be done nicer
lock (hub.Share)
{
foreach (System.Collections.Generic.KeyValuePair<string, Containers.ContentInfo> var in hub.Share)
{
if (var.Value == null)
continue;
bool foundEnough = false;
string ext = search.Info.Get(SearchInfo.EXTENTION);
string sch = search.Info.Get(SearchInfo.SEARCH);
if (ext != null && sch != null)
{
ContentInfo contentInfo = new ContentInfo();
if (search.Info.ContainsKey(SearchInfo.TYPE))
{
switch (search.Info.Get(SearchInfo.TYPE))
{
case "2":
contentInfo.Set(ContentInfo.TTH, search.Info.Get(SearchInfo.SEARCH));
if (hub.Share.ContainsContent(ref contentInfo))
{
ret.Add(contentInfo);
}
// We are looking through whole share here.
// If no TTH matching. Ignore.
foundEnough = true;
break;
case "1":
default:
if (var.Value.ContainsKey(ContentInfo.VIRTUAL) && (System.IO.Path.GetDirectoryName(var.Value.Get(ContentInfo.VIRTUAL)).IndexOf(sch, System.StringComparison.OrdinalIgnoreCase) != -1))
ret.Add(var.Value);
break;
}
}
if (!foundEnough)
{
string infoExt = System.IO.Path.GetExtension(var.Value.Get(ContentInfo.VIRTUAL)).TrimStart('.');
if (
var.Value.ContainsKey(ContentInfo.VIRTUAL)
&& (var.Value.Get(ContentInfo.VIRTUAL).IndexOf(sch, System.StringComparison.OrdinalIgnoreCase) != -1)
&& (ext.Length == 0 || ext.Contains(infoExt))
)
ret.Add(var.Value);
}
}
if (foundEnough || ret.Count >= maxReturns)
break;
}
}
// Test against size restrictions
for (int i = 0; i < ret.Count; i++)
{
bool send = true;
long size = -1;
try
{
size = long.Parse(search.Info.Get(SearchInfo.SIZE));
}
catch { }
if (search.Info.ContainsKey(SearchInfo.SIZETYPE) && size != -1)
{
switch (search.Info.Get(SearchInfo.SIZETYPE))
{
//.........这里部分代码省略.........
示例3: MyINFO
// Receiving
public MyINFO(Hub hub, string raw)
: base(hub, raw)
{
int pos1, pos2;
if ((pos1 = raw.IndexOf("$MyINFO $ALL ")) != -1)
{
if ((pos2 = raw.IndexOf(" ", 13)) > 13)
{
from = raw.Substring(13, pos2 - 13);
// Zline<Z++ V:2.00,M:P,H:4/4/25,S:2>$ $DSL[email protected]$0$
string temp = raw.Substring(++pos2);
string[] sections = temp.Split('$');
info = new UserInfo();
info.DisplayName = from;
info.Set(UserInfo.STOREID, hub.StoreId + from);
if (sections.Length == 6)
{
int pos = 0;
if ((pos = sections[0].LastIndexOf('<')) != -1)
{
info.Description = sections[0].Substring(0, pos);
// <Z++ V:2.00,M:P,H:4/4/25,S:2>
info.TagInfo.Tag = sections[0].Substring(pos);
// Parsing of tag
}
else
{
info.Description = sections[0];
}
info.Connection = sections[2];
if (info.Connection.Length > 0)
{
statusFlag = (byte)info.Connection[info.Connection.Length - 1];
UserStatusFlag flag = ConvertByteToStatusFlag(statusFlag);
if ((flag & UserStatusFlag.TLS) == UserStatusFlag.TLS)
info.Set(UserInfo.SECURE, "");
}
info.Email = sections[3];
info.Share = sections[4];
}
if (!string.IsNullOrEmpty(info.DisplayName))
IsValid = true;
}
}
}