Ejemplo n.º 1
0
        internal void Build(Microsoft.Management.Odata.Schema.Schema logicalSchema, Microsoft.Management.Odata.Schema.Schema userSchema, Runspace runspace)
        {
            HashSet <string> strs = null;
            Dictionary <string, CommandInfo> strs1 = null;

            PSSchemaBuilder.GetCommands(runspace, out strs, out strs1);
            List <PSSchemaBuilder.EntityDataForSchemaBuilding> entityDataForSchemaBuildings = this.CreateEntityDataForSchemaBuilding(logicalSchema, strs);

            this.AddEntitiesToSchema(logicalSchema, userSchema, entityDataForSchemaBuildings, strs1);
            userSchema.PopulateAllRelevantResourceTypes(logicalSchema);
        }
Ejemplo n.º 2
0
 private void AddEntitiesToSchema(Microsoft.Management.Odata.Schema.Schema logicalSchema, Microsoft.Management.Odata.Schema.Schema userSchema, List <PSSchemaBuilder.EntityDataForSchemaBuilding> entityDataCollection, Dictionary <string, CommandInfo> sessionCmdlets)
 {
     foreach (PSSchemaBuilder.EntityDataForSchemaBuilding referenceSetCommand in entityDataCollection)
     {
         if (!referenceSetCommand.IncludeInSchema)
         {
             continue;
         }
         userSchema.AddEntity(referenceSetCommand.EntityName, referenceSetCommand.IncludeEntitySet, logicalSchema);
         PSEntityMetadata pSEntityMetadatum = new PSEntityMetadata();
         PSEntityMetadata item = (PSEntityMetadata)logicalSchema.EntityMetadataDictionary[referenceSetCommand.EntityName];
         foreach (CommandType command in referenceSetCommand.Commands)
         {
             PSCmdletInfo pSCmdletInfo = item.Cmdlets[command];
             pSEntityMetadatum.Cmdlets.Add(command, PSSchemaBuilder.ConstructMetadata(pSCmdletInfo, sessionCmdlets));
         }
         Dictionary <string, PSSchemaBuilder.EntityDataForSchemaBuilding.ReferencePropertyData> .Enumerator enumerator = referenceSetCommand.ReferenceSetCommands.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 KeyValuePair <string, PSSchemaBuilder.EntityDataForSchemaBuilding.ReferencePropertyData> keyValuePair = enumerator.Current;
                 PSReferenceSetCmdletInfo pSReferenceSetCmdletInfo = null;
                 PSReferenceSetCmdletInfo item1 = null;
                 PSReferenceSetCmdletInfo pSReferenceSetCmdletInfo1 = null;
                 if (keyValuePair.Value.IncludeAdd)
                 {
                     pSReferenceSetCmdletInfo = item.CmdletsForReferenceSets[keyValuePair.Key].Cmdlets[CommandType.AddReference];
                 }
                 if (keyValuePair.Value.IncludeRemove)
                 {
                     item1 = item.CmdletsForReferenceSets[keyValuePair.Key].Cmdlets[CommandType.RemoveReference];
                 }
                 if (keyValuePair.Value.IncludeGet)
                 {
                     pSReferenceSetCmdletInfo1 = item.CmdletsForReferenceSets[keyValuePair.Key].Cmdlets[CommandType.GetReference];
                 }
                 PSEntityMetadata.ReferenceSetCmdlets referenceSetCmdlet = new PSEntityMetadata.ReferenceSetCmdlets(item.CmdletsForReferenceSets[keyValuePair.Key].PropertyType, pSReferenceSetCmdletInfo, item1, pSReferenceSetCmdletInfo1, keyValuePair.Value.GetHidden);
                 pSEntityMetadatum.CmdletsForReferenceSets[keyValuePair.Key] = referenceSetCmdlet;
             }
         }
         finally
         {
             enumerator.Dispose();
         }
         userSchema.EntityMetadataDictionary.Add(referenceSetCommand.EntityName, pSEntityMetadatum);
     }
 }