Exemple #1
0
        public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor)
        {
            this.functionDescriptor = functionDescriptor;

            var displayName = functionDescriptor.UserFriendlyName;

            if (functionDescriptor.IsOverloaded)
            {
                displayName += "(" + string.Join(", ", functionDescriptor.Parameters) + ")";
            }

            Name             = displayName;
            UserFriendlyName = functionDescriptor.UserFriendlyName;
            FullCategoryName = functionDescriptor.Category;
            Description      = functionDescriptor.Description;
            Assembly         = functionDescriptor.Assembly;

            ElementType = ElementTypes.ZeroTouch;

            if (functionDescriptor.IsBuiltIn)
            {
                ElementType |= ElementTypes.BuiltIn;
            }

            // Assembly, that is located in package directory, considered as part of package.
            var packageDirectories = functionDescriptor.PathManager.PackagesDirectories;

            if (packageDirectories.Any(directory => Assembly.StartsWith(directory)))
            {
                ElementType |= ElementTypes.Packaged;
            }

            inputParameters  = new List <Tuple <string, string> >(functionDescriptor.InputParameters);
            outputParameters = new List <string>()
            {
                functionDescriptor.ReturnType
            };

            foreach (var tag in functionDescriptor.GetSearchTags())
            {
                SearchKeywords.Add(tag);
            }

            var weights = functionDescriptor.GetSearchTagWeights();

            foreach (var weight in weights)
            {
                // Search tag weight can't be more then 1.
                if (weight <= 1)
                {
                    keywordWeights.Add(weight);
                }
            }

            int weightsCount = weights.Count();

            // If there weren't added weights for search tags, then add default value - 0.5
            if (weightsCount != SearchKeywords.Count)
            {
                int numberOfLackingWeights = SearchKeywords.Count - weightsCount;

                // Number of lacking weights should be more than 0.
                // It can be less then 0 only if there was some mistake in xml file.
                if (numberOfLackingWeights > 0)
                {
                    for (int i = 0; i < numberOfLackingWeights; i++)
                    {
                        keywordWeights.Add(0.5);
                    }
                }
            }

            iconName = GetIconName();
        }
Exemple #2
0
        public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor)
        {
            this.functionDescriptor = functionDescriptor;

            Name = functionDescriptor.UserFriendlyName;

            if (functionDescriptor.IsOverloaded)
            {
                var parameters = new StringBuilder();
                parameters.Append("(");
                parameters.Append(String.Join(", ", functionDescriptor.Parameters.Select(x => x.Name)));
                parameters.Append(")");

                Parameters = parameters.ToString();
            }

            FullCategoryName = functionDescriptor.Category;
            Description      = functionDescriptor.Description;
            Assembly         = functionDescriptor.Assembly;

            ElementType = ElementTypes.ZeroTouch;

            if (functionDescriptor.IsBuiltIn)
            {
                ElementType |= ElementTypes.BuiltIn;
            }

            if (functionDescriptor.IsPackageMember)
            {
                ElementType |= ElementTypes.Packaged;
            }

            inputParameters  = new List <Tuple <string, string> >(functionDescriptor.InputParameters);
            outputParameters = new List <string>()
            {
                functionDescriptor.ReturnType.ToShortString()
            };

            foreach (var tag in functionDescriptor.GetSearchTags())
            {
                SearchKeywords.Add(tag);
            }

            var weights = functionDescriptor.GetSearchTagWeights();

            foreach (var weight in weights)
            {
                // Search tag weight can't be more then 1.
                if (weight <= 1)
                {
                    keywordWeights.Add(weight);
                }
            }

            int weightsCount = weights.Count();

            // If there weren't added weights for search tags, then add default value - 0.5
            if (weightsCount != SearchKeywords.Count)
            {
                int numberOfLackingWeights = SearchKeywords.Count - weightsCount;

                // Number of lacking weights should be more than 0.
                // It can be less then 0 only if there was some mistake in xml file.
                if (numberOfLackingWeights > 0)
                {
                    for (int i = 0; i < numberOfLackingWeights; i++)
                    {
                        keywordWeights.Add(0.5);
                    }
                }
            }

            iconName = GetIconName();
        }