Exemplo n.º 1
0
        internal void UpdateCompleteObject(DataServiceQueryProvider.ResultSetCollection resultSets)
        {
            DataServiceQueryProvider.ResultSet resultSet = null;
            Tracer tracer = new Tracer();

            if (resultSets == null || !resultSets.TryGetValue(this.ResourceType.Name, out resultSet))
            {
                tracer.DebugMessage(string.Concat("UpdateCompleteObject: result set ", this.ResourceType.Name, " not found"));
                throw new PowerShellWebServiceException(string.Concat("no result set named ", this.ResourceType.Name));
            }
            else
            {
                this.completeObject = resultSet.FirstOrDefault <DSResource>((DSResource item) => this.MatchKeyProperties(item));
                if (this.completeObject != null)
                {
                    tracer.DebugMessage("UpdateCompleteObject: found complete object");
                    return;
                }
                else
                {
                    tracer.DebugMessage("UpdateCompleteObject: no match for key properties of this object");
                    throw new PowerShellWebServiceException(string.Concat("no matching instance in result set named", this.ResourceType.Name));
                }
            }
        }
Exemplo n.º 2
0
 private DSLinqQueryProvider(Microsoft.Management.Odata.Schema.Schema schema, ResourceType root, UserContext userContext, string membershipId, DataServiceQueryProvider.ResultSetCollection resultSets)
 {
     this.schema = schema;
     this.initialResourceRoot = new DataServiceQueryProvider.ResultSet(root);
     this.initialQueryable    = this.initialResourceRoot.AsQueryable <DSResource>();
     this.resultSets          = resultSets;
     this.userContext         = userContext;
     this.membershipId        = membershipId;
 }
Exemplo n.º 3
0
 public DSMethodTranslatingVisitor(DataServiceQueryProvider.ResultSetCollection resultSets)
 {
     this.resultSets = resultSets;
 }
Exemplo n.º 4
0
        public object GetValue(string propertyName, DataServiceQueryProvider.ResultSetCollection resultSets = null)
        {
            object obj = null;
            Func <ResourceProperty, bool> func = null;

            if (!this.ContainsNonKeyProperties && resultSets != null)
            {
                if (this.completeObject == null)
                {
                    ReadOnlyCollection <ResourceProperty> properties = this.ResourceType.Properties;
                    if (func == null)
                    {
                        func = (ResourceProperty it) => string.Equals(propertyName, it.Name, StringComparison.Ordinal);
                    }
                    ResourceProperty resourceProperty = properties.FirstOrDefault <ResourceProperty>(func);
                    bool             flag             = false;
                    if (!resourceProperty.IsKeyProperty())
                    {
                        if (resourceProperty.IsReferenceSetProperty())
                        {
                            flag = !this.properties.ContainsKey(propertyName);
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        this.UpdateCompleteObject(resultSets);
                    }
                }
                if (this.completeObject != null)
                {
                    return(this.completeObject.GetValue(propertyName, resultSets));
                }
            }
            if (!this.properties.TryGetValue(propertyName, out obj))
            {
                if (this.ResourceType.Properties.Any <ResourceProperty>((ResourceProperty item) => item.Name == propertyName))
                {
                    return(null);
                }
                else
                {
                    throw new ResourcePropertyNotFoundException(this.ResourceType.Name, propertyName);
                }
            }
            else
            {
                if (obj != null)
                {
                    IReferencedResourceSet referencedResourceSet = obj as IReferencedResourceSet;
                    if (referencedResourceSet != null)
                    {
                        Dictionary <string, object> strs = new Dictionary <string, object>();
                        foreach (ResourceProperty keyProperty in this.ResourceType.KeyProperties)
                        {
                            object obj1 = null;
                            if (this.properties.TryGetValue(keyProperty.Name, out obj1))
                            {
                                strs.Add(keyProperty.Name, obj1);
                            }
                            else
                            {
                                throw new ResourcePropertyNotFoundException(this.ResourceType.Name, keyProperty.Name);
                            }
                        }
                        List <DSResource> dSResources = referencedResourceSet.Get(strs);
                        this.properties[propertyName] = dSResources;
                        return(dSResources);
                    }
                }
                return(obj);
            }
        }
Exemplo n.º 5
0
        internal static IQueryable CreateQuery(Microsoft.Management.Odata.Schema.Schema schema, ResourceType type, UserContext userContext, string membershipId, DataServiceQueryProvider.ResultSetCollection resultSets)
        {
            DSLinqQueryProvider dSLinqQueryProvider = new DSLinqQueryProvider(schema, type, userContext, membershipId, resultSets);

            return(dSLinqQueryProvider.CreateRootQuery());
        }
 public DataServiceQueryProvider()
 {
     this.IsNullPropagationRequired = false;
     this.resultSets = new DataServiceQueryProvider.ResultSetCollection();
 }