public ICommand GetCommand(CommandType commandType, UserContext userContext, ResourceType entityType, EntityMetadata entityMetadata, string membershipId) { if (entityType.Name == "CommandInvocation") { CommandType commandType1 = commandType; switch (commandType1) { case CommandType.Create: case CommandType.Read: case CommandType.Delete: { return new GICommand(commandType, this.runspaceStore, entityType, userContext, membershipId); } case CommandType.Update: { throw new NotImplementedException(); } default: { throw new NotImplementedException(); } } } else { throw new NotImplementedException(); } }
public static DSResource CreateResourceWithKeyAndReferenceSetCmdlets(ResourceType resourceType, Dictionary<string, object> keyProperties, EntityMetadata entityMetadata) { DSResource dSResource = ResourceTypeExtensions.CreateKeyOnlyResource(resourceType, keyProperties); if (dSResource != null) { PSEntityMetadata pSEntityMetadatum = entityMetadata as PSEntityMetadata; ReadOnlyCollection<ResourceProperty> properties = resourceType.Properties; foreach (ResourceProperty resourceProperty in properties.Where<ResourceProperty>((ResourceProperty it) => (it.Kind & ResourcePropertyKind.ResourceSetReference) == ResourcePropertyKind.ResourceSetReference)) { PSEntityMetadata.ReferenceSetCmdlets referenceSetCmdlet = null; if (!pSEntityMetadatum.CmdletsForReferenceSets.TryGetValue(resourceProperty.Name, out referenceSetCmdlet) || !referenceSetCmdlet.Cmdlets.ContainsKey(CommandType.GetReference)) { continue; } if (referenceSetCmdlet.GetRefHidden) { dSResource.SetValue(resourceProperty.Name, null); } else { PSReferencedResourceSet pSReferencedResourceSet = new PSReferencedResourceSet(resourceProperty, resourceType); dSResource.SetValue(resourceProperty.Name, pSReferencedResourceSet); } } return dSResource; } else { return null; } }
public bool Extract(Expression tree, IQueryable<DSResource> resourceRoot, ResourceType resourceType, EntityMetadata entityMetadata) { this.resourceRoot = resourceRoot; this.entityMetadata = entityMetadata; this.navigationProperty = null; this.referredEntityKeys = new Dictionary<string, object>(); this.referringEntityKeys = new Dictionary<string, object>(); this.currentState = ReferredResourceExtractor.ExtractionState.ExtractingReferredEntityInfo; this.Visit(tree); if (this.currentState == ReferredResourceExtractor.ExtractionState.ExtractingReferringEntityInfo) { DSResource dSResource = ResourceTypeExtensions.CreateKeyOnlyResource(resourceType, this.referringEntityKeys); if (dSResource != null) { this.ReferredResource = ResourceTypeExtensions.CreateKeyOnlyResource(this.navigationProperty.ResourceType, this.referredEntityKeys); if (this.ReferredResource != null) { this.currentState = ReferredResourceExtractor.ExtractionState.ExtractionDone; } } } if (this.currentState != ReferredResourceExtractor.ExtractionState.ExtractionDone) { this.currentState = ReferredResourceExtractor.ExtractionState.ExtractionFailed; } return this.currentState == ReferredResourceExtractor.ExtractionState.ExtractionDone; }
public ReferredEntityInstance(DSResource resource, UserContext userContext, ResourceType type, EntityMetadata metadata, string membershipId) { this.userContext = userContext; this.resourceType = type; this.metadata = metadata; this.membershipId = membershipId; this.resource = resource; }
public bool GetInnermostCmdletExpression(Expression tree, IQueryable<DSResource> resourceRoot, EntityMetadata entityMetadata, out Expression innermost, out ExpressionCategory category) { this.category = ExpressionCategory.Unhandled; this.cmdletExpression = null; this.resourceRoot = resourceRoot; this.entityMetadata = entityMetadata; this.Visit(tree); innermost = this.cmdletExpression; category = this.category; return (int)category != 8; }
public EntityUpdate(UserContext userContext, ResourceType type, EntityMetadata metadata, string membershipId) { this.userContext = userContext; this.resourceType = type; this.metadata = metadata; this.commandType = CommandType.Create; this.query = null; this.membershipId = membershipId; this.propertyUpdates = new SortedDictionary<string, object>(); this.updatedResource = null; this.resolveResource = null; }
public ICommand GetCommand(CommandType commandType, UserContext userContext, ResourceType entityType, EntityMetadata entityMetadata, string membershipId) { Envelope<PSRunspace, UserContext> envelope = this.runspaceStore.Borrow(userContext, membershipId); PSEntityMetadata pSEntityMetadatum = entityMetadata as PSEntityMetadata; object[] assemblyQualifiedName = new object[3]; assemblyQualifiedName[0] = "entityMetadata"; assemblyQualifiedName[1] = entityMetadata.GetType().AssemblyQualifiedName; assemblyQualifiedName[2] = typeof(PSEntityMetadata).AssemblyQualifiedName; ExceptionHelpers.ThrowArgumentExceptionIf("entityMetadata", pSEntityMetadatum == null, Resources.InvalidArgClrType, assemblyQualifiedName); object[] name = new object[2]; name[0] = entityType.Name; name[1] = commandType.ToString(); ExceptionHelpers.ThrowArgumentExceptionIf("entityMetadata", !pSEntityMetadatum.Cmdlets.ContainsKey(commandType), Resources.EntityDoesNotHaveCommand, name); return new PSCommand(envelope, entityType, pSEntityMetadatum.Cmdlets[commandType], commandType); }
public static bool IsNavPropertyHasGetReferenceCmdlet(this ResourceProperty resourceProperty, EntityMetadata entityMetadata) { if (resourceProperty.IsReferenceSetProperty()) { PSEntityMetadata pSEntityMetadatum = entityMetadata as PSEntityMetadata; PSEntityMetadata.ReferenceSetCmdlets referenceSetCmdlet = null; if (!pSEntityMetadatum.CmdletsForReferenceSets.TryGetValue(resourceProperty.Name, out referenceSetCmdlet) || !referenceSetCmdlet.Cmdlets.ContainsKey(CommandType.GetReference)) { return false; } else { return true; } } else { return false; } }
public IReferenceSetCommand GetReferenceSetCommand(CommandType commandType, UserContext userContext, ResourceProperty property, EntityMetadata entityMetadata, string membershipId, ResourceType resourceType) { Envelope<PSRunspace, UserContext> envelope = this.runspaceStore.Borrow(userContext, membershipId); PSReferenceSetCmdletInfo item = null; try { item = ((PSEntityMetadata)entityMetadata).CmdletsForReferenceSets[property.Name].Cmdlets[commandType]; } catch (KeyNotFoundException keyNotFoundException) { Tracer tracer = new Tracer(); tracer.DebugMessage(string.Concat("GetCommand cannot find commandType: ", commandType.ToString())); object[] fullName = new object[3]; fullName[0] = property.ResourceType.FullName; fullName[1] = property.Name; fullName[2] = commandType.ToString(); string str = string.Format(CultureInfo.CurrentCulture, Resources.PropertyDoesNotHaveCommand, fullName); throw new InvalidOperationException(str); } return new PSReferenceCommand(envelope, resourceType, item); }
public EntityUpdate(CommandType commandType, UserContext userContext, ResourceType type, EntityMetadata metadata, IQueryable query, string membershipId) { ExceptionHelpers.ThrowArgumentExceptionIf("commandType", commandType != CommandType.Update, Resources.InternalErrorOccurred, new object[0]); this.query = query; this.userContext = userContext; this.membershipId = membershipId; this.resourceType = type; this.metadata = metadata; this.commandType = commandType; this.propertyUpdates = new SortedDictionary<string, object>(); this.updatedResource = null; this.resolveResource = null; CommandArgumentVisitor commandArgumentVisitor = new CommandArgumentVisitor(this); commandArgumentVisitor.Visit(query.Expression); if (this.AreAllKeyFieldsSpecified()) { return; } else { throw new ArgumentException(ExceptionHelpers.GetExceptionMessage(Resources.KeysMissingInQuery, new object[0])); } }
public IReferenceSetCommand GetReferenceSetCommand(CommandType commandType, UserContext userContext, ResourceProperty property, EntityMetadata entityMetadata, string membershipId, ResourceType entityType = null) { return this.cmdManagers[entityMetadata.MgmtSystem].GetReferenceSetCommand(commandType, userContext, property, entityMetadata, membershipId, entityType); }
public ICommand GetCommand(CommandType commandType, UserContext userContext, ResourceType entityType, EntityMetadata entityMetadata, string membershipId) { return this.cmdManagers[entityMetadata.MgmtSystem].GetCommand(commandType, userContext, entityType, entityMetadata, membershipId); }
public IReferenceSetCommand GetReferenceSetCommand(CommandType commandType, UserContext userContext, ResourceProperty property, EntityMetadata entityMetadata, string membershipId, ResourceType resourceType) { throw new NotImplementedException(); }
public ReferenceInstanceBuilderCommand(ResourceType type, EntityMetadata entityMetadata) { this.entityMetadata = entityMetadata; this.resourceType = type; this.properties = new Dictionary<string, object>(); }