/// <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() }; }
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; } }
public static void Reset() { Scores = new SafeDictionary<uint, Game.Clans>(100); ClanFlag.Hitpoints = ClanFlag.MaxHitpoints; IsWar = true; }
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(); }
/// <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(); } }
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; }
public Clans() { Members = new Dictionary<uint, ClanMembers>(); Allies = new SafeDictionary<uint, Clans>(10); Enemies = new SafeDictionary<uint, Clans>(10); }
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>()); } }
/// <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(); } }
/// <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; }
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"]); }
public TDSGlobalInlinePayResult(string jsonStr) { var dic = Json.Deserialize(jsonStr) as Dictionary <string, object>; if (dic != null) { code = SafeDictionary.GetValue <int>(dic, "code"); message = SafeDictionary.GetValue <string>(dic, "message"); } }
/// <summary> /// Looks up a Descendant Item of a Parent by name /// </summary> /// <param name="name"> /// The item name to search for /// </param> public Item GetDescendant(string name) { var refinement = new SafeDictionary <string> { { "_name", name } }; int hitsCount; var result = this._item.Search(refinement, out hitsCount, location: this._item.ID.Guid.ToString()); return(result.IsNotNull() ? result.First().GetItem() : null); }
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; }
public TDSAccessToken(string json) { Dictionary <string, object> dic = Json.Deserialize(json) as Dictionary <string, object>; this.kid = SafeDictionary.GetValue <string>(dic, "kid") as string; this.access_token = SafeDictionary.GetValue <string>(dic, "access_token") as string; this.token_type = SafeDictionary.GetValue <string>(dic, "token_type") as string; this.mac_key = SafeDictionary.GetValue <string>(dic, "mac_key") as string; this.mac_algorithm = SafeDictionary.GetValue <string>(dic, "mac_algorithm") as string; }
public void TestDefaultDefaultString() { var dic = new SafeDictionary <string, string>(); dic["A"] = "AA"; dic["B"] = "BB"; Assert.AreEqual("AA", dic["A"]); Assert.IsNull(dic["C"]); }
/// <summary> /// Looks up a Child Element of a Parent by ID /// </summary> /// <param name="childId"> /// The ID of the child item /// </param> public Item GetChild(ID childId) { var refinement = new SafeDictionary <string> { { "_id", childId.Guid.ToString() } }; int hitsCount; var result = this._item.Search(refinement, out hitsCount, location: this._item.ID.Guid.ToString()); return(result.IsNotNull() ? result.First().GetItem() : null); }
public static SafeDictionary <string, TValue> Map <TValue>(this SafeDictionary <string, TValue> dictionary, Expression <Func <object, TValue> > pair) { var key = pair.Parameters[0].Name; var eval = pair.Compile().Invoke(new object[1]); dictionary[key] = eval; return(dictionary); }
public Tactic(Empire owner) : base(null, "Tactic") { Owner = owner; Inputs["combatant"] = new TacticObjectInput(this, typeof(ICombatant)); // combatant executing the tactic Inputs["combatants"] = new TacticObjectInput(this, typeof(IEnumerable <ICombatant>)); // all combatants in battle Outputs["waypoint"] = new TacticConnectionOutput(this, true, typeof(CombatWaypoint)); // location and speed to match Outputs["targets"] = new TacticConnectionOutput(this, false, typeof(IEnumerable <ICombatant>)); // targets for each weapon group in order WeaponGroups = new SafeDictionary <MountedComponentTemplate, int>(); }
public void GetNew_AddsKey(string key, int defaultValue) { IDictionary <string, int> sut = new SafeDictionary <string, int>(defaultValue); sut[key]++; var actual = sut[key]; Assert.Equal(1, actual); }
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"]); }
/// <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 ); }
public void 新增鍵值對KeyValuePair型別_新增成功_SafeDictionary內應包含該鍵值對() { var safeDictionary = new SafeDictionary <int, int>(); var pair = new KeyValuePair <int, int>(1, 5); ((ICollection <KeyValuePair <int, int> >)safeDictionary).Add(pair); const int expectedValue = 5; safeDictionary[1].Should().Be(expectedValue); }
/// <summary> ///GetEnumerator 的测试 ///</summary> public void GetEnumeratorTestHelper <KeyT, ValueT>() { SafeDictionary <KeyT, ValueT> target = new SafeDictionary <KeyT, ValueT>(); // TODO: 初始化为适当的值 IEnumerator <KeyValuePair <KeyT, ValueT> > expected = null; // TODO: 初始化为适当的值 IEnumerator <KeyValuePair <KeyT, ValueT> > actual; actual = target.GetEnumerator(); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public CargoDelta() { RacePopulation = new GalaxyReferenceKeyedDictionary <Race, long?>(); AllPopulation = false; AnyPopulation = 0L; Units = new GalaxyReferenceSet <IUnit>(); UnitDesignTonnage = new GalaxyReferenceKeyedDictionary <IDesign <IUnit>, int?>(); UnitRoleTonnage = new SafeDictionary <string, int?>(); UnitTypeTonnage = new SafeDictionary <VehicleTypes, int?>(); }
/// <summary> ///ToArray 的测试 ///</summary> public void ToArrayTestHelper <KeyT, ValueT>() { SafeDictionary <KeyT, ValueT> target = new SafeDictionary <KeyT, ValueT>(); // TODO: 初始化为适当的值 KeyValuePair <KeyT, ValueT>[] expected = null; // TODO: 初始化为适当的值 KeyValuePair <KeyT, ValueT>[] actual; actual = target.ToArray(); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void TestDefaultDefaultString() { var dic = new SafeDictionary<string, string>(); dic["A"] = "AA"; dic["B"] = "BB"; Assert.AreEqual("AA",dic["A"]); Assert.IsNull(dic["C"]); }
public override void Act(TDomain domain, TContext context, SafeDictionary <string, ICollection <string> > EnabledMinisters) { var variables = new Dictionary <string, object>(); variables.Add("domain", domain); var readOnlyVariables = new Dictionary <string, object>(); readOnlyVariables.Add("context", context); readOnlyVariables.Add("enabledMinisters", EnabledMinisters); PythonScriptEngine.RunScript <object>(Script as PythonScript, variables, readOnlyVariables); }
public static SafeList <Field> GetInvolvedFields(IPexComponent host, TermManager termManager, Term t, out SafeDictionary <Field, FieldValueHolder> fieldValues, out SafeList <TypeEx> allFieldTypes) { using (var ofc = new ObjectFieldCollector(host, termManager)) { ofc.VisitTerm(default(TVoid), t); fieldValues = ofc.FieldValues; allFieldTypes = ofc.Types; return(ofc.Fields); } }
/// <summary> /// Default constructor /// </summary> public ReflectionService() { getPropertyAccessors = new SafeDictionary<string, GetPropertyDelegate>(); setPropertyAccessors = new SafeDictionary<string, SetPropertyDelegate>(); callAccessors = new SafeDictionary<string, CallMethodDelegate>(); }
/// <summary> /// simplifies the term based on the contents of the term. all /// </summary> /// <param name="host"></param> /// <param name="termManager"></param> /// <param name="condition"></param> /// <param name="binOp"></param> private static Term SimplifyTerm(IPexExplorationComponent host, TermManager termManager, Term condition) { Term left, right; BinaryOperator binOp; if (!termManager.TryGetBinary(condition, out binOp, out left, out right)) { return(condition); } if (!IsInteger(termManager, left) || !IsInteger(termManager, right)) { return(condition); } //Check whether the term is of the form x > 20, where one side is a constant. then no simplification needs to be done if (termManager.IsValue(left)) { //one side is constant. so just return over here return(condition); } if (termManager.IsValue(right)) { //one side is constant. so just return over here return(condition); } //none of the sides are concrete. both sides are symbolic. //find out which side can be more controlled based on the variables //contained on that side SafeList <Field> allFieldsInLeftCondition = new SafeList <Field>(); SafeList <TypeEx> allFieldTypes = new SafeList <TypeEx>(); SafeDictionary <Field, FieldValueHolder> leftfields = new SafeDictionary <Field, FieldValueHolder>(); VariablesCollector.Collect(termManager, left, leftfields, allFieldsInLeftCondition, allFieldTypes); //TODO: How to get the concrete value of the other side, could be either left //or right. and make a term out of the concrete value int lvalue; if (termManager.TryGetI4Constant(left, out lvalue)) { } int rvalue; if (termManager.TryGetI4Constant(right, out rvalue)) { } return(condition); }
/// <summary> /// 获取组件 /// </summary> private void Awake() { playerManager = GetComponent <PlayerManager>(); healthManager = GetComponent <HealthManager>(); attackManager = GetComponent <AttackManager>(); rigidbodySelf = GetComponent <Rigidbody>(); colliderSelf = GetComponent <Collider>(); startState = currentState; statePrefs = new SafeDictionary <CommonCode, object>(); instancePrefs = new SafeDictionary <CommonCode, object>(); }
public void ParseImapHeader() { SafeDictionary <string, string> headers = Utilities.ParseImapHeader(imapHeader); Assert.Equal("1454534995031287656", headers["X-GM-THRID"]); Assert.Equal("1454535169876473534", headers["X-GM-MSGID"]); Assert.Equal("\"\\Important\" \"\\Sent\"", headers["X-GM-LABELS"]); Assert.Equal("16638", headers["UID"]); Assert.Equal("\"16-Dec-2013 00:13:53 +0000\"", headers["INTERNALDATE"]); Assert.Equal("\\Seen", headers["FLAGS"]); }
/// <summary> ///ContainsKey 的测试 ///</summary> public void ContainsKeyTestHelper <KeyT, ValueT>() { SafeDictionary <KeyT, ValueT> target = new SafeDictionary <KeyT, ValueT>(); // TODO: 初始化为适当的值 KeyT key = default(KeyT); // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.ContainsKey(key); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///Exists 的测试 ///</summary> public void ExistsTestHelper <KeyT, ValueT>() { SafeDictionary <KeyT, ValueT> target = new SafeDictionary <KeyT, ValueT>(); // TODO: 初始化为适当的值 Predicate <KeyT, ValueT> match = null; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.Exists(match); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///FindAll 的测试 ///</summary> public void FindAllTestHelper <KeyT, ValueT>() { SafeDictionary <KeyT, ValueT> target = new SafeDictionary <KeyT, ValueT>(); // TODO: 初始化为适当的值 Predicate <KeyT, ValueT> match = null; // TODO: 初始化为适当的值 KeyValuePair <KeyT, ValueT>[] expected = null; // TODO: 初始化为适当的值 KeyValuePair <KeyT, ValueT>[] actual; actual = target.FindAll(match); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public static SafeList<Field> GetInvolvedFields(IPexComponent host, TermManager termManager, Term t, out SafeDictionary<Field, FieldValueHolder> fieldValues, out SafeList<TypeEx> allFieldTypes) { using (var ofc = new ObjectFieldCollector(host, termManager)) { ofc.VisitTerm(default(TVoid), t); fieldValues = ofc.FieldValues; allFieldTypes = ofc.Types; return ofc.Fields; } }
public GenDataProvider() : base() { this.oDescendantsLock = new ReaderWriterLock(); this.oPrefetchCacheLock = new object(); this.oPrefetchLock = new object(); this.oPrefetchSpecifications = new Collection <Pair <string, ID> >(); this.oPrefetchStatistics = new SafeDictionary <ID, int>(); this.lPrefetchCacheSize = Settings.Caching.DefaultDataCacheSize; this.oPrefetchChildLimit = 10000; }
/// <summary> ///GetValue 的测试 ///</summary> public void GetValueTestHelper <KeyT, ValueT>() { SafeDictionary <KeyT, ValueT> target = new SafeDictionary <KeyT, ValueT>(); // TODO: 初始化为适当的值 KeyT key = default(KeyT); // TODO: 初始化为适当的值 ValueT expected = default(ValueT); // TODO: 初始化为适当的值 ValueT actual; actual = target.GetValue(key); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> /// Determines what an empire would unlock by researching the next level of this technology. /// </summary> /// <param name="emp"></param> /// <returns></returns> public IEnumerable <IUnlockable> GetExpectedResults(Empire emp) { var techs = new SafeDictionary <Technology, int>(); foreach (var kvp in emp.ResearchedTechnologies) { techs.Add(kvp.Key, kvp.Value); } techs[this]++; return(GetUnlockedItems(emp, techs)); }
static void InitMicCache(int roomId, MicType micType, int count) { if (count > 0) { micCache[roomId][micType] = new SafeDictionary <int, MicStatusMessage>(); for (int i = 0; i < count; i++) { micCache[roomId][micType][i] = new MicStatusMessage(); } } }
public TDSGlobalUser(string json) { Dictionary <string, object> dic = Json.Deserialize(json) as Dictionary <string, object>; this.userId = SafeDictionary.GetValue <long>(dic, "userId"); this.sub = SafeDictionary.GetValue <string>(dic, "sub"); this.name = SafeDictionary.GetValue <string>(dic, "name"); this.loginType = SafeDictionary.GetValue <int>(dic, "loginType"); this.boundAccounts = SafeDictionary.GetValue <List <string> >(dic, "boundAccounts"); this.token = new TDSGlobalAccessToken(SafeDictionary.GetValue <Dictionary <string, object> >(dic, "token")); }
public static void CopyProperties(object source, SafeDictionary <string, string> target) { foreach (var propertyInfo in source.GetType().GetProperties()) { var obj = propertyInfo.GetValue(source, null); if (obj != null) { target[propertyInfo.Name.Replace("_", "-")] = obj.ToString(); } } }
private List <RenderingDefinition> GetRenderingDefinitions(SafeDictionary <string> data) { var device = data["deviceId"]; var renderingFieldId = WebUtility.IsEditAllVersionsTicked() ? FieldIDs.LayoutField : FieldIDs.FinalLayoutField; var field = item.Fields[renderingFieldId]; var layoutXml = Sitecore.Data.Fields.LayoutField.GetFieldValue(field); var layout = LayoutDefinition.Parse(layoutXml); var deviceLayout = string.IsNullOrEmpty(device) ? layout.Devices[0] as DeviceDefinition : layout.GetDevice(device); return(deviceLayout?.Renderings.ToArray().Select(r => r as RenderingDefinition).ToList()); }
public static void CopyProperties(object source, SafeDictionary<string, string> target) { foreach (var propertyInfo in source.GetType().GetProperties()) { var obj = propertyInfo.GetValue(source, null); if (obj != null) { target[propertyInfo.Name.Replace("_", "-")] = obj.ToString(); } } }
public void 新增鍵值對_新增成功_SafeDictionary內應包含該鍵值對() { var safeDictionary = new SafeDictionary <int, int>(); const int key = 1; const int value = 5; safeDictionary.Add(key, value); const int expectedValue = 5; safeDictionary[1].Should().Be(expectedValue); }
public void 拷貝SafeDictionary_從Index0開始拷貝_拷貝的結果應該與SafeDictionary相同() { var safeDictionary = new SafeDictionary <int, int>(); var fixture = new Fixture(); safeDictionary.AddMany(fixture.Create <KeyValuePair <int, int> >, 3); var array = new KeyValuePair <int, int> [3]; safeDictionary.CopyTo(array, 0); array.SequenceEqual(safeDictionary).Should().Be(true); }
public static void Start() { Scores = new SafeDictionary<uint, Guild>(100); StartTime = DateTime.Now; ServerBase.Kernel.SendWorldMessage(new Message("Elite Guild war has began!", System.Drawing.Color.Red, Message.Center), ServerBase.Kernel.GamePool.Values); FirstRound = true; foreach (Guild guild in ServerBase.Kernel.Guilds.Values) { guild.WarScore = 0; } IsWar = true; }
protected SafeDictionary<string> GetRefinements() { var refinements = new SafeDictionary<string>(); if (!FieldName1TextBox.Text.IsNullOrEmpty() && !FieldValue1TextBox.Text.IsNullOrEmpty()) refinements.Add(FieldName1TextBox.Text, FieldValue1TextBox.Text); if (!FieldName2TextBox.Text.IsNullOrEmpty() && !FieldValue2TextBox.Text.IsNullOrEmpty()) refinements.Add(FieldName2TextBox.Text, FieldValue2TextBox.Text); return refinements; }
public void TestCustomDefaultString() { var dic = new SafeDictionary<string, string>(); dic.DefaultValue = ""; dic["A"] = "AA"; dic["B"] = "BB"; Assert.AreEqual("AA", dic["A"]); Assert.AreEqual("", dic["C"]); }
public void TestCustomDefaultInt() { var dic = new SafeDictionary<string, int>(); dic.DefaultValue = 999; dic["A"] = 1; dic["B"] = 2; Assert.AreEqual(1, dic["A"]); Assert.AreEqual(999, dic["C"]); }
/// <summary> /// Converts a SafeDictionary into HTML attributes /// </summary> /// <param name="attributes">A list of attributes to convert</param> /// <returns>System.String.</returns> public static string ConvertAttributes(SafeDictionary<string> attributes, string quotationMark) { if (attributes == null || attributes.Count == 0) return ""; StringBuilder sb = new StringBuilder(); foreach (var pair in attributes) { sb.AppendFormat("{0}={2}{1}{2} ".Formatted(pair.Key, pair.Value ??"", quotationMark)); } return sb.ToString(); }
private static void CopyProperties(object source, SafeDictionary<string, string> target) { var sourceDict = ObjectToHtmlAttributes(source); foreach (var property in sourceDict) { var value = property.Value; if (value != null) { target[property.Key] = value.ToString(); } } }
public HeaderValue(string value) : this() { _Values = new SafeDictionary<string, string>(StringComparer.OrdinalIgnoreCase); _RawValue = (value ?? (value = string.Empty)); _Values[string.Empty] = RawValue; var semicolon = value.IndexOf(';'); if (semicolon > 0) { _Values[string.Empty] = value.Substring(0, semicolon).Trim(); value = value.Substring(semicolon).Trim(); ParseValues(_Values, value); } }
/// <summary> /// Initializes a new instance of the ChunkGeneratorBase class. /// </summary> public WorldGeneratorBase() { // set default generation options, may be changed later GenerationOptions = new SafeDictionary<int, object>(); GenerationOptions[GenerationOption.EnableBigTreesOption] = false; GenerationOptions[GenerationOption.EnableCavesOption] = false; GenerationOptions[GenerationOption.WaterLevelOption] = 20; GenerationOptions[GenerationOption.TreeDensityOption] = 0.008f; // set default chunk size to 32 // TODO: must be updated when Server.chunksize is changed this.ChunkSize = 32; }
public static void Reset() { Scores = new SafeDictionary<uint, Guild>(100); Poles.Hitpoints = Poles.MaxHitpoints; foreach (Guild guild in ServerBase.Kernel.Guilds.Values) { guild.WarScore = 0; } IsWar = true; }
public static SafeDictionary<string> ToSafeDictionary(this NameValueCollection collection) { var safeDictionary = new SafeDictionary<string>(); if (collection != null) { foreach (var key in collection.AllKeys) { safeDictionary.Add(key, collection[key]); } } return safeDictionary; }
public FindPeopleConsole(METAboltInstance instance, UUID queryID) { InitializeComponent(); findPeopleResults = new SafeDictionary<string, UUID>(); this.queryID = queryID; this.instance = instance; //netcom = this.instance.Netcom; client = this.instance.Client; AddClientEvents(); lvwColumnSorter = new NumericStringComparer(); lvwFindPeople.ListViewItemSorter = lvwColumnSorter; }
public MethodEffects(IFiniteSet<Field> writtenInstanceFields, IFiniteSet<Field> directSetFields, IFiniteSet<Method> directCalledMethods, IFiniteSet<Field> returnFields, SafeDictionary<Field, FieldModificationType> modificationTypeDic, int callDepth) { SafeDebug.AssumeNotNull(writtenInstanceFields, "writtenInstanceFields"); SafeDebug.Assume(callDepth >= 0, "callDepth>=0"); this.WrittenInstanceFields = writtenInstanceFields; this.DirectSetterFields = directSetFields; this.DirectCalledMethods = directCalledMethods; this.ReturnFields = returnFields; this.ModificationTypeDictionary = modificationTypeDic; this.CallDepth = callDepth; }
public FindPlaces(METAboltInstance instance, UUID queryID) { InitializeComponent(); findPlacesResults = new SafeDictionary<string, DirectoryManager.DirectoryParcel>(); this.queryID = queryID; this.instance = instance; //netcom = this.instance.Netcom; client = this.instance.Client; AddClientEvents(); lvwColumnSorter = new NumericStringComparer(); lvwFindPlaces.ListViewItemSorter = lvwColumnSorter; }