public OperationException(int errorCode, string errorName, string description)
        {
            this.Code        = errorCode;
            this.Name        = errorName;
            this.Description = description;

            this.ErrorCode = s_errorCodeCache.GetOrAdd(errorName, s_convertErrorCodeFunc);
        }
Example #2
0
        public OperationException(int errorCode, string errorName, string description)
            : base($"{errorName} : {description}")
        {
            Code        = errorCode;
            Name        = errorName;
            Description = description;

            ErrorCode = s_errorCodeCache.GetOrAdd(errorName, s_convertErrorCodeFunc);
        }
Example #3
0
        /// <summary>
        /// Returns a <see cref="string"/> form of <paramref name="type"/> which can be parsed by <see cref="Type.GetType(string)"/>.
        /// </summary>
        /// <param name="type">The type to format.</param>
        /// <returns>
        /// A <see cref="string"/> form of <paramref name="type"/> which can be parsed by <see cref="Type.GetType(string)"/>.
        /// </returns>
        public static string Format(TypeInfo type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (!Cache.TryGetValue(type, out var result))
            {
                string FormatType(Type t)
                {
                    var builder = new StringBuilder();

                    Format(builder, t.GetTypeInfo(), isElementType: false);
                    return(builder.ToString());
                }

                result = Cache.GetOrAdd(type, FormatType);
            }

            return(result);
        }
Example #4
0
        public static HttpMethod ValueOf(AsciiString name)
        {
            if (name is object)
            {
                HttpMethod result = ValueOfInline(name.Array);
                if (result is object)
                {
                    return(result);
                }

                // Fall back to slow path
                var methodName = name.ToString();
                if (MethodMap.TryGetValue(methodName, out result))
                {
                    return(result);
                }

                return(s_methodCache.GetOrAdd(methodName, s_convertToHttpMethodFunc));
            }
            // Really slow path and error handling
            return(new HttpMethod(name?.ToString()));
        }
Example #5
0
        static void ValidateTopicFilter(string topicFilter)
        {
            var errorStatus = s_topicFilterErrCache.GetOrAdd(topicFilter, s_getTopicFilterErrorStatusFunc);

            switch (errorStatus)
            {
            case TopicFilterErrorStatus.MQTT_471_2:
                ThrowHelper.ThrowDecoderException_MQTT_471_2(topicFilter);
                break;

            case TopicFilterErrorStatus.MQTT_471_3:
                ThrowHelper.ThrowDecoderException_MQTT_471_3(topicFilter);
                break;

            case TopicFilterErrorStatus.MQTT_473_1:
                ThrowHelper.ThrowDecoderException_MQTT_473_1();
                break;

            case TopicFilterErrorStatus.None:
            default:
                break;
            }
        }
        public CachedEntry GetSuitableSilos(int typeCode, int ifaceId, ushort requestedVersion)
        {
            var key = Tuple.Create(typeCode, ifaceId, requestedVersion);

            return(suitableSilosCache.GetOrAdd(key, getSilosFunc));
        }
        public IReadOnlyList <SiloAddress> GetSuitableSilos(int typeCode, int ifaceId, ushort requestedVersion)
        {
            var key = Tuple.Create(typeCode, ifaceId, requestedVersion);

            return(suitableSilosCache.GetOrAdd(key, getSilosFunc));
        }
Example #8
0
 public static bool IsSupportedType(Type objectType)
 {
     return(s_supportedTypeInfoSet.GetOrAdd(objectType, s_isSupportedTypeFunc));
 }
 public static EmptyCtorInvoker GetConstructorMethod(this Type instanceType)
 => s_constructorMethods.GetOrAdd(instanceType, s_getConstructorMethodToCacheFunc);