Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttributeTempFile"/> class.
 /// </summary>
 /// <param name="tempPath">
 /// The temp path.
 /// </param>
 /// <param name="map">
 /// The dimension position in the ARR map
 /// </param>
 /// <param name="level">
 /// The level.
 /// </param>
 public AttributeTempFile(string tempPath, GesmesKeyMap map, RelStatus level)
 {
     string filePath = Path.Combine(tempPath, Path.GetRandomFileName());
     this._fileStream = File.Create(filePath, BufferSize, FileOptions.DeleteOnClose | FileOptions.SequentialScan);
     this._writer = new GesmesAttributeGroupWriter(this._fileStream);
     this._currentGroup = new GesmesAttributeGroup(map, level);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="GesmesAttributeGroup"/> class.
        /// </summary>
        /// <param name="map">
        /// The map.
        /// </param>
        /// <param name="level">
        /// The attachment level 
        /// </param>
        public GesmesAttributeGroup(GesmesKeyMap map, RelStatus level)
        {
            this._map = map;
            switch (level)
            {
                case RelStatus.None:
                    throw new ArgumentException(Resources.ErrorInvalidAttachmentLevel, "level");
                case RelStatus.DataSet:

                    // no dimension
                    this._dimensionValues = new string[0];
                    this._level = AttachmentLevel.DataSet;
                    break;
                case RelStatus.Sibling:

                    // all dimensions. FREQ is wildcarded
                    this._dimensionValues = new string[map.Count];
                    this._dimensionValues[0] = string.Empty;
                    this._firstDimension = 1;
                    this._level = AttachmentLevel.Group;
                    break;
                case RelStatus.Series:

                    // all dimensions
                    this._dimensionValues = new string[map.Count];
                    this._level = AttachmentLevel.Series;
                    break;
                case RelStatus.Observation:

                    // all dimensions plus time period and time format
                    this._dimensionValues = new string[map.Count + 2];
                    this._timePeriodPosition = map.Count;
                    this._timeFormatPosition = this._timePeriodPosition + 1;
                    this._level = AttachmentLevel.Observation;
                    break;
            }
        }
        /// <summary>
        /// Create a <see cref="AttributeTempFile"/> if <paramref name="targetLevel"/> in <paramref name="levels"/>
        /// </summary>
        /// <param name="levels">
        /// The available levels
        /// </param>
        /// <param name="targetLevel">
        /// The target level
        /// </param>
        /// <returns>
        /// a <see cref="AttributeTempFile"/> if <paramref name="targetLevel"/> in <paramref name="levels"/> ; otherwise null
        /// </returns>
        private AttributeTempFile CreateTempStream(RelStatus levels, RelStatus targetLevel)
        {
            if ((levels & targetLevel) == targetLevel)
            {
                return new AttributeTempFile(this._tempPath, this._map, targetLevel);
            }

            return null;
        }