/// <summary> /// Add a list of allowed attributes to a tag. (If an attribute is not allowed on an element, it will be removed.) /// E.g.: AddAttributes("a", "href", "class") allows href and class attributes on a tags. /// </summary> /// <remarks> /// To make an attribute valid for <b>all tags</b>, use the pseudo tag <code>:all</code>, e.g. /// <code>AddAttributes(":all", "class")</code>. /// </remarks> /// <param name="tag">The tag the attributes are for. The tag will be added to the allowed tag list if necessary.</param> /// <param name="keys">List of valid attributes for the tag.</param> /// <returns>This (for chaining)</returns> public Whitelist AddAttributes(string tag, params string[] keys) { if (string.IsNullOrEmpty(tag)) { throw new ArgumentNullException("tag"); } if (keys == null) { throw new ArgumentNullException("keys"); } if (keys.Length <= 0) { throw new ArgumentException("No attributes supplied."); } TagName tagName = TagName.ValueOf(tag); if (!_tagNames.Contains(tagName)) { _tagNames.Add(tagName); } HashSet <AttributeKey> attributeSet = new HashSet <AttributeKey>(); foreach (string key in keys) { if (string.IsNullOrEmpty(key)) { throw new Exception("key"); } attributeSet.Add(AttributeKey.ValueOf(key)); } if (_attributes.ContainsKey(tagName)) { HashSet <AttributeKey> currentSet = _attributes[tagName]; foreach (AttributeKey item in attributeSet) { currentSet.Add(item); } } else { _attributes.Add(tagName, attributeSet); } return(this); }
public void HashCode_Works() { var key = new AttributeKey(); key.ReadFrom(Convert.FromBase64String("AC4AAAAAABcAAAAAABEAYwBvAG0ALgBhAHAAcABsAGUALgBkAGUAYwBtAHAAZgBz"), 0); var clone = new AttributeKey(); clone.ReadFrom(Convert.FromBase64String("AC4AAAAAABcAAAAAABEAYwBvAG0ALgBhAHAAcABsAGUALgBkAGUAYwBtAHAAZgBz"), 0); var other = new AttributeKey(); key.ReadFrom(Convert.FromBase64String("AC4AAAAAABcAAAAAABEAYwBvAG0ALgBhAHAAcABsAGUALgBkAGUAYwBtAHAAZgBz"), 0); Assert.Equal(key.GetHashCode(), key.GetHashCode()); Assert.Equal(key.GetHashCode(), clone.GetHashCode()); Assert.NotEqual(other.GetHashCode(), key.GetHashCode()); }
private void InitNetty(IContainer container) { var factory = container.Resolve <ClientSenderFactory>(); var loggerFactory = container.Resolve <ILoggerFactory>(); var logger = loggerFactory.Create(this.GetType()); var bootstrap = new Bootstrap(); logger.Info($"[config]use dotnetty for transfer"); bootstrap .Group(new MultithreadEventLoopGroup()) .Channel <TcpSocketChannel>() .Option(ChannelOption.TcpNodelay, true) .Handler(new ActionChannelInitializer <IChannel>(channel => { var pipeline = channel.Pipeline; pipeline.AddLast(new LengthFieldPrepender(4)); pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4)); pipeline.AddLast(new ReadClientMessageChannelHandlerAdapter(logger)); pipeline.AddLast(new ClientHandlerChannelHandlerAdapter(factory, logger)); })); //AttributeKey<IClientSender> clientSenderKey = AttributeKey<IClientSender>.ValueOf(typeof(DefaultTransportClientFactory), nameof(IClientSender)); AttributeKey <ClientListener> clientListenerKey = AttributeKey <ClientListener> .ValueOf(typeof(ClientSenderFactory), nameof(ClientListener)); //AttributeKey<EndPoint> endPointKey = AttributeKey<EndPoint>.ValueOf(typeof(DefaultTransportClientFactory), nameof(EndPoint)); AttributeKey <string> endPointKey = AttributeKey <string> .ValueOf(typeof(ClientSenderFactory), "addresscode"); factory.ClientSenderCreator += (JimuAddress address, ref IClientSender client) => { //if (client == null && address.GetType().IsAssignableFrom(typeof(DotNettyAddress))) if (client == null && address.Protocol == "Netty") { var ep = address.CreateEndPoint(); var channel = bootstrap.ConnectAsync(ep).Result; var listener = new ClientListener(); channel.GetAttribute(clientListenerKey).Set(listener); //var sender = new DotNettyClientSender(channel, logger); //channel.GetAttribute(clientSenderKey).Set(sender); channel.GetAttribute(endPointKey).Set($"{address.Protocol}-{address.Code}"); client = new DotNettyClientSender(listener, logger, channel); } }; }
/// <summary> /// /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task StartAsync(IEventLoopGroup BossGroup, IEventLoopGroup WorkerGroup, ServerOptions Options, AppFunc app) { X509Certificate2 tlsCertificate = null; if (Options.IsSsl) { tlsCertificate = new X509Certificate2(Path.Combine(_environment.ContentRootPath, Options.CertificatePath), Options.CertificateToken); } var bootstrap = new ServerBootstrap(); var appKey = AttributeKey <AppFunc> .ValueOf(Constants.AppAttributeKey); bootstrap.Group(BossGroup, WorkerGroup) .Channel <TcpServerSocketChannel>() .Option(ChannelOption.SoBacklog, 8192) //设置channelconfig .Handler(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; pipeline.AddLast(new LoggingHandler($"{Options.Name}-CONN")); this.Handler(channel, this._serviceProvider, Options); })) .ChildAttribute <AppFunc>(appKey, app) .ChildHandler(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; if (tlsCertificate != null) { pipeline.AddLast(TlsHandler.Server(tlsCertificate)); } pipeline.AddLast(new HttpServerCodec()); pipeline.AddLast(new HttpObjectAggregator(65536)); pipeline.AddLast(ActivatorUtilities.CreateInstance <WebSocketClientHandler>(this._serviceProvider, Options)); pipeline.AddLast(ActivatorUtilities.CreateInstance <WebSocketFrameHandler>(this._serviceProvider)); this.ChildHandler(channel, this._serviceProvider, Options); })); BoundChannel = await bootstrap.BindAsync(IPAddress.Loopback, Options.Port); _logger.LogInformation($"{Options.Name}-启动完成"); }
/// <summary> /// Adds a Member Attribute Override /// </summary> /// <param name="type">Type</param> /// <param name="member">Class Member</param> /// <param name="attribute">Overriding Attribute</param> public void Add(Type type, string member, Attribute attribute) { var mapping = new AttributeMapping(type, attribute); List <AttributeMapping> mappings; var attributeKey = new AttributeKey(attribute.GetType(), member); if (!overrides.TryGetValue(attributeKey, out mappings)) { mappings = new List <AttributeMapping>(); overrides.Add(attributeKey, mappings); } else if (mappings.Contains(mapping)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Attribute ({2}) already set for Type {0}, Member {1}", type.FullName, member, attribute)); } mappings.Add(mapping); }
public static IServiceHostClientBuilder UseRpcForTransfer(this IServiceHostClientBuilder serviceHostBuilder) { serviceHostBuilder.AddInitializer(container => { ITransportClientFactory factory = container.Resolve <ITransportClientFactory>(); ILogger logger = container.Resolve <ILogger>(); ISerializer serializer = container.Resolve <ISerializer>(); Bootstrap bootstrap = new Bootstrap(); logger.Info($"启动rpc客户端"); bootstrap .Group(new MultithreadEventLoopGroup()) .Channel <TcpSocketChannel>() .Option(ChannelOption.TcpNodelay, true) .Handler(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; pipeline.AddLast(new LengthFieldPrepender(4)); pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4)); pipeline.AddLast(new ReadClientMessageChannelHandler(serializer)); pipeline.AddLast(new RpcClientHandler(factory)); })); AttributeKey <IClientSender> clientSenderKey = AttributeKey <IClientSender> .ValueOf(typeof(DefaultTransportClientFactory), nameof(IClientSender)); AttributeKey <IClientListener> clientListenerKey = AttributeKey <IClientListener> .ValueOf(typeof(DefaultTransportClientFactory), nameof(IClientListener)); factory.ClientCreatorDelegate += (ServerAddress address, ref ITransportClient client) => { if (client == null && address.ServerFlag == ServerFlag.Rpc) { EndPoint ep = address.CreateEndPoint(); IChannel channel = bootstrap.ConnectAsync(ep).Result; RpcClientListener listener = new RpcClientListener(); channel.GetAttribute(clientListenerKey).Set(listener); RpcClientSender sender = new RpcClientSender(channel, serializer); channel.GetAttribute(clientSenderKey).Set(sender); client = new DefaultTransportClient(listener, sender, serializer, logger); } }; }); return(serviceHostBuilder); }
/// <summary> /// 检索应用于指定对象的指定类型的自定义特性(返回单个Attribute) /// </summary> /// <typeparam name="T">类型参数,要求从Attribute继承</typeparam> /// <param name="obj">包含Attribute的对象</param> /// <param name="inherit">如果检查 element 的上级,则为 true;否则为 false。</param> /// <returns>与 T 相匹配的自定义属性;否则,如果没有找到这类属性,则为 null。</returns> public static T GetOne <T>(object obj, bool inherit = false) where T : Attribute { var key = new AttributeKey { Target = obj, AttributeType = typeof(T) }; object result = s_table[key]; if (DBNull.Value.Equals(result)) { return(null); } if (result == null) { if (obj is MemberInfo) { result = (obj as MemberInfo).GetCustomAttribute <T>(inherit); } else if (obj is ParameterInfo) { result = (obj as ParameterInfo).GetCustomAttribute <T>(inherit); } else { throw new NotSupportedException(); } if (result == null) { s_table[key] = DBNull.Value; } else { s_table[key] = result; } } return(result as T); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="messageFactory">the factory to generate keep-alive messages</param> /// <param name="interestedIdleStatus"></param> /// <param name="strategy"></param> /// <param name="keepAliveRequestInterval">the interval to send a keep-alive request</param> /// <param name="keepAliveRequestTimeout">the time to wait for a keep-alive response before timed out</param> public KeepAliveFilter(IKeepAliveMessageFactory messageFactory, IdleStatus interestedIdleStatus, IKeepAliveRequestTimeoutHandler strategy, Int32 keepAliveRequestInterval, Int32 keepAliveRequestTimeout) { if (messageFactory == null) { throw new ArgumentNullException("messageFactory"); } if (strategy == null) { throw new ArgumentNullException("strategy"); } WAITING_FOR_RESPONSE = new AttributeKey(GetType(), "waitingForResponse"); IGNORE_READER_IDLE_ONCE = new AttributeKey(GetType(), "ignoreReaderIdleOnce"); _messageFactory = messageFactory; _interestedIdleStatus = interestedIdleStatus; _requestTimeoutHandler = strategy; RequestInterval = keepAliveRequestInterval; RequestTimeout = keepAliveRequestTimeout; }
protected override async void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output) { try { tenancyContext = context.GetAttribute <AbstractTenancyContext>(AttributeKey <AbstractTenancyContext> .ValueOf(AbstractTenancyContext.TENANCY_CONTEXT_KEY)).Get(); var dataPacket = await tenancyContext?.Decode(input); dataPacket.EventTopicAddress = GetDeviceD2CAddress(dataPacket.DeviceId); var connectPacket = await GetDeviceCredentialAsync(tenancyContext.TenantId, dataPacket.DeviceId); output.Add(new Dictionary <PacketType, Packet>() { { PacketType.CONNECT, connectPacket }, { PacketType.D2C, dataPacket } }); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } }
/// <summary> /// /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task StartAsync(IEventLoopGroup BossGroup, IEventLoopGroup WorkerGroup, ServerOptions Options, AppFunc app) { X509Certificate2 tlsCertificate = null; if (Options.IsSsl) { tlsCertificate = new X509Certificate2(Path.Combine(_environment.ContentRootPath, Options.CertificatePath), Options.CertificateToken); } var bootstrap = new ServerBootstrap(); var appKey = AttributeKey <AppFunc> .ValueOf(Constants.AppAttributeKey); bootstrap .Group(BossGroup, WorkerGroup) .Channel <UdpServerSocketDatagramChannel>() .Option(ChannelOption.SoBroadcast, true) .Handler(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; this.Handler(channel, this._serviceProvider, Options); pipeline.AddLast(ActivatorUtilities.CreateInstance <UdpChannelGroupHandler>(this._serviceProvider, Options)); })) .ChildAttribute <AppFunc>(appKey, app) .ChildHandler(new ActionChannelInitializer <IChannel>(channel => { if (tlsCertificate != null) { channel.Pipeline.AddLast(TlsHandler.Server(tlsCertificate)); } channel.Pipeline.AddLast(new IdleStateHandler(Options.Timeout, 0, 0)); channel.Pipeline.AddLast(new HeartBeatCheckHandler()); this.ChildHandler(channel, this._serviceProvider, Options); })); BoundChannel = await bootstrap.BindAsync(IPAddress.IPv6Any, Options.Port); _logger.LogInformation($"{Options.Name}-Server-启动完成.端口号:{Options.Port}"); }
public override void ChannelRead(IChannelHandlerContext context, object message) { var tenancyContext = context.GetAttribute <AbstractTenancyContext>(AttributeKey <AbstractTenancyContext> .ValueOf(AbstractTenancyContext.TENANCY_CONTEXT_KEY)).Get(); this.messagingBridgeFactory = tenancyContext.IotBridgeFactory; var packets = message as IDictionary <PacketType, Packet>; if (packets == null || (packets != null && packets.Count <= 0)) { Console.WriteLine(($"No messages (`{typeof(Packet).FullName}` ) received")); return; } var connectPacket = packets[PacketType.CONNECT] as ConnectPacket; var dataPacket = packets[PacketType.D2C] as DeviceDataPacket; this.lastClientActivityTime = DateTime.Now; if (this.IsInState(StateFlags.Connected)) //Already Connected, process DeviceDataPacket { this.ProcessPacket(context, dataPacket); } else if (this.IsInState(StateFlags.ProcessingConnect)) //Connect processing in progress, queue newer connect requests { //TODO Implement queue/ priority queue based on supported cases Queue <Packet> queue = this.connectPendingQueue ?? (this.connectPendingQueue = new Queue <Packet>(4)); queue.Enqueue(dataPacket); } else { //Not Connected and Not processing a connect - Use connect packet to create connection to IoTHub this.dataPacketWithConnect = dataPacket; this.ProcessPacket(context, connectPacket); } context.WriteAsync(message); }
private async Task <IChannel> NewAsync(EndPoint endPoint) { ConcurrentDictionary <string, IChannel> pool; string tempChannelId = Guid.NewGuid().ToString() + DateTime.Now.Ticks; lock (newChannelLocker) { Console.WriteLine(this.GetHashCode()); bool res = this.EndPointGroupPools.TryGetValue(endPoint, out pool); if (!res) { pool = new ConcurrentDictionary <string, IChannel>(); this.EndPointGroupPools.TryAdd(endPoint, pool); } if (pool.TryAdd(tempChannelId, null)) { Console.WriteLine(true); } if (pool.Count > clientOptions.MaxConnections) { pool.TryRemove(tempChannelId, out IChannel _); throw new Exception($"pool is full: Max:{clientOptions.MaxConnections}, Current:{pool.Count}"); } } IChannel channel = await Bootstrap.ConnectAsync(endPoint); if (channel != null && channel.Active) { channel.GetAttribute(AttributeKey <ClientChannelPool> .ValueOf(typeof(ClientChannelPool).Name)).Set(this); pool.TryAdd(GetChannelId(channel), channel); } pool.TryRemove(tempChannelId, out IChannel _); return(channel); }
/// <summary> /// 检索应用于指定对象的指定类型的自定义特性(返回Attribute数组) /// </summary> /// <typeparam name="T">类型参数,要求从Attribute继承</typeparam> /// <param name="obj">包含Attribute的对象</param> /// <param name="inherit">如果检查 element 的上级,则为 true;否则为 false。</param> /// <returns>与 T 相匹配的自定义属性;否则,如果没有找到这类属性,则为 null。</returns> public static T[] GetArray <T>(object obj, bool inherit = false) where T : Attribute { var key = new AttributeKey { Target = obj, AttributeType = typeof(T) }; object result = s_table[key]; if (result == null) { if (obj is MemberInfo) { result = (obj as MemberInfo).GetCustomAttributes <T>(inherit); } else if (obj is ParameterInfo) { result = (obj as ParameterInfo).GetCustomAttributes <T>(inherit); } else if (obj is Type) { result = (obj as Type).GetCustomAttributes <T>(inherit); } else { throw new NotSupportedException(); } // 就算是找不到指定的Attribute,GetCustomAttributes()会返回一个空数组,所以不需要引用空值判断 s_table[key] = result; } return(result as T[]); }
/// <summary> /// Add an enforced attribute to a tag. An enforced attribute will always be added to the element. If the element /// already has the attribute set, it will be overridden. /// </summary> /// <remarks>E.g.: <code>AddEnforcedAttribute("a", "rel", "nofollow")</code> will make all <code>a</code> tags output as /// <code><a href="..." rel="nofollow"></code></remarks> /// <param name="tag">The tag the enforced attribute is for. The tag will be added to the allowed tag list if necessary.</param> /// <param name="key">The attribute key</param> /// <param name="value">The enforced attribute value</param> /// <returns>this (for chaining)</returns> public Whitelist AddEnforcedAttribute(string tag, string key, string value) { if (string.IsNullOrEmpty(tag)) { throw new ArgumentNullException("tag"); } if (string.IsNullOrEmpty(key)) { throw new ArgumentNullException("key"); } if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException("value"); } TagName tagName = TagName.ValueOf(tag); if (!_tagNames.Contains(tagName)) { _tagNames.Add(tagName); } AttributeKey attrKey = AttributeKey.ValueOf(key); AttributeValue attrVal = AttributeValue.ValueOf(value); if (_enforcedAttributes.ContainsKey(tagName)) { _enforcedAttributes[tagName].Add(attrKey, attrVal); } else { Dictionary <AttributeKey, AttributeValue> attrMap = new Dictionary <AttributeKey, AttributeValue>(); attrMap.Add(attrKey, attrVal); _enforcedAttributes.Add(tagName, attrMap); } return(this); }
private ClientChannelPool GetPool(IChannelHandlerContext context) { return(context.Channel.GetAttribute(AttributeKey <ClientChannelPool> .ValueOf(typeof(ClientChannelPool).Name)).Get()); }
public override int GetHashCode() { return(AttributeKey.GetHashCode()); }
public bool Equals(ReferenceType <TElement, TAttribute> other) { return(other != null && AttributeKey.Equals(other.AttributeKey)); }
public IAttribute <T> GetAttribute <T>(AttributeKey <T> key) where T : class { return(this.Channel.GetAttribute(key)); }
protected AbstractStreamWriteFilter() { CURRENT_STREAM = new AttributeKey(GetType(), "stream"); WRITE_REQUEST_QUEUE = new AttributeKey(GetType(), "queue"); CURRENT_WRITE_REQUEST = new AttributeKey(GetType(), "writeRequest"); }
public override bool Equals(object obj) { AttributeKey attributeKey = (AttributeKey)obj; return(AttributeType.Equals(attributeKey.AttributeType) && PropertyName.Equals(attributeKey.PropertyName)); }
public IAttribute <T> GetAttribute <T>(AttributeKey <T> key) where T : class => _ctx.GetAttribute(key);
public int GetHashCode(AttributeKey obj) { return(obj.GetHashCode()); }
public void SetBaseAttribute(AttributeKey key, int value) { }
public int GetCurrentAttribute(AttributeKey key) { return(0); }
// Populate attributes void RegisterAttributes() { MonoBehaviour[] sceneObjects = FindObjectsOfType <MonoBehaviour>(); HashSet <MonoBehaviour> uniqueAttributeContainers = new HashSet <MonoBehaviour>(); foreach (MonoBehaviour mb in sceneObjects) { Type monoType = mb.GetType(); // Fields { // Retreive the fields from the mono instance FieldInfo[] objectFields = monoType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); // search all fields/properties for the [DebugGUIVar] attribute for (int i = 0; i < objectFields.Length; i++) { DebugGUIPrintAttribute printAttribute = Attribute.GetCustomAttribute(objectFields[i], typeof(DebugGUIPrintAttribute)) as DebugGUIPrintAttribute; if (printAttribute != null) { uniqueAttributeContainers.Add(mb); if (!debugGUIPrintFields.ContainsKey(monoType)) { debugGUIPrintFields.Add(monoType, new HashSet <FieldInfo>()); } if (!debugGUIPrintProperties.ContainsKey(monoType)) { debugGUIPrintProperties.Add(monoType, new HashSet <PropertyInfo>()); } debugGUIPrintFields[monoType].Add(objectFields[i]); } DebugGUIGraphAttribute graphAttribute = Attribute.GetCustomAttribute(objectFields[i], typeof(DebugGUIGraphAttribute)) as DebugGUIGraphAttribute; if (graphAttribute != null) { // Can't cast to float so we don't bother registering it if (objectFields[i].GetValue(mb) as float? == null) { UnityEngine.Debug.LogError(string.Format("Cannot cast {0}.{1} to float. This member will be ignored.", monoType.Name, objectFields[i].Name)); continue; } uniqueAttributeContainers.Add(mb); if (!debugGUIGraphFields.ContainsKey(monoType)) { debugGUIGraphFields.Add(monoType, new HashSet <FieldInfo>()); } if (!debugGUIGraphProperties.ContainsKey(monoType)) { debugGUIGraphProperties.Add(monoType, new HashSet <PropertyInfo>()); } debugGUIGraphFields[monoType].Add(objectFields[i]); GraphContainer graph = new GraphContainer(graphWidth, graphHeight) { name = objectFields[i].Name, max = graphAttribute.max, min = graphAttribute.min, group = graphAttribute.group, autoScale = graphAttribute.autoScale }; if (!graphAttribute.color.Equals(default(Color))) { graph.color = graphAttribute.color; } var key = new AttributeKey(objectFields[i]); if (!attributeKeys.ContainsKey(mb)) { attributeKeys.Add(mb, new List <AttributeKey>()); } attributeKeys[mb].Add(key); graphDictionary.Add(key, graph); graphs.Add(graph); } } } // Properties { PropertyInfo[] objectProperties = monoType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); for (int i = 0; i < objectProperties.Length; i++) { DebugGUIPrintAttribute printAttribute = Attribute.GetCustomAttribute(objectProperties[i], typeof(DebugGUIPrintAttribute)) as DebugGUIPrintAttribute; if (printAttribute != null) { uniqueAttributeContainers.Add(mb); if (!debugGUIPrintFields.ContainsKey(monoType)) { debugGUIPrintFields.Add(monoType, new HashSet <FieldInfo>()); } if (!debugGUIPrintProperties.ContainsKey(monoType)) { debugGUIPrintProperties.Add(monoType, new HashSet <PropertyInfo>()); } debugGUIPrintProperties[monoType].Add(objectProperties[i]); } DebugGUIGraphAttribute graphAttribute = Attribute.GetCustomAttribute(objectProperties[i], typeof(DebugGUIGraphAttribute)) as DebugGUIGraphAttribute; if (graphAttribute != null) { // Can't cast to float so we don't bother registering it if (objectProperties[i].GetValue(mb, null) as float? == null) { UnityEngine.Debug.LogError("Cannot cast " + objectProperties[i].Name + " to float. This member will be ignored."); continue; } uniqueAttributeContainers.Add(mb); if (!debugGUIGraphFields.ContainsKey(monoType)) { debugGUIGraphFields.Add(monoType, new HashSet <FieldInfo>()); } if (!debugGUIGraphProperties.ContainsKey(monoType)) { debugGUIGraphProperties.Add(monoType, new HashSet <PropertyInfo>()); } debugGUIGraphProperties[monoType].Add(objectProperties[i]); GraphContainer graph = new GraphContainer(graphWidth, graphHeight) { name = objectProperties[i].Name, max = graphAttribute.max, min = graphAttribute.min, group = graphAttribute.group, autoScale = graphAttribute.autoScale }; if (!graphAttribute.color.Equals(default(Color))) { graph.color = graphAttribute.color; } var key = new AttributeKey(objectProperties[i]); if (!attributeKeys.ContainsKey(mb)) { attributeKeys.Add(mb, new List <AttributeKey>()); } attributeKeys[mb].Add(key); graphDictionary.Add(key, graph); graphs.Add(graph); } } } } foreach (var mb in uniqueAttributeContainers) { attributeContainers.Add(mb); Type type = mb.GetType(); if (!typeInstanceCounts.ContainsKey(type)) { typeInstanceCounts.Add(type, 0); } typeInstanceCounts[type]++; } }
static SimpleChannelPool() { FullException = new InvalidOperationException("ChannelPool full"); PoolKey = AttributeKey <SimpleChannelPool> .NewInstance("io.netty.channel.pool.SimpleChannelPool"); }
public bool HasAttribute <T>(AttributeKey <T> key) where T : class { return(this.Channel.HasAttribute(key)); }
public DemuxingProtocolEncoder() { STATE = new AttributeKey(GetType(), "state"); }
public bool HasAttribute <T>(AttributeKey <T> key) where T : class => _ctx.HasAttribute(key);
public override void ChannelInactive(IChannelHandlerContext context) { _factory.Clients.TryRemove(context.Channel.GetAttribute(AttributeKey <string> .ValueOf(typeof(DefaultTransportClientFactory), "addresscode")).Get(), out _); }