Example #1
0
 protected override void ProcessRecord()
 {
     if (!(this.specifiedPath ^ this.isLiteralPath))
     {
         InvalidOperationException exception = new InvalidOperationException(CsvCommandStrings.CannotSpecifyPathAndLiteralPath);
         ErrorRecord errorRecord = new ErrorRecord(exception, "CannotSpecifyPathAndLiteralPath", ErrorCategory.InvalidData, null);
         base.ThrowTerminatingError(errorRecord);
     }
     if (this._paths != null)
     {
         foreach (string str in this._paths)
         {
             using (StreamReader reader = PathUtils.OpenStreamReader(this, str, this.Encoding, this.isLiteralPath))
             {
                 ImportCsvHelper helper = new ImportCsvHelper(this, this._delimiter, this._header, null, reader);
                 try
                 {
                     helper.Import(ref this._alreadyWarnedUnspecifiedNames);
                 }
                 catch (ExtendedTypeSystemException exception2)
                 {
                     ErrorRecord record2 = new ErrorRecord(exception2, "AlreadyPresentPSMemberInfoInternalCollectionAdd", ErrorCategory.NotSpecified, null);
                     base.ThrowTerminatingError(record2);
                 }
             }
         }
     }
 }
Example #2
0
 protected override void ProcessRecord()
 {
     foreach (PSObject obj2 in this._object)
     {
         using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(obj2.ToString())))
         {
             using (StreamReader reader = new StreamReader(stream, Encoding.Unicode))
             {
                 ImportCsvHelper helper = new ImportCsvHelper(this, this._delimiter, this._header, this._typeName, reader);
                 try
                 {
                     helper.Import(ref this._alreadyWarnedUnspecifiedNames);
                 }
                 catch (ExtendedTypeSystemException exception)
                 {
                     ErrorRecord errorRecord = new ErrorRecord(exception, "AlreadyPresentPSMemberInfoInternalCollectionAdd", ErrorCategory.NotSpecified, null);
                     base.ThrowTerminatingError(errorRecord);
                 }
                 if ((this._header == null) && (helper.Header != null))
                 {
                     this._header = helper.Header.ToArray<string>();
                 }
                 if ((this._typeName == null) && (helper.TypeName != null))
                 {
                     this._typeName = helper.TypeName;
                 }
             }
         }
     }
 }
 protected override void ProcessRecord()
 {
     foreach (PSObject obj2 in this._object)
     {
         using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(obj2.ToString())))
         {
             using (StreamReader reader = new StreamReader(stream, Encoding.Unicode))
             {
                 ImportCsvHelper helper = new ImportCsvHelper(this, this._delimiter, this._header, this._typeName, reader);
                 try
                 {
                     helper.Import(ref this._alreadyWarnedUnspecifiedNames);
                 }
                 catch (ExtendedTypeSystemException exception)
                 {
                     ErrorRecord errorRecord = new ErrorRecord(exception, "AlreadyPresentPSMemberInfoInternalCollectionAdd", ErrorCategory.NotSpecified, null);
                     base.ThrowTerminatingError(errorRecord);
                 }
                 if ((this._header == null) && (helper.Header != null))
                 {
                     this._header = helper.Header.ToArray <string>();
                 }
                 if ((this._typeName == null) && (helper.TypeName != null))
                 {
                     this._typeName = helper.TypeName;
                 }
             }
         }
     }
 }
Example #4
0
 protected override void ProcessRecord()
 {
     if (!(this.specifiedPath ^ this.isLiteralPath))
     {
         InvalidOperationException exception = new InvalidOperationException(CsvCommandStrings.CannotSpecifyPathAndLiteralPath);
         ErrorRecord errorRecord             = new ErrorRecord(exception, "CannotSpecifyPathAndLiteralPath", ErrorCategory.InvalidData, null);
         base.ThrowTerminatingError(errorRecord);
     }
     if (this._paths != null)
     {
         foreach (string str in this._paths)
         {
             using (StreamReader reader = PathUtils.OpenStreamReader(this, str, this.Encoding, this.isLiteralPath))
             {
                 ImportCsvHelper helper = new ImportCsvHelper(this, this._delimiter, this._header, null, reader);
                 try
                 {
                     helper.Import(ref this._alreadyWarnedUnspecifiedNames);
                 }
                 catch (ExtendedTypeSystemException exception2)
                 {
                     ErrorRecord record2 = new ErrorRecord(exception2, "AlreadyPresentPSMemberInfoInternalCollectionAdd", ErrorCategory.NotSpecified, null);
                     base.ThrowTerminatingError(record2);
                 }
             }
         }
     }
 }
Example #5
0
        ProcessRecord()
        {
            foreach (PSObject pObject in InputObject)
            {
                using (MemoryStream memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(pObject.ToString())))
                using (StreamReader streamReader = new StreamReader(memoryStream, System.Text.Encoding.Unicode))
                {
                    ImportCsvHelper helper = new ImportCsvHelper(this, Delimiter, Header, _typeName, streamReader);

                    try
                    {
                        helper.Import(ref _alreadyWarnedUnspecifiedNames);
                    }
                    catch (ExtendedTypeSystemException exception)
                    {
                        ErrorRecord errorRecord = new ErrorRecord(exception, "AlreadyPresentPSMemberInfoInternalCollectionAdd", ErrorCategory.NotSpecified, null);
                        this.ThrowTerminatingError(errorRecord);
                    }

                    if ((Header == null) && (helper.Header != null))
                    {
                        Header = helper.Header.ToArray();
                    }
                    if ((_typeName == null) && (helper.TypeName != null))
                    {
                        _typeName = helper.TypeName;
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// ProcessRecord overload
        /// </summary>
        protected override void ProcessRecord()
        {
            // Validate that they don't provide both Path and LiteralPath, but have provided at least one.
            if (!(_specifiedPath ^ _isLiteralPath))
            {
                InvalidOperationException exception = new InvalidOperationException(CsvCommandStrings.CannotSpecifyPathAndLiteralPath);
                ErrorRecord errorRecord = new ErrorRecord(exception, "CannotSpecifyPathAndLiteralPath", ErrorCategory.InvalidData, null);
                this.ThrowTerminatingError(errorRecord);
            }

            if (_paths != null)
            {
                foreach (string path in _paths)
                {
                    using (StreamReader streamReader = PathUtils.OpenStreamReader(this, path, this.Encoding, _isLiteralPath))
                    {
                        ImportCsvHelper helper = new ImportCsvHelper(this, Delimiter, Header, null /* typeName */, streamReader);

                        try
                        {
                            helper.Import(ref _alreadyWarnedUnspecifiedNames);
                        }
                        catch (ExtendedTypeSystemException exception)
                        {
                            ErrorRecord errorRecord = new ErrorRecord(exception, "AlreadyPresentPSMemberInfoInternalCollectionAdd", ErrorCategory.NotSpecified, null);
                            this.ThrowTerminatingError(errorRecord);
                        }
                    }
                }
            }//if
        }////ProcessRecord