Exemplo n.º 1
0
        /// <summary>
        /// Loads the necessary prerequisites for OriginRelationshipViewModel
        /// </summary>
        public async Task LoadViewModel(RelatedFeatureQueryResult relatedFeatureQueryResult, RelationshipInfo relationshipInfo)
        {
            if (relatedFeatureQueryResult.Count() > 0)
            {
                OriginRelatedRecords = new ObservableCollection <PopupManager>();

                foreach (var relatedRecord in relatedFeatureQueryResult)
                {
                    // load feature to be able to access popup
                    if (relatedRecord is ArcGISFeature loadableFeature)
                    {
                        await loadableFeature.LoadAsync();
                    }
                    var popupManager = new PopupManager(new Popup(relatedRecord, relatedRecord.FeatureTable.PopupDefinition));

                    OriginRelatedRecords.Add(popupManager);
                    RelationshipInfo = relationshipInfo;
                }

                // sort list if more than one record
                if (OriginRelatedRecords.Count > 1)
                {
                    OriginRelatedRecords = new ObservableCollection <PopupManager>(OriginRelatedRecords.OrderByDescending(x => x.DisplayedFields.First().Value));
                }
            }
        }
        private static TreeNode CreateChildNode(HeapCell aParent, HeapCell aCell, RelationshipInfo aRelationshipDescriptor /* optional */)
        {
            StringBuilder caption = new StringBuilder();

            caption.Append("[" + aCell.Address.ToString("x8") + "] ");
            if (aRelationshipDescriptor != null)
            {
                caption.Append("[" + aRelationshipDescriptor.LinkAddressOffsetWithinFromCell.ToString("d4") + "] ");
            }
            caption.Append("[" + aCell.PayloadLength.ToString("d6") + "] ");
            //
            System.Drawing.Color foreColour = Color.Black;
            if (aCell.Symbol != null)
            {
                caption.Append(aCell.Symbol.NameWithoutVTablePrefix);
                foreColour = Color.Blue;
            }
            else
            {
                caption.Append("No symbol");
                foreColour = Color.LightGray;
            }
            //
            TreeNode node = new TreeNode(caption.ToString());

            node.ForeColor = foreColour;
            return(node);
        }
Exemplo n.º 3
0
 public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, RawItem aRawItem)
 {
     try
     {
         System.Diagnostics.Debug.Assert(aCells.Count == 1);
         System.Diagnostics.Debug.Assert(aRawItem.Tag != null && aRawItem.Tag is RelationshipInfo);
         HeapCell            cell    = aCells[0];
         RelationshipManager relMgr  = cell.RelationshipManager;
         RelationshipInfo    relInfo = (RelationshipInfo)aRawItem.Tag;
         //
         StringBuilder msg = new StringBuilder();
         //
         msg.AppendFormat("This is an embedded reference to the cell at address 0x{0}", relInfo.ToCell.Address.ToString("x8"));
         if (relInfo.ToCell.Symbol != null)
         {
             msg.AppendFormat(", which is an instance of a {0} object.", relInfo.ToCell.SymbolString);
         }
         msg.Append(System.Environment.NewLine + System.Environment.NewLine);
         //
         msg.AppendFormat("In total, this cell references {0} other cell(s), and is referenced by {1} cell(s)", relMgr.EmbeddedReferencesTo.Count, relMgr.ReferencedBy.Count);
         msg.Append(System.Environment.NewLine + System.Environment.NewLine);
         //
         iLbl_Description.Text = msg.ToString();
     }
     finally
     {
         base.PrepareContent(aCells, aStats, aRawItem);
     }
 }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((ParentReference.Id.GetHashCode() * 397) ^ RelationshipInfo.GetHashCode());
     }
 }
        // Handle a new selected comment record in the table view.
        private async void CommentsTableSource_ServiceRequestCommentSelected(object sender, ServiceRequestCommentSelectedEventArgs e)
        {
            // Clear selected features from the graphics overlay.
            _selectedFeaturesOverlay.Graphics.Clear();

            // Get the map image layer that contains the service request sublayer and the service request comments table.
            ArcGISMapImageLayer serviceRequestsMapImageLayer = (ArcGISMapImageLayer)_myMapView.Map.OperationalLayers[0];

            // Get the (non-spatial) table that contains the service request comments.
            ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0];

            // Get the relationship that defines related service request features for features in the comments table (this is the first and only relationship).
            RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault();

            // Create query parameters to get the related service request for features in the comments table.
            RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo)
            {
                ReturnGeometry = true
            };

            try
            {
                // Query the comments table to get the related service request feature for the selected comment.
                IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(e.SelectedComment, relatedQueryParams);

                // Get the first result.
                RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault();

                // Get the first feature from the result. If it's null, warn the user and return.
                ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature;
                if (serviceRequestFeature == null)
                {
                    UIAlertController alert = UIAlertController.Create("No Feature", "Related feature not found.", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);

                    return;
                }

                // Load the related service request feature (so its geometry is available).
                await serviceRequestFeature.LoadAsync();

                // Get the service request geometry (point).
                MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint;

                // Create a cyan marker symbol to display the related feature.
                Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Cyan, 14);

                // Create a graphic using the service request point and marker symbol.
                Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol);

                // Add the graphic to the graphics overlay and zoom the map view to its extent.
                _selectedFeaturesOverlay.Graphics.Add(requestGraphic);
                await _myMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000);
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        public void HasMany()
        {
            InitKernel();
            IRelationshipBuilder relService = ObtainService();

            TableDefinition blogTable;
            TableDefinition postTable;

            BuildBlogPostsStructure(out blogTable, out postTable);

            ActiveRecordDescriptor desc       = new ActiveRecordDescriptor("Blog");
            ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Post");

            RelationshipInfo info = new RelationshipInfo(AssociationEnum.HasMany, desc, targetDesc);

            info.ChildCol = new ColumnDefinition("blog_id", false, true, true, false, OleDbType.Numeric);

            ActiveRecordPropertyRelationDescriptor propDesc = relService.Build(info);

            Assert.IsNotNull(propDesc);
            Assert.IsNotNull(propDesc as ActiveRecordHasManyDescriptor);
            Assert.AreEqual("Posts", propDesc.PropertyName);
            Assert.AreEqual(targetDesc, propDesc.TargetType);
            Assert.AreEqual("blog_id", propDesc.ColumnName);
        }
Exemplo n.º 7
0
        // Handle a new selected comment record in the table view.
        private async void CommentsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            // Clear selected features from the graphics overlay.
            _selectedFeaturesOverlay.Graphics.Clear();

            // Get the selected comment feature. If there is no selection, return.
            ArcGISFeature selectedComment = e.AddedItems[0] as ArcGISFeature;

            if (selectedComment == null)
            {
                return;
            }

            // Get the map image layer that contains the service request sublayer and the service request comments table.
            ArcGISMapImageLayer serviceRequestsMapImageLayer = MyMapView.Map.OperationalLayers[0] as ArcGISMapImageLayer;

            // Get the (non-spatial) table that contains the service request comments.
            ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0];

            // Get the relationship that defines related service request features for features in the comments table (this is the first and only relationship).
            RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault();

            // Create query parameters to get the related service request for features in the comments table.
            RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo)
            {
                ReturnGeometry = true
            };

            // Query the comments table to get the related service request feature for the selected comment.
            IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams);

            // Get the first result.
            RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault();

            // Get the first feature from the result. If it's null, warn the user and return.
            ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature;

            if (serviceRequestFeature == null)
            {
                MessageBox.Show("Related feature not found.", "No Feature");
                return;
            }

            // Load the related service request feature (so its geometry is available).
            await serviceRequestFeature.LoadAsync();

            // Get the service request geometry (point).
            MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint;

            // Create a cyan marker symbol to display the related feature.
            Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Cyan, 14);

            // Create a graphic using the service request point and marker symbol.
            Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol);

            // Add the graphic to the graphics overlay and zoom the map view to its extent.
            _selectedFeaturesOverlay.Graphics.Add(requestGraphic);
            await MyMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000);
        }
 /// <summary>
 /// Rule applied to origin relationships to determine if they are valid in the context of this application
 /// </summary>
 public static bool IsValidOriginRelationship(this RelationshipInfo relationshipInfo)
 {
     if ((relationshipInfo.Cardinality == RelationshipCardinality.OneToMany || relationshipInfo.Cardinality == RelationshipCardinality.OneToOne) &&
         relationshipInfo.Role == RelationshipRole.Origin)
     {
         return(true);
     }
     return(false);
 }
        private void Relationship_Insert_Or_Delete_After(object sender, ObjectEventArgs e)
        {
            RelationshipInfo     RelationshipObj     = (RelationshipInfo)e.Object;
            RelationshipNameInfo RelationshipNameObj = RelationshipNameInfo.Provider.Get(RelationshipObj.RelationshipNameId);

            if (IsCustomAdhocRelationshipName(RelationshipNameObj))
            {
                TreeNode LeftNode = new DocumentQuery().WhereEquals("NodeID", RelationshipObj.LeftNodeId).FirstOrDefault();
                if (RelHelper.IsStagingEnabled(LeftNode.NodeSiteID))
                {
                    DocumentSynchronizationHelper.LogDocumentChange(LeftNode.NodeSiteName, LeftNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, LeftNode.TreeProvider);
                }
            }
        }
Exemplo n.º 10
0
        public bool Equals(ExportedRelationDefinition other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(ParentReference.Id.Equals(other.ParentReference.Id) && RelationshipInfo.Equals(other.RelationshipInfo));
        }
Exemplo n.º 11
0
        private void okButton_Click(object sender, System.EventArgs e)
        {
            if (_association == AssociationEnum.Undefined)
            {
                cancelButton_Click(sender, e);
                return;
            }

            try
            {
                RelationshipInfo info = new RelationshipInfo(_association, _descriptor, SelectedTarget);

                info.ParentCol        = SelectedParentCol;
                info.ChildCol         = SelectedRelatedCol;
                info.AssociationTable = SelectedAssociationTable;

                info.Where     = where.Text;
                info.OrderBy   = order.Text;
                info.OuterJoin = outerJoin.Text;

                // TODO: Add checkbox for proxy
                info.UseProxy = false;

                info.Insert  = insertButton.Checked;
                info.Update  = updateButton.Checked;
                info.Lazy    = lazyButton.Checked;
                info.Cascade = cascade.SelectedText;

                ActiveRecordPropertyRelationDescriptor prop = _relationBuilder.Build(info);

                _descriptor.PropertiesRelations.Add(prop);
            }
            catch (Exception ex)
            {
                String message = String.Format("Something is missing... \r\n\r\n{0}", ex.Message);
                MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult = DialogResult.OK;
        }
        public void HasÁndBelongsToMany()
        {
            InitKernel();
            IRelationshipBuilder relService = ObtainService();

            DatabaseDefinition dbdef = new DatabaseDefinition("alias");

            TableDefinition compTable = new TableDefinition("companies", dbdef);

            compTable.AddColumn(new ColumnDefinition("id", true, false, true, false, OleDbType.Integer));
            compTable.AddColumn(new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar));

            TableDefinition peopleTable = new TableDefinition("people", dbdef);

            peopleTable.AddColumn(new ColumnDefinition("id", true, false, true, false, OleDbType.Integer));
            peopleTable.AddColumn(new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar));

            TableDefinition assocTable = new TableDefinition("companiespeople", dbdef);

            assocTable.AddColumn(new ColumnDefinition("comp_id", true, true, true, false, OleDbType.Integer));
            assocTable.AddColumn(new ColumnDefinition("person_id", true, true, false, false, OleDbType.Integer));

            ActiveRecordDescriptor desc       = new ActiveRecordDescriptor("Company");
            ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Person");

            RelationshipInfo info = new RelationshipInfo(AssociationEnum.HasAndBelongsToMany, desc, targetDesc);

            info.AssociationTable = assocTable;
            info.ParentCol        = new ColumnDefinition("comp_id", false, true, false, true, OleDbType.Integer);
            info.ChildCol         = new ColumnDefinition("person_id", false, true, false, true, OleDbType.Integer);

            ActiveRecordPropertyRelationDescriptor propDesc = relService.Build(info);

            Assert.IsNotNull(propDesc as ActiveRecordHasAndBelongsToManyDescriptor);
            Assert.IsNotNull(propDesc);
            Assert.AreEqual("People", propDesc.PropertyName);
            Assert.AreEqual(targetDesc, propDesc.TargetType);
            Assert.AreEqual("person_id", propDesc.ColumnName);
            Assert.AreEqual("comp_id", (propDesc as ActiveRecordHasAndBelongsToManyDescriptor).ColumnKey);
        }
Exemplo n.º 13
0
		public void HasMany()
		{
			InitKernel();
			IRelationshipBuilder relService = ObtainService();

			TableDefinition blogTable;
			TableDefinition postTable;

			BuildBlogPostsStructure(out blogTable, out postTable);

			ActiveRecordDescriptor desc = new ActiveRecordDescriptor("Blog");
			ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Post");

			RelationshipInfo info = new RelationshipInfo( AssociationEnum.HasMany, desc, targetDesc );
			info.ChildCol = new ColumnDefinition("blog_id", false, true, true, false, OleDbType.Numeric);

			ActiveRecordPropertyRelationDescriptor propDesc = relService.Build( info );
			Assert.IsNotNull(propDesc);
			Assert.IsNotNull(propDesc as ActiveRecordHasManyDescriptor);
			Assert.AreEqual( "Posts", propDesc.PropertyName );
			Assert.AreEqual( targetDesc, propDesc.TargetType );
			Assert.AreEqual( "blog_id", propDesc.ColumnName );
		}
Exemplo n.º 14
0
        private RelationshipInfo GetRelationship(string key, string otherKey, bool initialize = false)
        {
            RelationshipInfo relationship;

            if (m_relationships == null || !m_relationships.ContainsKey(key))
            {
                if (!initialize)
                {
                    return(null);
                }

                // Setup return value
                relationship = new RelationshipInfo();

                var dict = new Dictionary <string, RelationshipInfo>();
                dict.Add(otherKey, relationship);

                if (m_relationships == null)
                {
                    m_relationships = new Dictionary <string, Dictionary <string, RelationshipInfo> >();
                }
                m_relationships.Add(key, dict);

                return(relationship);
            }
            else
            {
                var dict = m_relationships[key];
                if (!dict.TryGetValue(otherKey, out relationship) && initialize)
                {
                    relationship = new RelationshipInfo();
                    dict.Add(otherKey, relationship);
                }

                return(relationship);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        ///     If the relationship instance is present in both directions, is this the direction that would be kept.
        /// </summary>
        /// <param name="relInfo">Relationship info</param>
        /// <param name="direction">Current direction</param>
        /// <returns></returns>
        private bool WouldDiscardIfDuplicate(RelationshipInfo relInfo, Direction direction)
        {
            // Prefer the 'CloneEntities', then the 'CloneRef', finally the 'Drop'.
            // All things being equal, prefer the forward copy

            if (relInfo.CloneAction == relInfo.ReverseCloneAction)
            {
                return(direction == Direction.Reverse);
            }

            var curAction = direction == Direction.Forward ? relInfo.CloneAction : relInfo.ReverseCloneAction;
            var revAction = direction == Direction.Forward ? relInfo.ReverseCloneAction : relInfo.CloneAction;

            if (curAction == CloneActionEnum_Enumeration.CloneEntities || revAction == CloneActionEnum_Enumeration.Drop)
            {
                return(false);
            }
            if (curAction == CloneActionEnum_Enumeration.Drop || revAction == CloneActionEnum_Enumeration.CloneEntities)
            {
                return(true);
            }

            return(direction == Direction.Forward);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Retrieves records related to a feature based on information from the relationship info
        /// </summary>
        internal static async Task <IReadOnlyList <RelatedFeatureQueryResult> > GetRelatedRecords(this FeatureTable featureTable, Feature feature, RelationshipInfo relationshipInfo)
        {
            var parameters = new RelatedQueryParameters(relationshipInfo);

            if (featureTable is ServiceFeatureTable serviceFeatureTable)
            {
                return(await serviceFeatureTable.QueryRelatedFeaturesAsync((ArcGISFeature)feature, parameters, QueryFeatureFields.LoadAll));
            }
            else if (featureTable is GeodatabaseFeatureTable geodatabaseFeatureTable)
            {
                return(await geodatabaseFeatureTable.QueryRelatedFeaturesAsync((ArcGISFeature)feature, parameters));
            }
            return(null);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Retrieves a related table based on information from the relationship info
 /// </summary>
 internal static ArcGISFeatureTable GetRelatedFeatureTable(this FeatureTable featureTable, RelationshipInfo relationshipInfo)
 {
     if (featureTable is ServiceFeatureTable serviceFeatureTable)
     {
         return(serviceFeatureTable.GetRelatedTables(relationshipInfo).FirstOrDefault());
     }
     else if (featureTable is GeodatabaseFeatureTable geodatabaseFeatureTable)
     {
         return(geodatabaseFeatureTable.GetRelatedTables(relationshipInfo).FirstOrDefault());
     }
     return(null);
 }
Exemplo n.º 18
0
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // Get the cell colour that is associated with the cell symbol object type
            aMetaData.CellBoxColor = ColourForHeapCell(aCell);
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);

            // Draw actual cell
            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }

            HeapCell.TRegion region = aMetaData.Region;
            if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0)
            {
                // If first box, we show the number of inwards links to the cell
                boxRect.Inflate(KShrinkSize, KShrinkSize);

                // Draw the fill
                Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor);
                using (SolidBrush brush = new SolidBrush(lightenColor))
                {
                    aGraphics.FillRectangle(brush, boxRect.Rectangle);
                }
                lightenColor = ColourUtils.Lighten(lightenColor);
                using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                {
                    aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);
                }

                // Draw the count
                PaintBoxedTextWithLuminanceHandling(aCell.RelationshipManager.EmbeddedReferencesTo.Count.ToString(), aGraphics, Color.Black, boxRect);
            }
            else
            {
                // If we're in the payload section, then get the raw item corresponding to the address we are drawing
                RawItem rawItem = aMetaData.RawItem;
                if (rawItem != null && rawItem.Tag != null && rawItem.Tag is HeapLib.Relationships.RelationshipInfo)
                {
                    RelationshipInfo relInfo = (RelationshipInfo)rawItem.Tag;

                    // Make the box a bit smaller
                    boxRect.Inflate(KShrinkSize, KShrinkSize);

                    // Draw the fill
                    Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor);
                    using (SolidBrush brush = new SolidBrush(lightenColor))
                    {
                        aGraphics.FillRectangle(brush, boxRect.Rectangle);
                    }
                    lightenColor = ColourUtils.Lighten(lightenColor);
                    using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                    {
                        aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);

                        // If it's a clean reference, then draw a diagonal line to decorate the box reference
                        if (relInfo.IsCleanLink)
                        {
                            Point linePosStart = boxRect.TopLeft;
                            linePosStart.X += KHeaderBoxLineCornerOffset;
                            Point linePosEnd = boxRect.TopLeft;
                            linePosEnd.Y += KHeaderBoxLineCornerOffset;
                            //
                            aGraphics.DrawLine(borderPen, linePosStart, linePosEnd);
                        }
                    }
                }
            }
        }
        public void GetRegistration_ContainerControlledCollectionWithDecorator_ContainsExpectedListOfRelationships()
        {
            // Arrange
            var expectedRelationship = new RelationshipInfo
            {
                ImplementationType = typeof(RealCommandHandlerDecorator),
                Lifestyle = Lifestyle.Transient,
                Dependency = new DependencyInfo(typeof(ICommandHandler<RealCommand>), Lifestyle.Transient)
            };

            var container = ContainerFactory.New();

            container.RegisterCollection<ICommandHandler<RealCommand>>(new[]
            {
                typeof(StubCommandHandler),
                typeof(RealCommandHandler)
            });

            // RealCommandHandlerDecorator only takes a dependency on ICommandHandler<RealCommand>
            container.RegisterDecorator(typeof(ICommandHandler<>), typeof(RealCommandHandlerDecorator));

            container.Verify();

            var producer = container.GetRegistration(typeof(IEnumerable<ICommandHandler<RealCommand>>));

            // Act
            var relationships = producer.GetRelationships();

            // Assert
            Assert.AreEqual(2, relationships.Length);
            Assert.AreEqual(2, relationships.Count(actual => expectedRelationship.Equals(actual)));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DestinationRelationshipViewModel"/> class.
 /// </summary>
 public OriginRelationshipViewModel(RelationshipInfo relationshipInfo, ConnectivityMode connectivityMode)
 {
     RelationshipInfo = relationshipInfo;
     ConnectivityMode = connectivityMode;
 }
        public void GetRegistration_ContainerUncontrolledCollectionWithDecorator_ContainsExpectedListOfRelationships()
        {
            // Arrange
            var expectedRelationship = new RelationshipInfo
            {
                ImplementationType = typeof(RealCommandHandlerDecorator),
                Lifestyle = Lifestyle.Transient,
                Dependency = new DependencyInfo(typeof(ICommandHandler<RealCommand>), Lifestyle.Unknown)
            };

            var container = ContainerFactory.New();

            IEnumerable<ICommandHandler<RealCommand>> containerUncontrolledCollection =
                new ICommandHandler<RealCommand>[] { new StubCommandHandler(), new RealCommandHandler() };

            container.RegisterCollection<ICommandHandler<RealCommand>>(containerUncontrolledCollection);

            // RealCommandHandlerDecorator only takes a dependency on ICommandHandler<RealCommand>
            container.RegisterDecorator(typeof(ICommandHandler<>), typeof(RealCommandHandlerDecorator));

            // Verify() ensures that all Relationships are built.
            container.Verify();

            var r = container.GetCurrentRegistrations();

            // Act
            var registration = container.GetRegistration(typeof(IEnumerable<ICommandHandler<RealCommand>>));
            var relationships = registration.GetRelationships();

            // Assert
            Assert.AreEqual(1, relationships.Length);
            Assert.IsTrue(expectedRelationship.Equals(relationships[0]),
                "Actual relationship: " + RelationshipInfo.ToString(relationships[0]));
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initialization code for the OriginRelationshipViewModel
        /// </summary>
        public Task InitializeAsync(RelatedFeatureQueryResult relatedFeatureQueryResult, RelationshipInfo relationshipInfo)
        {
            if (_initTcs == null)
            {
                _initTcs = new TaskCompletionSource <bool>();
                // Run initialization
                LoadViewModel(relatedFeatureQueryResult, relationshipInfo).ContinueWith(t =>
                {
                    // When init completes, set the task to complete
                    _initTcs.TrySetResult(true);
                });
            }

            return(_initTcs.Task);
        }
 public OriginRelationship(ArcGISFeatureTable relatedTable, RelationshipInfo relationshipInfo, ObservableCollection <OriginRelationshipViewModel> originRelationshipViewModelCollection)
 {
     RelatedTable     = relatedTable;
     RelationshipInfo = relationshipInfo;
     OriginRelationshipViewModelCollection = originRelationshipViewModelCollection;
 }
        private void UpdateTable()
        {
            HeapCell cell = Cell;

            //
            iTable_RawItems.BeginUpdate();
            iTableModel.Rows.Clear();
            //
            if (cell != null)
            {
                // Work out our raw item offset and how many raw items to create in this operation
                SymbianUtils.RawItems.RawItemCollection rawItems = cell.RawItems;
                int rawItemIndexStart = DisplayRawDataItemIndex;
                int rawItemIndexEnd   = Math.Min(rawItems.Count, rawItemIndexStart + KNumberOfRowsPerPage);
                //
                for (int rawItemIndex = rawItemIndexStart; rawItemIndex < rawItemIndexEnd; rawItemIndex++)
                {
                    SymbianUtils.RawItems.RawItem rawEntry = rawItems[rawItemIndex];
                    XPTable.Models.Row            row      = new XPTable.Models.Row();

                    // Cell 1: address
                    XPTable.Models.Cell cellAddress = new XPTable.Models.Cell(rawEntry.Address.ToString("x8"));

                    // Cell 2: raw data
                    XPTable.Models.Cell cellRawData = new XPTable.Models.Cell(rawEntry.OriginalData.ToString("x8"));

                    // Cell 3: interpreted data
                    XPTable.Models.Cell cellInterpretedData = new XPTable.Models.Cell(rawEntry.Data.ToString("x8"));

                    // Cell 4: characterised data
                    XPTable.Models.Cell cellCharacterisedData = new XPTable.Models.Cell(rawEntry.OriginalCharacterisedData);

                    // Update style of "interpreted data" if there is a link to another cell.
                    RelationshipInfo relationshipDescriptor = (rawEntry.Tag != null && rawEntry.Tag is RelationshipInfo) ? (RelationshipInfo)rawEntry.Tag : null;
                    if (relationshipDescriptor != null)
                    {
                        // The colour depends on whether it is a clean link or not. Clean means whether or not the
                        // link points to the start of the specified cell.
                        HeapCell linkedCell = relationshipDescriptor.ToCell;
                        //
                        if (relationshipDescriptor.IsCleanLink)
                        {
                            cellInterpretedData.ForeColor   = Color.Blue;
                            cellInterpretedData.ToolTipText = "Link to start of: " + linkedCell.SymbolString + " @ 0x" + linkedCell.Address.ToString("x8");
                        }
                        else
                        {
                            cellInterpretedData.ForeColor   = Color.DarkBlue;
                            cellInterpretedData.ToolTipText = "Link within: " + linkedCell.SymbolString + " @ 0x" + linkedCell.Address.ToString("x8");
                        }

                        cellInterpretedData.Font = new Font(iTable_RawItems.Font, FontStyle.Underline);
                        cellInterpretedData.Tag  = linkedCell;
                    }

                    // Finish construction
                    row.Cells.Add(cellAddress);
                    row.Cells.Add(cellRawData);
                    row.Cells.Add(cellInterpretedData);
                    row.Cells.Add(cellCharacterisedData);
                    iTableModel.Rows.Add(row);
                }
            }

            // Try to select first item
            if (iTable_RawItems.TableModel.Rows.Count > 0)
            {
                iTable_RawItems.EnsureVisible(0, 0);
                iTable_RawItems.TableModel.Selections.SelectCell(0, 0);
            }

            iTable_RawItems.EndUpdate();
        }
Exemplo n.º 25
0
		public void HasÁndBelongsToMany()
		{
			InitKernel();
			IRelationshipBuilder relService = ObtainService();

			DatabaseDefinition dbdef = new DatabaseDefinition("alias");

			TableDefinition compTable = new TableDefinition("companies", dbdef );
			compTable.AddColumn( new ColumnDefinition("id", true, false, true, false, OleDbType.Integer) );
			compTable.AddColumn( new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar) );

			TableDefinition peopleTable = new TableDefinition("people", dbdef );
			peopleTable.AddColumn( new ColumnDefinition("id", true, false, true, false, OleDbType.Integer) );
			peopleTable.AddColumn( new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar) );

			TableDefinition assocTable = new TableDefinition("companiespeople", dbdef );
			assocTable.AddColumn( new ColumnDefinition("comp_id", true, true, true, false, OleDbType.Integer) );
			assocTable.AddColumn( new ColumnDefinition("person_id", true, true, false, false, OleDbType.Integer) );

			ActiveRecordDescriptor desc = new ActiveRecordDescriptor("Company");
			ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Person");

			RelationshipInfo info = new RelationshipInfo( AssociationEnum.HasAndBelongsToMany, desc, targetDesc );
			info.AssociationTable = assocTable;
			info.ParentCol = new ColumnDefinition("comp_id", false, true, false, true, OleDbType.Integer);
			info.ChildCol = new ColumnDefinition("person_id", false, true, false, true, OleDbType.Integer);

			ActiveRecordPropertyRelationDescriptor propDesc = relService.Build( info );
			Assert.IsNotNull(propDesc as ActiveRecordHasAndBelongsToManyDescriptor);
			Assert.IsNotNull(propDesc);
			Assert.AreEqual( "People", propDesc.PropertyName );
			Assert.AreEqual( targetDesc, propDesc.TargetType );
			Assert.AreEqual( "person_id", propDesc.ColumnName );
			Assert.AreEqual( "comp_id", (propDesc as ActiveRecordHasAndBelongsToManyDescriptor).ColumnKey);
		}
        public RelationshipInfo Create(PersonInfo person1, PersonInfo person2, bool?isPartnership, ParentChildDirection?isParentChild)
        {
            // init
            var id = new long[] { person1.Id, person2.Id }
            .OrderBy(x => x)
            .ToArray();

            // match
            var match = this._Items
                        .SingleOrDefault(x => x.Person1Id == id[0] && x.Person2Id == id[1]);

            if (match == null)
            {
                // create
                match = new RelationshipInfo()
                {
                    Person1Id = id[0],
                    Person2Id = id[1],
                };

                // add
                this._Items.Add(match);
            }

            // partnership
            if (isPartnership.HasValue)
            {
                // init
                match.IsPartnership = match.IsPartnership.Ensure(isPartnership.Value);
            }

            // parent/child
            if (isParentChild.HasValue)
            {
                // init
                var isReversed = (id[0] != person1.Id);
                var value      = isParentChild.Value;
                if (isReversed)
                {
                    switch (value)
                    {
                    case ParentChildDirection.Person1IsParentOfPerson2:
                        value = ParentChildDirection.Person2IsParentOfPerson1;
                        break;

                    case ParentChildDirection.Person2IsParentOfPerson1:
                        value = ParentChildDirection.Person1IsParentOfPerson2;
                        break;

                    default:
                        throw new NotSupportedException();
                    }
                }

                // done
                match.IsParentChild = match.IsParentChild.Ensure(value);
            }

            // done
            return(match);
        }
Exemplo n.º 27
0
        // When a comment is clicked, get the related feature (service request) and select it on the map.
        private async void CommentsListBox_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            // Clear selected features from the graphics overlay.
            _selectedFeaturesOverlay.Graphics.Clear();

            // Get the clicked record (ArcGISFeature) using the list position. If one is not found, return.
            ArcGISFeature selectedComment = _commentFeatures[e.Position] as ArcGISFeature;

            if (selectedComment == null)
            {
                return;
            }

            // Get the map image layer that contains the service request sublayer and the service request comments table.
            ArcGISMapImageLayer serviceRequestsMapImageLayer = _myMapView.Map.OperationalLayers[0] as ArcGISMapImageLayer;

            // Get the (non-spatial) table that contains the service request comments.
            ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0];

            // Get the relationship that defines related service request features to features in the comments table (this is the first and only relationship).
            RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault();

            // Create query parameters to get the related service request for features in the comments table.
            RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo)
            {
                ReturnGeometry = true
            };

            // Query the comments table to get the related service request feature for the selected comment.
            IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams);

            // Get the first result.
            RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault();

            // Get the first feature from the result. If it's null, warn the user and return.
            ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature;

            if (serviceRequestFeature == null)
            {
                // Report to the user that a related feature was not found, then return.
                AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
                AlertDialog         alert        = alertBuilder.Create();
                alert.SetMessage("Related feature not found.");
                alert.Show();

                return;
            }

            // Load the related service request feature (so its geometry is available).
            await serviceRequestFeature.LoadAsync();

            // Get the service request geometry (point).
            MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint;

            // Create a cyan marker symbol to display the related feature.
            Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Cyan, 14);

            // Create a graphic using the service request point and marker symbol.
            Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol);

            // Add the graphic to the graphics overlay and zoom the map view to its extent.
            _selectedFeaturesOverlay.Graphics.Add(requestGraphic);
            await _myMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000);
        }
Exemplo n.º 28
0
 public static ClientRelationship CreateNew(RelationshipInfo address)
 {
     return(new ClientRelationship(address.Id, address.RelatedClientId, address.RelationshipTypeId, address.IsIndex, address.ClientId));
 }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DestinationRelationshipViewModel"/> class.
 /// </summary>
 public DestinationRelationshipViewModel(RelationshipInfo relationshipInfo, ArcGISFeatureTable relatedTable, ConnectivityMode connectivityMode)
 {
     RelationshipInfo = relationshipInfo;
     FeatureTable     = relatedTable;
     ConnectivityMode = connectivityMode;
 }
Exemplo n.º 30
0
        public static void ShowRelationship_UpdateRelationship(UIRelationship __instance, RelationshipInfo _info)
        {
            var  t       = Traverse.Create(__instance);
            Text expText = Traverse.Create(__instance).Field("expbar").GetValue <Slider>().GetComponentInChildren <Text>();

            if (expText != null)
            {
                UnityEngine.Object.Destroy(expText);
            }
            if (showFavExp.Value)
            {
                GameObject gameObject = new GameObject("Text");
                gameObject.transform.SetParent(t.Field("expbar").GetValue <Slider>().transform, false);
                expText = gameObject.AddComponent <Text>();
                FavorabilityData favorability = Game.GameData.Community[t.Field("currentId").GetValue <string>()].Favorability;
                expText.text      = favorability.Exp + " / " + favorability.GetMaxExpByLevel(favorability.Level);
                expText.font      = Game.Resource.Load <Font>("Assets/Font/kaiu.ttf");
                expText.fontSize  = 25;
                expText.alignment = TextAnchor.MiddleLeft;
                expText.rectTransform.sizeDelta = new Vector2(120f, 40f);
                expText.transform.localPosition = new Vector3(-5f, 50f, 0f);
            }
        }