/**
         * <summary>Attempts to add the MechanicQuery specified by toAdd to the file MechanicQueryFilePath</summary>
         * <param name="toAdd">Mechanic Query to add</param>
         */
        public override bool AddData(MechanicQuery toAdd)
        {
            DataContractJsonSerializer querySerializer = new DataContractJsonSerializer(
                typeof(List <MechanicQuery>)
                );
            List <MechanicQuery> retList = LoadMechanicQueries();

            retList.Add(toAdd);

            MemoryStream streamOut = new MemoryStream();

            try
            {
                querySerializer.WriteObject(streamOut, retList);
            } catch (SerializationException)
            {
                return(false);
            }
            BitWriter writerOut = new BitWriter(
                new FileStream(MechanicQueryFilePath, FileMode.Create, FileAccess.Write)
                );

            streamOut = new MemoryStream(streamOut.ToArray());
            AnsBlockEncoder encoder = new AnsBlockEncoder(1048576, writerOut);

            encoder.EncodeStream(streamOut, 8);
            writerOut.Flush();
            writerOut.Close();
            return(true);
        }
Example #2
0
        // override object.Equals
        public override bool Equals(object obj)
        {
            //
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //

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

            MechanicQuery other = obj as MechanicQuery;

            if (Make != other.Make)
            {
                return(false);
            }
            if (Model != other.Model)
            {
                return(false);
            }
            if (Vin != other.Vin)
            {
                return(false);
            }
            if (Complaint != other.Complaint)
            {
                return(false);
            }
            return(Problem == other.Problem);
        }
Example #3
0
 public abstract bool AddData(MechanicQuery toAdd);