Exemple #1
0
        public static void Open(IEnumerable <DataType> datas, int count)
        {
            IndexedModel <DataType> .Close();

            IndexedModel <DataType> .IsOpened = true;
#if LOG_DEBUG
            ClosableDebugger.Open(CLASSNAME);
#endif// LOG_DEBUG
            ModelDisposer.Regist(typeof(IndexedModel <DataType>), IndexedModel <DataType> .Close);

            var array = IndexedModel <DataType> .array = new DataType[count];
            try
            {
                if (null == datas)
                {
                    throw new NullReferenceException("datas is null");
                }

                var enumerator = datas.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var data = enumerator.Current;

                    if (null == data)
                    {
                        throw new NullReferenceException("data(element) is null");
                    }

                    var index = data.Index;

                    if (index < 0 || array.Length <= index)
                    {
                        throw new ArgumentException(string.Format("invalid data(element).index:{0}, count:{1}, data(element):{2}", index, count, data));
                    }

                    if (null != array[index])
                    {
                        throw new ArgumentException(string.Format("duplicated data(element).index:{0}, count:{1}, data(element):{2}, prev_data(element):{3}", index, count, data, array[index]));
                    }

                    array[index] = data;
                }
            }
            catch (Exception e)
            {
                string         args = string.Format("{0}, {1}", ModelException.ToStringOrNull(datas), count);
                ModelException me   = new ModelException(CLASSNAME, "Open", args, e);

                if (null != ModelException.ExceptHandler)
                {
                    ModelException.ExceptHandler(me);
                }
                else
                {
                    throw me;
                }
            }
        }
        public static void Open(int collectionCount = 1)
        {
            SequentialModel <DataType> .Close();

            SequentialModel <DataType> .IsOpened = true;
#if LOG_DEBUG
            ClosableDebugger.Open(CLASSNAME);
#endif// LOG_DEBUG
            ModelDisposer.Regist(typeof(SequentialModel <DataType>), SequentialModel <DataType> .Close);

            var colls = SequentialModel <DataType> .collections = new Collection[collectionCount];
            for (int n = 0, cnt = colls.Length; n < cnt; ++n)
            {
                colls[n] = new Collection(n);
            }
        }
Exemple #3
0
        public static void Close()
        {
            if (IndexedModel <DataType> .IsOpened)
            {
                IndexedModel <DataType> .IsOpened = false;
#if LOG_DEBUG
                ClosableDebugger.Close(CLASSNAME);
#endif// LOG_DEBUG
                if (!ModelDisposer.IsWork)
                {
                    ModelDisposer.Unregist(typeof(IndexedModel <DataType>));
                }

                IndexedModel <DataType> .array = null;
            }
        }
Exemple #4
0
        public static void Open(GetKeyCallback getKey, IEnumerable <DataType> datas = null)
        {
            Model <KeyType, DataType> .Close();

            Model <KeyType, DataType> .IsOpened = true;
#if LOG_DEBUG
            ClosableDebugger.Open(CLASSNAME);
#endif// LOG_DEBUG
            ModelDisposer.Regist(typeof(Model <KeyType, DataType>), Model <KeyType, DataType> .Close);

            Model <KeyType, DataType> .GetKey = getKey;

            if (null != datas)
            {
                Model <KeyType, DataType> .AddRange(datas);
            }
        }
Exemple #5
0
        public static void Close()
        {
            if (Model <KeyType, DataType> .IsOpened)
            {
                Model <KeyType, DataType> .IsOpened = false;
#if LOG_DEBUG
                ClosableDebugger.Close(CLASSNAME);
#endif// LOG_DEBUG
                if (!ModelDisposer.IsWork)
                {
                    ModelDisposer.Unregist(typeof(Model <KeyType, DataType>));
                }

                Model <KeyType, DataType> .Clear();

                Model <KeyType, DataType> .UnregistUpdateCallbackAll();

                Model <KeyType, DataType> .GetKey = null;
                Model <KeyType, DataType> .map.Clear();
            }
        }
        public static void Close()
        {
            if (SequentialModel <DataType> .IsOpened)
            {
                SequentialModel <DataType> .IsOpened = false;
#if LOG_DEBUG
                ClosableDebugger.Close(CLASSNAME);
#endif// LOG_DEBUG
                if (!ModelDisposer.IsWork)
                {
                    ModelDisposer.Unregist(typeof(SequentialModel <DataType>));
                }

                var colls = SequentialModel <DataType> .collections;
                SequentialModel <DataType> .collections = null;

                for (int n = 0, cnt = colls.Length; n < cnt; ++n)
                {
                    colls[n].__InternalAccessList().Clear();
                }
            }
        }