public DeliveryFee(ExpressType type, NormalFeeMethod normal, CustomFeeMethod[] customs) : this(type, normal) { TkDebug.AssertArgumentNull(normal, "normal", null); TkDebug.AssertArgumentNull(customs, "customs", null); Customs.AddRange(customs); }
public IEnumerable <entity> GetEntities(ExpressType type) { //collect upper inheritance var types = new List <ExpressType> { type }; while (type.SuperType != null) { types.Add(type.SuperType); type = type.SuperType; } return(types.Select(expressType => GetEntity(expressType.ExpressName)).Where(entity => entity != null)); }
private void AddType(ConceptRoot conceptRoot, ExpressType st) { List <ConceptRoot> dicItem; if (_expressTypeConceptRootLookup.TryGetValue(st, out dicItem)) { dicItem.Add(conceptRoot); } else { _expressTypeConceptRootLookup.Add(st, new List <ConceptRoot>() { conceptRoot }); } }
public Express(ExpressType id, int price) { Id = id; Price = price; }
private DeliveryFee(ExpressType type, NormalFeeMethod normal) { Type = type; Normal = normal; Customs = new List<CustomFeeMethod>(); }
private static void WriteProperty(Type propType, object propVal, BinaryWriter entityWriter) { Type itemType; if (propVal == null) //null or a value type that maybe null { entityWriter.Write(Convert.ToByte(P21ParseAction.SetNonDefinedValue)); } else if (propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(Nullable <>)) //deal with undefined types (nullables) { if (typeof(ExpressComplexType).IsAssignableFrom(propVal.GetType())) { entityWriter.Write(Convert.ToByte(P21ParseAction.BeginList)); foreach (var compVal in ((ExpressComplexType)propVal).Properties) { WriteProperty(compVal.GetType(), compVal, entityWriter); } entityWriter.Write(Convert.ToByte(P21ParseAction.EndList)); } else if ((typeof(ExpressType).IsAssignableFrom(propVal.GetType()))) { ExpressType expressVal = (ExpressType)propVal; WriteValueType(expressVal.UnderlyingSystemType, expressVal.Value, entityWriter); } else { WriteValueType(propVal.GetType(), propVal, entityWriter); } } else if (typeof(ExpressComplexType).IsAssignableFrom(propType)) { entityWriter.Write(Convert.ToByte(P21ParseAction.BeginList)); foreach (var compVal in ((ExpressComplexType)propVal).Properties) { WriteProperty(compVal.GetType(), compVal, entityWriter); } entityWriter.Write(Convert.ToByte(P21ParseAction.EndList)); } else if (typeof(ExpressType).IsAssignableFrom(propType)) //value types with a single property (IfcLabel, IfcInteger) { Type realType = propVal.GetType(); if (realType != propType) //we have a type but it is a select type use the actual value but write out explicitly { entityWriter.Write(Convert.ToByte(P21ParseAction.BeginNestedType)); entityWriter.Write(realType.Name.ToUpper()); entityWriter.Write(Convert.ToByte(P21ParseAction.BeginList)); WriteProperty(realType, propVal, entityWriter); entityWriter.Write(Convert.ToByte(P21ParseAction.EndList)); entityWriter.Write(Convert.ToByte(P21ParseAction.EndNestedType)); } else //need to write out underlying property value { ExpressType expressVal = (ExpressType)propVal; WriteValueType(expressVal.UnderlyingSystemType, expressVal.Value, entityWriter); } } else if (typeof(ExpressEnumerable).IsAssignableFrom(propType) && (itemType = propType.GetItemTypeFromGenericType()) != null) //only process lists that are real lists, see cartesianpoint { entityWriter.Write(Convert.ToByte(P21ParseAction.BeginList)); foreach (var item in ((ExpressEnumerable)propVal)) { WriteProperty(itemType, item, entityWriter); } entityWriter.Write(Convert.ToByte(P21ParseAction.EndList)); } else if (typeof(IPersistIfcEntity).IsAssignableFrom(propType)) //all writable entities must support this interface and ExpressType have been handled so only entities left { int val = ((IPersistIfcEntity)propVal).EntityLabel; if (val <= UInt16.MaxValue) { entityWriter.Write((byte)P21ParseAction.SetObjectValueUInt16); entityWriter.Write(Convert.ToUInt16(val)); } else if (val <= Int32.MaxValue) { entityWriter.Write((byte)P21ParseAction.SetObjectValueInt32); entityWriter.Write(Convert.ToInt32(val)); } //else if (val <= Int64.MaxValue) //{ // //This is a very large model and it is unlikely we will be able to handle this number of entities, // //it is possible they have just created big labels and it needs to be renumbered // //Entity Label could be redfined as a long bu this is a large overhead if never required, let's see... // throw new XbimException("Entity Label is Init64, this is not currently supported"); // //entityWriter.Write((byte)P21ParseAction.SetObjectValueInt64); // //entityWriter.Write(val); //} else { throw new Exception("Entity Label exceeds maximim value for a an int32 long number"); } } else if (propType.IsValueType) //it might be an in-built value type double, string etc { WriteValueType(propVal.GetType(), propVal, entityWriter); } else if (typeof(ExpressSelectType).IsAssignableFrom(propType)) // a select type get the type of the actual value { if (propVal.GetType().IsValueType) //we have a value type, so write out explicitly { entityWriter.Write(Convert.ToByte(P21ParseAction.BeginNestedType)); entityWriter.Write(propVal.GetType().Name.ToUpper()); entityWriter.Write(Convert.ToByte(P21ParseAction.BeginList)); WriteProperty(propVal.GetType(), propVal, entityWriter); entityWriter.Write(Convert.ToByte(P21ParseAction.EndList)); entityWriter.Write(Convert.ToByte(P21ParseAction.EndNestedType)); } else //could be anything so re-evaluate actual type { WriteProperty(propVal.GetType(), propVal, entityWriter); } } else { throw new Exception(string.Format("Entity has illegal property {0} of type {1}", propType.Name, propType.Name)); } }
/// <summary> /// Writes a property of an entity to the TextWriter in the Part21 format /// </summary> /// <param name="propType"></param> /// <param name="propVal"></param> /// <param name="entityWriter"></param> private static void WriteProperty(Type propType, object propVal, TextWriter entityWriter, IDictionary <int, int> map) { Type itemType; if (propVal == null) //null or a value type that maybe null { entityWriter.Write('$'); } else if (propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(Nullable <>)) //deal with undefined types (nullables) { if (typeof(ExpressComplexType).IsAssignableFrom(propVal.GetType())) { entityWriter.Write('('); bool first = true; foreach (var compVal in ((ExpressComplexType)propVal).Properties) { if (!first) { entityWriter.Write(','); } WriteProperty(compVal.GetType(), compVal, entityWriter, map); first = false; } entityWriter.Write(')'); } else if ((typeof(ExpressType).IsAssignableFrom(propVal.GetType()))) { ExpressType expressVal = (ExpressType)propVal; WriteValueType(expressVal.UnderlyingSystemType, expressVal.Value, entityWriter); } else // if (propVal.GetType().IsEnum) { WriteValueType(propVal.GetType(), propVal, entityWriter); } } else if (typeof(ExpressComplexType).IsAssignableFrom(propType)) { entityWriter.Write('('); bool first = true; foreach (var compVal in ((ExpressComplexType)propVal).Properties) { if (!first) { entityWriter.Write(','); } WriteProperty(compVal.GetType(), compVal, entityWriter, map); first = false; } entityWriter.Write(')'); } else if (typeof(ExpressType).IsAssignableFrom(propType)) //value types with a single property (IfcLabel, IfcInteger) { Type realType = propVal.GetType(); if (realType != propType) //we have a type but it is a select type use the actual value but write out explricitly { entityWriter.Write(realType.Name.ToUpper()); entityWriter.Write('('); WriteProperty(realType, propVal, entityWriter, map); entityWriter.Write(')'); } else //need to write out underlying property value { ExpressType expressVal = (ExpressType)propVal; WriteValueType(expressVal.UnderlyingSystemType, expressVal.Value, entityWriter); } } else if (typeof(ExpressEnumerable).IsAssignableFrom(propType) && (itemType = propType.GetItemTypeFromGenericType()) != null) //only process lists that are real lists, see cartesianpoint { entityWriter.Write('('); bool first = true; foreach (var item in ((ExpressEnumerable)propVal)) { if (!first) { entityWriter.Write(','); } WriteProperty(itemType, item, entityWriter, map); first = false; } entityWriter.Write(')'); } else if (typeof(IPersistIfcEntity).IsAssignableFrom(propType)) //all writable entities must support this interface and ExpressType have been handled so only entities left { entityWriter.Write('#'); int label = ((IPersistIfcEntity)propVal).EntityLabel; int mapLabel; if (map != null && map.TryGetValue(label, out mapLabel)) { label = mapLabel; } entityWriter.Write(label); } else if (propType.IsValueType) //it might be an in-built value type double, string etc { WriteValueType(propVal.GetType(), propVal, entityWriter); } else if (typeof(ExpressSelectType).IsAssignableFrom(propType)) // a select type get the type of the actual value { if (propVal.GetType().IsValueType) //we have a value type, so write out explicitly { entityWriter.Write(propVal.GetType().Name.ToUpper()); entityWriter.Write('('); WriteProperty(propVal.GetType(), propVal, entityWriter, map); entityWriter.Write(')'); } else //could be anything so re-evaluate actual type { WriteProperty(propVal.GetType(), propVal, entityWriter, map); } } else { throw new Exception(string.Format("Entity has illegal property {0} of type {1}", propType.Name, propType.Name)); } }