Пример #1
0
 public void InvokeCommand()
 {
     if (PSCommandManager.IsReferenceCmdlet(this.commandType))
     {
         IReferenceSetCommand referenceSetCommand = DataServiceController.Current.GetReferenceSetCommand(this.commandType, this.userContext, this.referringProperty, this.metadata, this.membershipId, null);
         using (referenceSetCommand)
         {
             UriParametersHelper.AddParametersToCommand(referenceSetCommand, DataServiceController.Current.GetCurrentResourceUri());
             this.AddPropertyUpdates(referenceSetCommand);
             referenceSetCommand.AddReferredObject(this.referredInstance.GetKeyValues());
             referenceSetCommand.AddReferringObject(this.GetKeyValues());
             List <DSResource> dSResources = new List <DSResource>();
             DataServiceController.Current.QuotaSystem.CheckCmdletExecutionQuota(this.userContext);
             IEnumerator <DSResource> enumerator = referenceSetCommand.InvokeAsync(dSResources.AsQueryable <DSResource>().Expression, true);
             while (enumerator.MoveNext())
             {
             }
         }
     }
     else
     {
         ICommand command = DataServiceController.Current.GetCommand(this.commandType, this.userContext, this.resourceType, this.metadata, this.membershipId);
         using (command)
         {
             UriParametersHelper.AddParametersToCommand(command, DataServiceController.Current.GetCurrentResourceUri());
             this.AddPropertyUpdates(command);
             List <DSResource>        dSResources1 = new List <DSResource>();
             IEnumerator <DSResource> enumerator1  = command.InvokeAsync(dSResources1.AsQueryable <DSResource>().Expression, true);
             while (enumerator1.MoveNext())
             {
                 dSResources1.Add(enumerator1.Current);
             }
             if (this.commandType == CommandType.Delete || dSResources1.Count < 1)
             {
                 if (this.commandType != CommandType.Create || dSResources1.Count > 0)
                 {
                     this.updatedResource = null;
                 }
                 else
                 {
                     throw new DataServiceException(string.Format(Resources.CreateCommandNotReturnedInstance, this.resourceType.Name));
                 }
             }
             else
             {
                 this.updatedResource = dSResources1.First <DSResource>();
             }
         }
     }
 }