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>(); } } } }
public List <DSResource> Get(Dictionary <string, object> parameters) { List <DSResource> dSResources; DataContext currentContext; PSReferencedResourceSet.CommandFactory commandFactory; if (PSReferencedResourceSet.TestHookDataContext == null) { currentContext = DataServiceController.Current.GetCurrentContext(); } else { currentContext = PSReferencedResourceSet.TestHookDataContext; } DataContext dataContext = currentContext; if (PSReferencedResourceSet.TestHookCommandFactory == null) { commandFactory = new PSReferencedResourceSet.CommandFactory(DataServiceController.Current.GetReferenceSetCommand); } else { commandFactory = PSReferencedResourceSet.TestHookCommandFactory; } PSReferencedResourceSet.CommandFactory commandFactory1 = commandFactory; IReferenceSetCommand userContext = commandFactory1((CommandType)5, dataContext.UserContext, this.referenceResourceProperty, dataContext.UserSchema.GetEntityMetadata(this.referenceeResourceType), dataContext.MembershipId, this.referenceResourceProperty.ResourceType); using (userContext) { UriParametersHelper.AddParametersToCommand(userContext, DataServiceController.Current.GetCurrentResourceUri()); userContext.AddReferringObject(parameters); IEnumerator <DSResource> enumerator = userContext.InvokeAsync(null, false); List <DSResource> dSResources1 = new List <DSResource>(); while (enumerator.MoveNext()) { dSResources1.Add(enumerator.Current); } dSResources = dSResources1; } return(dSResources); }