// PRIVATE METHODS ////////////////////////////////////////////////// #region Methods private Relationships GetRelationships() { var relationships = new Relationships(); var domRelationshipsNodes = this.Nodes(); foreach (var domRelationshipsNode in domRelationshipsNodes) { var domRelationshipsNodeType = domRelationshipsNode.NodeType; switch (domRelationshipsNodeType) { case DomNodeType.Relationship: { var domRelationship = (IDomRelationship)domRelationshipsNode; var rel = domRelationship.Rel; var relationship = domRelationship.Relationship; relationships.Add(rel, relationship); } break; default: { var detail = InfrastructureErrorStrings.DomExceptionDetailNodeHasUnexpectedChildNode .FormatWith(this.NodeType, domRelationshipsNodeType); throw new DomException(detail); } } } return(relationships); }
private void GenerateRelationships(Dictionary <RedYarn.Character, CharacterViewModel> characterDictionary, Func <Relationship, Guid, Guid, Guid> getIdForRelationshipFunc) { var uniqueRelationships = new HashSet <Relationship>(); foreach (var character in characterDictionary.Keys) { foreach (var relationship in character.Relationships) { uniqueRelationships.Add(relationship); } } foreach (var relationship in uniqueRelationships) { Relationships.Add(new RelationshipViewModel() { Id = getIdForRelationshipFunc(relationship, characterDictionary[relationship.FirstCharacter].Id, characterDictionary[relationship.SecondCharacter].Id), FromNodeId = characterDictionary[relationship.FirstCharacter].Id, ToNodeId = characterDictionary[relationship.SecondCharacter].Id, Name = relationship.Name, IsDirectional = relationship.IsDirectional }); } }
// TODO: Finding visible entities should be done somewhere else, like gravity entity or something? void Update() { // Right now, just looks at currently visible entities and adds new ones var contactFilter = new ContactFilter2D { useLayerMask = true, layerMask = layerMask }; var visibleColliders = new Collider2D[maxVisible]; if (lineOfSight != null && Physics2D.OverlapCollider(lineOfSight, contactFilter, visibleColliders) > 0) { for (int i = 0; i < visibleColliders.Length; i++) { var col = visibleColliders[i]; if (col != null) { var relationship = col?.GetComponent <RelationshipEntity>(); if (relationship != null && relationship?.gameObject != this.gameObject && !Relationships.Contains(relationship) ) { Relationships.Add(relationship); var relationshipEvent = new RelationshipEvent { Target = relationship, Rating = Vector2.zero, Text = $"Met {relationship.Name}", }; Events.Add(relationshipEvent); RelationshipRatings[relationship] = relationshipEvent.Rating; } } } } }
private PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, string id, bool loading) { if (!loading) { Package.CheckIsReadOnly(); } Check.TargetUri(targetUri); Check.RelationshipTypeIsValid(relationshipType); Check.IdIsValid(id); if (id == null) { id = NextId(); } if (Relationships.ContainsKey(id)) { throw new XmlException("A relationship with this ID already exists"); } PackageRelationship r = new PackageRelationship(id, Package, relationshipType, Uri, targetMode, targetUri); Relationships.Add(r.Id, r); if (!loading) { WriteRelationships(); } return(r); }
protected void LoadTriggerRelationships() { DataTable trigs = new DataTable(); using (SqlConnection conn = new SqlConnection(ConnectionStringBuilder.ConnectionString)) { conn.Open(); using (SqlDataAdapter sda = new SqlDataAdapter(TRIGGER_QUERY, conn)) { sda.Fill(trigs); } conn.Close(); } foreach (DataRow trow in trigs.Rows) { string tblname = trow["table_name"].ToString(); string trigname = trow["trigger_name"].ToString(); SqlServerTriggerNode trignode = trigList.Where(t => t.ObjectName == trigname).SingleOrDefault(); SqlServerTableNode tblnode = tableList.Where(t => t.ObjectName == tblname).SingleOrDefault(); if (trignode != null && tblnode != null) { DataConnection trigrel = new DataConnection { ConnectionType = DbProcesses.Trigger, StartNode = trignode, EndNode = tblnode, Name = String.Format("Trigger {0} => {1}.{2}", trignode.ObjectName, tblnode.Schema, tblnode.ObjectName), Description = "Table Trigger" }; Relationships.Add(trigrel); } } }
///-------------------------------------------------------------------------------- /// <summary>This method updates the view model data and sends update command back /// to the solution builder.</summary> ///-------------------------------------------------------------------------------- protected override void OnUpdate() { // send update for any updated children foreach (RelationshipViewModel item in Relationships) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (RelationshipViewModel item in ItemsToAdd.OfType <RelationshipViewModel>()) { item.Update(); Relationships.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (RelationshipViewModel item in ItemsToDelete.OfType <RelationshipViewModel>()) { item.Delete(); Relationships.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (RelationshipViewModel item in Relationships) { item.ResetModified(false); } }
public TypeRelationships(TypeRelationships key, Relationship fields) { Type = key.Type; BaseType = key.BaseType; Relationships.AddRange(key.Relationships); Relationships.Add(fields); }
/// <summary> /// copy a relationship /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btCopyRel_Click(object sender, RoutedEventArgs e) { //get the selected item if (lbRelations.SelectedItem == null) { return; } IRelationshipMetadata copy = lbRelations.SelectedItem as IRelationshipMetadata; //create the new item IRelationshipMetadata rel = new RelationshipMetadata(Catalog.CatalogMetadata); BermudaConfigUtil.CopyRelationship(copy, rel); //open the window RelationshipConfig window = new RelationshipConfig(rel, ""); var ret = window.ShowDialog(); if (!ret.HasValue || ret == false) { return; } //add to list Relationships.Add(rel); Catalog.CatalogMetadata.Relationships.Add(rel.RelationshipName, rel); }
public void AddRelationship(RelationshipType type) { if (type == RelationshipType.UseThis || type == RelationshipType.UsedBy) { OccurrenceCount++; } Relationships.Add(type); }
protected override void ResolveIds(int currentModuleId) { base.ResolveIds(currentModuleId); //display tab using (IDataReader dr = DataProvider.Instance().GetPublishTabId(ChildDisplayTabName, PortalId)) { if (dr.Read()) { _childDisplayTabId = (int)dr["TabId"]; } else { //Default to setting for module string settingName = Utility.PublishDefaultDisplayPage + PortalId.ToString(CultureInfo.InvariantCulture); string setting = HostController.Instance.GetString(settingName); _childDisplayTabId = Convert.ToInt32(setting, CultureInfo.InvariantCulture); } } // For situations where the user is importing content from another system (file not generated from Publish) // they have no way of knowing what the top level category GUIDS are nor to include the entries in the // relationships section of the file. Note, the stored procedure verifies the relationship doesn't exist // before inserting a new row. var relationship = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.CategoryToTopLevelCategory.GetId(), ParentItemId = TopLevelCategoryItemType.Category.GetId() }; Relationships.Add(relationship); bool save = false; //now the Unique Id's //Does this ItemVersion exist in my db? using (IDataReader dr = DataProvider.Instance().GetItemVersion(ItemVersionIdentifier, PortalId)) { if (dr.Read()) { //this item already exists //update some stuff??? } else { //this version does not exist. ItemId = -1; ItemVersionId = -1; ModuleId = currentModuleId; save = true; } } if (save) { Save(RevisingUserId); } }
public void AddLink(Guid mapId, IGlymaRelationship relationship) { if (!IsRelationshipExist(relationship)) { var xmlLink = new Link(mapId, relationship, Doc, _xmlElementLinks); xmlLink.CreateElement(); Relationships.Add(relationship); } }
public Query <T> IncludeRelationship(IList <Expression <Func <T, object> > > relationships) { foreach (var relationship in relationships) { Relationships.Add(relationship); } return(this); }
/// <summary> /// Adds IRelationship to the graph. /// </summary> /// <param name="relationship"></param> public void Add(IRelationship relationship) { //if (relationship is SubclassRelationship) // Add(relationship as SubclassRelationship); //else if (relationship is PropertyRelationship) // Add(relationship as PropertyRelationship); //else if (relationship is EquivalenceRelationship) // Add(relationship as EquivalenceRelationship); //else Relationships.Add(relationship); }
/// <summary> /// Add a relationship to the data set. /// </summary> /// <param name="relationship">The relationship to be added.</param> public void AddRelationship(Relationship relationship) { if (relationship != null) { if (Relationships == null) { Relationships = new List <Relationship>(); } Relationships.Add(relationship); } }
public bool AddRelationship(Relationship relationship) { if (!Relationships.Contains(relationship)) { if (Nodes.Contains(relationship.From) && Nodes.Contains(relationship.To)) { Relationships.Add(relationship); } } return(false); }
public void AddPreventDeleteRelationship() { RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef lRelPropDef = new RelPropDef(ClassDef.PropDefcol["ContactPersonID"], "ContactPersonID"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef = new MultipleRelationshipDef("AddressesNoDelete", typeof(Address), relKeyDef, false, "", DeleteParentAction.Prevent); ClassDef.RelationshipDefCol = new RelationshipDefCol(); ClassDef.RelationshipDefCol.Add(relDef); Relationships.Add(new MultipleRelationship <Address>(this, relDef, Props)); }
public PhotoRelation AddRelationship(Photo other, bool otherIsNewer) { if (Relationships.TryGetValue(other, out var rel)) { // relationship already exists so return it return(rel); } rel = new PhotoRelation(this, other, otherIsNewer); Relationships.Add(other, rel); RefreshFromRelationships(); return(rel); }
public void Add(Relationship.Relationship relationship) { Relationships.Add(relationship); if (RelationshipsByType.ContainsKey(relationship.GetType())) { RelationshipsByType[relationship.GetType()].Add(relationship); } else { RelationshipsByType.Add(relationship.GetType(), new List <Relationship.Relationship> { relationship }); } }
public void Initialise() { for (int i = 0; i < characterNames.Length; i++) { for (int j = i + 1; j < characterNames.Length; j++) { Relationships.Add(new RelationShipEntry() { Person1 = characterNames[i], Person2 = characterNames[j], Status = 0 }); } } EnforceStartingState(); }
public virtual RelationshipView Add(Relationship relationship) { if (relationship != null) { if (IsElementInView(relationship.Source) && IsElementInView(relationship.Destination)) { RelationshipView relationshipView = new RelationshipView(relationship); Relationships.Add(relationshipView); return relationshipView; } } return null; }
/// <summary> /// Tries to add a Relationship for the given field name. /// Throws and exception if field cannot be found. /// </summary> private void TryAddRelationshipForField(string fieldName) { // Set strategy to filter for public or private fields ConventionMapStrategy strategy = new ConventionMapStrategy(false); // Find the field that matches the given field name strategy.RelationshipPredicate = mi => mi.Name == fieldName; Relationship relationship = strategy.MapRelationships(typeof(TEntity)).FirstOrDefault(); if (relationship == null) { throw new DataMappingException(string.Format("Could not find the field '{0}' in '{1}'.", fieldName, typeof(TEntity).Name)); } Relationships.Add(relationship); }
public RelationshipCollection GetRelationships(Type type) { if (!Relationships.ContainsKey(type)) { lock (_relationshipsLock) { if (!Relationships.ContainsKey(type)) { RelationshipCollection relationships = GetMapStrategy(type).MapRelationships(type); Relationships.Add(type, relationships); return(relationships); } } } return(Relationships[type]); }
/// <summary> /// new realtionship /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btNewRel_Click(object sender, RoutedEventArgs e) { //create the new item IRelationshipMetadata rel = new RelationshipMetadata(Catalog.CatalogMetadata); //open the window RelationshipConfig window = new RelationshipConfig(rel, ""); var ret = window.ShowDialog(); if (!ret.HasValue || ret == false) { return; } //add to list Relationships.Add(rel); Catalog.CatalogMetadata.Relationships.Add(rel.RelationshipName, rel); }
///-------------------------------------------------------------------------------- /// <summary>This method loads Relationships into the view model.</summary> /// /// <param name="entity">The entity to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadRelationships(Entity entity, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Relationships == null) { Relationships = new EnterpriseDataObjectList <RelationshipViewModel>(); } if (loadChildren == true) { foreach (Relationship item in entity.RelationshipList) { RelationshipViewModel itemView = new RelationshipViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); Relationships.Add(itemView); Items.Add(itemView); } } }
protected void LoadTableRelationships() { DataTable fkdatatable = new DataTable(); using (SqlConnection conn = new SqlConnection(ConnectionStringBuilder.ConnectionString)) { conn.Open(); using (SqlDataAdapter sda = new SqlDataAdapter(FK_QUERY, conn)) { sda.Fill(fkdatatable); } conn.Close(); } //start parsing through the data rows string pktable; string pkcolumn; string fktable; string fkcolumn; foreach (DataRow fkrow in fkdatatable.Rows) { pktable = fkrow["PK_table"].ToString(); pkcolumn = fkrow["PK_column"].ToString(); fktable = fkrow["FK_table"].ToString(); fkcolumn = fkrow["FK_column"].ToString(); SqlServerTableNode pknode = tableList.Where(t => t.ObjectName == pktable).SingleOrDefault(); SqlServerTableNode fknode = tableList.Where(t => t.ObjectName == fktable).SingleOrDefault(); if (pknode != null && fknode != null) { DataConnection fkrel = new DataConnection { ConnectionType = RecordKeys.ForeignKey, StartNode = pknode, EndNode = fknode, Name = String.Format("{0}.{1}.{2} => {3}.{4}.{5}", pknode.Schema, pknode.ObjectName, pkcolumn, fknode.Schema, fknode.ObjectName, fkcolumn), Description = String.Format("{0}: On Update = {1}, On Delete = {2}", fkrow["FK_name"].ToString(), fkrow["Update_Action"], fkrow["Delete_Action"].ToString()) }; Relationships.Add(fkrel); } } }
internal PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, string id, bool loading) { if (!loading) { CheckIsReadOnly(); } Check.TargetUri(targetUri); if (targetUri.IsAbsoluteUri && targetMode == TargetMode.Internal) { throw new ArgumentException("TargetUri cannot be absolute for an internal relationship"); } Check.RelationshipTypeIsValid(relationshipType); Check.IdIsValid(id); if (id == null) { id = NextId(); } PackageRelationship r = new PackageRelationship(id, this, relationshipType, Uri, targetMode, targetUri); if (!PartExists(RelationshipUri)) { CreatePartCore(RelationshipUri, RelationshipContentType, CompressionOption.NotCompressed).IsRelationship = true; } Relationships.Add(r.Id, r); relationshipsCollection.Relationships.Add(r); if (!loading) { using (Stream s = GetPart(RelationshipUri).GetStream()) WriteRelationships(relationships, s); } return(r); }
private void BuildWorld() { foreach (var node1 in Nodes) { foreach (var node2 in Nodes) { if (node1 == node2) { continue; } if (node2.Relationships.ContainsKey(node1)) { continue; } var rel = new Relationship(node1, node2, States[Random.Next(0, States.Count)], States); node1.Relationships.Add(node2, rel); node2.Relationships.Add(node1, rel); Relationships.Add(rel); } } }
public string ProcessRecord(IRecord record) { var sourceNode = record["s"].As <INode>(); var destNode = record["d1"].As <INode>(); var relationship = record["r1"].As <IRelationship>(); var destNode2 = record["d2"].As <INode>(); var relationship2 = record["r2"].As <IRelationship>(); Nodes[sourceNode.Id] = sourceNode; SelectedNodeId = sourceNode.Id; string?sourceLabel = sourceNode.Properties.ContainsKey(SourcePropertyName) ? sourceNode.Properties[SourcePropertyName].ToString() : string.Empty; string result = sourceLabel ?? string.Empty; if (relationship != null) { Relationships.Add(relationship); result += $" - [{relationship.Type}]"; } if (destNode != null) { Nodes[destNode.Id] = destNode; result += " - " + (destNode.Properties.ContainsKey(DestPropertyName) ? destNode.Properties[DestPropertyName].ToString() : string.Empty); } if (relationship2 != null) { Relationships.Add(relationship2); result += $" - [{relationship2.Type}]"; } if (destNode2 != null) { Nodes[destNode2.Id] = destNode2; result += " - " + (destNode2.Properties.ContainsKey(DestPropertyName) ? destNode2.Properties[DestPropertyName].ToString() : string.Empty); } return(result); }
///-------------------------------------------------------------------------------- /// <summary>This method applies relationship updates.</summary> ///-------------------------------------------------------------------------------- public void ProcessEditRelationshipPerformed(RelationshipEventArgs data) { try { bool isItemMatch = false; if (data != null && data.Relationship != null) { foreach (RelationshipViewModel item in Relationships) { if (item.Relationship.RelationshipID == data.Relationship.RelationshipID) { isItemMatch = true; item.Relationship.TransformDataFromObject(data.Relationship, null, false); item.OnUpdated(item, null); item.ShowInTreeView(); break; } } if (isItemMatch == false) { // add new Relationship data.Relationship.Entity = Entity; RelationshipViewModel newItem = new RelationshipViewModel(data.Relationship, Solution); newItem.Updated += new EventHandler(Children_Updated); Relationships.Add(newItem); Entity.RelationshipList.Add(newItem.Relationship); Solution.RelationshipList.Add(newItem.Relationship); Items.Add(newItem); OnUpdated(this, null); newItem.ShowInTreeView(); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }
public void AddRelationship(IRelationship relationship) { Relationships.Add(relationship); }