Example #1
0
        public void Build(Microsoft.Management.Odata.Schema.Schema logicalSchema, Microsoft.Management.Odata.Schema.Schema userSchema, UserContext userContext, string membershipId)
        {
            ResourceSet resourceSet = null;

            if (logicalSchema.ResourceSets.TryGetValue("CommandInvocations", out resourceSet))
            {
                string str = "PowerShell.CommandInvocation";
                userSchema.AddEntity(str, true, logicalSchema);
                userSchema.EntityMetadataDictionary.Add(str, logicalSchema.EntityMetadataDictionary[str]);
                userSchema.PopulateAllRelevantResourceTypes(logicalSchema);
            }
        }
Example #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);
     }
 }