GeometryGym.Ifc.ParserIfc.extractSimpleValue C# (CSharp) Méthode

extractSimpleValue() static private méthode

static private extractSimpleValue ( Type type, string value ) : IfcSimpleValue
type System.Type
value string
Résultat IfcSimpleValue
        internal static IfcSimpleValue extractSimpleValue(Type type, string value)
        {
            if(type.GetInterfaces().Contains(typeof(IfcSimpleValue)))
            {
                string name = type.Name.ToUpper();
                if(string.Compare(name,"IFCBOOLEAN") == 0)
                {
                    bool result = false;
                    if (bool.TryParse(value, out result))
                        return new IfcBoolean(result);
                    return new IfcBoolean( value.Contains("T"));
                }
                if (string.Compare(name, "IFCIDENTIFIER") == 0)
                    return new IfcIdentifier(value);
                if (string.Compare(name, "IFCINTEGER") == 0)
                    return new IfcInteger(int.Parse(value));
                if (string.Compare(name, "IFCLABEL") == 0)
                    return new IfcLabel(value);
                if(string.Compare(name, "IFCLOGICAL") == 0)
                {
                    bool result = false;
                    if (bool.TryParse(value, out result))
                        return new IfcLogical(result);
                    return new IfcLogical(IfcLogicalEnum.UNKNOWN);
                }
                if (string.Compare(name, "IFCREAL") == 0)
                    return new IfcReal(double.Parse(value));
                if (string.Compare(name, "IFCTEXT") == 0)
                    return new IfcText(value);
            }
            return null;
        }