/// <summary>
        ///     get a output exchange item
        /// </summary>
        /// <param name="index">index number of the requested output exchange item</param>
        /// <returns>The requested exchange item</returns>
        public override IOutputExchangeItem GetOutputExchangeItem(int index)
        {
            var outputExchangeItem = outputs[index];

            //Add dataoperations to outputExchangeItems
            var elementMapper = new ElementMapper();
            var dataOperations = new ArrayList();
            dataOperations = elementMapper.GetAvailableDataOperations(outputExchangeItem.ElementSet.ElementType);
            bool spatialDataOperationExists;
            bool linearConversionDataOperationExists;
            bool smartBufferDataOperationExists;
            foreach (IDataOperation dataOperation in dataOperations)
            {
                spatialDataOperationExists = false;
                foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
                {
                    if (dataOperation.ID == existingDataOperation.ID)
                    {
                        spatialDataOperationExists = true;
                    }
                }

                if (!spatialDataOperationExists)
                {
                    outputExchangeItem.AddDataOperation(dataOperation);
                }
            }

            IDataOperation linearConversionDataOperation = new LinearConversionDataOperation();
            linearConversionDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
            {
                if (linearConversionDataOperation.ID == existingDataOperation.ID)
                {
                    linearConversionDataOperationExists = true;
                }
            }

            if (!linearConversionDataOperationExists)
            {
                outputExchangeItem.AddDataOperation(new LinearConversionDataOperation());
            }

            IDataOperation smartBufferDataOperaion = new SmartBufferDataOperation();
            smartBufferDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
            {
                if (smartBufferDataOperaion.ID == existingDataOperation.ID)
                {
                    smartBufferDataOperationExists = true;
                }
            }

            if (!smartBufferDataOperationExists)
            {
                outputExchangeItem.AddDataOperation(new SmartBufferDataOperation());
            }

            return outputExchangeItem;
        }
예제 #2
0
		public void GetAvailableDataOperations()
		{
			ElementMapper elementMapper = new ElementMapper();

			Console.WriteLine("=========================FROM XYPoint====================================");
			ArrayList dataOperationsXYPoint = elementMapper.GetAvailableDataOperations(ElementType.XYPoint);
			foreach (IDataOperation operation in dataOperationsXYPoint)
			{
				Console.WriteLine(" ");
				Console.WriteLine("------------------------------------");
				Console.WriteLine("DataOperationID: " + operation.ID);
				for (int i = 0; i <  operation.ArgumentCount; i++)
				{
					Console.WriteLine(" ");
					Console.WriteLine("Key:         " + operation.GetArgument(i).Key);
					Console.WriteLine("Value:       " + operation.GetArgument(i).Value);
					Console.WriteLine("ReadOnly:    " + operation.GetArgument(i).ReadOnly.ToString());
					Console.WriteLine("Description: " + operation.GetArgument(i).Description);
				}
			}

            Console.WriteLine(" ");
			Console.WriteLine("========================= FROM XYLine ====================================");
			ArrayList dataOperationsXYLine = elementMapper.GetAvailableDataOperations(ElementType.XYLine);
			foreach (IDataOperation operation in dataOperationsXYLine)
			{
				Console.WriteLine(" ");
				Console.WriteLine("------------------------------------");
				Console.WriteLine("DataOperationID: " + operation.ID);
				for (int i = 0; i <  operation.ArgumentCount; i++)
				{
					Console.WriteLine(" ");
					Console.WriteLine("Key:         " + operation.GetArgument(i).Key);
					Console.WriteLine("Value:       " + operation.GetArgument(i).Value);
					Console.WriteLine("ReadOnly:    " + operation.GetArgument(i).ReadOnly.ToString());
					Console.WriteLine("Description: " + operation.GetArgument(i).Description);
				}
			}

			Console.WriteLine(" ");
			Console.WriteLine("========================= FROM XYPolyLine ====================================");
			ArrayList dataOperationsXYPolyLine = elementMapper.GetAvailableDataOperations(ElementType.XYPolyLine);
			foreach (IDataOperation operation in dataOperationsXYPolyLine)
			{
				Console.WriteLine(" ");
				Console.WriteLine("------------------------------------");
				Console.WriteLine("DataOperationID: " + operation.ID);
				for (int i = 0; i <  operation.ArgumentCount; i++)
				{
					Console.WriteLine(" ");
					Console.WriteLine("Key:         " + operation.GetArgument(i).Key);
					Console.WriteLine("Value:       " + operation.GetArgument(i).Value);
					Console.WriteLine("ReadOnly:    " + operation.GetArgument(i).ReadOnly.ToString());
					Console.WriteLine("Description: " + operation.GetArgument(i).Description);
				}
			}

            Console.WriteLine(" ");
			Console.WriteLine("=========================FROM XYPolygon====================================");
			ArrayList dataOperationsXYPolygon = elementMapper.GetAvailableDataOperations(ElementType.XYPolygon);
			foreach (IDataOperation operation in dataOperationsXYPolygon)
			{
				Console.WriteLine(" ");
				Console.WriteLine("------------------------------------");
				Console.WriteLine("DataOperationID: " + operation.ID);
				for (int i = 0; i <  operation.ArgumentCount; i++)
				{
					Console.WriteLine(" ");
					Console.WriteLine("Key:         " + operation.GetArgument(i).Key);
					Console.WriteLine("Value:       " + operation.GetArgument(i).Value);
					Console.WriteLine("ReadOnly:    " + operation.GetArgument(i).ReadOnly.ToString());
					Console.WriteLine("Description: " + operation.GetArgument(i).Description);
	 			}
			}

			bool operationWasFound       = false;
			bool IDWasFound              = false;
			bool descriptionWasFound     = false;
			bool typeWasFound            = false;
			bool fromElementTypeWasFound = false;
			bool toElementTypeWasFound   = false;

			foreach (IDataOperation operation in dataOperationsXYPolygon)
			{
				if (operation.ID == "ElementMapper801")
				{
					operationWasFound = true;

					for (int i = 0; i <  operation.ArgumentCount; i++)
					{
						if (operation.GetArgument(i).Key == "ID")
						{
							Assert.AreEqual("801",operation.GetArgument(i).Value);
							IDWasFound = true;
						}
						if (operation.GetArgument(i).Key == "Description")
						{
							Assert.AreEqual("Weighted Sum",operation.GetArgument(i).Value);
							descriptionWasFound = true;
						}
						if (operation.GetArgument(i).Key == "Type")
						{
							Assert.AreEqual("SpatialMapping",operation.GetArgument(i).Value);
							typeWasFound = true;
						}
						if (operation.GetArgument(i).Key == "FromElementType")
						{
							Assert.AreEqual("XYPolygon",operation.GetArgument(i).Value);
							fromElementTypeWasFound = true;
						}
						if (operation.GetArgument(i).Key == "ToElementType")
						{
							Assert.AreEqual("XYPolygon",operation.GetArgument(i).Value);
							toElementTypeWasFound = true;
						}
					}
				}
			}

			Assert.AreEqual(true,operationWasFound);
			Assert.AreEqual(true,IDWasFound);
			Assert.AreEqual(true,descriptionWasFound);
			Assert.AreEqual(true,typeWasFound);
			Assert.AreEqual(true,fromElementTypeWasFound);
			Assert.AreEqual(true,toElementTypeWasFound);
		
		}