Esempio n. 1
0
 public bool compatible(BDFHeader header)
 {
     if (!(LocalSubject.Equals(header.LocalSubject)))
     {
         return(false);
     }
     if (!(LocalRecording.Equals(header.LocalRecording)))
     {
         return(false);
     }
     if (!(DataFormat.Equals(header.DataFormat)))
     {
         return(false);
     }
     if (ChannelCount != header.ChannelCount)
     {
         return(false);
     }
     for (int i = 0; i < ChannelCount; i++)
     {
         if (!(ChannelHeaders[i].Equals(header.ChannelHeaders[i])))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null)
            {
                return(false);
            }

            if (GetType() != obj.GetType())
            {
                return(false);
            }

            ConcurrentDependencyGraph other = (ConcurrentDependencyGraph)obj;

            if (DataFormat == null)
            {
                if (other.DataFormat != null)
                {
                    return(false);
                }
            }
            else if (!DataFormat.Equals(other.DataFormat))
            {
                return(false);
            }

            return(Arrays.Equals(nodes, other.nodes));
        }
Esempio n. 3
0
        }// end WriteToFile method

        public static bool ReadFile(string path, DataFormat dataFormat, out object data)
        {
            data = null;

            try
            {
                var file = new FileStream(path, FileMode.Open,
                                          FileAccess.Read);
                if (dataFormat.Equals(DataFormat.Binary))
                {
                    #region Binary Reader

                    var reader = new BinaryReader(file);
                    int length = (int)reader.BaseStream.Length;

                    //read all data into an array
                    byte[] binaryData = new byte[length];
                    reader.Read(binaryData, 0, length);

                    reader.Close();
                    file.Close();

                    data = binaryData;

                    #endregion
                }
                else if (dataFormat.Equals(DataFormat.Text))
                {
                    #region Stream Reader

                    StreamReader reader = new StreamReader(file);
                    data = reader.ReadToEnd();
                    reader.Close();
                    file.Close();

                    #endregion
                }


                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 4
0
        public static bool WriteToFile(string path, DataFormat dataFormat, object data)
        {
            try
            {
                var file = new FileStream(path, FileMode.Create, FileAccess.Write);

                if (dataFormat.Equals(DataFormat.Binary))
                {
                    #region Binary Writer

                    var writer = new BinaryWriter(file);

                    foreach (byte b in data as byte[])
                    {
                        writer.Write(b);
                    }
                    writer.Close();
                    file.Close();

                    #endregion
                }
                else if (dataFormat.Equals(DataFormat.Text))
                {
                    #region Stream Writer

                    StreamWriter writer = new StreamWriter(file);
                    writer.WriteLine(data);
                    writer.Close();
                    file.Close();

                    #endregion
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }// end WriteToFile method
Esempio n. 5
0
 public dynamic ReadBinary()
 {
     if (DataFormat.Equals(DataFormatChoices.INT_32))
     {
         return((Int32)this.io.ReadNumber(IEEEASCIIType.ASCIIType_I4, true));
     }
     else if (DataFormat.Equals(DataFormatChoices.REAL_32))
     {
         return((float)this.io.ReadNumber(IEEEASCIIType.ASCIIType_R4, true));
     }
     else if (DataFormat.Equals(DataFormatChoices.REAL_64))
     {
         return((float)this.io.ReadNumber(IEEEASCIIType.ASCIIType_R8, true));
     }
     else
     {
         return((string)this.io.ReadString());
     }
 }
Esempio n. 6
0
 public dynamic ReadBlock()
 {
     if (DataFormat.Equals(DataFormatChoices.INT_32))
     {
         return((int[])this.io.ReadIEEEBlock(IEEEBinaryType.BinaryType_I4, true, true));
     }
     else if (DataFormat.Equals(DataFormatChoices.REAL_32))
     {
         return((float[])this.io.ReadIEEEBlock(IEEEBinaryType.BinaryType_R4, true, true));
     }
     else if (DataFormat.Equals(DataFormatChoices.REAL_64))
     {
         return((double[])this.io.ReadIEEEBlock(IEEEBinaryType.BinaryType_R8, true, true));
     }
     else
     {
         return((string)this.io.ReadString());
     }
 }