Ejemplo n.º 1
0
        /// <summary>
        /// given an appliesTo list, it finds all the types that are contained (following type
        /// group references)
        /// </summary>
        /// <param name="db">database to use</param>
        /// <param name="appliesTo">object to lookup</param>
        /// <returns></returns>
        internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo appliesTo)
        {
            Hashtable allTypes = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (TypeOrGroupReference r in appliesTo.referenceList)
            {
                // if it is a type reference, just add the type name
                TypeReference tr = r as TypeReference;
                if (tr != null)
                {
                    if (!allTypes.ContainsKey(tr.name))
                    {
                        allTypes.Add(tr.name, null);
                    }
                }
                else
                {
                    // check if we have a type group reference
                    TypeGroupReference tgr = r as TypeGroupReference;

                    if (tgr == null)
                    {
                        continue;
                    }

                    // find the type group definition the reference points to
                    TypeGroupDefinition tgd = FindGroupDefinition(db, tgr.name);

                    if (tgd == null)
                    {
                        continue;
                    }

                    // we found the group, go over it
                    foreach (TypeReference x in tgd.typeReferenceList)
                    {
                        if (!allTypes.ContainsKey(x.name))
                        {
                            allTypes.Add(x.name, null);
                        }
                    }
                }
            }

            AppliesTo retVal = new AppliesTo();

            foreach (DictionaryEntry x in allTypes)
            {
                retVal.AddAppliesToType(x.Key as string);
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo appliesTo)
        {
            Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (TypeOrGroupReference reference in appliesTo.referenceList)
            {
                TypeReference reference2 = reference as TypeReference;
                if (reference2 != null)
                {
                    if (!hashtable.ContainsKey(reference2.name))
                    {
                        hashtable.Add(reference2.name, null);
                    }
                }
                else
                {
                    TypeGroupReference reference3 = reference as TypeGroupReference;
                    if (reference3 != null)
                    {
                        TypeGroupDefinition definition = FindGroupDefinition(db, reference3.name);
                        if (definition != null)
                        {
                            foreach (TypeReference reference4 in definition.typeReferenceList)
                            {
                                if (!hashtable.ContainsKey(reference4.name))
                                {
                                    hashtable.Add(reference4.name, null);
                                }
                            }
                        }
                    }
                }
            }
            AppliesTo to = new AppliesTo();

            foreach (DictionaryEntry entry in hashtable)
            {
                to.AddAppliesToType(entry.Key as string);
            }
            return(to);
        }
Ejemplo n.º 3
0
 internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo appliesTo)
 {
     Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
     foreach (TypeOrGroupReference reference in appliesTo.referenceList)
     {
         TypeReference reference2 = reference as TypeReference;
         if (reference2 != null)
         {
             if (!hashtable.ContainsKey(reference2.name))
             {
                 hashtable.Add(reference2.name, null);
             }
         }
         else
         {
             TypeGroupReference reference3 = reference as TypeGroupReference;
             if (reference3 != null)
             {
                 TypeGroupDefinition definition = FindGroupDefinition(db, reference3.name);
                 if (definition != null)
                 {
                     foreach (TypeReference reference4 in definition.typeReferenceList)
                     {
                         if (!hashtable.ContainsKey(reference4.name))
                         {
                             hashtable.Add(reference4.name, null);
                         }
                     }
                 }
             }
         }
     }
     AppliesTo to = new AppliesTo();
     foreach (DictionaryEntry entry in hashtable)
     {
         to.AddAppliesToType(entry.Key as string);
     }
     return to;
 }
Ejemplo n.º 4
0
        internal static AppliesTo GetAllApplicableTypes(
            TypeInfoDataBase db,
            AppliesTo appliesTo)
        {
            Hashtable hashtable = new Hashtable((IEqualityComparer)StringComparer.OrdinalIgnoreCase);

            foreach (TypeOrGroupReference reference in appliesTo.referenceList)
            {
                if (reference is TypeReference typeReference)
                {
                    if (!hashtable.ContainsKey((object)typeReference.name))
                    {
                        hashtable.Add((object)typeReference.name, (object)null);
                    }
                }
                else if (reference is TypeGroupReference typeGroupReference)
                {
                    TypeGroupDefinition groupDefinition = DisplayDataQuery.FindGroupDefinition(db, typeGroupReference.name);
                    if (groupDefinition != null)
                    {
                        foreach (TypeReference typeReference in groupDefinition.typeReferenceList)
                        {
                            if (!hashtable.ContainsKey((object)typeReference.name))
                            {
                                hashtable.Add((object)typeReference.name, (object)null);
                            }
                        }
                    }
                }
            }
            AppliesTo appliesTo1 = new AppliesTo();

            foreach (DictionaryEntry dictionaryEntry in hashtable)
            {
                appliesTo1.AddAppliesToType(dictionaryEntry.Key as string);
            }
            return(appliesTo1);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// given an appliesTo list, it finds all the types that are contained (following type
        /// group references)
        /// </summary>
        /// <param name="db">database to use</param>
        /// <param name="appliesTo">object to lookup</param>
        /// <returns></returns>
        internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo appliesTo)
        {
            Hashtable allTypes = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (TypeOrGroupReference r in appliesTo.referenceList)
            {
                // if it is a type reference, just add the type name
                TypeReference tr = r as TypeReference;
                if (tr != null)
                {
                    if (!allTypes.ContainsKey(tr.name))
                        allTypes.Add(tr.name, null);
                }
                else
                {
                    // check if we have a type group reference
                    TypeGroupReference tgr = r as TypeGroupReference;

                    if (tgr == null)
                        continue;

                    // find the type group definition the reference points to
                    TypeGroupDefinition tgd = FindGroupDefinition(db, tgr.name);

                    if (tgd == null)
                        continue;

                    // we found the group, go over it
                    foreach (TypeReference x in tgd.typeReferenceList)
                    {
                        if (!allTypes.ContainsKey(x.name))
                            allTypes.Add(x.name, null);
                    }
                }
            }

            AppliesTo retVal = new AppliesTo();
            foreach (DictionaryEntry x in allTypes)
            {
                retVal.AddAppliesToType(x.Key as string);
            }

            return retVal;
        }
Ejemplo n.º 6
0
            internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
            {
                // Prepare a table view.
                TableView tableView = new TableView();
                tableView.Initialize(parentCmd._expressionFactory, parentCmd._typeInfoDataBase);

                // Request a view definition from the type database.
                ViewDefinition viewDefinition = DisplayDataQuery.GetViewByShapeAndType(parentCmd._expressionFactory, parentCmd._typeInfoDataBase, FormatShape.Table, input.TypeNames, null);
                if (viewDefinition != null)
                {
                    // Create a header using a view definition provided by the types database.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView, (TableControlBody)viewDefinition.mainControl);

                    // Remember all type names and type groups the current view applies to.
                    _appliesTo = viewDefinition.appliesTo;
                }
                else
                {
                    // Create a header using only the input object's properties.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView);
                    _appliesTo = new AppliesTo();

                    // Add all type names except for Object and MarshalByRefObject types because they are too generic.
                    // Leave the Object type name if it is the only type name.
                    int index = 0;
                    foreach (string typeName in input.TypeNames)
                    {
                        if (index > 0 && (typeName.Equals(typeof(Object).FullName, StringComparison.OrdinalIgnoreCase) ||
                            typeName.Equals(typeof(MarshalByRefObject).FullName, StringComparison.OrdinalIgnoreCase)))
                        {
                            break;
                        }
                        _appliesTo.AddAppliesToType(typeName);
                        index++;
                    }
                }
            }