Ejemplo n.º 1
0
        // TODO: We have "ImplementingType" property and "GetImplementingType" method.  UGLY!
        public Type GetImplementingType(ISemanticTypeSystem sts)
        {
            switch (ImplementingType.ToLower())
            {
            case "string":
                return(typeof(string));

            case "int":
            case "integer":
                return(typeof(int));

            case "uint":
                return(typeof(uint));

            case "short":
                return(typeof(short));

            case "ushort":
                return(typeof(ushort));

            case "long":
                return(typeof(long));

            case "ulong":
                return(typeof(ulong));

            case "float":
                return(typeof(float));

            case "double":
                return(typeof(double));

            case "decimal":
                return(typeof(decimal));

            case "bool":
            case "boolean":
                return(typeof(bool));

            case "datetime":
                // TODO: Should be an ST made up of date/time, which themselves are ST's of day, month, year, hour, minute second?
                return(typeof(DateTime));

            case "byte":
                return(typeof(byte));

            case "sbyte":
                return(typeof(sbyte));

            case "char":
                return(typeof(char));

            case "object":
                return(typeof(object));

            default:
                // throw new ApplicationException("Unknown implementing type: " + ImplementingType);
                return(null);
            }
        }
Ejemplo n.º 2
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Relationship = sts.Create("Relationship", this);
     //Additional semantic type initializers.
     Relationship.ForwardName = "Father of";
     Relationship.ReverseName = "Son of";
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Set the native type property of the dynamic instance to the specified value.
        /// </summary>
        public void SetValue(ISemanticTypeSystem sts, object instance, object value)
        {
            Type         type = instance.GetType();
            PropertyInfo pi   = type.GetProperty(Name);
            object       val  = Converter.Convert(value, pi.PropertyType);

            pi.SetValue(instance, val);
        }
Ejemplo n.º 4
0
        public Membrane(ISemanticTypeSystem sts)
        {
            receptorSystem     = new ReceptorsContainer(sts);
            SemanticTypeSystem = sts;

            receptorSystem.NewReceptor     += OnNewReceptor;
            receptorSystem.NewCarrier      += OnNewCarrier;
            receptorSystem.ReceptorRemoved += OnReceptorRemoved;

            Membranes            = new List <IMembrane>();
            ProtocolPermeability = new Dictionary <PermeabilityKey, PermeabilityConfiguration>();
        }
Ejemplo n.º 5
0
		public Membrane(ISemanticTypeSystem sts, IApplicationController appController)
		{
			receptorSystem = new ReceptorsContainer(sts, this);
			SemanticTypeSystem = sts;
			ApplicationController = appController;

			receptorSystem.NewReceptor += OnNewReceptor;
			receptorSystem.NewCarrier += OnNewCarrier;
			receptorSystem.ReceptorRemoved += OnReceptorRemoved;

			Membranes = new List<IMembrane>();
			ProtocolPermeability = new Dictionary<PermeabilityKey, PermeabilityConfiguration>();
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Returns the underlying native type of an element in a semantic structure, resolving sub-semenantic elements as well down to their native type.
		/// </summary>
		public Type GetImplementingType(ISemanticTypeSystem sts)
		{
			Type ret = null;
			List<INativeType> ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
			List<ISemanticElement> stypes = sts.GetSemanticTypeStruct(Name).SemanticElements;
			Assert.That(ntypes.Count + stypes.Count == 1, "Getting the element type of a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");

			if (ntypes.Count == 1)
			{
				ret = ntypes[0].GetImplementingType(sts);
			}
			else
			{
				ret = stypes[0].GetImplementingType(sts);
			}

			return ret;
		}
Ejemplo n.º 7
0
		// TODO: We have "ImplementingType" property and "GetImplementingType" method.  UGLY!
		public Type GetImplementingType(ISemanticTypeSystem sts)
		{
			switch (ImplementingType.ToLower())
			{
				case "string":
					return typeof(string);
				case "int":
				case "integer":
					return typeof(int);
				case "uint":
					return typeof(uint);
				case "short":
					return typeof(short);
				case "ushort":
					return typeof(ushort);
				case "long":
					return typeof(long);
				case "ulong":
					return typeof(ulong);
				case "float":
					return typeof(float);
				case "double":
					return typeof(double);
				case "decimal":
					return typeof(decimal);
				case "bool":
				case "boolean":
					return typeof(bool);
				case "datetime":
					// TODO: Should be an ST made up of date/time, which themselves are ST's of day, month, year, hour, minute second?
					return typeof(DateTime);
				case "byte":
					return typeof(byte);
				case "sbyte":
					return typeof(sbyte);
				case "char":
					return typeof(char);
				case "object":
					return typeof(object);
				default:
					// throw new ApplicationException("Unknown implementing type: " + ImplementingType);
					return null;
			}
		}
Ejemplo n.º 8
0
        /// <summary>
        /// Returns the underlying native type of an element in a semantic structure, resolving sub-semenantic elements as well down to their native type.
        /// </summary>
        public Type GetImplementingType(ISemanticTypeSystem sts)
        {
            Type ret = null;
            List <INativeType>      ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
            List <ISemanticElement> stypes = sts.GetSemanticTypeStruct(Name).SemanticElements;

            Assert.That(ntypes.Count + stypes.Count == 1, "Getting the element type of a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");

            if (ntypes.Count == 1)
            {
                ret = ntypes[0].GetImplementingType(sts);
            }
            else
            {
                ret = stypes[0].GetImplementingType(sts);
            }

            return(ret);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Resolve the ST down to it's singleton native type and return the value.
        /// </summary>
        public void SetValue(ISemanticTypeSystem sts, object instance, object value)
        {
            // Don't set the value if it's null from the DB.
            if (value != DBNull.Value)
            {
                PropertyInfo pi = instance.GetType().GetProperty(Name);

                if (pi == null)
                {
                    // The instance IS the native type that is wrapped by the semantic type.
                    List <INativeType> ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
                    Assert.That(ntypes.Count == 1, "Setting a value on a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");
                    PropertyInfo piTarget = instance.GetType().GetProperty(ntypes[0].Name);
                    piTarget.SetValue(instance, value);
                }
                else
                {
                    Type type = pi.GetType();

                    List <INativeType>      ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
                    List <ISemanticElement> stypes = sts.GetSemanticTypeStruct(Name).SemanticElements;
                    Assert.That(ntypes.Count + stypes.Count == 1, "Setting a value on a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");
                    object item = pi.GetValue(instance);

                    if (ntypes.Count == 1)
                    {
                        PropertyInfo piTarget = item.GetType().GetProperty(ntypes[0].Name);
                        piTarget.SetValue(item, value);
                    }
                    else
                    {
                        stypes[0].SetValue(sts, item, value);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Resolve the ST down to it's singleton native type and return the value.
        /// </summary>
        public object GetValue(ISemanticTypeSystem sts, object instance)
        {
            object ret = null;

            PropertyInfo pi = instance.GetType().GetProperty(Name);

            List <INativeType>      ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
            List <ISemanticElement> stypes = sts.GetSemanticTypeStruct(Name).SemanticElements;

            Assert.That(ntypes.Count + stypes.Count == 1, "Getting a value on a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");
            object item = pi.GetValue(instance);

            if (ntypes.Count == 1)
            {
                PropertyInfo piTarget = item.GetType().GetProperty(ntypes[0].Name);
                ret = piTarget.GetValue(item);
            }
            else
            {
                ret = stypes[0].GetValue(sts, item);
            }

            return(ret);
        }
Ejemplo n.º 11
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     //Native type initializers.
     Name = "Constant";
     //Additional semantic type initializers.
 }
Ejemplo n.º 12
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Line = sts.Create("Line", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 13
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     PointA = sts.Create("PointA", this);
     PointB = sts.Create("PointB", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 14
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     X = sts.Create("X", this);
     Y = sts.Create("Y", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 15
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Relationship = sts.Create("Relationship", this);
     //Additional semantic type initializers.
     Relationship.ForwardName = "Father of";
     Relationship.ReverseName = "Son of";
 }
Ejemplo n.º 16
0
		/// <summary>
		/// Constructor, initializes internal collections.
		/// </summary>
		public ReceptorsContainer(ISemanticTypeSystem sts, IMembrane membrane = null)
		{
			Membrane = membrane;
			SemanticTypeSystem = sts;
			Initialize();
		}
Ejemplo n.º 17
0
		/// <summary>
		/// Set the native type property of the dynamic instance to the specified value.
		/// </summary>
		public void SetValue(ISemanticTypeSystem sts, object instance, object value)
		{
			Type type = instance.GetType();
			PropertyInfo pi = type.GetProperty(Name);
			object val = Converter.Convert(value, pi.PropertyType);
			pi.SetValue(instance, val);
		}
Ejemplo n.º 18
0
 /// <summary>
 /// Constructor, initializes internal collections.
 /// </summary>
 public ReceptorsContainer(ISemanticTypeSystem sts)
 {
     SemanticTypeSystem = sts;
     Initialize();
 }
Ejemplo n.º 19
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Name = sts.Create("Name", this);
     Abbreviation = sts.Create("Abbreviation", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Returns the value of a native type for the specified dynamic instance.
        /// </summary>
        public object GetValue(ISemanticTypeSystem sts, object instance)
        {
            PropertyInfo pi = instance.GetType().GetProperty(Name);

            return(pi.GetValue(instance));
        }
Ejemplo n.º 21
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Point = sts.Create("Point", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 22
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     X = sts.Create("X", this);
     Y = sts.Create("Y", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 23
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Line = sts.Create("Line", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 24
0
		/// <summary>
		/// Resolve the ST down to it's singleton native type and return the value.
		/// </summary>
		public void SetValue(ISemanticTypeSystem sts, object instance, object value)
		{
			// Don't set the value if it's null from the DB.
			if (value != DBNull.Value)
			{
				PropertyInfo pi = instance.GetType().GetProperty(Name);

				if (pi == null)
				{
					// The instance IS the native type that is wrapped by the semantic type.
					List<INativeType> ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
					Assert.That(ntypes.Count == 1, "Setting a value on a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");
					PropertyInfo piTarget = instance.GetType().GetProperty(ntypes[0].Name);
					piTarget.SetValue(instance, value);
				}
				else
				{
					Type type = pi.GetType();

					List<INativeType> ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
					List<ISemanticElement> stypes = sts.GetSemanticTypeStruct(Name).SemanticElements;
					Assert.That(ntypes.Count + stypes.Count == 1, "Setting a value on a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");
					object item = pi.GetValue(instance);

					if (ntypes.Count == 1)
					{
						PropertyInfo piTarget = item.GetType().GetProperty(ntypes[0].Name);
						piTarget.SetValue(item, value);
					}
					else
					{
						stypes[0].SetValue(sts, item, value);
					}
				}
			}
		}
Ejemplo n.º 25
0
 /// <summary>
 /// Constructor, initializes internal collections.
 /// </summary>
 public ReceptorsContainer(ISemanticTypeSystem sts, IMembrane membrane = null)
 {
     Membrane           = membrane;
     SemanticTypeSystem = sts;
     Initialize();
 }
Ejemplo n.º 26
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     //Native type initializers.
     //Additional semantic type initializers.
 }
Ejemplo n.º 27
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Name         = sts.Create("Name", this);
     Abbreviation = sts.Create("Abbreviation", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 28
0
		/// <summary>
		/// Resolve the ST down to it's singleton native type and return the value.
		/// </summary>
		public object GetValue(ISemanticTypeSystem sts, object instance)
		{
			object ret = null;

			PropertyInfo pi = instance.GetType().GetProperty(Name);

			List<INativeType> ntypes = sts.GetSemanticTypeStruct(Name).NativeTypes;
			List<ISemanticElement> stypes = sts.GetSemanticTypeStruct(Name).SemanticElements;
			Assert.That(ntypes.Count + stypes.Count == 1, "Getting a value on a semantic type requires that the semantic type defines one and only one native type or child semantic type in order to resolve the native type property whose value is to be set.");
			object item = pi.GetValue(instance);

			if (ntypes.Count == 1)
			{
				PropertyInfo piTarget = item.GetType().GetProperty(ntypes[0].Name);
				ret = piTarget.GetValue(item);
			}
			else
			{
				ret = stypes[0].GetValue(sts, item);
			}

			return ret;
		}
Ejemplo n.º 29
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Integer = sts.Create("Integer", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 30
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     Integer = sts.Create("Integer", this);
     //Additional semantic type initializers.
 }
Ejemplo n.º 31
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     //Native type initializers.
     Name = "Constant";
     //Additional semantic type initializers.
 }
Ejemplo n.º 32
0
 //Implements ICreate.
 public void Initialize(ISemanticTypeSystem sts)
 {
     //Native type initializers.
     //Additional semantic type initializers.
 }
Ejemplo n.º 33
0
		/// <summary>
		/// Returns the value of a native type for the specified dynamic instance.
		/// </summary>
		public object GetValue(ISemanticTypeSystem sts, object instance)
		{
			PropertyInfo pi = instance.GetType().GetProperty(Name);

			return pi.GetValue(instance);
		}