internal static NormalizedName NameNormalizer(EFElement parent, string refName) { Debug.Assert(parent != null, "parent should not be null"); NormalizedName normalizedName = null; if (refName == null) { return(null); } var parentEndProperty = parent as EndProperty; if (parentEndProperty != null) { normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForMSL(parentEndProperty, refName); } else { var parentItem = parent; normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForEDM(parentItem, refName); } if (normalizedName == null) { normalizedName = new NormalizedName(new Symbol(refName), null, null, refName); } return(normalizedName); }
internal static NormalizedName NameNormalizer(EFElement parent, string refName) { Debug.Assert(parent != null, "parent should not be null"); NormalizedName normalizedName = null; if (refName == null) { return(null); } var modfunc = parent as ModificationFunction; if (modfunc != null) { normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForMSL(modfunc, refName); } else { var parentItem = parent; normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForEDM(parentItem, refName); } if (normalizedName == null) { var symbol = new Symbol(refName); normalizedName = new NormalizedName(symbol, null, null, refName); } return(normalizedName); }
internal static NormalizedName NameNormalizer(EFElement parent, string refName) { Debug.Assert(parent != null, "parent should not be null"); if (refName == null) { return(null); } NormalizedName normalizedName = null; var parentAssociation = parent as Association; var parentAssociationSet = parent as AssociationSet; var parentAssociationSetMapping = parent as AssociationSetMapping; var parentNavigationProperty = parent as NavigationProperty; if (parentAssociation != null) { var model = parentAssociation.Parent as BaseEntityModel; if (model != null) { // we are coming up with the object's name for the first time var symbol = new Symbol(model.NamespaceValue, parentAssociation.LocalName.Value); normalizedName = new NormalizedName(symbol, null, null, parentAssociation.LocalName.Value); } } else if (parentAssociationSet != null) { // we are wanting to resolve a reference from an Association Set that may or may not // use the alias defined in the EntityModel normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForEDM(parentAssociationSet, refName); } else if (parentAssociationSetMapping != null) { normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForMSL(parentAssociationSetMapping, refName); } else if (parentNavigationProperty != null) { normalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForEDM(parentNavigationProperty, refName); } if (normalizedName == null) { var symbol = new Symbol(refName); normalizedName = new NormalizedName(symbol, null, null, refName); } return(normalizedName); }
protected override void InvokeInternal(CommandProcessorContext cpc) { // get unique name for the property var propertyName = ModelHelper.GetUniqueName(typeof(ConceptualProperty), _parentComplexType, _clipboardProperty.PropertyName); if (!_clipboardProperty.IsComplexProperty) { // scalar property case var cmd = new CreateComplexTypePropertyCommand( propertyName, _parentComplexType, _clipboardProperty.PropertyType, _clipboardProperty.IsNullable); CommandProcessor.InvokeSingleCommand(cpc, cmd); _createdProperty = cmd.Property; } else { // complex property case // first try to find ComplexType by it's name var complexTypeNormalizedName = EFNormalizableItemDefaults.DefaultNameNormalizerForEDM( _parentComplexType, _clipboardProperty.PropertyType); var items = _parentComplexType.Artifact.ArtifactSet.GetSymbolList(complexTypeNormalizedName.Symbol); ComplexType complexType = null; foreach (var efElement in items) { // the GetSymbolList() method might return more than one element so choose the first ComplexType complexType = efElement as ComplexType; if (complexType != null) { break; } } if (complexType != null) { // if the ComplexType is found, simply use the create command var cmd = new CreateComplexTypePropertyCommand(propertyName, _parentComplexType, complexType, false); CommandProcessor.InvokeSingleCommand(cpc, cmd); _createdProperty = cmd.Property; } else { // in this case we're going to create ComplexProperty with unresolved type var complexProperty = new ComplexConceptualProperty(_parentComplexType, null); complexProperty.ComplexType.SetXAttributeValue(_clipboardProperty.PropertyType); // set the name and add to the parent entity complexProperty.LocalName.Value = propertyName; _parentComplexType.AddProperty(complexProperty); // set other attributes of the property complexProperty.Nullable.Value = BoolOrNone.FalseValue; XmlModelHelper.NormalizeAndResolve(complexProperty); Debug.Assert( complexProperty.ComplexType.Status != BindingStatus.Known, "Why didn't we find the ComplexType in the ArtifactSet previously?"); _createdProperty = complexProperty; } } // safety check Debug.Assert(_createdProperty != null, "We didn't get good Property out of the command"); if (_createdProperty != null) { // set Property attributes var cmd2 = new SetConceptualPropertyFacetsCommand( _createdProperty, _clipboardProperty.Default, _clipboardProperty.ConcurrencyMode, _clipboardProperty.GetterAccessModifier, _clipboardProperty.SetterAccessModifier, _clipboardProperty.MaxLength, DefaultableValueBoolOrNone.GetFromNullableBool(_clipboardProperty.FixedLength), _clipboardProperty.Precision, _clipboardProperty.Scale, DefaultableValueBoolOrNone.GetFromNullableBool(_clipboardProperty.Unicode), _clipboardProperty.Collation); CommandProcessor.InvokeSingleCommand(cpc, cmd2); } }