private Dictionary <long, MethodNameBuilder> CreateMethodNameBuilders(
            IEnumerable <KeyValuePair <long, MethodInfo> > actorMethodInfo)
        {
            var methodNameInfo = new Dictionary <long, MethodNameBuilder>();

            foreach (var kvp in actorMethodInfo)
            {
                var mi     = kvp.Value;
                var mnInfo = new MethodNameBuilder()
                {
                    MethodInfo = mi, Names = new string[(int)MethodNameFormat.Count]
                };

                // Compute method name in the format <DeclaringType>.<MethodName>
                mnInfo.Names[(int)MethodNameFormat.TypeAndMember] = String.Concat(mi.DeclaringType.Name, ".", mi.Name);

                // Compute method name in the most detailed format, i.e. <ReturnType> <DeclaringType>.<MethodName>[paramType1, paramType2, ...]
                mnInfo.Names[(int)MethodNameFormat.TypeMemberParamsAndReturn] =
                    mi.ToString().Replace('(', '[').Replace(')', ']');

                methodNameInfo[kvp.Key] = mnInfo;
            }

            return(methodNameInfo);
        }
        private string ComputeTruncatedMethodName(MethodNameBuilder methodNameBuilder)
        {
            var availableSpaceForTruncatedParts = methodNameBuilder.MethodNameMaxLength;
            var minLengthToQualifyForTruncation = methodNameBuilder.MethodNameMaxLength / ((int)MethodNameParts.Count);

            var partsToTruncate = new List <MethodNameParts>();

            // Check if we should truncate the type component of the method name
            var    typeFull = methodNameBuilder.MethodInfo.DeclaringType.Name;
            string typeTruncated;

            this.PrepareMethodNamePartForTruncation(
                typeFull,
                MethodNameParts.DeclaringType,
                minLengthToQualifyForTruncation,
                partsToTruncate,
                ref availableSpaceForTruncatedParts,
                out typeTruncated);

            // Check if we should truncate the method name component of the method name
            var    methodNameFull = methodNameBuilder.MethodInfo.Name;
            string methodNameTruncated;

            this.PrepareMethodNamePartForTruncation(
                methodNameFull,
                MethodNameParts.MethodName,
                minLengthToQualifyForTruncation,
                partsToTruncate,
                ref availableSpaceForTruncatedParts,
                out methodNameTruncated);

            // Check if we should truncate the parameters component of the method name.
            var    parametersFull = this.FormatMethodParameters(methodNameBuilder.MethodInfo);
            string paramsTruncated;

            this.PrepareMethodNamePartForTruncation(
                parametersFull,
                MethodNameParts.Params,
                minLengthToQualifyForTruncation,
                partsToTruncate,
                ref availableSpaceForTruncatedParts,
                out paramsTruncated);

            // Divide the available space equally among the parts that need to be truncated
            int maxSizeOfTruncatedPart = availableSpaceForTruncatedParts / partsToTruncate.Count;

            // Truncate each part that we need to
            foreach (var methodNamePart in partsToTruncate)
            {
                switch (methodNamePart)
                {
                case MethodNameParts.DeclaringType:
                    typeTruncated = this.TruncateTypeOrMethod(typeFull, maxSizeOfTruncatedPart);
                    break;

                case MethodNameParts.MethodName:
                    methodNameTruncated = this.TruncateTypeOrMethod(methodNameFull, maxSizeOfTruncatedPart);
                    break;

                case MethodNameParts.Params:
                    paramsTruncated = this.TruncateParams(methodNameBuilder.MethodInfo.GetParameters(),
                                                          maxSizeOfTruncatedPart);
                    break;
                }
            }

            // Compute the truncated method name
            return(String.Concat(
                       typeTruncated,
                       ".",
                       methodNameTruncated,
                       paramsTruncated));
        }