public ChoDictionary <string, ChoObjConfigurable> ConvertToDistinctDictionary(ChoObjConfigurable[] objConfigurables) { ChoDictionary <string, ChoObjConfigurable> _distinctObjectConfigurables = new ChoDictionary <string, ChoObjConfigurable>(); if (ChoGuard.IsArgumentNotNullOrEmpty(objConfigurables)) { return(_distinctObjectConfigurables); } foreach (ChoObjConfigurable objConfigurable in objConfigurables) { if (objConfigurable == null) { continue; } if (String.IsNullOrEmpty(objConfigurable.Name)) { continue; } if (_distinctObjectConfigurables.ContainsKey(objConfigurable.Name)) { ChoTrace.Debug(String.Format("Item with {0} key already exists.", objConfigurable.Name)); continue; } _distinctObjectConfigurables.Add(objConfigurable.Name, objConfigurable); } return(_distinctObjectConfigurables); }
private static string GetApplicationName() { string applicatioName = NotAvailableText; try { applicatioName = AppDomain.CurrentDomain.FriendlyName; } catch (System.Security.SecurityException ex) { // This security exception will occur if the caller does not have // some undefined set of SecurityPermission flags. ChoTrace.Debug("SystemInfo: Security exception while trying to get current domain friendly name. Error Ignored.", ex); try { applicatioName = System.IO.Path.GetFileName(EntryAssemblyLocation); } catch (System.Security.SecurityException) { } } return(applicatioName); }
public ChoSerializerAttribute(string objectSerializerTypeName) { try { ObjectSerializerType = ChoType.GetType(objectSerializerTypeName); if (!typeof(IChoObjectSerializer).IsAssignableFrom(ObjectSerializerType)) { ObjectSerializerType = null; } } catch (Exception ex) { ChoTrace.Debug("Failed to find '{0}' object serializer. {1}".FormatString(objectSerializerTypeName, ex.Message)); } }
private bool IsExists(ArrayList list, object element) { foreach (object item in list) { if (item.Equals(element)) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Duplicate entry found"); msg.AppendFormatLine(ChoObject.ToString(element)); ChoTrace.Debug(msg.ToString()); return(true); } } return(false); }
private void OnTryToReconnect(object state) { try { _reconnectTimer.Change(Timeout.Infinite, Timeout.Infinite); var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(_endPoint); ChoTrace.Info("Reconnected successfully."); Init(socket); } catch (Exception err) { ChoTrace.Debug("Failed to reconnect.", err); _reconnectTimer.Change(Timeout.Infinite, 5000); } }
public void Start() { if (_socket != null) { ChoTrace.Warn("Already got a socket, disconnect first."); return; } _reconnectTimer = new Timer(OnTryToReconnect, null, Timeout.Infinite, Timeout.Infinite); try { Connect(); } catch (Exception ex) { ChoTrace.Debug("Failed to reconnect.", ex); HandleDisconnected(); } }
private void AddToMap(ChoDictionary <string, string> typeShortNameMap, ChoBufferProfileEx errProfile, Type type, string typeShortName, bool overrideType) { if (typeShortNameMap.ContainsKey(typeShortName)) { if (!overrideType) { errProfile.AppendLine(String.Format("Type: {0}, ShortName: {1}", type.SimpleQualifiedName(), typeShortName)); return; } else { ChoTrace.Debug(String.Format("DELETED: Type: {0}, ShortName: {1}", typeShortNameMap[typeShortName], typeShortName)); typeShortNameMap.Remove(typeShortName); } } typeShortNameMap.Add(typeShortName, type.SimpleQualifiedName()); ChoTrace.Debug(String.Format("ADDED: Type: {0}, ShortName: {1}", type.SimpleQualifiedName(), typeShortName)); }
private void OnTryToReconnect(object state) { if (_reconnectTimer == null) { return; } try { _reconnectTimer.Change(Timeout.Infinite, Timeout.Infinite); Connect(); ChoTrace.Info("Reconnected successfully."); } catch (Exception ex) { ChoTrace.Debug("Failed to reconnect.", ex); //_reconnectTimer.Change(Timeout.Infinite, 5000); _reconnectTimer.Change(ReconnectInterval, Timeout.Infinite); } }