public void TestPofSerialization() { ISerializer serializer = new SimplePofContext(); IDictionary original = InstantiateDictionary(); original.Add("A", "A"); original.Add("B", "B"); original.Add("C", "C"); var stream = new BinaryMemoryStream(); serializer.Serialize(new DataWriter(stream), original); Binary bin = stream.ToBinary(); IPofReader reader = new PofStreamReader(bin.GetReader(), (IPofContext)serializer); Object copy = reader.ReadDictionary(-1, InstantiateDictionary()); Assert.AreEqual(original, copy); Assert.AreEqual(original.GetHashCode(), copy.GetHashCode()); original.Add(null, null); stream = new BinaryMemoryStream(); serializer.Serialize(new DataWriter(stream), original); bin = stream.ToBinary(); reader = new PofStreamReader(bin.GetReader(), (IPofContext)serializer); copy = reader.ReadDictionary(-1, InstantiateDictionary()); Assert.AreEqual(original, copy); Assert.AreEqual(original.GetHashCode(), copy.GetHashCode()); Assert.AreEqual(original.ToString(), copy.ToString()); }
public override int GetHashCode() { if (consumerIdString != null && topicCountMap != null) { return(consumerIdString.GetHashCode() ^ topicCountMap.GetHashCode()); } if (consumerIdString != null) { return(consumerIdString.GetHashCode()); } if (topicCountMap != null) { return(topicCountMap.GetHashCode()); } return(0); }
public override int GetHashCode() { return(source.GetHashCode() ^ destination.GetHashCode() ^ routingKey.GetHashCode() ^ (arguments != null ? arguments.GetHashCode() : 0)); }
/// <summary> /// Determines whether the specified Object is equal to the current Object. /// </summary> /// <param name="obj">The Object to compare with the current Object. </param> /// <returns>true if the specified Object is equal to the current Object; /// otherwise, false.</returns> public override bool Equals(object obj) { //if(!(obj instanceof Map)) // return false; //Map m = (Map) obj; IDictionary d = obj as IDictionary; if (d == null) { return(false); } // Java had the following. // This works on other APersistentMap implementations, but not on // arbitrary dictionaries. if (d.Count != this.Count || d.GetHashCode() != this.GetHashCode()) { return(false); } //if (d.Count != this.Count) // return false; for (ISeq s = seq(); s != null; s = s.next()) { IMapEntry me = (IMapEntry)s.first(); bool found = d.Contains(me.key()); if (!found || !Util.equals(me.val(), d[me.key()])) { return(false); } } return(true); }
public override int GetHashCode() { int result = _instances.GetHashCode(); result = 31 * result + ( int )(_lastDeliveredInstanceId ^ (( long )(( ulong )_lastDeliveredInstanceId >> 32))); return(result); }
public override int GetHashCode() { int result = _failed != null?_failed.GetHashCode() : 0; result = 31 * result + (_nodeSuspicions != null ? _nodeSuspicions.GetHashCode() : 0); return(result); }
public override int GetHashCode() { unchecked { return(((_dictionary != null ? _dictionary.GetHashCode() : 0) * 397) ^ (Provenance != null ? Provenance.GetHashCode() : 0)); } }
public override int GetHashCode() { var result = generalErrors.GetHashCode(); result = 31 * result + fieldErrors.GetHashCode(); return(result); }
public override int GetHashCode() { int result = _roles != null?_roles.GetHashCode() : 0; result = 31 * result + (_elections != null ? _elections.GetHashCode() : 0); return(result); }
private void RequeueCommand(IDictionary <string, object> command) { object value; if (!command.TryGetValue("retryAttempt", out value)) { value = 0; } var retryAttempts = (int)value; Logging.LogLine(command.Get(Command) + " " + command.GetHashCode() + " fail #" + (retryAttempts + 1), "cmnd serv"); if (retryAttempts >= 5) { return; } retryAttempts++; command["retryAttempt"] = retryAttempts; var delay = new Timer(2000 ^ retryAttempts); delay.Elapsed += (s, e) => { EnqueueAction(command); delay.Stop(); delay.Dispose(); }; delay.Start(); }
public override int GetHashCode() { int result = objects.GetHashCode(); result = 31 * result + indexes.GetHashCode(); return(result); }
public override int GetHashCode() { unchecked { return((parameters.GetHashCode() * 397) ^ ChannelVariables.GetHashCode()); } }
public override int GetHashCode() { int result = _messageType != null?_messageType.GetHashCode() : 0; result = 31 * result + (_payload != null ? _payload.GetHashCode() : 0); result = 31 * result + (_headers != null ? _headers.GetHashCode() : 0); return(result); }
public override int GetHashCode() { //No particular reasoning behind this hashing int hash = 112; hash = hash * 3 + attributesAndStyles.GetHashCode(); return(hash); }
public override int GetHashCode() { int result = _queued; result = 31 * result + _delivered.GetHashCode(); result = 31 * result + _instances.GetHashCode(); return(result); }
public override int GetHashCode() { int result = _pendingValues != null?_pendingValues.GetHashCode() : 0; result = 31 * result + (_bookedInstances != null ? _bookedInstances.GetHashCode() : 0); result = 31 * result + (_paxosInstances != null ? _paxosInstances.GetHashCode() : 0); return(result); }
public override int GetHashCode() { unchecked { return(((attributes != null ? attributes.GetHashCode() : 0) * 397) ^ (defaults != null ? defaults.GetHashCode() : 0)); } }
public int GetHashCode(IDictionary <string, T> obj) { if (obj == null) { throw new ArgumentNullException("obj"); } return(obj.GetHashCode()); }
public override int GetHashCode() { int result = base.GetHashCode(); result = 31 * result + parser.GetHashCode(); result = 31 * result + enumIntToStringMap.GetHashCode(); result = 31 * result + enumStringToIntMap.GetHashCode(); return(result); }
public override int GetHashCode() { int result = _name.GetHashCode(); result = 31 * result + _candidateMembers.GetHashCode(); result = 31 * result + _members.GetHashCode(); result = 31 * result + _roles.GetHashCode(); return(result); }
public override int GetHashCode() { int hash = 17; hash = hash * 23 + identifier.GetHashCode(); hash = hash * 23 + content.GetHashCode(); hash = hash * 23 + meta.GetHashCode(); hash = hash * 23 + modificationTime.GetHashCode(); return(hash); }
public override int GetHashCode() { unchecked { var hashCode = (Permissions != null ? Permissions.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Admins != null ? Admins.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Blocked != null ? Blocked.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { const int prime = 31; int result = 1; result = prime * result + ((address == null) ? 0 : address.GetHashCode()); result = prime * result + ((string.ReferenceEquals(cookies, null)) ? 0 : cookies.GetHashCode()); result = prime * result + ((extraHeaders == null) ? 0 : extraHeaders.GetHashCode()); return(result); }
public override int GetHashCode() { unchecked { int result = (_messageType != null ? _messageType.GetHashCode() : 0); result = (result * 397) ^ (_routingKey != null ? _routingKey.GetHashCode() : 0); result = (result * 397) ^ (_arguments != null ? _arguments.GetHashCode() : 0); return(result); } }
public string GetResponse(string host, IDictionary<string, object> arguments, bool useCookies = false) { const string contentType = "application/x-www-form-urlencoded"; const string requestType = "POST"; Logging.LogLine("POSTing to " + host + " " + arguments.GetHashCode(), "browser serv"); var isFirst = true; if (useCookies) { if (!arguments.ContainsKey("csrf_token")) arguments["csrf_token"] = GetCsrfToken(); } var totalRequest = new StringBuilder(); foreach (var arg in arguments.Where(arg => arg.Key != "type")) { if (!isFirst) totalRequest.Append('&'); else isFirst = false; totalRequest.Append(arg.Key); totalRequest.Append('='); totalRequest.Append(HttpUtility.UrlEncode((string) arg.Value)); } var toPost = Encoding.ASCII.GetBytes(totalRequest.ToString()); var cachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); var req = (HttpWebRequest) WebRequest.Create(host); req.CachePolicy = cachePolicy; req.Method = requestType; req.ContentType = contentType; req.ContentLength = toPost.Length; req.UserAgent = Constants.FriendlyName; if (useCookies) req.CookieContainer = loginCookies; using (var postStream = req.GetRequestStream()) postStream.Write(toPost, 0, toPost.Length); using (var rep = (HttpWebResponse) req.GetResponse()) using (var answerStream = rep.GetResponseStream()) { if (answerStream == null) return null; using (var answerReader = new StreamReader(answerStream)) return answerReader.ReadToEnd(); } }
public override int GetHashCode() { unchecked { var hashCode = (_columns != null ? _columns.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (_indexes != null ? _indexes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (_columnNames != null ? _columnNames.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (_primaryKeyColumns != null ? _primaryKeyColumns.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { const int prime = 31; int result = 1; result = prime * result + ((_key == null) ? 0 : _key.GetHashCode()); result = prime * result + ((_tags == null) ? 0 : _tags.GetHashCode()); return(result); } }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object" />. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { return(((_settings != null ? _settings.GetHashCode() : 0) * 397) ^ (Name != null ? Name.GetHashCode() : 0)); } }
public static Type CreateType(IDictionary <string, Type> propertyTypes) { var typeName = DYNAMIC_CLASS_PREFIX + propertyTypes.GetHashCode().ToString(); TypeBuilder typeBuilder = _moduleBuilder.DefineType(typeName, TypeAttributes.Class | TypeAttributes.Public, typeof(DynamicClass)); FieldInfo[] fields = GenerateProperties(typeBuilder, propertyTypes); GenerateEquals(typeBuilder, fields); GenerateGetHashCode(typeBuilder, fields); Type result = typeBuilder.CreateType(); return(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: IndexType getIndexType(IndexIdentifier identifier, boolean recovery) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException internal virtual IndexType GetIndexType(IndexIdentifier identifier, bool recovery) { Pair <int, IndexType> type = _cache[identifier]; IDictionary <string, string> config = _indexStore.get(identifier.EntityType.entityClass(), identifier.IndexName); if (config == null) { if (recovery) { return(null); } throw new ExplicitIndexNotFoundKernelException("Index '%s' doesn't exist.", identifier); } if (type != null && config.GetHashCode() == type.First()) { return(type.Other()); } type = Pair.of(config.GetHashCode(), IndexType.GetIndexType(config)); _cache[identifier] = type; return(type.Other()); }
public override int GetHashCode() { int hashCode = 0; unchecked { if (store != null) { hashCode += 1000000007 * store.GetHashCode(); } } return(hashCode); }
/// <summary> /// Renders the macro output as a string /// </summary> /// <param name="macroAlias"></param> /// <param name="macroParams"></param> /// <param name="currentControllerContext"></param> /// <param name="isForRichTextEditor">If the request is to render the contents in the back office rich text editor</param> /// <param name="resolveContent"></param> /// <returns></returns> public string RenderMacroAsString( string macroAlias, IDictionary<string, string> macroParams, ControllerContext currentControllerContext, bool isForRichTextEditor, Func<Content> resolveContent) { //method to get the string output of the ActionResult Func<ActionResult, string> getStringOutput = ar => { if (ar is ViewResultBase) { var viewResult = (ViewResultBase)ar; return currentControllerContext.RenderViewResultAsString(viewResult); } if (ar is ContentResult) { var contentResult = (ContentResult)ar; return contentResult.Content; } throw new NotSupportedException("Its not possible to retreive the output of a macro that doesn't return a ViewResultBase"); }; if (isForRichTextEditor) { return getStringOutput(RenderMacro(macroAlias, macroParams, currentControllerContext, true, resolveContent)); } //if we not rendering for the rich text editor then check if we've cached this in the ScopedCache first, //even though we are caching some macros in application cache, we're only caching the ActionResult and not the text //output which still requires a tiny amount of processing, so we'll store all equal macro string output in ScopedCache too, //as this will speed things regardless of whehter macros are cached or not if there's a few of the same ones per page return _applicationContext.FrameworkContext .ScopedCache.GetOrCreate("umb-macro-" + macroAlias + macroParams.GetHashCode(), () => getStringOutput(RenderMacro(macroAlias, macroParams, currentControllerContext, false, resolveContent))) .ToString(); }
/// <summary> /// Performs the action rendering /// </summary> /// <param name="macroAlias"></param> /// <param name="currentControllerContext"></param> /// <param name="isForRichTextEditor">If the request is to render the contents in the back office rich text editor</param> /// <param name="resolveContent">callback to get the 'Content' model</param> /// <param name="macroParams"></param> /// <returns></returns> /// <remarks> /// /// We need to check if this is for the rich text editor, in which case, we need to bypass any caching /// so that it renders out the correct content, /// Then if its not for the RTE, we need to check our cache to see if its in there, if so then we'll just /// return it, otherwise we will add the cached item with a dependency on our cache 'File' path. /// /// </remarks> public ActionResult RenderMacro( string macroAlias, IDictionary<string, string> macroParams, ControllerContext currentControllerContext, bool isForRichTextEditor, Func<Content> resolveContent) { ActionResult macroResult = null; if (!isForRichTextEditor) { //if its not for rich text.... try { var output = _applicationContext.FrameworkContext .ApplicationCache.GetOrCreate("umb-macro-" + macroAlias + macroParams.GetHashCode(), () => { var macroModel = GetMacroModel(macroAlias); //set the macroResult to the local variable macroResult = GetMacroResult(macroAlias, () => macroModel.Item1, resolveContent, macroParams, currentControllerContext); //if it is null, it means that there was no content item if (macroResult == null) return null; //check if the macro should be cached at all if (!macroModel.Item1.CacheByPage) { //By returning null, this will not be added to the cache and a null value returned return null; } //TODO: Check caching by member! //return our caching parameters //TODO: We might not want a 'normal' cache dependency at some point, need to determine a way to specify cache dependencies or create a custom one based on the 'File' object or something var cacheParams = new HttpRuntimeCacheParameters<ActionResult>(macroResult) { Dependencies = new CacheDependency(macroModel.Item2.RootedPath), SlidingExpiration = new TimeSpan(0, 0, 0, macroModel.Item1.CachePeriodSeconds) }; return cacheParams; }); //if this is null, it means: // - there was no current node, or it didn't get cached because the macro definition said to not cache it. //then we can check if our local 'macroResult' variable was set, if so it means: // - there was a current node and it simply wasn't cached because of the macro definition. if (output != null) return (ActionResult)output; if (macroResult != null) return macroResult; //return null because there must be no 'currentNode' return null; } catch (ApplicationException ex) { //if there's an exception, display a friendly message and log the error var txt = "Macro.RenderingFailed.Message".Localize(this, new { Error = ex.Message, MacroName = macroAlias }); var title = "Macro.RenderingFailed.Title".Localize(); LogHelper.Error<MacroRenderer>(txt, ex); return MacroError(txt, title); } } else { try { //if it is for rich text... var macroModel = GetMacroModel(macroAlias); return !macroModel.Item1.RenderContentInEditor ? NoRichTextRenderMode(macroAlias) : GetMacroResult(macroAlias, () => macroModel.Item1, resolveContent, macroParams, currentControllerContext); } catch (ApplicationException ex) { //if there's an exception, display a friendly message and log the error var txt = "Macro.RenderingFailed.Message".Localize(this, new { Error = ex.Message, MacroName = macroAlias }); var title = "Macro.RenderingFailed.Title".Localize(); LogHelper.Error<MacroRenderer>(txt, ex); return MacroError(txt, title); } } }
private void RequeueCommand(IDictionary<string, object> command) { object value; if (!command.TryGetValue("retryAttempt", out value)) value = 0; var retryAttempts = (int) value; Logging.LogLine(command.Get(Command) + " " + command.GetHashCode() + " fail #" + (retryAttempts + 1), "cmnd serv"); if (retryAttempts >= 5) return; retryAttempts++; command["retryAttempt"] = retryAttempts; var delay = new Timer(2000 ^ retryAttempts); delay.Elapsed += (s, e) => { EnqueueAction(command); delay.Stop(); delay.Dispose(); }; delay.Start(); }
private CommandHandlerDelegate InterpretCommand(IDictionary<string, object> command) { ChatModel.LastMessageReceived = DateTimeOffset.Now; if (command == null) return null; var commandType = command.Get(Command); Log(commandType + " " + command.GetHashCode(), noisyTypes.Contains(commandType)); switch (commandType) { case SystemAuthenticate: return LoginCommand; case SystemUptime: return UptimeCommand; case AdminList: return AdminsListCommand; case UserIgnore: return IgnoreUserCommand; case UserList: return InitialCharacterListCommand; case PublicChannelList: return PublicChannelListCommand; case PrivateChannelList: return PrivateChannelListCommand; case UserStatus: return StatusChangedCommand; case ChannelAd: return AdMessageCommand; case ChannelMessage: return ChannelMessageCommand; case UserMessage: return PrivateMessageCommand; case UserTyping: return TypingStatusCommand; case ChannelJoin: return JoinChannelCommand; case ChannelLeave: return LeaveChannelCommand; case ChannelModerators: return ChannelOperatorListCommand; case ChannelInitialize: return ChannelInitializedCommand; case ChannelDescription: return ChannelDescriptionCommand; case SystemMessage: case SystemError: return ErrorCommand; case UserInvite: return InviteCommand; case ChannelKick: case ChannelBan: return KickCommand; case UserJoin: return UserLoggedInCommand; case UserLeave: return CharacterDisconnectCommand; case ChannelRoll: return RollCommand; case AdminDemote: return OperatorDemoteCommand; case AdminPromote: return OperatorPromoteCommand; case ChannelDemote: return OperatorDemoteCommand; case ChannelPromote: return OperatorPromoteCommand; case Constants.ServerCommands.ChannelMode: return RoomModeChangedCommand; case AdminBroadcast: return BroadcastCommand; case SystemBridge: return RealTimeBridgeCommand; case AdminReport: return NewReportCommand; case SearchResult: return SearchResultCommand; case ChannelSetOwner: return SetNewOwnerCommand; default: return null; } }