private void UpdateFields() { var first = (association.First as CompositeType); if (first != null) { foreach (var f in first.Fields) cbxStartRole.Items.Add(f.Name); foreach (var p in first.Operations) if (p is Property) cbxStartRole.Items.Add(p.Name); } var second = (association.Second as CompositeType); if (second != null) { foreach (var f in second.Fields) cbxEndRole.Items.Add(f.Name); foreach (var p in second.Operations) if (p is Property) cbxEndRole.Items.Add(p.Name); } cbxStartRole.Text = association.StartRole; cbxEndRole.Text = association.EndRole; modifiedDirection = association.Direction; modifiedType = association.AssociationType; txtName.Text = association.Label; cbxStartMultiplicity.SelectedItem = association.StartMultiplicity; cbxEndMultiplicity.SelectedItem = association.EndMultiplicity; }
public void returns_expected_result_when_valid(string value, AssociationType expectedResult) { var parser = BuildParser(); var result = parser.ParseProperty(value); Assert.AreEqual(expectedResult, result); }
public Operator(string name, OperatorType type, int precedence, AssociationType association, Func<double, double, double> body) : base(name) { this.Type = type; this.Precedence = precedence; this.Association = association; this.Body = body; }
/// <summary> /// Initializes a new instance of the <see cref="COMServerAssociationAttribute"/> class. /// </summary> /// <param name="associationType">Type of the association.</param> /// <param name="associations">The associations.</param> public COMServerAssociationAttribute(AssociationType associationType, params string[] associations) { // Set the assocation type. this.associationType = associationType; // Set the associations. this.associations = associations; }
private void UpdateFields() { modifiedDirection = association.Direction; modifiedType = association.AssociationType; txtName.Text = association.Label; txtStartRole.Text = association.StartRole; txtEndRole.Text = association.EndRole; cboStartMultiplicity.Text = association.StartMultiplicity; cboEndMultiplicity.Text = association.EndMultiplicity; }
private string GetAssociationCreateScript(AssociationType a) { StringBuilder sql = new StringBuilder(); StringBuilder keySql = new StringBuilder(); if (a.IsForeignKey) { EntityType childType = (EntityType)a.ReferentialConstraints[0].ToProperties[0].DeclaringType; EntityType parentType = (EntityType)a.ReferentialConstraints[0].FromProperties[0].DeclaringType; sql.AppendLine(String.Format( "ALTER TABLE `{0}` ADD CONSTRAINT {1}", childType.Name, a.Name)); sql.Append("\t FOREIGN KEY ("); string delimiter = ""; foreach (EdmProperty p in a.ReferentialConstraints[0].ToProperties) { EdmMember member; if (!childType.KeyMembers.TryGetValue(p.Name, false, out member)) { keySql.AppendLine(String.Format( "ALTER TABLE `{0}` ADD KEY (`{1}`);", childType.Name, p.Name)); } sql.AppendFormat("{0}{1}", delimiter, p.Name); delimiter = ", "; } sql.AppendLine(")"); delimiter = ""; sql.Append(String.Format("\tREFERENCES {0} (", parentType.Name)); foreach (EdmProperty p in a.ReferentialConstraints[0].FromProperties) { EdmMember member; if (!parentType.KeyMembers.TryGetValue(p.Name, false, out member)) { keySql.AppendLine(String.Format( "ALTER TABLE `{0}` ADD KEY (`{1}`);", parentType.Name, p.Name)); } sql.AppendFormat("{0}{1}", delimiter, p.Name); delimiter = ", "; } sql.AppendLine(");"); sql.AppendLine(); } keySql.Append(sql.ToString()); return(keySql.ToString()); }
public void HasCascadeDeletePath_should_return_true_for_self_ref_cascade() { var model = new EdmModel(DataSpace.CSpace); var entityType = model.AddEntityType("A"); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace) { SourceEnd = new AssociationEndMember("S", entityType) }; associationType.TargetEnd = new AssociationEndMember("T", associationType.SourceEnd.GetEntityType()); associationType.SourceEnd.DeleteBehavior = OperationAction.Cascade; model.AddAssociationType(associationType); Assert.True(model.HasCascadeDeletePath(entityType, entityType)); }
/// <inheritdoc/> protected override bool MatchDependentKeyProperty( AssociationType associationType, AssociationEndMember dependentAssociationEnd, EdmProperty dependentProperty, EntityType principalEntityType, EdmProperty principalKeyProperty) { Check.NotNull(associationType, "associationType"); Check.NotNull(dependentAssociationEnd, "dependentAssociationEnd"); Check.NotNull(dependentProperty, "dependentProperty"); Check.NotNull(principalEntityType, "principalEntityType"); Check.NotNull(principalKeyProperty, "principalKeyProperty"); return(string.Equals( dependentProperty.Name, principalEntityType.Name + principalKeyProperty.Name, StringComparison.OrdinalIgnoreCase)); }
public void Configure_should_validate_consistency_of_function_configuration_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); var functionConfiguration1 = new ModificationFunctionConfiguration(); functionConfiguration1.HasName("Foo"); var functionConfiguration2 = new ModificationFunctionConfiguration(); functionConfiguration2.HasName("Bar"); var functionsConfiguration1 = new ModificationFunctionsConfiguration(); functionsConfiguration1.Insert(functionConfiguration1); var functionsConfiguration2 = new ModificationFunctionsConfiguration(); functionsConfiguration2.Insert(functionConfiguration2); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()) { ModificationFunctionsConfiguration = functionsConfiguration1 }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()) { ModificationFunctionsConfiguration = functionsConfiguration2 }; Assert.Equal( Strings.ConflictingFunctionsMapping("P", typeof(object)), Assert.Throws <InvalidOperationException>( () => navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)))).Message); }
/// <summary> /// Creates a new instance of <see cref="GenerateDTOsParams"/>. /// </summary> /// <param name="targetProject">Project where the DTOs are going to be generated.</param> /// <param name="targetProjectFolder">Project folder where DTO's are going to be generated. /// Null value indicates to generate at project level.</param> /// <param name="entitySource">Entity source (can be a Project or a ProjectItem representing an EDMX).</param> /// <param name="typesToGenerateFilter">Types from which to generate the DTOs.</param> /// <param name="generateAllTypes">Indicates if all types must be generated.</param> /// <param name="generateAllComplexTypes">Indicates if all complex types must be generated.</param> /// <param name="generateAllEntityTypes">Indicates if all complex types must be generated.</param> /// <param name="sourceFileHeaderComment">Source File Header Comment (optional).</param> /// <param name="useProjectDefaultNamespace">Indicates if Target Project default namespace is going to be used.</param> /// <param name="sourceNamespace">Namespace used for the DTOs.</param> /// <param name="dtosServiceReady">Specifies if the DTOs are Service-Ready (this means if they can be serialized or not).</param> /// <param name="classIdentifierUse">Indicates use of identifier in class names.</param> /// <param name="classIdentifierWord">Identifier to use in class names.</param> /// <param name="sourceFileGenerationType">Specifies the Source File Generation Type desired.</param> /// <param name="sourceFileName">Source File Name to use if the Source File Generation Type is OneSourceFile.</param> /// <param name="associationType">Class Association Type desired.</param> /// <param name="generateDTOConstructors">Indicates if DTO's Constructor methods should be created.</param> public GenerateDTOsParams(Project targetProject, ProjectItem targetProjectFolder, dynamic entitySource, List<string> typesToGenerateFilter, bool generateAllTypes, bool generateAllComplexTypes, bool generateAllEntityTypes, string sourceFileHeaderComment, bool useProjectDefaultNamespace, string sourceNamespace, bool dtosServiceReady, ClassIdentifierUse classIdentifierUse, string classIdentifierWord, SourceFileGenerationType sourceFileGenerationType, string sourceFileName, AssociationType associationType, bool generateDTOConstructors) { this.TargetProject = targetProject; this.TargetProjectFolder = targetProjectFolder; this.TargetType = (this.TargetProjectFolder == null ? TargetType.Project : TargetType.ProjectFolder); this.EDMXProject = (entitySource is ProjectItem ? entitySource.ContainingProject : null); // TODO: ffernandez, use EntitySource (enum), add new property for the type and for Project this.EDMXProjectItem = entitySource; this.EDMXDocument = EdmxHelper.GetEdmxDocument(this.EDMXProjectItem); // TODO: ffernandez, review Project case this.EntitiesNamespace = EdmxHelper.GetEntitiesNamespace(entitySource); this.TypesToGenerateFilter = typesToGenerateFilter; this.GenerateAllTypes = generateAllTypes; this.GenerateAllComplexTypes = generateAllComplexTypes; this.GenerateAllEntityTypes = generateAllEntityTypes; this.SourceFileHeaderComment = sourceFileHeaderComment; this.UseProjectDefaultNamespace = useProjectDefaultNamespace; this.SourceNamespace = sourceNamespace; this.DTOsServiceReady = dtosServiceReady; this.ClassIdentifierUse = classIdentifierUse; this.ClassIdentifierWord = classIdentifierWord; if (this.ClassIdentifierUse == ClassIdentifierUse.None) { this.ClassIdentifierWord = string.Empty; } this.SourceFileGenerationType = sourceFileGenerationType; this.SourceFileName = sourceFileName; this.AssociationType = associationType; this.GenerateDTOConstructors = generateDTOConstructors; }
/// <summary> /// Creates a new instance of <see cref="GenerateDTOsParams"/>. /// </summary> /// <param name="targetProject">Project where the DTOs are going to be generated.</param> /// <param name="targetProjectFolder">Project folder where DTO's are going to be generated. /// Null value indicates to generate at project level.</param> /// <param name="entitySource">Entity source (can be a Project or a ProjectItem representing an EDMX).</param> /// <param name="typesToGenerateFilter">Types from which to generate the DTOs.</param> /// <param name="generateAllTypes">Indicates if all types must be generated.</param> /// <param name="generateAllComplexTypes">Indicates if all complex types must be generated.</param> /// <param name="generateAllEntityTypes">Indicates if all complex types must be generated.</param> /// <param name="sourceFileHeaderComment">Source File Header Comment (optional).</param> /// <param name="useProjectDefaultNamespace">Indicates if Target Project default namespace is going to be used.</param> /// <param name="sourceNamespace">Namespace used for the DTOs.</param> /// <param name="dtosServiceReady">Specifies if the DTOs are Service-Ready (this means if they can be serialized or not).</param> /// <param name="classIdentifierUse">Indicates use of identifier in class names.</param> /// <param name="classIdentifierWord">Identifier to use in class names.</param> /// <param name="sourceFileGenerationType">Specifies the Source File Generation Type desired.</param> /// <param name="sourceFileName">Source File Name to use if the Source File Generation Type is OneSourceFile.</param> /// <param name="associationType">Class Association Type desired.</param> /// <param name="generateDTOConstructors">Indicates if DTO's Constructor methods should be created.</param> public GenerateDTOsParams(Project targetProject, ProjectItem targetProjectFolder, dynamic entitySource, List <string> typesToGenerateFilter, bool generateAllTypes, bool generateAllComplexTypes, bool generateAllEntityTypes, string sourceFileHeaderComment, bool useProjectDefaultNamespace, string sourceNamespace, bool dtosServiceReady, ClassIdentifierUse classIdentifierUse, string classIdentifierWord, SourceFileGenerationType sourceFileGenerationType, string sourceFileName, AssociationType associationType, bool generateDTOConstructors) { this.TargetProject = targetProject; this.TargetProjectFolder = targetProjectFolder; this.TargetType = (this.TargetProjectFolder == null ? TargetType.Project : TargetType.ProjectFolder); this.EDMXProject = (entitySource is ProjectItem ? entitySource.ContainingProject : null); // TODO: ffernandez, use EntitySource (enum), add new property for the type and for Project this.EDMXProjectItem = entitySource; this.EDMXDocument = EdmxHelper.GetEdmxDocument(this.EDMXProjectItem); // TODO: ffernandez, review Project case this.EntitiesNamespace = EdmxHelper.GetEntitiesNamespace(entitySource); this.TypesToGenerateFilter = typesToGenerateFilter; this.GenerateAllTypes = generateAllTypes; this.GenerateAllComplexTypes = generateAllComplexTypes; this.GenerateAllEntityTypes = generateAllEntityTypes; this.SourceFileHeaderComment = sourceFileHeaderComment; this.UseProjectDefaultNamespace = useProjectDefaultNamespace; this.SourceNamespace = sourceNamespace; this.DTOsServiceReady = dtosServiceReady; this.ClassIdentifierUse = classIdentifierUse; this.ClassIdentifierWord = classIdentifierWord; if (this.ClassIdentifierUse == ClassIdentifierUse.None) { this.ClassIdentifierWord = string.Empty; } this.SourceFileGenerationType = sourceFileGenerationType; this.SourceFileName = sourceFileName; this.AssociationType = associationType; this.GenerateDTOConstructors = generateDTOConstructors; }
private AssociationType GenerateAssociationType( SimpleMappingContext mappingContext, AssociationType storeAssociationType, UniqueIdentifierService globallyUniqueTypeNames) { Debug.Assert(storeAssociationType.RelationshipEndMembers.Count == 2); var storeEndMember0 = (AssociationEndMember)storeAssociationType.RelationshipEndMembers[0]; var storeEndMember1 = (AssociationEndMember)storeAssociationType.RelationshipEndMembers[1]; var storeSchemaVersion = EntityFrameworkVersion.DoubleToVersion(mappingContext.StoreModel.SchemaVersion); var isFkAssociation = storeSchemaVersion > EntityFrameworkVersion.Version1 && (_generateForeignKeyProperties || RequiresReferentialConstraint(storeAssociationType)); var uniqueEndMemberNames = new UniqueIdentifierService(StringComparer.OrdinalIgnoreCase); var multiplicityOverride = GetMultiplicityOverride(storeAssociationType); var conceptualEndMember0 = GenerateAssociationEndMember( mappingContext, storeEndMember0, uniqueEndMemberNames, multiplicityOverride); var conceptualEndMember1 = GenerateAssociationEndMember( mappingContext, storeEndMember1, uniqueEndMemberNames, multiplicityOverride); var conceptualAssociationType = AssociationType.Create( CreateModelName(storeAssociationType.Name, globallyUniqueTypeNames), _namespaceName, isFkAssociation, DataSpace.CSpace, conceptualEndMember0, conceptualEndMember1, CreateReferentialConstraint(mappingContext, storeAssociationType), null); CreateModelNavigationProperties(conceptualAssociationType); mappingContext.AddMapping(storeAssociationType, conceptualAssociationType); return(conceptualAssociationType); }
private AssociationType CreateAssociationType(ReferentialConstraint referentialConstraint) { var relationshipName = $"{this.fromEntityType.Name}_{this.toEntityType.Name}"; var relationshipType = AssociationType.Create( relationshipName, this.fromEntityType.NamespaceName, // NOTE: I am blindly assuming this is true. I think this is a // safe bet for my tests. true /*foreignKey*/, DataSpace.CSpace, this.fromAssociationEndMember, this.toAssociationEndMember, referentialConstraint, Enumerable.Empty <MetadataProperty>()); return(relationshipType); }
public static NavigationProperty AddNavigationProperty( this EntityType entityType, string name, AssociationType associationType) { DebugCheck.NotNull(entityType); DebugCheck.NotEmpty(name); DebugCheck.NotNull(associationType); var navigationProperty = new NavigationProperty(name, TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType, ToEndMember = associationType.TargetEnd }; entityType.AddMember(navigationProperty); return(navigationProperty); }
/// <inheritdoc /> protected override bool MatchDependentKeyProperty( AssociationType associationType, AssociationEndMember dependentAssociationEnd, EdmProperty dependentProperty, EntityType principalEntityType, EdmProperty principalKeyProperty) { Check.NotNull<AssociationType>(associationType, nameof (associationType)); Check.NotNull<AssociationEndMember>(dependentAssociationEnd, nameof (dependentAssociationEnd)); Check.NotNull<EdmProperty>(dependentProperty, nameof (dependentProperty)); Check.NotNull<EntityType>(principalEntityType, nameof (principalEntityType)); Check.NotNull<EdmProperty>(principalKeyProperty, nameof (principalKeyProperty)); AssociationEndMember otherEnd = associationType.GetOtherEnd(dependentAssociationEnd); NavigationProperty navigationProperty = dependentAssociationEnd.GetEntityType().NavigationProperties.SingleOrDefault<NavigationProperty>((Func<NavigationProperty, bool>) (n => n.ResultEnd == otherEnd)); if (navigationProperty == null) return false; return string.Equals(dependentProperty.Name, navigationProperty.Name + principalKeyProperty.Name, StringComparison.OrdinalIgnoreCase); }
public void Generate(AssociationType associationType, DbDatabaseMapping databaseMapping) { DebugCheck.NotNull(associationType); DebugCheck.NotNull(databaseMapping); if (associationType.Constraint != null) { GenerateForeignKeyAssociationType(associationType, databaseMapping); } else if (associationType.IsManyToMany()) { GenerateManyToManyAssociation(associationType, databaseMapping); } else { GenerateIndependentAssociationType(associationType, databaseMapping); } }
public void GetAssociationSet_should_return_association_set() { var model = new EdmModel().Initialize(); var entityType = model.AddEntityType("Foo"); model.AddEntitySet("FooESet", entityType); var associationType = new AssociationType(); associationType.SourceEnd = new AssociationEndMember("S", entityType); associationType.TargetEnd = new AssociationEndMember("T", entityType); model.AddAssociationSet("FooSet", associationType); var associationSet = model.GetAssociationSet(associationType); Assert.NotNull(associationSet); Assert.Same(associationType, associationSet.ElementType); }
public static void MoveAllDeclaredForeignKeyConstraintsForPrimaryKeyColumns( EntityType entityType, EntityType fromTable, EntityType toTable) { foreach (EdmProperty keyProperty in fromTable.KeyProperties) { ((IEnumerable <ForeignKeyBuilder>)ForeignKeyPrimitiveOperations.FindAllForeignKeyConstraintsForColumn(fromTable, toTable, keyProperty).ToArray <ForeignKeyBuilder>()).Each <ForeignKeyBuilder>((Action <ForeignKeyBuilder>)(fk => { AssociationType associationType = fk.GetAssociationType(); if (associationType == null || associationType.Constraint.ToRole.GetEntityType() != entityType || fk.GetIsTypeConstraint()) { return; } ForeignKeyPrimitiveOperations.MoveForeignKeyConstraint(fromTable, toTable, fk); })); } }
private static void GenerateForeignKeyAssociationType( AssociationType associationType, DbDatabaseMapping databaseMapping) { AssociationEndMember dependentEnd = associationType.Constraint.DependentEnd; AssociationEndMember otherEnd = associationType.GetOtherEnd(dependentEnd); EntityTypeMapping mappingInHierarchy = StructuralTypeMappingGenerator.GetEntityTypeMappingInHierarchy(databaseMapping, otherEnd.GetEntityType()); EntityTypeMapping dependentEntityTypeMapping = StructuralTypeMappingGenerator.GetEntityTypeMappingInHierarchy(databaseMapping, dependentEnd.GetEntityType()); ForeignKeyBuilder foreignKeyBuilder = new ForeignKeyBuilder(databaseMapping.Database, associationType.Name) { PrincipalTable = mappingInHierarchy.MappingFragments.Single <MappingFragment>().Table, DeleteAction = otherEnd.DeleteBehavior != OperationAction.None ? otherEnd.DeleteBehavior : OperationAction.None }; dependentEntityTypeMapping.MappingFragments.Single <MappingFragment>().Table.AddForeignKey(foreignKeyBuilder); foreignKeyBuilder.DependentColumns = associationType.Constraint.ToProperties.Select <EdmProperty, EdmProperty>((Func <EdmProperty, EdmProperty>)(dependentProperty => dependentEntityTypeMapping.GetPropertyMapping(dependentProperty).ColumnProperty)); foreignKeyBuilder.SetAssociationType(associationType); }
private static bool IsValidRelationshipSpan( EntityType compareType, AssociationType associationType, AssociationEndMember fromEnd, AssociationEndMember toEnd) { if (associationType.IsForeignKey || RelationshipMultiplicity.One != toEnd.RelationshipMultiplicity && toEnd.RelationshipMultiplicity != RelationshipMultiplicity.ZeroOrOne) { return(false); } EntityType elementType = (EntityType)((RefType)fromEnd.TypeUsage.EdmType).ElementType; if (!ObjectSpanRewriter.EntityTypeEquals((EntityTypeBase)compareType, (EntityTypeBase)elementType) && !TypeSemantics.IsSubTypeOf((EdmType)compareType, (EdmType)elementType)) { return(TypeSemantics.IsSubTypeOf((EdmType)elementType, (EdmType)compareType)); } return(true); }
public static AssociationType AddAssociationType( this EdmModel model, string name, System.Data.Entity.Core.Metadata.Edm.EntityType sourceEntityType, RelationshipMultiplicity sourceAssociationEndKind, System.Data.Entity.Core.Metadata.Edm.EntityType targetEntityType, RelationshipMultiplicity targetAssociationEndKind, string modelNamespace = null) { AssociationType associationType = new AssociationType(name, modelNamespace ?? "CodeFirstNamespace", false, DataSpace.CSpace) { SourceEnd = new AssociationEndMember(name + "_Source", sourceEntityType.GetReferenceType(), sourceAssociationEndKind), TargetEnd = new AssociationEndMember(name + "_Target", targetEntityType.GetReferenceType(), targetAssociationEndKind) }; model.AddAssociationType(associationType); return(associationType); }
private DataModelErrorEventArgs ValidateAssociationTypeWithNonFkeyReference(DataSpace dataSpace) { var model = new EdmModel(dataSpace, 1.0); var intType = dataSpace == DataSpace.CSpace ? PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32) : FakeSqlProviderServices.Instance.GetProviderManifest("2008").GetStoreTypes().Single(t => t.Name == "int"); var principal = new EntityType("P", "ns", dataSpace, new [] { "Id" }, new[] { EdmProperty.Primitive("Id", intType) }); var dependent = new EntityType("P", "ns", dataSpace, new [] { "Id" }, new[] { EdmProperty.Primitive("Id", intType), EdmProperty.Primitive("NonKeyProperty", intType) }); foreach (var property in principal.Properties.Concat(dependent.Properties)) { property.Nullable = false; } var associationType = new AssociationType("AT", "ns", false, dataSpace) { Constraint = new ReferentialConstraint( new AssociationEndMember("P", principal.GetReferenceType(), RelationshipMultiplicity.One), new AssociationEndMember("C", dependent.GetReferenceType(), RelationshipMultiplicity.Many), principal.KeyProperties, dependent.Properties.Where(p => p.Name == "NonKeyProperty")) }; model.AddAssociationType(associationType); var validationContext = new EdmModelValidationContext(model, true); DataModelErrorEventArgs errorEventArgs = null; validationContext.OnError += (_, e) => errorEventArgs = e; EdmModelSemanticValidationRules .EdmAssociationType_ValidateReferentialConstraint .Evaluate(validationContext, model.AssociationTypes.Single()); return(errorEventArgs); }
private void ConfigureConstraint( AssociationType associationType, AssociationEndMember dependentEnd, EntityTypeConfiguration entityTypeConfiguration) { if (this._constraint == null) { return; } this._constraint.Configure(associationType, dependentEnd, entityTypeConfiguration); ReferentialConstraint constraint = associationType.Constraint; if (constraint == null || !constraint.ToProperties.SequenceEqual <EdmProperty>((IEnumerable <EdmProperty>)constraint.ToRole.GetEntityType().KeyProperties) || (this._inverseEndKind.HasValue || !associationType.SourceEnd.IsMany())) { return; } associationType.SourceEnd.RelationshipMultiplicity = System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne; associationType.TargetEnd.RelationshipMultiplicity = System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity.One; }
private static bool IsTableSplitDependent( EntityTypeBase entityTypeBase, DbDatabaseMapping databaseMapping) { AssociationType associationType = databaseMapping.Model.AssociationTypes.SingleOrDefault <AssociationType>((Func <AssociationType, bool>)(at => { if (at.IsForeignKey && at.IsRequiredToRequired() && !at.IsSelfReferencing() && (at.SourceEnd.GetEntityType().IsAssignableFrom((EdmType)entityTypeBase) || at.TargetEnd.GetEntityType().IsAssignableFrom((EdmType)entityTypeBase))) { return(databaseMapping.Database.AssociationTypes.All <AssociationType>((Func <AssociationType, bool>)(fk => fk.Name != at.Name))); } return(false); })); if (associationType != null) { return(associationType.TargetEnd.GetEntityType() == entityTypeBase); } return(false); }
protected AssociationBase(T source, AssociationType associationType, IEntity entity, IEntity foreignEntity, bool isParentEntity, string @namespace, IAssociation intermediaryAssociation = null) { if (source == null) { throw new ArgumentException("Association source cannot be null.", "source"); } AssociationSource = source; AssociationType = associationType; Entity = entity; ForeignEntity = foreignEntity; IntermediaryAssociation = intermediaryAssociation; IsParentEntity = isParentEntity; Namespace = @namespace; // TODO: The code below could invoke code that will run before the inheriting constructor sets values etc.. Initialize(); AccessibilityHelper.UpdateAssociationAccessibility(this); }
private AssociationEnd ResolveAssociationEndReference(AssociationType association, AssociationEnd associationEnd) { AssociationEndReference endRef = associationEnd as AssociationEndReference; if (endRef != null) { AssociationEnd end = association.Ends.SingleOrDefault(e => e.RoleName == endRef.RoleName); if (end == null) { throw new TaupoInvalidOperationException("The association end with role name: '" + endRef.RoleName + "' was not found."); } return(end); } else { return(associationEnd); } }
public static AssociationSet AddAssociationSet( this EdmModel model, string name, AssociationType associationType) { DebugCheck.NotNull(model); DebugCheck.NotEmpty(name); DebugCheck.NotNull(associationType); Debug.Assert(model.Containers.Count() == 1); var associationSet = new AssociationSet(name, associationType) { SourceSet = model.GetEntitySet(associationType.SourceEnd.GetEntityType()), TargetSet = model.GetEntitySet(associationType.TargetEnd.GetEntityType()) }; model.Containers.Single().AddEntitySetBase(associationSet); return(associationSet); }
protected internal override void VisitEdmAssociationType(AssociationType item) { var builder = new StringBuilder(); AppendSchemaErrors(builder, item); if (MetadataItemHelper.IsInvalid(item)) { AppendMetadataItem(builder, item, (v, i) => v.InternalVisitEdmAssociationType(i)); WriteComment(builder.ToString()); } else { WriteComment(builder.ToString()); InternalVisitEdmAssociationType(item); } }
public static void RemoveAssociationType( this EdmModel model, AssociationType associationType) { DebugCheck.NotNull(model); DebugCheck.NotNull(associationType); Debug.Assert(model.Containers.Count() == 1); model.RemoveItem(associationType); var container = model.Containers.Single(); var associationSet = container.AssociationSets.SingleOrDefault(a => a.ElementType == associationType); if (associationSet != null) { container.RemoveEntitySetBase(associationSet); } }
public void Configure_should_throw_when_dependent_property_not_found() { var constraintConfiguration = new ForeignKeyConstraintConfiguration( new[] { new MockPropertyInfo(typeof(int), "P").Object }); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); Assert.Equal( Strings.ForeignKeyPropertyNotFound("P", "T"), Assert.Throws <InvalidOperationException>( () => constraintConfiguration.Configure( associationType, new AssociationEndMember( "E", new EntityType("T", "N", DataSpace.CSpace)) , new EntityTypeConfiguration(typeof(object)))).Message); }
private static void InitializeForeignKeyMaps( HashSet <EntityContainer> containers, HashSet <EntitySet> tables, out KeyToListMap <EntitySetBase, ReferentialConstraint> sourceMap, out KeyToListMap <EntitySetBase, ReferentialConstraint> targetMap) { sourceMap = new KeyToListMap <EntitySetBase, ReferentialConstraint>((IEqualityComparer <EntitySetBase>)EqualityComparer <EntitySetBase> .Default); targetMap = new KeyToListMap <EntitySetBase, ReferentialConstraint>((IEqualityComparer <EntitySetBase>)EqualityComparer <EntitySetBase> .Default); foreach (EntityContainer container in containers) { foreach (EntitySetBase baseEntitySet in container.BaseEntitySets) { AssociationSet associationSet = baseEntitySet as AssociationSet; if (associationSet != null) { AssociationSetEnd associationSetEnd1 = (AssociationSetEnd)null; AssociationSetEnd associationSetEnd2 = (AssociationSetEnd)null; if (2 == associationSet.AssociationSetEnds.Count) { AssociationType elementType = associationSet.ElementType; bool flag = false; ReferentialConstraint referentialConstraint1 = (ReferentialConstraint)null; foreach (ReferentialConstraint referentialConstraint2 in elementType.ReferentialConstraints) { if (!flag) { flag = true; } associationSetEnd1 = associationSet.AssociationSetEnds[referentialConstraint2.ToRole.Name]; associationSetEnd2 = associationSet.AssociationSetEnds[referentialConstraint2.FromRole.Name]; referentialConstraint1 = referentialConstraint2; } if (associationSetEnd2 != null && associationSetEnd1 != null && (tables.Contains(associationSetEnd2.EntitySet) && tables.Contains(associationSetEnd1.EntitySet))) { sourceMap.Add((EntitySetBase)associationSetEnd1.EntitySet, referentialConstraint1); targetMap.Add((EntitySetBase)associationSetEnd2.EntitySet, referentialConstraint1); } } } } } }
public void Configure_should_not_validate_consistency_of_dependent_end_when_both_false() { var associationType = new AssociationType(); associationType.SourceEnd = new AssociationEndMember("S", new EntityType()); associationType.TargetEnd = new AssociationEndMember("T", new EntityType()); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()); associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()); navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(), new EntityTypeConfiguration(typeof(object))); }
public void GetAssociationSet_should_return_association_set() { var model = new EdmModel(DataSpace.CSpace); var entityType = model.AddEntityType("Foo"); model.AddEntitySet("FooESet", entityType); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace) { SourceEnd = new AssociationEndMember("S", entityType), TargetEnd = new AssociationEndMember("T", entityType) }; model.AddAssociationSet("FooSet", associationType); var associationSet = model.GetAssociationSet(associationType); Assert.NotNull(associationSet); Assert.Same(associationType, associationSet.ElementType); }
protected internal virtual void VisitEdmAssociationType(AssociationType item) { VisitMetadataItem(item); if (item != null) { if (item.SourceEnd != null) { VisitEdmAssociationEnd(item.SourceEnd); } if (item.TargetEnd != null) { VisitEdmAssociationEnd(item.TargetEnd); } } if (item.Constraint != null) { VisitEdmAssociationConstraint(item.Constraint); } }
private AssociationType ParseAssociation(XElement associationTypeElement) { string name = associationTypeElement.GetRequiredAttributeValue("Name"); var association = new AssociationType(this.CurrentNamespace, name); foreach (var associationEndElement in associationTypeElement.Elements().Where(el => this.IsXsdlElement(el, "End"))) { association.Ends.Add(this.ParseAssociationEnd(associationEndElement)); } var constraintElement = associationTypeElement.Elements().Where(el => this.IsXsdlElement(el, "ReferentialConstraint")).SingleOrDefault(); if (constraintElement != null) { association.ReferentialConstraint = this.ParseReferentialConstraint(constraintElement); } this.ParseAnnotations(association, associationTypeElement); return(association); }
public void Apply_is_noop_when_unknown_dependent() { var model = new EdmModel(DataSpace.CSpace); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); var navigationProperty = new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }; var foreignKeyAnnotation = new ForeignKeyAttribute("AId"); navigationProperty.Annotations.SetClrAttributes(new[] { foreignKeyAnnotation }); ((IEdmConvention <NavigationProperty>) new ForeignKeyNavigationPropertyAttributeConvention()) .Apply(navigationProperty, model); Assert.Null(associationType.Constraint); }
/// <summary> /// Checks if the given association is a FK association with cardinality 1 to 1 or 0..1 to 1 /// </summary> /// <param name="association">metadata for the association.</param> /// <returns>Returns true if the given association is a FK association with cardinality 1 to 1 or 0..1 to 1.</returns> private static bool IsOneToOneFKAssocation(AssociationType association) { // first check if the relationship type is a FK relationship. If no, then return , since updates are not supported only for FK relationships if (!association.IsForeignKey) { return false; } // check if the relationship is 1 to 1 or 1 to 0..1 relationship (FK relationships are not supported for 0..1 to 0..1 cardinality) // if its neither, we do support updates and there is no need to throw. if (association.RelationshipEndMembers[0].RelationshipMultiplicity == RelationshipMultiplicity.Many || association.RelationshipEndMembers[1].RelationshipMultiplicity == RelationshipMultiplicity.Many) { return false; } return true; }
// Associates one or more extensions with the corresponding campaign or ad group entities. private void SetAdExtensionsAssociationsAsync(long accountId, IList<AdExtensionIdToEntityIdAssociation> associations, AssociationType associationType) { var request = new SetAdExtensionsAssociationsRequest { AccountId = accountId, AdExtensionIdToEntityIdAssociations = associations, AssociationType = associationType }; Service.CallAsync((s, r) => s.SetAdExtensionsAssociationsAsync(r), request); }
/// <summary> /// Populate the ResourceAssociationType from the AssociationType instance. /// </summary> /// <param name="associationType">AssociationType instance.</param> /// <param name="end1">ResourceAssociationTypeEnd instance.</param> /// <param name="end2">ResourceAssociationTypeEnd instance.</param> /// <returns>An instance of ResourceAssociationType.</returns> private static ResourceAssociationType PopulateResourceAssociationType(AssociationType associationType, ResourceAssociationTypeEnd end1, ResourceAssociationTypeEnd end2) { ResourceAssociationType resourceAssociationType = new ResourceAssociationType( associationType.Name, associationType.NamespaceName, end1, end2); ObjectContextServiceProvider.PopulateAnnotations(associationType.MetadataProperties, resourceAssociationType.AddCustomAnnotation); if (associationType.ReferentialConstraints != null && associationType.ReferentialConstraints.Count != 0) { PopulateReferentialConstraint(resourceAssociationType, associationType.ReferentialConstraints[0]); } return resourceAssociationType; }
static public AssociationType CreateAssociation(string type, string source, string target, string id, SlotType[] slots) { AssociationType assoc = new AssociationType(type, source, target, id, slots); return assoc; }
// Gets the reasons why the specified extension failed editorial when // in the context of an associated campaign or ad group. private async Task<IList<AdExtensionEditorialReasonCollection>> GetAdExtensionsEditorialReasons( long accountId, IList<AdExtensionIdToEntityIdAssociation> associations, AssociationType associationType) { var request = new GetAdExtensionsEditorialReasonsRequest { AccountId = accountId, AdExtensionIdToEntityIdAssociations = associations, AssociationType = associationType }; return (await CampaignService.CallAsync( (s, r) => s.GetAdExtensionsEditorialReasonsAsync(r), request)).EditorialReasons; }
public static MilToken GetAssociation(AssociationType direction) { return new MilToken(direction == AssociationType.Origin ? MilTypeConstant.OriginAssociationToken : MilTypeConstant.DesintationAssociationToken); }
protected override void CopyFrom(Relationship relationship) { base.CopyFrom(relationship); AssociationRelationship association = (AssociationRelationship) relationship; associationType = association.associationType; direction = association.direction; startRole = association.startRole; endRole = association.endRole; startMultiplicity = association.startMultiplicity; endMultiplicity = association.endMultiplicity; }
/// <summary> /// Unregisters the server associations. /// </summary> /// <param name="serverClsid">The server CLSID.</param> /// <param name="serverType">Type of the server.</param> /// <param name="serverName">Name of the server.</param> /// <param name="associationType">Type of the association.</param> /// <param name="associations">The associations.</param> /// <param name="registrationType">Type of the registration.</param> internal static void UnregisterServerAssociations(Guid serverClsid, ServerType serverType, string serverName, AssociationType associationType, IEnumerable<string> associations, RegistrationType registrationType) { // Get the assocation classes. var associationClassNames = CreateClassNamesForAssociations(associationType, associations, registrationType); // Open the classes key. using (var classesKey = OpenClassesRoot(registrationType)) { // For each one, create the server type key. foreach (var associationClassName in associationClassNames) { // Get the key for the association. var associationKeyPath = GetKeyForServerType(associationClassName, serverType, serverName); // Does it exist? bool exists; using (var associationKey = classesKey.OpenSubKey(associationKeyPath)) exists = associationKey != null; // If it does, delete it. if (exists) Registry.ClassesRoot.DeleteSubKeyTree(associationKeyPath); // If we're a shell icon handler, we must also unset the defaulticon. if (serverType == ServerType.ShellIconHandler) UnsetIconHandlerDefaultIcon(classesKey, associationClassName); } } }
/// <summary> /// Creates the class names for associations. /// </summary> /// <param name="associationType">Type of the association.</param> /// <param name="associations">The associations.</param> /// <param name="registrationType">Type of the registration.</param> /// <returns> /// The class names for the associations. /// </returns> private static IEnumerable<string> CreateClassNamesForAssociations(AssociationType associationType, IEnumerable<string> associations, RegistrationType registrationType) { // Switch on the association type. switch (associationType) { case AssociationType.FileExtension: // We're dealing with file extensions only, so we can return them directly. return associations; case AssociationType.ClassOfExtension: // Open the classes sub key. using (var classesKey = OpenClassesRoot(registrationType)) { // The file type classes. var fileTypeClasses = new List<string>(); // We've got extensions, but we need the classes for them. foreach (var association in associations) { // Open the file type key. using (var fileTypeKey = classesKey.OpenSubKey(association)) { // If the file type key is null, we're done. if (fileTypeKey == null) continue; // Get the default value, this should be the file type class. var fileTypeClass = fileTypeKey.GetValue(null) as string; // If the file type class is valid, we can return it. fileTypeClasses.Add(fileTypeClass); } } // Return the file type classes. return fileTypeClasses; } case AssociationType.Class: // We're dealing with classes only, so we can return them directly. return associations; case AssociationType.AllFiles: // Return the all files class. return new [] { SpecialClass_AllFiles }; case AssociationType.Directory: // Return the directory class. return new[] { SpecialClass_Directory }; case AssociationType.Drive: // Return the directory class. return new[] { SpecialClass_Drive }; case AssociationType.UnknownFiles: // Return the directory class. return new[] { SpecialClass_UnknownFiles }; default: // Take a best guess, return the associations. return associations; } }
/// <summary> /// Initializes a new instance of AssocationSet with the given name and the association type /// </summary> /// <param name="name">The name of the Assocation set</param> /// <param name="associationType">The association type of the entities that this associationship set type contains</param> internal AssociationSet(string name, AssociationType associationType) : base(name, null, null, null, associationType) { }
private void AddAssociation(IUIItem designerSurface, string entity1, string entity2, AssociationType associationType) { designerSurface.RightClickAt(designerSurface.Location); var popUpMenu = _visualStudioMainWindow.Popup; var menuItem = popUpMenu.Item("Add New"); menuItem.Click(); var newAssociation = menuItem.SubMenu(SearchCriteria.ByText("Association...")); newAssociation.Click(); var addAssociation = _visualStudio.Find( x => x.Equals(_resourceHelper.GetEntityDesignResourceString("NewAssociationDialog_Title")), InitializeOption.NoCache); var entity1Combo = addAssociation.Get<ComboBox>(SearchCriteria.ByAutomationId("entity1ComboBox")); entity1Combo.Select(entity1); var entity2Combo = addAssociation.Get<ComboBox>(SearchCriteria.ByAutomationId("entity2ComboBox")); entity2Combo.Select(entity2); var multiplicity1ComboBox = addAssociation.Get<ComboBox>(SearchCriteria.ByAutomationId("multiplicity1ComboBox")); var multiplicity2ComboBox = addAssociation.Get<ComboBox>(SearchCriteria.ByAutomationId("multiplicity2ComboBox")); switch (associationType) { case AssociationType.OneToOne: multiplicity1ComboBox.Select(0); multiplicity2ComboBox.Select(0); break; case AssociationType.OneToMany: multiplicity1ComboBox.Select(0); multiplicity2ComboBox.Select(2); break; case AssociationType.ManyToMany: multiplicity1ComboBox.Select(2); multiplicity2ComboBox.Select(2); break; } var okButton = addAssociation.Get<Button>(SearchCriteria.ByText(_resourceHelper.GetEntityDesignResourceString("OKButton_AccessibleName"))); okButton.Click(); }
private void ProcessCollection( @class hClass, key keyNode, index indexNode, manytomany many, string className, string schema, string tableName, string propertyName, string cascade, AssociationType associationType, string whereClause, collectionFetchMode fetchMode, bool inverse, collectionLazy lazy, string orderByClause) { #region OrderBy string orderByPropertyName = ""; bool orderByIsAsc = true; if (!string.IsNullOrWhiteSpace(orderByClause)) { orderByClause = orderByClause.Trim(); if (orderByClause.EndsWith(" desc", StringComparison.InvariantCultureIgnoreCase)) { orderByIsAsc = false; orderByPropertyName = orderByClause.Substring(0, orderByClause.LastIndexOf(" desc", StringComparison.InvariantCultureIgnoreCase)).Trim(); } else if (orderByClause.EndsWith(" asc", StringComparison.InvariantCultureIgnoreCase)) { orderByIsAsc = false; orderByPropertyName = orderByClause.Substring(0, orderByClause.LastIndexOf(" asc", StringComparison.InvariantCultureIgnoreCase)).Trim(); } else orderByPropertyName = orderByClause; } #endregion string indexName = null; if (indexNode != null) { if (indexNode.column != null && indexNode.column.Count() > 0) indexName = indexNode.column[0].name; else indexName = indexNode.column1; } if (many != null) { var fkColumns = GetColumnNames(many.column, many.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(many.@class, out otherEntityName); var collectionInfo = new AssociationInformation { PropertyName = propertyName, ForeignKeyColumnNames = fkColumns, ForeignKeyBelongsToThisTable = !ForeignKeyBelongsToThisTable(hClass, fkColumns), AssociationTableName = new AssociationInformation.TableNameType(schema, tableName), ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, Cardinality = Cardinality.Many, CollectionCascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionCascadeType(cascade), CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(lazy.ToString()), CollectionFetchMode = (CollectionFetchModes)Enum.Parse(typeof(CollectionFetchModes), fetchMode.ToString(), true), IndexColumn = indexName, WhereClause = whereClause, AssociationType = associationType, Inverse = inverse ? ArchAngel.Interfaces.NHibernateEnums.BooleanInheritedTypes.@true : ArchAngel.Interfaces.NHibernateEnums.BooleanInheritedTypes.@false, OrderByColumnName = orderByPropertyName, OrderByIsAsc = orderByIsAsc }; associationInformation.Add(collectionInfo); } else { var fkColumns = GetColumnNames(keyNode.column1, keyNode.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(className, out otherEntityName); bool topLevelInverse = ArchAngel.Interfaces.SharedData.CurrentProject.GetProjectDefaultInverse(); BooleanInheritedTypes inverseValue = inverse ? BooleanInheritedTypes.@true : BooleanInheritedTypes.@false; if ((inverseValue == BooleanInheritedTypes.@false && topLevelInverse == false) || (inverseValue == BooleanInheritedTypes.@true && topLevelInverse == true)) inverseValue = BooleanInheritedTypes.inherit_default; var collectionInfo = new AssociationInformation { PropertyName = propertyName, ForeignKeyColumnNames = fkColumns, ForeignKeyBelongsToThisTable = ForeignKeyBelongsToThisTable(hClass, fkColumns), // GFH ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, Cardinality = Cardinality.Many, CollectionCascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionCascadeType(cascade), CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(lazy.ToString()), CollectionFetchMode = (CollectionFetchModes)Enum.Parse(typeof(CollectionFetchModes), fetchMode.ToString(), true), IndexColumn = indexName, AssociationType = associationType, Inverse = inverseValue, OrderByColumnName = orderByPropertyName, OrderByIsAsc = orderByIsAsc }; associationInformation.Add(collectionInfo); } }
private string GetAssociationCreateScript(AssociationType a) { StringBuilder sql = new StringBuilder(); StringBuilder keySql = new StringBuilder(); if (a.IsForeignKey) { EntityType childType = (EntityType)a.ReferentialConstraints[0].ToProperties[0].DeclaringType; EntityType parentType = (EntityType)a.ReferentialConstraints[0].FromProperties[0].DeclaringType; string fkName = a.Name; if (fkName.Length > 64) { fkName = "FK_" + Guid.NewGuid().ToString().Replace("-", ""); } sql.AppendLine(String.Format( "ALTER TABLE `{0}` ADD CONSTRAINT {1}", _pluralizedNames[ childType.Name ], fkName)); sql.Append("\t FOREIGN KEY ("); string delimiter = ""; foreach (EdmProperty p in a.ReferentialConstraints[0].ToProperties) { EdmMember member; if (!childType.KeyMembers.TryGetValue(p.Name, false, out member)) keySql.AppendLine(String.Format( "ALTER TABLE `{0}` ADD KEY (`{1}`);", _pluralizedNames[childType.Name], p.Name)); sql.AppendFormat("{0}{1}", delimiter, p.Name); delimiter = ", "; } sql.AppendLine(")"); delimiter = ""; sql.Append(String.Format("\tREFERENCES {0} (", _pluralizedNames[parentType.Name])); foreach (EdmProperty p in a.ReferentialConstraints[0].FromProperties) { EdmMember member; if (!parentType.KeyMembers.TryGetValue(p.Name, false, out member)) keySql.AppendLine(String.Format( "ALTER TABLE `{0}` ADD KEY (`{1}`);", _pluralizedNames[parentType.Name], p.Name)); sql.AppendFormat("{0}{1}", delimiter, p.Name); delimiter = ", "; } sql.AppendLine(")"); OperationAction oa = a.AssociationEndMembers[0].DeleteBehavior; sql.AppendLine(String.Format(" ON DELETE {0} ON UPDATE {1};", oa == OperationAction.None ? "NO ACTION" : oa.ToString(), "NO ACTION")); sql.AppendLine(); } keySql.Append(sql.ToString()); return keySql.ToString(); }
/// <exception cref="ArgumentNullException"> /// <paramref name="node"/> is null. /// </exception> protected internal override void Deserialize(XmlElement node) { base.Deserialize(node); RaiseChangedEvent = false; direction = node["Direction"].GetValue(Direction.Bidirectional); associationType = node["AssociationType"].GetValue(AssociationType.Association); startRole = node["StartRole"].GetValue(""); endRole = node["EndRole"].GetValue(""); startMultiplicity = node["StartMultiplicity"].GetValue("1"); endMultiplicity = node["EndMultiplicity"].GetValue("1"); RaiseChangedEvent = true; }
// Removes the specified association from the respective campaigns or ad groups. private async Task DeleteAdExtensionsAssociationsAsync(long accountId, IList<AdExtensionIdToEntityIdAssociation> associations, AssociationType associationType) { var request = new DeleteAdExtensionsAssociationsRequest { AccountId = accountId, AdExtensionIdToEntityIdAssociations = associations, AssociationType = associationType }; await CampaignService.CallAsync((s, r) => s.DeleteAdExtensionsAssociationsAsync(r), request); }
/// <exception cref="ArgumentNullException"> /// <paramref name="first"/> is null.-or- /// <paramref name="second"/> is null. /// </exception> internal AssociationRelationship(TypeBase first, TypeBase second, AssociationType type) : base(first, second) { this.associationType = type; Attach(); }
/// <exception cref="ArgumentNullException"> /// <paramref name="node"/> is null. /// </exception> protected internal override void Deserialize(XmlElement node) { base.Deserialize(node); XmlElement child = node["Direction"]; RaiseChangedEvent = false; if (child != null) { // Old file format if (child.InnerText == "Unidirectional" || child.InnerText == "SourceDestination") Direction = Direction.Unidirectional; else Direction = Direction.Bidirectional; } try { // Old file format { child = node["IsAggregation"]; if (child != null && bool.Parse(child.InnerText)) associationType = AssociationType.Aggregation; child = node["IsComposition"]; if (child != null && bool.Parse(child.InnerText)) associationType = AssociationType.Composition; } child = node["AssociationType"]; if (child != null) { if (child.InnerText == "Aggregation") associationType = AssociationType.Aggregation; else if (child.InnerText == "Composition") associationType = AssociationType.Composition; else associationType = AssociationType.Association; } child = node["StartRole"]; if (child != null) startRole = child.InnerText; child = node["EndRole"]; if (child != null) endRole = child.InnerText; child = node["StartMultiplicity"]; if (child != null) startMultiplicity = child.InnerText; child = node["EndMultiplicity"]; if (child != null) endMultiplicity = child.InnerText; } catch (ArgumentException) { // Wrong format } RaiseChangedEvent = true; }
/// <summary> /// Registers the server associations. /// </summary> /// <param name="serverClsid">The server CLSID.</param> /// <param name="serverType">Type of the server.</param> /// <param name="serverName">Name of the server.</param> /// <param name="associationType">Type of the association.</param> /// <param name="associations">The associations.</param> /// <param name="registrationType">Type of the registration.</param> internal static void RegisterServerAssociations(Guid serverClsid, ServerType serverType, string serverName, AssociationType associationType, IEnumerable<string> associations, RegistrationType registrationType) { // Get the assocation classes. var associationClassNames = CreateClassNamesForAssociations(associationType, associations, registrationType); // Open the classes key. using (var classesKey = OpenClassesRoot(registrationType)) { // For each one, create the server type key. foreach (var associationClassName in associationClassNames) { // Create the server key. using (var serverKey = classesKey.CreateSubKey(GetKeyForServerType(associationClassName, serverType, serverName))) { // Set the server class id. if (serverKey != null) serverKey.SetValue(null, serverClsid.ToRegistryString()); } // If we're a shell icon handler, we must also set the defaulticon. if (serverType == ServerType.ShellIconHandler) SetIconHandlerDefaultIcon(classesKey, associationClassName); } } }
public void CreateOperator(String opToken, OperatorType type, int precedence, AssociationType association, Func<double, double, double> body) { _commands.Add(opToken, new Operator(opToken, type, precedence, association, body)); }
private void ChangeType() { if (modifiedType == AssociationType.Association) { modifiedType = AssociationType.Aggregation; } else if (modifiedType == AssociationType.Aggregation) { modifiedType = AssociationType.Composition; } else { modifiedType = AssociationType.Association; } }