コード例 #1
0
        }// end:CopyStream()

        public static void WriteToByte(InstanceDB DataSet)
        {
            Stream       bstr      = File.Create(@"c:\cpd\a.cpd");
            BinaryWriter binWriter = new BinaryWriter(bstr, Encoding.ASCII);

            //for (int i = 0; i < DataSet.aDataSectionList.Count; i++)
            //{
            //DataSection aDataSection = DataSet.aDataSectionList[i];
            //for (int j = 0; j < aDataSection.DataList.Count; j++)
            //{
            //    WriteInstance(aDataSection.DataList.GetByIndex(j), binWriter, DataSet);
            //}
            foreach (KeyValuePair <uint, Instance> kvp in DataSet.DataList)
            {
                WriteInstance(kvp.Value, binWriter, DataSet);
            }
            //}
            //FileStream outfile = File.Create(@"c:\a.cpz");

            //GZipStream compress = new GZipStream(bstr, CompressionMode.Compress);
            //bstr.CopyTo(compress);
            //compress.Close();
            //outfile.Close();

            bstr.Close();
            //            ZipFile();
            //Compress(new FileInfo(@"c:\a.cpd"));
        }
コード例 #2
0
        public static void WriteSerializedInstances(InstanceDB DataSet)
        {
            Stream          str = File.Create(@"c:\cpdsample\aSerialized.bin");
            BinaryFormatter bf  = new BinaryFormatter();

            bf.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
            bf.Serialize(str, DataSet);
            str.Close();
        }
コード例 #3
0
        public static void WriteCompressedSerializedInstances(InstanceDB DataSet)
        {
            Stream          str        = File.Create(@"c:\cpdsample\CompressedSerialized.bgz");
            GZipStream      compressor = new GZipStream(str, CompressionMode.Compress);
            BinaryFormatter bf         = new BinaryFormatter();

            bf.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
            bf.Serialize(compressor, DataSet);
            compressor.Close();
            str.Close();
        }
コード例 #4
0
        public static InstanceDB ReadCompressedSerialization()
        {
            Stream          str          = File.OpenRead(@"c:\cpd\a.bgz");
            GZipStream      decompressor = new GZipStream(str, CompressionMode.Decompress);
            BinaryFormatter bf           = new BinaryFormatter();
            //P21Data aData = (P21Data)bf.Deserialize(str);
            InstanceDB aData = (InstanceDB)bf.Deserialize(decompressor);

            decompressor.Close();
            str.Close();
            return(aData);
        }
コード例 #5
0
ファイル: ParamEntity.cs プロジェクト: JackTing/ifctoolkit
 public ParamEntity(uint value, InstanceDB DataSet)
     : base(SParamType.ENTITY)
 {
     // this fucntion only works with SimpleInstance Populations
     if (DataSet.DataList.ContainsKey(value))
     { EntityInstance = DataSet.DataList[value]; }
     else
     {
         EntityInstance = new InstanceSimple(value);
         DataSet.DataList.Add((uint)value, EntityInstance);
     }
 }
コード例 #6
0
 public ParamEntity(uint value, InstanceDB DataSet)
     : base(SParamType.ENTITY)
 {
     // this fucntion only works with SimpleInstance Populations
     if (DataSet.DataList.ContainsKey(value))
     {
         EntityInstance = DataSet.DataList[value];
     }
     else
     {
         EntityInstance = new InstanceSimple(value);
         DataSet.DataList.Add((uint)value, EntityInstance);
     }
 }
コード例 #7
0
        public static void TestWriter()
        {
            var instanceDB   = new InstanceDB();
            var simpleRecord = new SimpleRecord("IFCORGANIZATION", instanceDB);

            simpleRecord.ParameterList.Add(new ParamNullValue());
            simpleRecord.ParameterList.Add(new ParamString("Georgia Tech"));
            simpleRecord.ParameterList.Add(new ParamNullValue());
            simpleRecord.ParameterList.Add(new ParamNullValue());
            simpleRecord.ParameterList.Add(new ParamNullValue());
            var instanceSimple = new InstanceSimple(10);

            instanceSimple.Record = simpleRecord;
            instanceDB.DataList.Add(instanceSimple.EntityInstanceName, instanceSimple);
        }
コード例 #8
0
        public static void WriteInstance(Instance aInstance, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
        {
            strWriter.Write('#');
            strWriter.Write(aInstance.EntityInstanceName.ToString());
            strWriter.Write('=');

            if (aInstance is InstanceSimple)
            {
                WriteSimpleRecord(((InstanceSimple)aInstance).Record, strWriter, DataSet, IsDictionaryType);
            }
            else if (aInstance is InstanceComplex)
            {
            }
            else
            {
            }
            strWriter.WriteLine(";");
        }
コード例 #9
0
        /// <summary>
        /// Write out regular p21 file
        /// </summary>
        /// <param name="DataSet"></param>
        /// <param name="FileName"></param>
        public static void WriteP21File(InstanceDB DataSet, string FileName, bool IsDictionaryType)
        {
            using (StreamWriter aFile = new StreamWriter(FileName))
            {
                if (IsDictionaryType)
                {
                    aFile.WriteLine(DICTIONARYstr);
                    for (int i = 0; i < DataSet.KeywordDic.Count; i++)
                    {
                        aFile.WriteLine("@{0}={1}", i, DataSet.KeywordDic[i]);
                    }
                    aFile.WriteLine(ENDSECstr);
                }

                aFile.WriteLine(ISOstr);
                aFile.WriteLine(HEADERstr);

                for (int i = 0; i < DataSet.HeaderList.Count; i++)
                {
                    WriteSimpleRecord(DataSet.HeaderList[i], aFile, DataSet, false);
                    aFile.Write(";\n");
                }

                aFile.WriteLine(ENDSECstr);


                //for (int i = 0; i < DataSet.aDataSectionList.Count; i++)
                //{
                aFile.WriteLine(DATAstr);
                //DataSection aDataSection = DataSet.aDataSectionList[i];
                //for (int j = 0; j < aDataSection.DataList.Count; j++)
                //{
                //    WriteInstance(aDataSection.DataList, aFile, DataSet);
                //}
                foreach (KeyValuePair <uint, Instance> kvp in DataSet.DataList)
                {
                    WriteInstance(kvp.Value, aFile, DataSet, IsDictionaryType);
                }
                aFile.WriteLine(ENDSECstr);
                //}
                aFile.WriteLine(ENDISOstr);
                //aFile.Close();
            }
        }
コード例 #10
0
ファイル: ParamEnum.cs プロジェクト: mind-peace/ifctoolkit
 public ParamEnum(string value, InstanceDB DataSet)
     : base(SParamType.ENUMERATION)
 {
     p_EnumValueInt    = DataSet.AddKeyword(value);
     p_EnumValueString = value;
 }
コード例 #11
0
 /// <summary>(
 /// IFC MODEL Reader
 /// </summary>
 /// <param name="p21FileName">Filename to read</param>
 private EarlyBindingInstanceModel(string p21FileName)
     : this()
 {
     var model = new InstanceDB(p21FileName);
     ConvertToEarlyBinding(model);
 }
コード例 #12
0
ファイル: ParamEnum.cs プロジェクト: mind-peace/ifctoolkit
 public string GetStringValue(InstanceDB DataSet)
 {
     return(DataSet.GetKeyword(p_EnumValueInt));
 }
コード例 #13
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
        public static void WriteSimpleRecord(SimpleRecord aRecord, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
        {
            if (IsDictionaryType)
            { strWriter.Write("@{0}", aRecord.IntKeyword.ToString()); }
            else
            {
                //strWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
                strWriter.Write(aRecord.Keyword);
            }
            //byte[] aTemp = BitConverter.GetBytes('(');

            strWriter.Write('(');
            for (int i = 0; i < aRecord.ParameterList.Count; i++)
            {
                if (i > 0)
                { strWriter.Write(','); }
                WriteParameter(aRecord.ParameterList[i], strWriter, DataSet, IsDictionaryType);
            }
            strWriter.Write(')');
        }
コード例 #14
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
 public static void TestWriter()
 {
     var instanceDB = new InstanceDB();
     var simpleRecord = new SimpleRecord("IFCORGANIZATION", instanceDB);
     simpleRecord.ParameterList.Add(new ParamNullValue());
     simpleRecord.ParameterList.Add(new ParamString("Georgia Tech"));
     simpleRecord.ParameterList.Add(new ParamNullValue());
     simpleRecord.ParameterList.Add(new ParamNullValue());
     simpleRecord.ParameterList.Add(new ParamNullValue());
     var instanceSimple = new InstanceSimple(10);
     instanceSimple.Record = simpleRecord;
     instanceDB.DataList.Add(instanceSimple.EntityInstanceName, instanceSimple);
 }
コード例 #15
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
 public static void WriteParameter(Parameter aParameter, BinaryWriter aBinaryWriter, InstanceDB DataSet)
 {
     //if (aParameter.ParameterTypeValue == ParameterType.ENTITY_INSTANCE_NAME)
     if (aParameter is ParamEntity)
     {
         aBinaryWriter.Write('#');
         aBinaryWriter.Write(((ParamEntity)aParameter).EntityInstance.EntityInstanceName.ToString());
     }
     //else if (aParameter.ParameterTypeValue == ParameterType.INTEGER)
     else if (aParameter is ParamInteger)
     {
         aBinaryWriter.Write(BitConverter.GetBytes(((ParamInteger)aParameter).IntegerValue));
     }
     //else if (aParameter.ParameterTypeValue == ParameterType.ENUMERATION)
     else if (aParameter is ParamEnum)
     {
         aBinaryWriter.Write('.');
         aBinaryWriter.Write(((ParamEnum)aParameter).EnumerationValueString);
         aBinaryWriter.Write('.');
     }
     else if (aParameter is ParamNullValue)
     {
         aBinaryWriter.Write('$');
     }
     else if (aParameter is ParamOmitted)
     {
         aBinaryWriter.Write('*');
     }
     else if (aParameter is ParamString)
     {
         aBinaryWriter.Write('\'');
         aBinaryWriter.Write(((ParamString)aParameter).StringValue);
         aBinaryWriter.Write('\'');
     }
     else if (aParameter is ParamReal)
     {
         aBinaryWriter.Write(BitConverter.GetBytes(((ParamReal)aParameter).RealValue));
     }
     else if (aParameter is ParamList)
     {
         aBinaryWriter.Write('(');
         for (int i = 0; i < ((ParamList)aParameter).ParameterList.Count; i++)
         {
             if (i > 0)
             {
                 aBinaryWriter.Write(',');
             }
             WriteParameter(((ParamList)aParameter).ParameterList[i], aBinaryWriter, DataSet);
         }
         aBinaryWriter.Write(')');
     }
     else if (aParameter is ParamSelect)
     {
         //WriteSimpleRecord(((ParamSelect)aParameter).TypedParameterValue, aBinaryWriter, DataSet);
         aBinaryWriter.Write(
             string.Format("{0}({1})",
             ((ParamSelect)aParameter).SelectName,
             ((ParamSelect)aParameter).SelectValue));
     }
 }
コード例 #16
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
 public static void WriteSerializedInstances(InstanceDB DataSet)
 {
     Stream str = File.Create(@"c:\cpdsample\aSerialized.bin");
     BinaryFormatter bf = new BinaryFormatter();
     bf.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
     bf.Serialize(str, DataSet);
     str.Close();
 }
コード例 #17
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
 public static void WriteCompressedSerializedInstances(InstanceDB DataSet)
 {
     Stream str = File.Create(@"c:\cpdsample\CompressedSerialized.bgz");
     GZipStream compressor = new GZipStream(str, CompressionMode.Compress);
     BinaryFormatter bf = new BinaryFormatter();
     bf.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
     bf.Serialize(compressor, DataSet);
     compressor.Close();
     str.Close();
 }
コード例 #18
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
        public static void WriteInstance(Instance aInstance, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
        {
            strWriter.Write('#');
            strWriter.Write(aInstance.EntityInstanceName.ToString());
            strWriter.Write('=');

            if (aInstance is InstanceSimple)
            {
                WriteSimpleRecord(((InstanceSimple)aInstance).Record, strWriter, DataSet, IsDictionaryType);

            }
            else if (aInstance is InstanceComplex)
            {
            }
            else
            {
            }
            strWriter.WriteLine(";");
        }
コード例 #19
0
 public static void WriteParameter(Parameter aParameter, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
 {
     if (aParameter is ParamEntity)
     {
         strWriter.Write('#');
         strWriter.Write(((ParamEntity)aParameter).EntityInstance.EntityInstanceName.ToString());
     }
     else if (aParameter is ParamInteger)
     {
         strWriter.Write(((ParamInteger)aParameter).IntegerValue.ToString());
     }
     else if (aParameter is ParamEnum)
     {
         //strWriter.Write('.');
         //strWriter.Write(aParameter.StringValue);
         //((EnumerationParameter)aParameter).GetStringValue(DataSet)
         if (IsDictionaryType)
         {
             strWriter.Write("@{0}", ((ParamEnum)aParameter).EnumerationValueInt);
         }
         else
         {
             strWriter.Write("@{0}", ((ParamEnum)aParameter).EnumerationValueString);
         }
         //strWriter.Write('.');
     }
     else if (aParameter is ParamNullValue)
     {
         strWriter.Write('$');
     }
     else if (aParameter is ParamOmitted)
     {
         strWriter.Write('*');
     }
     else if (aParameter is ParamString)
     {
         strWriter.Write('\'');
         strWriter.Write(((ParamString)aParameter).StringValue);
         strWriter.Write('\'');
     }
     else if (aParameter is ParamReal)
     {
         int    front  = (int)((ParamReal)aParameter).RealValue;
         double remain = ((ParamReal)aParameter).RealValue - front;
         if (remain == 0.0)
         {
             strWriter.Write("{0}.", ((ParamReal)aParameter).RealValue.ToString());
         }
         else
         {
             strWriter.Write("{0}", ((ParamReal)aParameter).RealValue.ToString("G", CultureInfo.InvariantCulture));
         }
     }
     else if (aParameter is ParamList)
     {
         strWriter.Write('(');
         for (int i = 0; i < ((ParamList)aParameter).ParameterList.Count; i++)
         {
             if (i > 0)
             {
                 strWriter.Write(',');
             }
             WriteParameter(((ParamList)aParameter).ParameterList[i], strWriter, DataSet, IsDictionaryType);
         }
         strWriter.Write(')');
     }
     else if (aParameter is ParamSelect)
     {
         //WriteSimpleRecord(((ParamSelect)aParameter).TypedParameterValue, strWriter, DataSet, IsDictionaryType);
         strWriter.Write(
             string.Format("{0}({1})",
                           ((ParamSelect)aParameter).SelectName,
                           ((ParamSelect)aParameter).SelectValue));
     }
     else if (aParameter is ParamBoolean)
     {
         strWriter.Write("{0}.", ((ParamBoolean)aParameter).BoolValue.ToString());
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #20
0
        public static void WriteSimpleRecord(SimpleRecord aRecord, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
        {
            if (IsDictionaryType)
            {
                strWriter.Write("@{0}", aRecord.IntKeyword.ToString());
            }
            else
            {
                //strWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
                strWriter.Write(aRecord.Keyword);
            }
            //byte[] aTemp = BitConverter.GetBytes('(');

            strWriter.Write('(');
            for (int i = 0; i < aRecord.ParameterList.Count; i++)
            {
                if (i > 0)
                {
                    strWriter.Write(',');
                }
                WriteParameter(aRecord.ParameterList[i], strWriter, DataSet, IsDictionaryType);
            }
            strWriter.Write(')');
        }
コード例 #21
0
        public static void WriteInstance(Instance aInstance, BinaryWriter aBinaryWriter, InstanceDB DataSet)
        {
            aBinaryWriter.Write('#');
            aBinaryWriter.Write(aInstance.EntityInstanceName.ToString());
            aBinaryWriter.Write('=');

            if (aInstance is InstanceSimple)
            {
                WriteSimpleRecord(((InstanceSimple)aInstance).Record, aBinaryWriter, DataSet);
            }
            else if (aInstance is InstanceComplex)
            {
            }
            else
            {
            }
            aBinaryWriter.Write(BitConverter.GetBytes(';'));
        }
コード例 #22
0
 public static void WriteParameter(Parameter aParameter, BinaryWriter aBinaryWriter, InstanceDB DataSet)
 {
     //if (aParameter.ParameterTypeValue == ParameterType.ENTITY_INSTANCE_NAME)
     if (aParameter is ParamEntity)
     {
         aBinaryWriter.Write('#');
         aBinaryWriter.Write(((ParamEntity)aParameter).EntityInstance.EntityInstanceName.ToString());
     }
     //else if (aParameter.ParameterTypeValue == ParameterType.INTEGER)
     else if (aParameter is ParamInteger)
     {
         aBinaryWriter.Write(BitConverter.GetBytes(((ParamInteger)aParameter).IntegerValue));
     }
     //else if (aParameter.ParameterTypeValue == ParameterType.ENUMERATION)
     else if (aParameter is ParamEnum)
     {
         aBinaryWriter.Write('.');
         aBinaryWriter.Write(((ParamEnum)aParameter).EnumerationValueString);
         aBinaryWriter.Write('.');
     }
     else if (aParameter is ParamNullValue)
     {
         aBinaryWriter.Write('$');
     }
     else if (aParameter is ParamOmitted)
     {
         aBinaryWriter.Write('*');
     }
     else if (aParameter is ParamString)
     {
         aBinaryWriter.Write('\'');
         aBinaryWriter.Write(((ParamString)aParameter).StringValue);
         aBinaryWriter.Write('\'');
     }
     else if (aParameter is ParamReal)
     {
         aBinaryWriter.Write(BitConverter.GetBytes(((ParamReal)aParameter).RealValue));
     }
     else if (aParameter is ParamList)
     {
         aBinaryWriter.Write('(');
         for (int i = 0; i < ((ParamList)aParameter).ParameterList.Count; i++)
         {
             if (i > 0)
             {
                 aBinaryWriter.Write(',');
             }
             WriteParameter(((ParamList)aParameter).ParameterList[i], aBinaryWriter, DataSet);
         }
         aBinaryWriter.Write(')');
     }
     else if (aParameter is ParamSelect)
     {
         //WriteSimpleRecord(((ParamSelect)aParameter).TypedParameterValue, aBinaryWriter, DataSet);
         aBinaryWriter.Write(
             string.Format("{0}({1})",
                           ((ParamSelect)aParameter).SelectName,
                           ((ParamSelect)aParameter).SelectValue));
     }
 }
コード例 #23
0
 public static void WriteSimpleRecord(SimpleRecord aRecord, BinaryWriter aBinaryWriter, InstanceDB DataSet)
 {
     //aBinaryWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
     aBinaryWriter.Write(aRecord.Keyword);
     //aBinaryWriter.Write(aRecord.GetKeyword(DataSet));
     //byte[] aTemp = BitConverter.GetBytes('(');
     aBinaryWriter.Write('(');
     for (int i = 0; i < aRecord.ParameterList.Count; i++)
     {
         if (i > 0)
         {
             aBinaryWriter.Write(',');
         }
         WriteParameter(aRecord.ParameterList[i], aBinaryWriter, DataSet);
     }
     aBinaryWriter.Write(')');
 }
コード例 #24
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
        public static void WriteInstance(Instance aInstance, BinaryWriter aBinaryWriter, InstanceDB DataSet)
        {
            aBinaryWriter.Write('#');
            aBinaryWriter.Write(aInstance.EntityInstanceName.ToString());
            aBinaryWriter.Write('=');

            if (aInstance is InstanceSimple)
            {
                WriteSimpleRecord(((InstanceSimple)aInstance).Record, aBinaryWriter, DataSet);

            }
            else if (aInstance is InstanceComplex)
            {
            }
            else
            {
            }
            aBinaryWriter.Write(BitConverter.GetBytes(';'));
        }
コード例 #25
0
        /// <summary>
        /// use this function
        /// </summary>
        /// <param name="sData"></param>
        /// <param name="instanceDb"></param>
        private void AssignEntityDefToInstance(SData sData, InstanceDB instanceDb)
        {
            foreach (KeyValuePair<uint, Instance> kvp in instanceDb.DataList)
            {
                if (kvp.Value is InstanceSimple)
                {
                    var sInstance = kvp.Value as InstanceSimple;

                    var sEntity = sData.EntityList[sInstance.Keyword];

                    AddSimpleDef(sInstance, sEntity);
                }
                else if (kvp.Value is InstanceComplex)
                {
                    // need to implement
                }
                else
                {
                    throw new InvalidDataException(
                        string.Format("Undefined instantiation of instance at {0} : {1}",
                                      kvp.Value.EntityInstanceName, kvp.Value.Keyword));
                }
            }
        }
コード例 #26
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
        /// <summary>
        /// Write out regular p21 file
        /// </summary>
        /// <param name="DataSet"></param>
        /// <param name="FileName"></param>
        public static void WriteP21File(InstanceDB DataSet, string FileName, bool IsDictionaryType)
        {
            using (StreamWriter aFile = new StreamWriter(FileName))
            {
                if (IsDictionaryType)
                {
                    aFile.WriteLine(DICTIONARYstr);
                    for (int i = 0; i < DataSet.KeywordDic.Count; i++)
                    {
                        aFile.WriteLine("@{0}={1}", i, DataSet.KeywordDic[i]);
                    }
                    aFile.WriteLine(ENDSECstr);
                }

                aFile.WriteLine(ISOstr);
                aFile.WriteLine(HEADERstr);

                for (int i = 0; i < DataSet.HeaderList.Count; i++)
                {
                    WriteSimpleRecord(DataSet.HeaderList[i], aFile, DataSet, false);
                    aFile.Write(";\n");
                }

                aFile.WriteLine(ENDSECstr);

                //for (int i = 0; i < DataSet.aDataSectionList.Count; i++)
                //{
                aFile.WriteLine(DATAstr);
                //DataSection aDataSection = DataSet.aDataSectionList[i];
                //for (int j = 0; j < aDataSection.DataList.Count; j++)
                //{
                //    WriteInstance(aDataSection.DataList, aFile, DataSet);
                //}
                foreach (KeyValuePair<uint, Instance> kvp in DataSet.DataList)
                {
                    WriteInstance(kvp.Value, aFile, DataSet, IsDictionaryType);
                }
                aFile.WriteLine(ENDSECstr);
                //}
                aFile.WriteLine(ENDISOstr);
                //aFile.Close();
            }
        }
コード例 #27
0
ファイル: ParamEntRef.cs プロジェクト: mind-peace/ifctoolkit
 public ParamEntRef(uint value, InstanceDB DataSet)
     : base(value, DataSet)
 {
 }
コード例 #28
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
 public static void WriteParameter(Parameter aParameter, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
 {
     if (aParameter is ParamEntity)
     {
         strWriter.Write('#');
         strWriter.Write(((ParamEntity)aParameter).EntityInstance.EntityInstanceName.ToString());
     }
     else if (aParameter is ParamInteger)
     {
         strWriter.Write(((ParamInteger)aParameter).IntegerValue.ToString());
     }
     else if (aParameter is ParamEnum)
     {
         //strWriter.Write('.');
         //strWriter.Write(aParameter.StringValue);
         //((EnumerationParameter)aParameter).GetStringValue(DataSet)
         if (IsDictionaryType)
         { strWriter.Write("@{0}", ((ParamEnum)aParameter).EnumerationValueInt); }
         else
         { strWriter.Write("@{0}", ((ParamEnum)aParameter).EnumerationValueString); }
         //strWriter.Write('.');
     }
     else if (aParameter is ParamNullValue)
     {
         strWriter.Write('$');
     }
     else if (aParameter is ParamOmitted)
     {
         strWriter.Write('*');
     }
     else if (aParameter is ParamString)
     {
         strWriter.Write('\'');
         strWriter.Write(((ParamString)aParameter).StringValue);
         strWriter.Write('\'');
     }
     else if (aParameter is ParamReal)
     {
         int front = (int)((ParamReal)aParameter).RealValue;
         double remain = ((ParamReal)aParameter).RealValue - front;
         if (remain == 0.0)
         {
             strWriter.Write("{0}.", ((ParamReal)aParameter).RealValue.ToString());
         }
         else
             strWriter.Write("{0}", ((ParamReal)aParameter).RealValue.ToString("G", CultureInfo.InvariantCulture));
     }
     else if (aParameter is ParamList)
     {
         strWriter.Write('(');
         for (int i = 0; i < ((ParamList)aParameter).ParameterList.Count; i++)
         {
             if (i > 0)
             {
                 strWriter.Write(',');
             }
             WriteParameter(((ParamList)aParameter).ParameterList[i], strWriter, DataSet, IsDictionaryType);
         }
         strWriter.Write(')');
     }
     else if (aParameter is ParamSelect)
     {
         //WriteSimpleRecord(((ParamSelect)aParameter).TypedParameterValue, strWriter, DataSet, IsDictionaryType);
         strWriter.Write(
                 string.Format("{0}({1})",
                 ((ParamSelect)aParameter).SelectName,
                 ((ParamSelect)aParameter).SelectValue));
     }
     else if (aParameter is ParamBoolean)
     {
         strWriter.Write("{0}.", ((ParamBoolean)aParameter).BoolValue.ToString());
     }
     else
         throw new NotImplementedException();
 }
コード例 #29
0
 public static bool Read(RegisteredSchema schemaName, string p21FileName)
 {
     try
     {
         var p21 = new InstanceDB(p21FileName);
         var sData = SParser.ReadSchema(schemaName);
         Instance.AssignEntityDefToInstance(sData, p21);
         Instance.ConvertToEarlyBinding(p21);
         return true;
     }
     catch (Exception)
     {
         MessageBox.Show(string.Format("There was an error in parsing {0}.", Path.GetFileName(p21FileName)));
         return false;
     }
 }
コード例 #30
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
        public static void WriteSimpleRecord(SimpleRecord aRecord, BinaryWriter aBinaryWriter, InstanceDB DataSet)
        {
            //aBinaryWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
            aBinaryWriter.Write(aRecord.Keyword);
            //aBinaryWriter.Write(aRecord.GetKeyword(DataSet));
            //byte[] aTemp = BitConverter.GetBytes('(');
            aBinaryWriter.Write('(');
            for (int i = 0; i < aRecord.ParameterList.Count; i++)
            {
                if (i > 0)
                {

                    aBinaryWriter.Write(',');
                }
                WriteParameter(aRecord.ParameterList[i], aBinaryWriter, DataSet);
            }
            aBinaryWriter.Write(')');
        }
コード例 #31
0
ファイル: ParamEntRef.cs プロジェクト: JackTing/ifctoolkit
 public ParamEntRef(uint value, InstanceDB DataSet)
     : base(value, DataSet)
 {
 }
コード例 #32
0
ファイル: P21Writer.cs プロジェクト: JackTing/ifctoolkit
        public static void WriteToByte(InstanceDB DataSet)
        {
            Stream bstr = File.Create(@"c:\cpd\a.cpd");
            BinaryWriter binWriter = new BinaryWriter(bstr, Encoding.ASCII);

            //for (int i = 0; i < DataSet.aDataSectionList.Count; i++)
            //{
            //DataSection aDataSection = DataSet.aDataSectionList[i];
            //for (int j = 0; j < aDataSection.DataList.Count; j++)
            //{
            //    WriteInstance(aDataSection.DataList.GetByIndex(j), binWriter, DataSet);
            //}
            foreach (KeyValuePair<uint, Instance> kvp in DataSet.DataList)
            {
                WriteInstance(kvp.Value, binWriter, DataSet);
            }
            //}
            //FileStream outfile = File.Create(@"c:\a.cpz");

            //GZipStream compress = new GZipStream(bstr, CompressionMode.Compress);
            //bstr.CopyTo(compress);
            //compress.Close();
            //outfile.Close();

            bstr.Close();
            //            ZipFile();
            //Compress(new FileInfo(@"c:\a.cpd"));
        }
コード例 #33
0
 public SimpleRecord(String Keyword, InstanceDB DataSet)
 {
     p_Keyword     = Keyword;
     p_IntKeyword  = DataSet.AddKeyword(Keyword);
     ParameterList = new List <Parameter>();
 }
コード例 #34
0
ファイル: ParamEnum.cs プロジェクト: JackTing/ifctoolkit
 public ParamEnum(string value, InstanceDB DataSet)
     : base(SParamType.ENUMERATION)
 {
     p_EnumValueInt = DataSet.AddKeyword(value);
     p_EnumValueString = value;
 }
コード例 #35
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="instanceDb"></param>
        private void ConvertToEarlyBinding(InstanceDB instanceDb)
        {
            #region header section
            FILE_DESCRIPTION _fileDescription = null;
            FILE_NAME _fileName = null;
            FILE_SCHEMA _fileSchema = null;

            foreach (var header in instanceDb.HeaderList)
            {
                //FILE_DESCRIPTION fd = new FILE_DESCRIPTION();
                //var aa = fd.GetType().Assembly;
                //var bb = aa.CreateInstance(header.Keyword);
                var obj = Activator.CreateInstance(EbConstants.Part21NSName,
                                                   EbConstants.Part21NSName + "." + header.Keyword);
                var cobj = obj.Unwrap() as P21Instance;

                if (cobj is FILE_DESCRIPTION)
                {
                    var fdesc = cobj as FILE_DESCRIPTION;
                    fdesc.DESCRIPTION = new List<STRING>();
                    var list = header.ParameterList[0] as ParamList;
                    foreach (var item in list.ParameterList)
                    {
                        var str = item as ParamString;
                        fdesc.DESCRIPTION.Add(str.StringValue);
                    }

                    var pstr = header.ParameterList[1] as ParamString;
                    fdesc.IMPLEMTATION_LEVEL = pstr.StringValue;

                    if (fdesc.DESCRIPTION.Count > 0)
                        _fileDescription = fdesc;
                    //_headerSection.Add(fdesc);
                }
                else if (cobj is FILE_NAME)
                {
                    var fname = cobj as FILE_NAME;
                    ParamString pstring;

                    if (header.ParameterList[0].ParameterType == SParamType.STRING)
                    {
                        pstring = header.ParameterList[0] as ParamString;
                        fname.NAME = pstring.StringValue;
                    }
                    if (header.ParameterList[1].ParameterType == SParamType.STRING)
                    {
                        pstring = header.ParameterList[1] as ParamString;
                        fname.TIME_STAMP = new TIME_STAMP_TEXT();
                        fname.TIME_STAMP.Value = pstring.StringValue;
                    }

                    ParamList list;
                    if (header.ParameterList[2].ParameterType == SParamType.SET)
                    {
                        list = header.ParameterList[2] as ParamList;
                        if (list != null && list.ParameterList.Count > 0)
                        {
                            fname.AUTHOR = new List<STRING>();
                            foreach (var item in list.ParameterList)
                            {
                                var str = item as ParamString;
                                fname.AUTHOR.Add(str.StringValue);
                            }
                        }
                    }

                    if (header.ParameterList[3].ParameterType == SParamType.SET)
                    {
                        list = header.ParameterList[3] as ParamList;
                        if (list != null && list.ParameterList.Count > 0)
                        {
                            fname.ORGANIZATION = new List<STRING>();
                            foreach (var item in list.ParameterList)
                            {
                                var str = item as ParamString;
                                fname.ORGANIZATION.Add(str.StringValue);
                            }
                        }
                    }

                    if (header.ParameterList[4].ParameterType == SParamType.STRING)
                    {
                        pstring = header.ParameterList[4] as ParamString;
                        fname.PREPROCESSOR_VERSION = pstring.StringValue;
                    }

                    if (header.ParameterList[5].ParameterType == SParamType.STRING)
                    {
                        pstring = header.ParameterList[5] as ParamString;
                        fname.ORIGINATING_SYSTEM = pstring.StringValue;
                    }

                    if (header.ParameterList[6].ParameterType == SParamType.STRING)
                    {
                        pstring = header.ParameterList[6] as ParamString;
                        fname.AUTHORIZATION = pstring.StringValue;
                    }

                    if (null != fname.NAME)
                    {
                        // _headerSection.Add(fname);
                        _fileName = fname;
                    }
                }
                else if (cobj is FILE_SCHEMA)
                {
                    var fsch = cobj as FILE_SCHEMA;
                    if (header.ParameterList[0].ParameterType == SParamType.SET)
                    {
                        ParamList list = header.ParameterList[0] as ParamList;
                        if (list != null && list.ParameterList.Count > 0)
                        {
                            fsch.SCHEMA_IDENTIFIERS = new List<SCHEMA_NAME>();
                            foreach (var item in list.ParameterList)
                            {
                                var str = item as ParamString;
                                SCHEMA_NAME sname = new SCHEMA_NAME();
                                sname.Value = str.StringValue;
                                fsch.SCHEMA_IDENTIFIERS.Add(sname);
                            }
                        }
                    }
                    if (fsch.SCHEMA_IDENTIFIERS != null && fsch.SCHEMA_IDENTIFIERS.Count > 0)
                    {
                        //_headerSection.Add(fsch);
                        _fileSchema = fsch;
                    }
                }
            }

            if (_fileDescription != null && _fileName != null && _fileSchema != null)
                HeaderSection.SetHeader(_fileSchema, _fileDescription, _fileName);

            #endregion header section

            #region body section

            //foreach (var kvp in instanceDb.DataList)
            //{
            //    if (!_dataSection.ContainsKey(kvp.Key))
            //        ConvertInstance(kvp.Value);
            //}

            foreach (var kvp in instanceDb.DataList.Where(kvp => !_dataSection.ContainsKey(kvp.Key)))
            {
                ConvertInstance(kvp.Value);
            }

            #endregion body section
        }
コード例 #36
0
ファイル: ParamEnum.cs プロジェクト: JackTing/ifctoolkit
 public string GetStringValue(InstanceDB DataSet)
 {
     return DataSet.GetKeyword(p_EnumValueInt);
 }
コード例 #37
0
ファイル: SimpleRecord.cs プロジェクト: JackTing/ifctoolkit
 public SimpleRecord(String Keyword, InstanceDB DataSet)
 {
     p_Keyword = Keyword;
     p_IntKeyword = DataSet.AddKeyword(Keyword);
     ParameterList = new List<Parameter>();
 }