private void SerializeHeader(IStepWriter writer, IList<StepDataObject> header){
     if(writer == null) throw new ArgumentNullException("writer");
     if(header == null) throw new ArgumentNullException("header");
     
     writer.WriteStartHeader();
     foreach(StepDataObject sdo in header)
         SerializeObject( writer, sdo );
     writer.WriteEndSection();
 }
 public void Serialize(IStepWriter writer, StepFile step){
     if(writer == null) throw new ArgumentNullException("writer");
     if(step == null) throw new ArgumentNullException("step");
     
     writer.WriteStartStep();
     SerializeHeader(writer, step.Header);
     SerializeData(writer, step.Data);
     writer.WriteEndStep();
 }
 private void SerializeData(IStepWriter writer, IDictionary<int, StepDataObject> data){
     if(writer == null) throw new ArgumentNullException("writer");
     if(data == null) throw new ArgumentNullException("data");
     
     writer.WriteStartData();
     foreach(KeyValuePair<int, StepDataObject> kvp in data){
         SerializeEntity( writer, kvp.Key, kvp.Value );
     }
     writer.WriteEndSection();
 }
Exemple #4
0
        private void SerializeEntity(IStepWriter writer, int entityId, StepDataObject sdo)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (sdo == null)
            {
                throw new ArgumentNullException("sdo");
            }

            writer.WriteLineIdentifier(entityId);
            SerializeObject(writer, sdo);
        }
Exemple #5
0
        public void Serialize(IStepWriter writer, StepFile step)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (step == null)
            {
                throw new ArgumentNullException("step");
            }

            writer.WriteStartStep();
            SerializeHeader(writer, step.Header);
            SerializeData(writer, step.Data);
            writer.WriteEndStep();
        }
Exemple #6
0
 private void SerializeArray(IStepWriter writer, IList <StepValue> items)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (items == null)
     {
         throw new ArgumentNullException("items");
     }
     writer.WriteStartArray();
     foreach (StepValue sv in items)
     {
         SerializeProperty(writer, sv);
     }
     writer.WriteEndArray();
 }
Exemple #7
0
        private void SerializeData(IStepWriter writer, IDictionary <int, StepDataObject> data)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            writer.WriteStartData();
            foreach (KeyValuePair <int, StepDataObject> kvp in data)
            {
                SerializeEntity(writer, kvp.Key, kvp.Value);
            }
            writer.WriteEndSection();
        }
Exemple #8
0
        private void SerializeHeader(IStepWriter writer, IList <StepDataObject> header)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (header == null)
            {
                throw new ArgumentNullException("header");
            }

            writer.WriteStartHeader();
            foreach (StepDataObject sdo in header)
            {
                SerializeObject(writer, sdo);
            }
            writer.WriteEndSection();
        }
Exemple #9
0
        /// <summary>
        /// Serializes an iso_10303 object into STEP format, writing the data to the given StepWriter
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="iso10303"></param>
        public void Serialize(IStepWriter writer, iso_10303 iso10303)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (iso10303 == null)
            {
                throw new ArgumentNullException("iso10303");
            }

            this._internalSerializer = new StepParser.Serialization.StepSerializer();
            this._extractor          = new StepObjectExtractor();

            //Convert from iso_10303 to StepDataObjects
            StepFile stepFile = this._extractor.Extract(iso10303);

            //use the InternalStepSerializer to write StepDataObjects to the StepWriter
            this._internalSerializer.Serialize(writer, stepFile);
        }
Exemple #10
0
        private void SerializeObject(IStepWriter writer, StepDataObject sdo)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (sdo == null)
            {
                throw new ArgumentNullException("sdo");
            }

            if (String.IsNullOrEmpty(sdo.ObjectName))
            {
                throw new ArgumentNullException("sdo.ObjectName");
            }
            writer.WriteObjectName(sdo.ObjectName);
            writer.WriteStartObject();
            foreach (StepValue sv in sdo.Properties)
            {
                SerializeProperty(writer, sv);
            }
            writer.WriteEndObject();
        }
Exemple #11
0
 private void SerializeObject(IStepWriter writer, StepDataObject sdo ){
     if( writer == null ) throw new ArgumentNullException("writer");
     if(sdo == null ) throw new ArgumentNullException("sdo");
     
     if(String.IsNullOrEmpty( sdo.ObjectName )) throw new ArgumentNullException("sdo.ObjectName");
     writer.WriteObjectName( sdo.ObjectName );
     writer.WriteStartObject();
     foreach(StepValue sv in sdo.Properties){
         SerializeProperty(writer, sv);
     }
     writer.WriteEndObject();
 }
Exemple #12
0
 private void SerializeEntity( IStepWriter writer, int entityId, StepDataObject sdo ){
     if( writer == null ) throw new ArgumentNullException("writer");
     if( sdo == null ) throw new ArgumentNullException( "sdo" );
     
     writer.WriteLineIdentifier( entityId );
     SerializeObject( writer, sdo );
 }
Exemple #13
0
 private void SerializeArray( IStepWriter writer, IList<StepValue> items ){
     if(writer == null) throw new ArgumentNullException("writer");
     if(items == null ) throw new ArgumentNullException("items");
     writer.WriteStartArray();
     foreach(StepValue sv in items){
         SerializeProperty( writer, sv );
     }
     writer.WriteEndArray();
 }
Exemple #14
0
 private void SerializeProperty( IStepWriter writer, StepValue sv){
     if(writer == null) throw new ArgumentNullException("writer");
     
     switch(sv.Token){
         case StepToken.StartArray:
             //TODO assert that sv.ValueType.Equals(typeof(IList<StepValue>)
             SerializeArray( writer, sv.Value as List<StepValue> );
             break;
         case StepToken.Overridden:
             writer.WriteOverridden();
             break;
         case StepToken.Enumeration:
             writer.WriteEnum((string)sv.Value);
             break;
         case StepToken.String:
             writer.WriteValue((string)sv.Value);
             break;
         case StepToken.Integer:
             switch(sv.ValueType.ToString()){
                 case "System.Int16":
                     writer.WriteValue((System.Int16)sv.Value);
                     break;
                 case "System.Int32":
                     writer.WriteValue((System.Int32)sv.Value);
                     break;
                 case "System.Int64":
                     writer.WriteValue((System.Int64)sv.Value);
                     break;
                 default:
                     throw new StepSerializerException("SerializeProperty(StepWriter, StepValue) has a StepValue of token type Integer, but the ValueType is not an integer");
             }
             break;
         case StepToken.Float:
             writer.WriteValue((double)sv.Value);
             break;
         case StepToken.Boolean:
             writer.WriteBool((bool)sv.Value);
             break;
         case StepToken.Date:
             writer.WriteValue(((DateTime)sv.Value).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
             break;
         case StepToken.Null:
             writer.WriteNull();
             break;
         case StepToken.LineReference:
             writer.WriteLineReference( (int)sv.Value );
             break;
         case StepToken.StartEntity:
             logger.Debug("StartEntity : " + ((StepDataObject)sv.Value).ObjectName);
             SerializeObject(writer, (StepDataObject)sv.Value);
             break;
         default:
             throw new NotImplementedException(String.Format(CultureInfo.InvariantCulture,
                                                             "SerializeProperty(StepValue) cannot, yet, handle token {0}",
                                                             sv.Token.ToString()));
     }
 }
Exemple #15
0
        private void SerializeProperty(IStepWriter writer, StepValue sv)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            switch (sv.Token)
            {
            case StepToken.StartArray:
                //TODO assert that sv.ValueType.Equals(typeof(IList<StepValue>)
                SerializeArray(writer, sv.Value as List <StepValue>);
                break;

            case StepToken.Overridden:
                writer.WriteOverridden();
                break;

            case StepToken.Enumeration:
                writer.WriteEnum((string)sv.Value);
                break;

            case StepToken.String:
                writer.WriteValue((string)sv.Value);
                break;

            case StepToken.Integer:
                switch (sv.ValueType.ToString())
                {
                case "System.Int16":
                    writer.WriteValue((System.Int16)sv.Value);
                    break;

                case "System.Int32":
                    writer.WriteValue((System.Int32)sv.Value);
                    break;

                case "System.Int64":
                    writer.WriteValue((System.Int64)sv.Value);
                    break;

                default:
                    throw new StepSerializerException("SerializeProperty(StepWriter, StepValue) has a StepValue of token type Integer, but the ValueType is not an integer");
                }
                break;

            case StepToken.Float:
                writer.WriteValue((double)sv.Value);
                break;

            case StepToken.Boolean:
                writer.WriteBool((bool)sv.Value);
                break;

            case StepToken.Date:
                writer.WriteValue(((DateTime)sv.Value).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
                break;

            case StepToken.Null:
                writer.WriteNull();
                break;

            case StepToken.LineReference:
                writer.WriteLineReference((int)sv.Value);
                break;

            case StepToken.StartEntity:
                logger.Debug("StartEntity : " + ((StepDataObject)sv.Value).ObjectName);
                SerializeObject(writer, (StepDataObject)sv.Value);
                break;

            default:
                throw new NotImplementedException(String.Format(CultureInfo.InvariantCulture,
                                                                "SerializeProperty(StepValue) cannot, yet, handle token {0}",
                                                                sv.Token.ToString()));
            }
        }
 /// <summary>
 /// Serializes an iso_10303 object into STEP format, writing the data to the given StepWriter
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="iso10303"></param>
 public void Serialize(IStepWriter writer, iso_10303 iso10303){
     if(writer == null)
         throw new ArgumentNullException("writer");
     if(iso10303 == null)
         throw new ArgumentNullException("iso10303");
     
     this._internalSerializer = new StepParser.Serialization.StepSerializer();
     this._extractor = new StepObjectExtractor();
     
     //Convert from iso_10303 to StepDataObjects
     StepFile stepFile = this._extractor.Extract( iso10303 );
     //use the InternalStepSerializer to write StepDataObjects to the StepWriter
     this._internalSerializer.Serialize(writer, stepFile );
 }