Exemplo n.º 1
0
 private static void AddNestedTypeNode(IntellisenseEntry targetNodes, Type target)
 {
     foreach (
         Type val in target.GetNestedTypes(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance))
     {
         var memberNodes = new IntellisenseEntry
         {
             Name       = val.Name,
             SimpleName = val.Name,
             Type       = IntellisenseEntryType.Method,
             Parent     = targetNodes,
         };
         targetNodes.AddNode(memberNodes);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Add an event node into the intellisense graph
 /// </summary>
 /// <param name="targetNodes"></param>
 /// <param name="target"></param>
 private static void AddEventNode(IntellisenseEntry targetNodes, Type target)
 {
     foreach (
         EventInfo val in target.GetEvents(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance))
     {
         var memberNodes = new IntellisenseEntry
         {
             Name        = val.Name,
             SimpleName  = val.Name,
             Type        = IntellisenseEntryType.Event,
             Parent      = targetNodes,
             Description = CreateEventDescription(val),
         };
         targetNodes.AddNode(memberNodes);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Adds a node into the intellisense graph
        /// </summary>
        /// <param name="targetNodes"></param>
        /// <param name="namePath"></param>
        /// <param name="isNamespace"></param>
        private static void AddNode(IntellisenseEntry targetNodes, string namePath, bool isNamespace)
        {
            IntellisenseEntry existsNode;

            string[] targetPath = namePath.Split('.');
            List <IntellisenseEntry> validNode =
                targetNodes.Children.Where(
                    x => String.Equals(x.Name, targetPath[0], StringComparison.InvariantCultureIgnoreCase)).ToList();

            if (validNode.Count > 0)
            {
                existsNode = validNode[0];
            }
            else
            {
                existsNode = new IntellisenseEntry
                {
                    Name       = targetPath[0],
                    SimpleName = targetPath[0],
                    Type       =
                        (isNamespace) ? IntellisenseEntryType.Namespace : IntellisenseEntryType.Primitive,
                    Parent      = targetNodes,
                    Description = (isNamespace) ? string.Format("Namespace {0}", targetPath[0]) : "",
                };
                targetNodes.AddNode(existsNode);
            }

            if (isNamespace)
            {
                string nextPath = namePath.Substring(targetPath[0].Length, namePath.Length - targetPath[0].Length);
                if (nextPath.StartsWith("."))
                {
                    nextPath = nextPath.Substring(1, nextPath.Length - 1);
                }
                if (!string.IsNullOrWhiteSpace(nextPath))
                {
                    AddNode(existsNode, nextPath);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add a method node into the intellisense graph
        /// </summary>
        /// <param name="targetNodes"></param>
        /// <param name="target"></param>
        private static void AddMethodNode(IntellisenseEntry targetNodes, Type target)
        {
            foreach (
                MethodInfo val in target.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance))
            {
                // Ignore property implementation methods
                if (val.IsSpecialName)
                {
                    continue;
                }

                var memberNodes = new IntellisenseEntry
                {
                    Name        = val.Name,
                    SimpleName  = val.Name,
                    Type        = IntellisenseEntryType.Method,
                    Parent      = targetNodes,
                    Description = CreateMethodDescription(val),
                };
                targetNodes.AddNode(memberNodes);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Adds a type node into the intellisense graph
        /// </summary>
        /// <param name="targetNodes"></param>
        /// <param name="target"></param>
        /// <param name="allowAbstract"></param>
        internal static void AddTypeNode(IntellisenseEntry targetNodes, Type target, bool allowAbstract = false)
        {
            if ((!target.IsAbstract || allowAbstract) && target.IsVisible)
            {
                string            namePath = target.Namespace;
                string            name     = target.Name;
                IntellisenseEntry nodes    = SearchNodes(targetNodes, namePath);
                string            str      = name;

                var node = new IntellisenseEntry
                {
                    Name       = name,
                    SimpleName = name,
                    Parent     = nodes,
                    SystemType = target
                };

                if (target.IsGenericType)
                {
                    node.Type = IntellisenseEntryType.Class;
                    if (name.Contains("`"))
                    {
                        str             = name.Substring(0, name.LastIndexOf("`", StringComparison.Ordinal));
                        node.SimpleName = str;
                    }

                    var builder = new StringBuilder();
                    int num     = 0;
                    foreach (Type type in target.GetGenericArguments())
                    {
                        if (num > 0)
                        {
                            builder.Append(", ");
                        }
                        builder.Append(type.Name);
                        num++;
                    }
                    str              = str + "(" + builder + ")";
                    node.Name        = str;
                    node.Description = string.Format("Class {0}", node.SimpleName);
                }
                else if (target.IsClass)
                {
                    node.Type        = IntellisenseEntryType.Class;
                    node.Description = string.Format("Class {0}", node.SimpleName);
                }
                else if (target.IsEnum)
                {
                    node.Type        = IntellisenseEntryType.Enum;
                    node.Description = string.Format("Enum {0}", node.SimpleName);
                }
                else if (target.IsInterface)
                {
                    node.Type        = IntellisenseEntryType.Interface;
                    node.Description = string.Format("Interface {0}", node.SimpleName);
                }
                else if (target.IsPrimitive)
                {
                    node.Type        = IntellisenseEntryType.Primitive;
                    node.Description = string.Format("{0}", node.SimpleName);
                }
                else if (target.IsValueType)
                {
                    node.Type        = IntellisenseEntryType.ValueType;
                    node.Description = string.Format("{0}", node.SimpleName);
                }
                else
                {
                    return;
                }

                if (nodes == null)
                {
                    targetNodes.AddNode(node);
                }
                else
                {
                    nodes.AddNode(node);
                }

                AddMethodNode(node, target);
                AddPropertyNode(node, target);
                AddFieldNode(node, target);
                AddEventNode(node, target);
                AddNestedTypeNode(node, target);
            }
        }