Exemple #1
0
 public SystemMapFile(PSObject value, FileMap map) : base(value, map)
 {
 }
Exemple #2
0
        internal static FileMap MakeMap(ref Meta[] metas, object[] columns)
        {
            // pass 1: get metas and types and pre-process only specified default types
            if (metas == null)
            {
                metas = SetupColumns(columns);
            }
            else
            {
                SetupMetas(metas);
            }

            // pass 2: process all, use still available default column types
            var map = new FileMap();

            foreach (Meta meta in metas)
            {
                // type -> map:
                switch (meta.Kind[0])
                {
                case 'N':
                    map.Name = meta;
                    break;

                case 'O':
                    map.Owner = meta;
                    break;

                case 'Z':
                    map.Description = meta;
                    break;

                case 'C':
                    map.Columns.Add(meta);
                    break;

                case 'S':
                {
                    if (map.Length != null)
                    {
                        throw new InvalidOperationException("Column 'S' is used twice.");
                    }
                    map.Length = meta;
                }
                break;

                case 'D':
                {
                    if (meta.Kind.Length < 2)
                    {
                        throw new InvalidOperationException(Res.InvalidColumnKind + "D");
                    }

                    switch (meta.Kind[1])
                    {
                    case 'C':
                    {
                        if (map.CreationTime != null)
                        {
                            throw new InvalidOperationException("Column 'DC' is used twice.");
                        }

                        map.CreationTime = meta;
                    }
                    break;

                    case 'M':
                    {
                        if (map.LastWriteTime != null)
                        {
                            throw new InvalidOperationException("Column 'DM' is used twice.");
                        }

                        map.LastWriteTime = meta;
                    }
                    break;

                    case 'A':
                    {
                        if (map.LastAccessTime != null)
                        {
                            throw new InvalidOperationException("Column 'DA' is used twice.");
                        }

                        map.LastAccessTime = meta;
                    }
                    break;

                    default:
                        throw new InvalidOperationException(Res.InvalidColumnKind + meta.Kind);
                    }
                }
                break;

                default:
                    throw new InvalidOperationException("Unknown column type: " + meta.Kind);
                }
            }

            return(map);
        }
Exemple #3
0
 public MapFile(PSObject value, FileMap map)
 {
     Value = value;
     Map   = map;
 }
Exemple #4
0
        internal static FileMap MakeMap(ref Meta[] metas, object[] columns)
        {
            // pass 1: get metas and types and pre-process only specified default types
            if (metas == null)
                metas = SetupColumns(columns);
            else
                SetupMetas(metas);

            // pass 2: process all, use still available default column types
            var map = new FileMap();
            foreach (Meta meta in metas)
            {
                // type -> map:
                switch (meta.Kind[0])
                {
                    case 'N':
                        map.Name = meta;
                        break;
                    case 'O':
                        map.Owner = meta;
                        break;
                    case 'Z':
                        map.Description = meta;
                        break;
                    case 'C':
                        map.Columns.Add(meta);
                        break;
                    case 'S':
                        {
                            if (map.Length != null)
                                throw new InvalidOperationException("Column 'S' is used twice.");
                            map.Length = meta;
                        }
                        break;
                    case 'D':
                        {
                            if (meta.Kind.Length < 2)
                                throw new InvalidOperationException(Res.InvalidColumnKind + "D");

                            switch (meta.Kind[1])
                            {
                                case 'C':
                                    {
                                        if (map.CreationTime != null)
                                            throw new InvalidOperationException("Column 'DC' is used twice.");

                                        map.CreationTime = meta;
                                    }
                                    break;
                                case 'M':
                                    {
                                        if (map.LastWriteTime != null)
                                            throw new InvalidOperationException("Column 'DM' is used twice.");

                                        map.LastWriteTime = meta;
                                    }
                                    break;
                                case 'A':
                                    {
                                        if (map.LastAccessTime != null)
                                            throw new InvalidOperationException("Column 'DA' is used twice.");

                                        map.LastAccessTime = meta;
                                    }
                                    break;
                                default:
                                    throw new InvalidOperationException(Res.InvalidColumnKind + meta.Kind);
                            }
                        }
                        break;
                    default:
                        throw new InvalidOperationException("Unknown column type: " + meta.Kind);
                }
            }

            return map;
        }