本文整理汇总了C#中SafeDictionary类的典型用法代码示例。如果您正苦于以下问题:C# SafeDictionary类的具体用法?C# SafeDictionary怎么用?C# SafeDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeDictionary类属于命名空间,在下文中一共展示了SafeDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LocalCache
private LocalCache()
{
AllSecureCommandVMs = new List<SecureCommandViewModel>();
AllRoomGroupVMs = new List<RoomGroupViewModel>();
AllRoomVMs = new List<RoomViewModel>();
RoomServicePort = int.Parse(ConfigurationManager.AppSettings["RoomServicePort"]);
RoomAudioServicePort = int.Parse(ConfigurationManager.AppSettings["RoomAudioServicePort"]);
VideoFps = int.Parse(ConfigurationManager.AppSettings["VideoFps"]);
VideoQuality = int.Parse(ConfigurationManager.AppSettings["VideoQuality"]);
PublicChatMessageCount = int.Parse(ConfigurationManager.AppSettings["PublicChatMessageCount"]);
PrivateChatMessageCount = int.Parse(ConfigurationManager.AppSettings["PrivateChatMessageCount"]);
MessagePerSecond = int.Parse(ConfigurationManager.AppSettings["MessagePerSecond"]);
AllImages = new Dictionary<int, Dictionary<int, ImageViewModel>>();
AllGiftGroupVMs = new List<GiftGroupViewModel>();
AllGiftVMs = new List<GiftViewModel>();
AllUserVMs = new SafeDictionary<int, UserViewModel>();
AllRoleVMs = new List<RoleViewModel>();
AllCommandVMs = new List<CommandViewModel>();
AllRoleCommandVMs = new List<RoleCommandViewModel>();
AllRoomRoleVMs = new List<RoomRoleViewModel>();
AllExchangeRateVMs = new List<ExchangeRateViewModel>();
foreach(var imgType in BuiltIns.ImageTypes)
{
AllImages.Add(imgType.Id,new Dictionary<int,ImageViewModel>());
}
}
示例2: Clans
public Clans()
{
Members = new Dictionary<uint, ClanMembers>();
Allies = new SafeDictionary<uint, Clans>(10);
Enemies = new SafeDictionary<uint, Clans>(10);
}
示例3: Reset
public static void Reset()
{
Scores = new SafeDictionary<uint, Game.Clans>(100);
ClanFlag.Hitpoints = ClanFlag.MaxHitpoints;
IsWar = true;
}
示例4: GetFieldCrawlerValues
/// <summary>
/// The get field crawler values.
/// </summary>
/// <param name="field">
/// The field.
/// </param>
/// <param name="fieldCrawlers">
/// The field crawlers.
/// </param>
/// <returns>
/// The IEnumerable of field crawler values.
/// </returns>
public static IEnumerable<string> GetFieldCrawlerValues(Field field, SafeDictionary<string, string> fieldCrawlers)
{
Assert.IsNotNull(field, "Field was not supplied");
Assert.IsNotNull(fieldCrawlers, "Field Crawler collection is not specified");
if (fieldCrawlers.ContainsKey(field.TypeKey))
{
var fieldCrawlerType = fieldCrawlers[field.TypeKey];
if (!string.IsNullOrEmpty(fieldCrawlerType))
{
var fieldCrawler = ReflectionUtil.CreateObject(fieldCrawlerType, new object[] { field });
if (fieldCrawler is IMultivaluedFieldCrawler)
{
return (fieldCrawler as IMultivaluedFieldCrawler).GetValues();
}
if (fieldCrawler is FieldCrawlerBase)
{
return new[] { (fieldCrawler as FieldCrawlerBase).GetValue() };
}
}
}
return new[] { new DefaultFieldCrawler(field).GetValue() };
}
示例5: RunEnumeration
/// <summary>
/// Reflect the Class Name in the Source
/// </summary>
/// <param name="templateSource">
/// The template source.
/// </param>
/// <returns>
/// </returns>
private static Item[] RunEnumeration(string templateSource, Item sourceItem)
{
templateSource = templateSource.Replace("lucene:", string.Empty);
var commands = templateSource.Split(';');
var refinements = new SafeDictionary<string>();
foreach (var command in commands)
{
if (!command.IsNullOrEmpty())
{
var commandSplit = command.Split(':');
if (commandSplit.Length == 2)
{
refinements.Add(commandSplit[0], commandSplit[1]);
}
}
}
if (refinements.ContainsKey("location"))
{
int hitsCount;
var items = Context.ContentDatabase.GetItem(refinements["location"]).Search(refinements, out hitsCount);
return items.ToList().Select(x => x.GetItem()).ToArray();
}
else
{
int hitsCount;
var items = sourceItem.Search(refinements, out hitsCount);
return items.ToList().Select(x => x.GetItem()).ToArray();
}
}
示例6: InitializeSites
private void InitializeSites()
{
Database database = Factory.GetDatabase(DatabaseName, false);
if (database == null)
return;
if (_siteDictionary != null && _siteDictionary.Any())
return;
lock (_lock)
{
if (_siteDictionary != null && _siteDictionary.Any())
return;
var sitesCollection = new SiteCollection();
var siteDictionary = new SafeDictionary<string, Site>(StringComparer.InvariantCultureIgnoreCase);
foreach (Item siteItem in GetSiteDeinitionItems(database))
{
Site site = ResolveSite(siteItem);
if (site != null)
{
siteDictionary[site.Name] = site;
sitesCollection.Add(site);
}
}
_sitesCollection = sitesCollection;
_siteDictionary = siteDictionary;
}
}
示例7: Filter
public List<FacetReturn> Filter(Query query, List<SearchStringModel> searchQuery, string locationFilter, BitArray baseQuery)
{
var refinement = new SafeDictionary<string> { { "is facet", "1" } };
int hitsCount;
var facetFields =
Context.ContentDatabase.GetItem(ItemIDs.TemplateRoot)
.Search(refinement, out hitsCount, location: ItemIDs.TemplateRoot.ToString(),
numberOfItemsToReturn: 2000, pageNumber: 1)
.ToList()
.Select((item, sitecoreItem) =>
new
{
FieldId = item.ItemId,
Facet = new Facet(item.Name)
})
.ToList();
facetFields.Sort((f1, f2) => System.String.Compare(f1.Facet.FieldName, f2.Facet.FieldName, System.StringComparison.Ordinal));
var returnFacets = (from facetField in facetFields
from facet in facetField.Facet.GetValues(query, locationFilter, baseQuery).Select(facet => new FacetReturn
{
KeyName = facet.Key,
Value = facet.Value.ToString(),
Type = facetField.Facet.FieldName.ToLower(),
ID = facetField.FieldId + "|" + facet.Key
})
select facet).ToList();
return returnFacets.ToList();
}
示例8: InventoryComponent
internal InventoryComponent(uint UserId, GameClient Client, UserData UserData)
{
this.mClient = Client;
this.UserId = UserId;
this.floorItems = new HybridDictionary();
this.wallItems = new HybridDictionary();
this.discs = new HybridDictionary();
foreach (UserItem current in UserData.inventory)
{
if (current.GetBaseItem().InteractionType == InteractionType.musicdisc)
{
this.discs.Add(current.Id, current);
}
if (current.isWallItem)
{
this.wallItems.Add(current.Id, current);
}
else
{
this.floorItems.Add(current.Id, current);
}
}
this.InventoryPets = new SafeDictionary<uint, Pet>(UserData.pets);
this.InventoryBots = new SafeDictionary<uint, RoomBot>(UserData.Botinv);
this.mAddedItems = new HybridDictionary();
this.mRemovedItems = new HybridDictionary();
this.isUpdated = false;
}
示例9: AddRetweet
/// <summary>
/// Retweetしたユーザーとして追加します。
/// </summary>
public bool AddRetweet(TwitterUser user, DateTime time)
{
if (retweetDict == null)
retweetDict = new SafeDictionary<TwitterUser, DateTime>();
var ret = retweetDict.AddOrUpdate(user, time);
RetweetTableUpdated();
TweetModel.RaiseExtraDataTableUpdated(this.LinkId);
return ret;
}
示例10: GetItems
/// <summary>
/// Get Items to be loaded when the Control is loaded on the item
/// </summary>
/// <param name="current">
/// The current.
/// </param>
/// <returns>
/// Array of Item
/// </returns>
protected override Item[] GetItems(Item current)
{
Assert.ArgumentNotNull(current, "current");
var values = StringUtil.GetNameValues(Source, '=', '&');
var refinements = new SafeDictionary<string>();
if (values["FieldsFilter"] != null)
{
var splittedFields = StringUtil.GetNameValues(values["FieldsFilter"], ':', ',');
foreach (string key in splittedFields.Keys)
{
refinements.Add(key, splittedFields[key]);
}
}
var locationFilter = values["StartSearchLocation"];
locationFilter = MakeFilterQuerable(locationFilter);
var templateFilter = values["TemplateFilter"];
templateFilter = MakeTemplateFilterQuerable(templateFilter);
var pageSize = values["PageSize"];
var searchParam = new DateRangeSearchParam
{
Refinements = refinements,
LocationIds = locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(this.ItemID).GetParentBucketItemOrRootOrSelf().ID.ToString() : locationFilter,
TemplateIds = templateFilter,
FullTextQuery = values["FullTextQuery"],
Language = values["Language"],
PageSize = pageSize.IsEmpty() ? 10 : int.Parse(pageSize),
PageNumber = this.pageNumber,
SortByField = values["SortField"],
SortDirection = values["SortDirection"]
};
this.filter = "&location=" + (locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(this.ItemID).GetParentBucketItemOrRootOrSelf().ID.ToString() : locationFilter) +
"&filterText=" + values["FullTextQuery"] +
"&language=" + values["Language"] +
"&pageSize=" + (pageSize.IsEmpty() ? 10 : int.Parse(pageSize)) +
"&sort=" + values["SortField"];
if (values["TemplateFilter"].IsNotNull())
{
this.filter += "&template=" + templateFilter;
}
using (var searcher = new IndexSearcher(Constants.Index.Name))
{
var keyValuePair = searcher.GetItems(searchParam);
var items = keyValuePair.Value;
this.pageNumber = keyValuePair.Key / searchParam.PageSize;
if (this.pageNumber <= 0)
{
this.pageNumber = 1;
}
return items.Select(sitecoreItem => sitecoreItem.GetItem()).Where(i => i != null).ToArray();
}
}
示例11: AddCreateInfo
/// <summary>
///
/// </summary>
/// <param name="iRace"></param>
/// <param name="iClass"></param>
/// <param name="playerLevelStats"></param>
public void AddCreateInfo( uint iRace, uint iClass, WowCharacterCreateInfo playerCreateInfo )
{
SafeDictionary<uint, WowCharacterCreateInfo> safeWowPlayerCreateInfo = m_PlayerCreateInfo.GetValue( iRace );
if ( safeWowPlayerCreateInfo == null )
safeWowPlayerCreateInfo = new SafeDictionary<uint, WowCharacterCreateInfo>();
safeWowPlayerCreateInfo.Add( iClass, playerCreateInfo );
m_PlayerCreateInfo.Add( iRace, safeWowPlayerCreateInfo );
}
示例12: Start
public static void Start()
{
Scores = new SafeDictionary<uint, Game.Clans>(100);
StartTime = DateTime.Now;
//LeftGate.Mesh = (ushort)(240 + LeftGate.Mesh % 10);
//RightGate.Mesh = (ushort)(270 + LeftGate.Mesh % 10);
ServerBase.Kernel.SendWorldMessage(new Message("Clan war has began!", System.Drawing.Color.Red, Message.Center), ServerBase.Kernel.GamePool.Values);
FirstRound = true;
IsWar = true;
}
示例13: TestDefaultDefaultString
public void TestDefaultDefaultString()
{
var dic = new SafeDictionary<string, string>();
dic["A"] = "AA";
dic["B"] = "BB";
Assert.AreEqual("AA",dic["A"]);
Assert.IsNull(dic["C"]);
}
示例14: TestDefaultDefaultInt
public void TestDefaultDefaultInt()
{
var dic = new SafeDictionary<string, int>();
dic["A"] = 1;
dic["B"] = 2;
Assert.AreEqual(1, dic["A"]);
Assert.AreEqual(0, dic["C"]);
}
示例15: ReflectionService
/// <summary>
/// Default constructor
/// </summary>
public ReflectionService()
{
getPropertyAccessors =
new SafeDictionary<string, GetPropertyDelegate>();
setPropertyAccessors =
new SafeDictionary<string, SetPropertyDelegate>();
callAccessors =
new SafeDictionary<string, CallMethodDelegate>();
}