GeometryGym.Ifc.IfcElement.constructElement C# (CSharp) Méthode

constructElement() static private méthode

static private constructElement ( string className, IfcObjectDefinition host, IfcObjectPlacement pl, IfcProductRepresentation r, IfcDistributionSystem system ) : IfcElement
className string
host IfcObjectDefinition
pl IfcObjectPlacement
r IfcProductRepresentation
system IfcDistributionSystem
Résultat IfcElement
		internal static IfcElement constructElement(string className, IfcObjectDefinition host, IfcObjectPlacement pl, IfcProductRepresentation r, IfcDistributionSystem system)
		{
			string str = className, definedType = "";
			if (!string.IsNullOrEmpty(str))
			{
				string[] fields = str.Split(".".ToCharArray());
				if (fields.Length > 1)
				{
					str = fields[0];
					definedType = fields[1];
				}
			}
			IfcElement element = null;
			Type type = Type.GetType("GeometryGym.Ifc." + str);
			if (type != null)
			{
				ConstructorInfo ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, new[] { typeof(IfcObjectDefinition), typeof(IfcObjectPlacement), typeof(IfcProductRepresentation) }, null);
				if (ctor == null)
				{
					ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, new[] { typeof(IfcObjectDefinition), typeof(IfcObjectPlacement), typeof(IfcProductRepresentation), typeof(IfcDistributionSystem) },null);
					if (ctor == null)
						throw new Exception("XXX Unrecognized Ifc Constructor for " + className);
					else
						element = ctor.Invoke(new object[] { host, pl, r, system }) as IfcElement;
				}
				else
					element = ctor.Invoke(new object[] { host, pl, r }) as IfcElement;
				
			}
			if (element == null)
				element = new IfcBuildingElementProxy(host, pl, r);

			if (!string.IsNullOrEmpty(definedType))
			{
				if (host.mDatabase.mRelease == ReleaseVersion.IFC2x3)
					element.ObjectType = definedType;
				else
				{
					type = element.GetType();
					PropertyInfo pi = type.GetProperty("PredefinedType");
					if (pi != null)
					{
						Type enumType = Type.GetType("GeometryGym.Ifc." + type.Name + "TypeEnum");
						if (enumType != null)
						{
							FieldInfo fi = enumType.GetField(definedType);
							if (fi == null)
							{
								element.ObjectType = definedType;
								fi = enumType.GetField("NOTDEFINED");
							}
							if (fi != null)
							{
								int i = (int)fi.GetValue(enumType);
								object newEnumValue = Enum.ToObject(enumType, i);
								pi.SetValue(element, newEnumValue, null);
							}
							else
								element.ObjectType = definedType;
						}
						else
							element.ObjectType = definedType;
					}
					else
						element.ObjectType = definedType;
				}
			}
			return element;
		}
		public void AddStructuralMember(IfcStructuralMember m)

Same methods

IfcElement::constructElement ( string className, IfcObjectDefinition container, IfcObjectPlacement pl, IfcProductRepresentation r ) : IfcElement