本文整理汇总了C#中Microsoft.Data.Entity.Design.Model.Commands.CommandProcessorContext类的典型用法代码示例。如果您正苦于以下问题:C# CommandProcessorContext类的具体用法?C# CommandProcessorContext怎么用?C# CommandProcessorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandProcessorContext类属于Microsoft.Data.Entity.Design.Model.Commands命名空间,在下文中一共展示了CommandProcessorContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
Debug.Assert(_properties != null && _properties.Count > 0, "There is no property to be moved.");
if (_properties != null
&& _properties.Count > 0)
{
Debug.Assert(_step > 0, "Parameter step value is not valid. The value must be greater than 0.");
if (_step > 0)
{
// Properties are moved in the following order:
// - If the properties are moved forward (MoveDirection == Down), we need to move the property that are closer to the last-property first.
// - If the properties are moved backward (MoveDirection == Up), we need to move the property that are closer to the first-property first.
var sortedProperties = ModelHelper.GetListOfPropertiesInTheirXElementsOrder(_properties);
Debug.Assert(
sortedProperties.Count == _properties.Count, "The sorted properties should have the same number of properties.");
PropertyBase previouslyMovedProperty = null;
foreach (var property in (_moveDirection == MoveDirection.Up ? sortedProperties : sortedProperties.Reverse()))
{
// Ensure that properties are moved don't change order.
// For example: if property A, B and C are moved forward, the move should not cause property A to be placed after Property B.
var numberOfSteps = GetNumberOfMoveStep(property, previouslyMovedProperty);
if (numberOfSteps > 0)
{
CommandProcessor.InvokeSingleCommand(cpc, new MovePropertyCommand(property, _moveDirection, numberOfSteps));
}
previouslyMovedProperty = property;
}
}
}
}
示例2: PreInvoke
protected override void PreInvoke(CommandProcessorContext cpc)
{
// Save off the deleted function mport name
DeletedFunctionImportName = FunctionImport.Name.Value;
base.PreInvoke(cpc);
}
示例3: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
Debug.Assert(cpc != null, "InvokeInternal is called when EntityContainerMapping is null.");
// safety check, this should never be hit
if (EntityType == null)
{
throw new InvalidOperationException("InvokeInternal is called when entity type is null");
}
EntityType.Abstract.Value = SetAbstract;
// remove any function mappings if we are setting this to abstract
if (SetAbstract)
{
var etms = new List<EntityTypeMapping>();
etms.AddRange(EntityType.GetAntiDependenciesOfType<EntityTypeMapping>());
for (var i = etms.Count - 1; i >= 0; i--)
{
var etm = etms[i];
if (etm != null
&& etm.Kind == EntityTypeMappingKind.Function)
{
DeleteEFElementCommand.DeleteInTransaction(cpc, etm);
}
}
}
XmlModelHelper.NormalizeAndResolve(EntityType);
}
示例4: ScheduleChildAntiDependenciesForRebinding
internal static void ScheduleChildAntiDependenciesForRebinding(CommandProcessorContext cpc, EFObject efObject)
{
// identify any binding that was referencing this symbol, and add it to the list of things to rebind.
var visitor = new AntiDependencyCollectorVisitor();
visitor.Traverse(efObject);
ScheduleBindingsForRebind(cpc, visitor.AntiDependencyBindings);
}
示例5: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
if (_entityProperty != null)
{
Debug.Assert(_entityProperty.EntityModel.IsCSDL, "_entityProperty should be from C-side model");
ScalarProperty.Name.SetRefName(_entityProperty);
}
if (TableColumn != null)
{
Debug.Assert(TableColumn.EntityModel.IsCSDL != true, "_tableColumn should not be from C-side model");
ScalarProperty.ColumnName.SetRefName(TableColumn);
}
XmlModelHelper.NormalizeAndResolve(ScalarProperty);
// if we change a scalar in an association mapping, make sure that we still have good MSL
if (ScalarProperty.EndProperty != null)
{
var asm = ScalarProperty.EndProperty.Parent as AssociationSetMapping;
Debug.Assert(asm != null, "_sp.EndProperty parent is not an AssociationSetMapping");
if (asm != null)
{
EnforceAssociationSetMappingRules.AddRule(cpc, asm);
var assoc = asm.TypeName.Target;
Debug.Assert(assoc != null, "Could not resolve association reference");
if (assoc != null)
{
InferReferentialConstraints.AddRule(cpc, assoc);
}
}
}
}
示例6: PropagateStoreGeneratedPatternToStorageModel
internal PropagateStoreGeneratedPatternToStorageModel(
CommandProcessorContext cpc, StorageProperty storageProperty, bool propagateNoneSGP)
{
_cpc = cpc;
_storageProperty = storageProperty;
_propagateNoneSGP = propagateNoneSGP;
}
示例7: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
var cmd = new UpdateDefaultableValueCommand<string>(_typeAccess, _newValue);
CommandProcessor.InvokeSingleCommand(cpc, cmd);
if (ModelConstants.CodeGenerationAccessInternal.Equals(_newValue, StringComparison.Ordinal))
{
var cet = _typeAccess.GetParentOfType(typeof(ConceptualEntityType)) as ConceptualEntityType;
Debug.Assert(null != cet, "parent of _typeAccess should be of type " + typeof(ConceptualEntityType).FullName);
if (null != cet)
{
// Note: it is valid for the EntitySet to be null
var ces = cet.EntitySet as ConceptualEntitySet;
if (null != ces)
{
var entitySetGetterAccess = ces.GetterAccess.Value;
if (ModelConstants.CodeGenerationAccessPublic.Equals(entitySetGetterAccess)
|| ModelConstants.CodeGenerationAccessProtected.Equals(entitySetGetterAccess))
{
// new value is Internal and EntitySet's existing value is Public or Protected
// so need to also update the GetterAccess attribute on the EntitySet
// (otherwise will get runtime error 6036)
var cmd2 = new UpdateDefaultableValueCommand<string>(ces.GetterAccess, _newValue);
CommandProcessor.InvokeSingleCommand(cpc, cmd2);
}
}
}
}
}
示例8: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
if (!string.IsNullOrEmpty(Role)
&& !string.Equals(End.Role.Value, Role, StringComparison.Ordinal))
{
// TODO: should this command be enqueued in the command processor?
RenameCommand c = new EntityDesignRenameCommand(End, Role, true);
CommandProcessor.InvokeSingleCommand(cpc, c);
// bug 563525: we need to update EndProperties within AssociationSetMappings if the AssociationEnd changes.
// we update the "Role" of an AssociationSetEnd in the RenameCommand but the SingleItemBinding that we have to update
// that is bound to the AssociationSetEnd is unique to this situation; it is not technically a "refactor rename".
var associationSetEnd = End.GetAntiDependenciesOfType<AssociationSetEnd>().FirstOrDefault();
if (associationSetEnd != null)
{
// we need to renormalize the associationSetEnd, since the role name will have changed.
XmlModelHelper.NormalizeAndResolve(associationSetEnd);
var endPropertiesInAssocSetMappings = associationSetEnd.GetAntiDependenciesOfType<EndProperty>();
foreach (var endProperty in endPropertiesInAssocSetMappings)
{
endProperty.Name.SetRefName(associationSetEnd);
CheckArtifactBindings.ScheduleBindingsForRebind(cpc, new HashSet<ItemBinding> { endProperty.Name });
}
}
}
}
示例9: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
if (_diagram != null)
{
// Add diagram id information in the transaction context.
// This is to ensure the diagram objects are created correctly.
if (cpc.EfiTransaction.GetContextValue<DiagramContextItem>(EfiTransactionOriginator.TransactionOriginatorDiagramId) == null)
{
cpc.EfiTransaction.AddContextValue(
EfiTransactionOriginator.TransactionOriginatorDiagramId, new DiagramContextItem(_diagram.Id.Value));
}
}
var service = cpc.EditingContext.GetEFArtifactService();
var artifact = service.Artifact;
// check if entity is in the model
_createdEntity = artifact.ArtifactSet.LookupSymbol(_clipboardEntity.NormalizedName) as EntityType;
if (_diagram != null
&& _createdEntity != null
&& _createdEntity is ConceptualEntityType)
{
if (_createdEntity.GetAntiDependenciesOfType<EntityTypeShape>().Count(ets => ets.Diagram.Id == _diagram.Id.Value) == 0)
{
// CreateEntityTypeShapeAndConnectorsInDiagram method will check if the shape for the entity-type has been created;
// and it will not create one if the shape already exists in the diagram.
// Also, VerifyDiagramModelIntegrityVisitor will assert if there are duplicate diagram shapes (shapes that point to the same model element)
// every-time a command transaction is committed. So adding another check to do the same thing here is redundant.
CreateEntityTypeShapeCommand.CreateEntityTypeShapeAndConnectorsInDiagram(
cpc, _diagram, _createdEntity as ConceptualEntityType, _clipboardEntity.EntityTypeShapeFillColor, false);
return;
}
}
CreateEntityCopyInModel(cpc);
}
示例10: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
// if don't have an ECM yet, go create one
if (_entityContainerMapping == null)
{
var cmd = new CreateEntityContainerMappingCommand(_entitySet.Artifact);
CommandProcessor.InvokeSingleCommand(cpc, cmd);
_entityContainerMapping = cmd.EntityContainerMapping;
}
Debug.Assert(_entityContainerMapping != null, "_entityContainerMapping should not be null");
if (_entityContainerMapping == null)
{
throw new CannotLocateParentItemException();
}
// create the ESM
var esm = new EntitySetMapping(_entityContainerMapping, null);
esm.Name.SetRefName(_entitySet);
_entityContainerMapping.AddEntitySetMapping(esm);
XmlModelHelper.NormalizeAndResolve(esm);
_created = esm;
}
示例11: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
var associationSetMapping = ModelHelper.FindAssociationSetMappingForConceptualAssociation(Association);
if (associationSetMapping == null)
{
// This AssociationSetMapping does not exist, create it
base.InvokeInternal(cpc);
associationSetMapping = AssociationSetMapping;
Debug.Assert(associationSetMapping != null, "Could not create AssociationSetMapping");
}
else
{
// The AssociationSetMapping already exists, update it
associationSetMapping.Name.SetRefName(AssociationSet);
associationSetMapping.TypeName.SetRefName(Association);
associationSetMapping.StoreEntitySet.SetRefName(StorageEntitySet);
XmlModelHelper.NormalizeAndResolve(associationSetMapping);
Debug.Assert(associationSetMapping.Name.Target != null, "Could not resolve association set reference");
Debug.Assert(associationSetMapping.TypeName.Target != null, "Could not resolve association type reference");
Debug.Assert(associationSetMapping.StoreEntitySet.Target != null, "Could not resolve table reference");
InferReferentialConstraints.AddRule(cpc, Association);
}
}
示例12: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
// safety check, this should never be hit
Debug.Assert(Property != null, "InvokeInternal is called when Property is null.");
if (Property == null)
{
throw new InvalidOperationException("InvokeInternal is called when Property is null.");
}
var cmd = new UpdateDefaultableValueCommand<string>(Property.StoreGeneratedPattern, SgpValue);
CommandProcessor.InvokeSingleCommand(cpc, cmd);
// ensure view keys are propagated from C-side to S-side
var cet = Property.EntityType as ConceptualEntityType;
if (cet != null)
{
PropagateViewKeysToStorageModel.AddRule(cpc, cet);
}
// ensure StoreGeneratedPattern is propagated from C-side to S-side
// unless we are part of an Update Model txn in which case there is no need
// as the whole artifact has this integrity check applied by UpdateModelFromDatabaseCommand
if (EfiTransactionOriginator.UpdateModelFromDatabaseId != cpc.OriginatorId)
{
var cProp = Property as ConceptualProperty;
Debug.Assert(cProp != null, "expected Property of type ConceptualProperty, instead got type " + Property.GetType().FullName);
if (cProp != null)
{
PropagateStoreGeneratedPatternToStorageModel.AddRule(cpc, cProp, true);
}
}
}
示例13: StaticInvoke
internal static void StaticInvoke(CommandProcessorContext cpc, InheritanceConnector inheritanceConnector)
{
// if there was a circular inheritance, this connector will be deleted, if so, we just return
if (inheritanceConnector.IsDeleted)
{
return;
}
var viewModel = inheritanceConnector.GetRootViewModel();
Debug.Assert(
viewModel != null, "Unable to find root view model from inheritance connector: " + inheritanceConnector.AccessibleName);
if (viewModel != null)
{
var modelEntityTypeBase = viewModel.ModelXRef.GetExisting(inheritanceConnector.ModelElement) as EntityTypeBaseType;
if (modelEntityTypeBase != null)
{
var modelEntity = modelEntityTypeBase.Parent as EntityType;
var modelDiagram = viewModel.ModelXRef.GetExisting(inheritanceConnector.Diagram) as Diagram;
Debug.Assert(modelEntity != null && modelDiagram != null);
if (modelEntity != null
&& modelDiagram != null)
{
var cmd = new CreateInheritanceConnectorCommand(modelDiagram, modelEntity);
CommandProcessor.InvokeSingleCommand(cpc, cmd);
var modelInheritanceConnector = cmd.InheritanceConnector;
viewModel.ModelXRef.Add(modelInheritanceConnector, inheritanceConnector, viewModel.EditingContext);
}
}
}
}
示例14: Invoke
internal override void Invoke(CommandProcessorContext cpc)
{
var viewModel = _inheritance.GetRootViewModel();
Debug.Assert(viewModel != null, "Unable to find root view model from inheritance: " + _inheritance);
if (viewModel != null)
{
if (ViewUtils.SetBaseEntityType(cpc, _derivedEntity, _baseEntity))
{
viewModel.ModelXRef.Add(_derivedEntity.BaseType, _inheritance, viewModel.EditingContext);
}
else
{
try
{
// setting null will clear out the selection, which may be this Inheritance thing we are deleting
viewModel.GetDiagram().ActiveDiagramView.Selection.Set((DiagramItem)null);
// in this case inheritance was not created in the model, so we need to delete it from the view model
// we don't want any rules to fire for this, so suspend them temporarly
_inheritance.Store.RuleManager.SuspendRuleNotification();
using (var t = _inheritance.Store.TransactionManager.BeginTransaction())
{
_inheritance.Delete();
t.Commit();
}
}
finally
{
_inheritance.Store.RuleManager.ResumeRuleNotification();
}
}
}
}
示例15: InvokeInternal
protected override void InvokeInternal(CommandProcessorContext cpc)
{
// check that we have an existing artifact
var service = cpc.EditingContext.GetEFArtifactService();
var existingArtifact = service.Artifact as EntityDesignArtifact;
if (null == existingArtifact)
{
Debug.Fail("Null Artifact in ReplaceSsdlCommand.InvokeInternal()");
return;
}
// replace the old SSDL with the new
ReplaceSsdl(cpc, existingArtifact, _newSsdlReader);
// replace the old MSL with the new
ReplaceMsl(cpc, existingArtifact, _newMslReader);
// normalize and resolve the StorageModel
XmlModelHelper.NormalizeAndResolve(existingArtifact.StorageModel);
Debug.Assert(EFElementState.Resolved == existingArtifact.StorageModel.State, "StorageModel State should be Resolved");
// normalize and resolve the MappingModel
XmlModelHelper.NormalizeAndResolve(existingArtifact.MappingModel);
Debug.Assert(EFElementState.Resolved == existingArtifact.MappingModel.State, "MappingModel State should be Resolved");
}