Inheritance: BioVersionedNativeObject
Ejemplo n.º 1
0
		/// <summary>
		/// </summary>
		/// <param name="other"></param>
		public BioStateEvent(BioStateEvent other)
			: base(other)
		{
			Elements = new List<BioStateEventElement>();

			if (other.Elements == null)
			{
				return;
			}

			foreach (var element in other.Elements)
			{
				switch (element.ElementType)
				{
					case BioStateEventElementType.Bool:
					{
						Elements.Add(new BioStateEventElementBool(element as BioStateEventElementBool));

						break;
					}
					case BioStateEventElementType.Consequence:
					{
						Elements.Add(new BioStateEventElementConsequence(element as BioStateEventElementConsequence));

						break;
					}
					case BioStateEventElementType.Float:
					{
						Elements.Add(new BioStateEventElementFloat(element as BioStateEventElementFloat));

						break;
					}
					case BioStateEventElementType.Function:
					{
						Elements.Add(new BioStateEventElementFunction(element as BioStateEventElementFunction));

						break;
					}
					case BioStateEventElementType.Int:
					{
						Elements.Add(new BioStateEventElementInt(element as BioStateEventElementInt));

						break;
					}
					case BioStateEventElementType.LocalBool:
					{
						Elements.Add(new BioStateEventElementLocalBool(element as BioStateEventElementLocalBool));

						break;
					}
					case BioStateEventElementType.LocalFloat:
					{
						Elements.Add(new BioStateEventElementLocalFloat(element as BioStateEventElementLocalFloat));

						break;
					}
					case BioStateEventElementType.LocalInt:
					{
						Elements.Add(new BioStateEventElementLocalInt(element as BioStateEventElementLocalInt));

						break;
					}
					case BioStateEventElementType.Substate:
					{
						Elements.Add(new BioStateEventElementSubstate(element as BioStateEventElementSubstate));

						break;
					}
				}
			}
		}
			public BioStateEvent ReadStateEvent()
			{
				var stateEvent = new BioStateEvent
				{
					InstanceVersion = ReadInt32()
				};

				var eventElementsCount = ReadInt32();
				stateEvent.Elements = new List<BioStateEventElement>();

				for (var i = 0; i < eventElementsCount; i++)
				{
					var elementType = (BioStateEventElementType)ReadInt32();
					BioStateEventElement element;

					switch (elementType)
					{
						case BioStateEventElementType.Bool:
							{
								element = ReadEventElementBool();

								break;
							}
						case BioStateEventElementType.Consequence:
							{
								element = ReadEventElementConsequence();

								break;
							}
						case BioStateEventElementType.Float:
							{
								element = ReadEventElementFloat();

								break;
							}
						case BioStateEventElementType.Function:
							{
								element = ReadEventElementFunction();

								break;
							}
						case BioStateEventElementType.Int:
							{
								element = ReadEventElementInt();

								break;
							}
						case BioStateEventElementType.LocalBool:
							{
								element = ReadEventElementLocalBool();

								break;
							}
						case BioStateEventElementType.LocalFloat:
							{
								element = ReadEventElementLocalFloat();

								break;
							}
						case BioStateEventElementType.LocalInt:
							{
								element = ReadEventElementLocalInt();

								break;
							}
						case BioStateEventElementType.Substate:
							{
								element = ReadEventElementSubstate();

								break;
							}
						default:
							{
								throw new ArgumentOutOfRangeException();
							}
					}

					stateEvent.Elements.Add(element);
				}

				return stateEvent;
			}
			public void Write(BioStateEvent stateEvent)
			{
				if (stateEvent == null)
				{
					throw new ArgumentNullException(nameof(stateEvent));
				}

				//
				Write(stateEvent.InstanceVersion);

				//
				Write(stateEvent.Elements.Count);

				foreach (var element in stateEvent.Elements)
				{
					Write((int)element.ElementType);

					switch (element.ElementType)
					{
						case BioStateEventElementType.Bool:
							{
								Write(element as BioStateEventElementBool);

								break;
							}
						case BioStateEventElementType.Consequence:
							{
								Write(element as BioStateEventElementConsequence);

								break;
							}
						case BioStateEventElementType.Float:
							{
								Write(element as BioStateEventElementFloat);

								break;
							}
						case BioStateEventElementType.Function:
							{
								Write(element as BioStateEventElementFunction);

								break;
							}
						case BioStateEventElementType.Int:
							{
								Write(element as BioStateEventElementInt);

								break;
							}
						case BioStateEventElementType.LocalBool:
							{
								Write(element as BioStateEventElementLocalBool);

								break;
							}
						case BioStateEventElementType.LocalFloat:
							{
								Write(element as BioStateEventElementLocalFloat);

								break;
							}
						case BioStateEventElementType.LocalInt:
							{
								Write(element as BioStateEventElementLocalInt);

								break;
							}
						case BioStateEventElementType.Substate:
							{
								Write(element as BioStateEventElementSubstate);

								break;
							}
						default:
							{
								throw new ArgumentOutOfRangeException();
							}
					}
				}
			}
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="other"></param>
        public BioStateEvent(BioStateEvent other)
            : base(other)
        {
            Elements = new List <BioStateEventElement>();

            if (other.Elements == null)
            {
                return;
            }

            foreach (var element in other.Elements)
            {
                switch (element.ElementType)
                {
                case BioStateEventElementType.Bool:
                {
                    Elements.Add(new BioStateEventElementBool(element as BioStateEventElementBool));

                    break;
                }

                case BioStateEventElementType.Consequence:
                {
                    Elements.Add(new BioStateEventElementConsequence(element as BioStateEventElementConsequence));

                    break;
                }

                case BioStateEventElementType.Float:
                {
                    Elements.Add(new BioStateEventElementFloat(element as BioStateEventElementFloat));

                    break;
                }

                case BioStateEventElementType.Function:
                {
                    Elements.Add(new BioStateEventElementFunction(element as BioStateEventElementFunction));

                    break;
                }

                case BioStateEventElementType.Int:
                {
                    Elements.Add(new BioStateEventElementInt(element as BioStateEventElementInt));

                    break;
                }

                case BioStateEventElementType.LocalBool:
                {
                    Elements.Add(new BioStateEventElementLocalBool(element as BioStateEventElementLocalBool));

                    break;
                }

                case BioStateEventElementType.LocalFloat:
                {
                    Elements.Add(new BioStateEventElementLocalFloat(element as BioStateEventElementLocalFloat));

                    break;
                }

                case BioStateEventElementType.LocalInt:
                {
                    Elements.Add(new BioStateEventElementLocalInt(element as BioStateEventElementLocalInt));

                    break;
                }

                case BioStateEventElementType.Substate:
                {
                    Elements.Add(new BioStateEventElementSubstate(element as BioStateEventElementSubstate));

                    break;
                }
                }
            }
        }
            public void Write(BioStateEvent stateEvent)
            {
                if (stateEvent == null)
                {
                    throw new ArgumentNullException(nameof(stateEvent));
                }

                //
                Write(stateEvent.InstanceVersion);

                //
                Write(stateEvent.Elements.Count);

                foreach (var element in stateEvent.Elements)
                {
                    Write((int)element.ElementType);

                    switch (element.ElementType)
                    {
                    case BioStateEventElementType.Bool:
                    {
                        Write(element as BioStateEventElementBool);

                        break;
                    }

                    case BioStateEventElementType.Consequence:
                    {
                        Write(element as BioStateEventElementConsequence);

                        break;
                    }

                    case BioStateEventElementType.Float:
                    {
                        Write(element as BioStateEventElementFloat);

                        break;
                    }

                    case BioStateEventElementType.Function:
                    {
                        Write(element as BioStateEventElementFunction);

                        break;
                    }

                    case BioStateEventElementType.Int:
                    {
                        Write(element as BioStateEventElementInt);

                        break;
                    }

                    case BioStateEventElementType.LocalBool:
                    {
                        Write(element as BioStateEventElementLocalBool);

                        break;
                    }

                    case BioStateEventElementType.LocalFloat:
                    {
                        Write(element as BioStateEventElementLocalFloat);

                        break;
                    }

                    case BioStateEventElementType.LocalInt:
                    {
                        Write(element as BioStateEventElementLocalInt);

                        break;
                    }

                    case BioStateEventElementType.Substate:
                    {
                        Write(element as BioStateEventElementSubstate);

                        break;
                    }

                    default:
                    {
                        throw new ArgumentOutOfRangeException();
                    }
                    }
                }
            }
            public BioStateEvent ReadStateEvent()
            {
                var stateEvent = new BioStateEvent
                {
                    InstanceVersion = ReadInt32()
                };

                var eventElementsCount = ReadInt32();

                stateEvent.Elements = new List <BioStateEventElement>();

                for (var i = 0; i < eventElementsCount; i++)
                {
                    var elementType = (BioStateEventElementType)ReadInt32();
                    BioStateEventElement element;

                    switch (elementType)
                    {
                    case BioStateEventElementType.Bool:
                    {
                        element = ReadEventElementBool();

                        break;
                    }

                    case BioStateEventElementType.Consequence:
                    {
                        element = ReadEventElementConsequence();

                        break;
                    }

                    case BioStateEventElementType.Float:
                    {
                        element = ReadEventElementFloat();

                        break;
                    }

                    case BioStateEventElementType.Function:
                    {
                        element = ReadEventElementFunction();

                        break;
                    }

                    case BioStateEventElementType.Int:
                    {
                        element = ReadEventElementInt();

                        break;
                    }

                    case BioStateEventElementType.LocalBool:
                    {
                        element = ReadEventElementLocalBool();

                        break;
                    }

                    case BioStateEventElementType.LocalFloat:
                    {
                        element = ReadEventElementLocalFloat();

                        break;
                    }

                    case BioStateEventElementType.LocalInt:
                    {
                        element = ReadEventElementLocalInt();

                        break;
                    }

                    case BioStateEventElementType.Substate:
                    {
                        element = ReadEventElementSubstate();

                        break;
                    }

                    default:
                    {
                        throw new ArgumentOutOfRangeException();
                    }
                    }

                    stateEvent.Elements.Add(element);
                }

                return(stateEvent);
            }