Ejemplo n.º 1
0
        public InstanceDB(string schemaFileName, string instanceFileName, string logFileName)
            : this(instanceFileName)
        {
            //SParser aParser = new SParser();
            //p_schemaModel = aParser.ReadSchemaFile(schemaFileName, schemaFileName + ".log");
            p_schemaModel = SParser.ReadSchema(schemaFileName);
            AssignEntityDefToInstance(logFileName);

            //p_InstanceModel.UpdateGuidToIFCInstanceGuid();
        }
        /// <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));
                }
            }
        }