Example #1
0
        public static StepFile simpleStepRepresentation()
        {
            StepDataObject entity0 = new StepDataObject("IFCPROJECT",
                                                        StepValue.CreateString("3MD_HkJ6X2EwpfIbCFm0g_"),
                                                        StepValue.CreateLineReference(2),
                                                        StepValue.CreateString("Default Project"),
                                                        StepValue.CreateString("Description of Default Project"),
                                                        StepValue.CreateNull(),
                                                        StepValue.CreateFloat(-22.4),
                                                        StepValue.CreateNull(),
                                                        StepValue.CreateArray(
                                                            StepValue.CreateLineReference(20)
                                                            ),
                                                        StepValue.CreateLineReference(7)
                                                        );
            StepDataObject entity1 = new StepDataObject("IFCOWNERHISTORY",
                                                        StepValue.CreateLineReference(3),
                                                        StepValue.CreateNestedEntity(new StepDataObject("IFCTEXT",
                                                                                                        StepValue.CreateString("foobar"))),
                                                        StepValue.CreateNull(),
                                                        StepValue.CreateEnum("ADDED"),
                                                        StepValue.CreateNull(),
                                                        StepValue.CreateBoolean(false),
                                                        StepValue.CreateOverridden(),
                                                        StepValue.CreateInteger(1217620436)
                                                        );
            StepFile sf = new StepFile();

            appendHeaderToStepFile(sf, createHeader());
            sf.Data.Add(1, entity0);
            sf.Data.Add(2, entity1);
            return(sf);
        }
        private StepValue ExtractProperty(Object entity, PropertyInfo pi)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (pi == null)
            {
                throw new ArgumentNullException("pi");
            }
            logger.Debug(String.Format(CultureInfo.InvariantCulture,
                                       "Method ExtractProperty(Object, PropertyInfo) called with parameters 'entity', an object of type {0}, and 'pi', a PropertyInfo of name '{1}' and PropertyType {2}",
                                       entity.GetType().FullName, pi.Name, pi.PropertyType));

            if (pi.Name == "ValueAsString")
            {
                throw new StepBindingException("Property extraction has gone wrong - it should not be working with any properties named 'ValueAsString'");
            }

            if (IsOverriddenProperty(pi))
            {
                return(StepValue.CreateOverridden());
            }

            object value = pi.GetValue(entity, null);

            if (value == null)
            {
                return(StepValue.CreateNull());
            }
            if (IsIndirectProperty(pi))
            {
                return(ExtractProperty(value, GetIndirectProperty(pi.PropertyType)));                 //TODO what if this is indexed??
            }
            if (pi.PropertyType == typeof(object))
            {
                //TODO

                /*
                 * The value should be wrapped as an object
                 * e.g. IFCMEASUREWITHUNIT(1.745E-2, ...
                 * should become
                 * IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(1.745E-2), ...
                 *
                 *
                 **/
                logger.Debug(String.Format("\t\tFound an object property. Type of value is {0}", value.GetType()));
                return(StepValue.CreateNestedEntity(ExtractObject(value)));
            }
            return(ExtractPropertyValue(value));
        }
Example #3
0
 private StepValue deserializeOverridden()
 {
     return(StepValue.CreateOverridden());
 }