Click here to Skip to main content
15,892,517 members
Articles / Programming Languages / C# 4.0

Relationship Oriented Programming - The IDE plus More on Agile Project Management

Rate me:
Please Sign up or sign in to vote.
4.98/5 (25 votes)
12 Mar 2012CPOL81 min read 77.7K   1.2K   49  
An Integrated Development Environment (IDE) for the Relationship Oriented Programming Tool.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace ROPLib
{
	public class AttributeNameConverter : StringConverter
	{
		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}

		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			List<string> names = Schema.Instance.GetSortedAttributeNames();

			return new StandardValuesCollection(names);
		}
	}

	/// <summary>
	/// Gets a list of entity attributes for a Relationship.EntityA property or an Entity instance.
	/// </summary>
	public class EntityAttributesConverter : StringConverter
	{
		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}

		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			List<string> names = new List<string>();
			string entityName;

			if (context.Instance is Relationship)
			{
				entityName = ((Relationship)context.Instance).EntityA;
				Entity entity = null;

				foreach (EntitiesContainer ec in Schema.Instance.EntitiesContainer)
				{
					entity = ec.Entities.Find(t => t.Name == entityName);

					if (entity != null)
					{
						break;
					}
				}

				entity.EntityAttributes.ForEach(t => names.Add(t.Name));
			}
			else if (context.Instance is Entity)
			{
				((Entity)context.Instance).EntityAttributes.ForEach(t => names.Add(t.Name));
			}

			names.Sort();

			return new StandardValuesCollection(names);
		}
	}

	public class EntityNameConverter : StringConverter
	{
		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}

		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			List<string> names = new List<string>();
			Schema.Instance.EntitiesContainer.ForEach(t => t.Entities.ForEach(a => names.Add(a.Name)));
			names.Sort();

			return new StandardValuesCollection(names);
		}
	}

	public class ListOfItemsNameConverter : StringConverter
	{
		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}

		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			List<string> names = new List<string>();
			Schema.Instance.ListsContainer.ForEach(t => t.ListOfItems.ForEach(l => names.Add(l.Name)));
			names.Sort();

			return new StandardValuesCollection(names);
		}
	}

	public class ListOfPairsNameConverter : StringConverter
	{
		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}

		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			List<string> names = new List<string>();
			Schema.Instance.PairsContainer.ForEach(t => t.ListOfPairs.ForEach(l => names.Add(l.Name)));
			names.Sort();

			return new StandardValuesCollection(names);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions