using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

using CategoryTheory;

namespace DataPerformer
{
    [Serializable()]
    public class RandomGenerator : ISerializable, ICategoryObject, IMeasurements
    {
        #region Fields

        Random random = new Random();

        private object obj;

        private bool isUpdated;

        private IMeasure measure;

        #endregion

        #region Ctor

        public RandomGenerator()
        {
            init();
        }


        protected RandomGenerator(SerializationInfo info, StreamingContext context)
        {
            init();
        }

        #endregion


        #region ISerializable Members

        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {
        }

        #endregion

        #region ICategoryObject Members

        ICategory ICategoryObject.Category
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        ICategoryArrow ICategoryObject.Id
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        #endregion

        #region IAssociatedObject Members

        object IAssociatedObject.Object
        {
            get
            {
                return obj;
            }
            set
            {
                obj = value;
            }
        }

        #endregion

        #region IMeasurements Members

        int IMeasurements.Count
        {
            get { return 1; }
        }

        IMeasure IMeasurements.this[int n]
        {
            get { return measure; }
        }

        void IMeasurements.UpdateMeasurements()
        {
        }

        bool IMeasurements.IsUpdated
        {
            get
            {
                return isUpdated;
            }
            set
            {
                isUpdated = value;
            }
        }

        #endregion

        #region Specifc Members

        private void init()
        {
            Double a = 0;
            MeasureParameter p = getMeasure;
            measure = new Measure(a, p, "Random");
        }

        private object getMeasure()
        {
            return random.NextDouble();
        }

        #endregion
    }
}
