public void test_type() { var f = new AnyOf <Apple, Orange>(new Apple()); f.Is <Apple>().Should().BeTrue(); f.As <Apple>().Should().NotBeNull(); }
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary> /// <param name="other">An object to compare with this object.</param> /// <returns>true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.</returns> public bool Equals(OasSchema other) { if (other is null) return false; if (ReferenceEquals(this, other)) return true; if (JsonType != other.JsonType) return false; if (Format != other.Format) return false; if (Options != other.Options) return false; if (!NumberRange.Equals(other.NumberRange)) return false; if (!ItemsRange.Equals(other.ItemsRange)) return false; if (!LengthRange.Equals(other.LengthRange)) return false; if (!PropertiesRange.Equals(other.PropertiesRange)) return false; if (!ExternalDocumentation.Equals(other.ExternalDocumentation)) return false; if (!StringComparer.Ordinal.Equals(Title, other.Title)) return false; if (!StringComparer.Ordinal.Equals(Description, other.Description)) return false; if (!StringComparer.Ordinal.Equals(Pattern, other.Pattern)) return false; if (!Enum.NullableSetEquals(other.Enum)) return false; if (!AllOf.NullableSetEquals(other.AllOf)) return false; if (!OneOf.NullableSetEquals(other.OneOf)) return false; if (!AnyOf.NullableSetEquals(other.AnyOf)) return false; if (!Not.NullableSetEquals(other.Not)) return false; if (Items != other.Items) return false; if (!Properties.NullableDictionaryEquals(other.Properties)) return false; if (!AdditionalProperties.NullableDictionaryEquals(other.AdditionalProperties)) return false; return true; }
public static Log Log(this AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade> material) { if (material == null) { return(null); } Log result = new Log(); if (material.Obj is IIDdBase) { Core.Modify.AddRange(result, Log((IIDdBase)material.Obj)); } if (material.Obj is EnergyMaterial) { EnergyMaterial energyMaterial = (EnergyMaterial)material.Obj; if (energyMaterial.Thickness * 200 < energyMaterial.Conductivity) { string identifier = energyMaterial.Identifier; if (string.IsNullOrWhiteSpace(identifier)) { identifier = "???"; } result.Add("Possible converge error due to small thickness for {0} material ", LogRecordType.Warning, identifier); } } return(result); }
public void Load_Valid() { // Act AnyOf <string, StringPattern> pattern = "x"; var result = PluginLoader.Load <ICSharpCodeMatcher>(MatchBehaviour.AcceptOnMatch, pattern); // Assert result.Should().NotBeNull(); }
public static Core.IMaterial ToSAM(AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGlazing, EnergyWindowMaterialGas> material) { if (material.Obj is HoneybeeSchema.Energy.IMaterial) { return(ToSAM((HoneybeeSchema.Energy.IMaterial)material.Obj)); } return(null); }
public void TestAnyOfEmptyList() { var env = new Environment(); var evt = new AnyOf(env, Enumerable.Empty<Event>()); Assert.IsTrue(evt.IsTriggered); Assert.IsFalse(evt.IsProcessed); env.Run(evt); Assert.IsTrue(evt.IsProcessed); Assert.AreEqual(0, env.NowD); }
public void TestAnyOfEmptyList() { var env = new Environment(); var evt = new AnyOf(env, Enumerable.Empty <Event>()); Assert.IsTrue(evt.IsTriggered); Assert.IsFalse(evt.IsProcessed); env.Run(evt); Assert.IsTrue(evt.IsProcessed); Assert.AreEqual(0, env.NowD); }
public void TestAnyOfEmptyList() { var env = new Simulation(); var evt = new AnyOf(env, Enumerable.Empty <Event>()); Assert.True(evt.IsTriggered); Assert.False(evt.IsProcessed); env.Run(evt); Assert.True(evt.IsProcessed); Assert.Equal(0, env.NowD); }
public void Test1() { AnyOf <string, bool> anyOf = new AnyOf <string, bool>(true); Assert.AreEqual(typeof(bool), anyOf.GetUnderlyingType()); Assert.AreEqual(true, anyOf.GetValue()); AnyOf <string, bool> anyOf2 = new AnyOf <string, bool>("hello"); Assert.AreEqual(typeof(string), anyOf2.GetUnderlyingType()); Assert.AreEqual("hello", anyOf2.GetValue()); var ex = Assert.Throws <ArgumentException>(() => new AnyOf <string, bool>(3)); }
public static Log Log(this AnyOf <ScheduleRulesetAbridged, ScheduleFixedIntervalAbridged, ScheduleRuleset, ScheduleFixedInterval> schedule) { if (schedule == null) { return(null); } if (schedule.Obj is IIDdBase) { return(Log((IIDdBase)schedule.Obj)); } return(null); }
public static Log Log(this AnyOf <IdealAirSystemAbridged, VAV, PVAV, PSZ, PTAC, ForcedAirFurnace, FCUwithDOASAbridged, WSHPwithDOASAbridged, VRFwithDOASAbridged, FCU, WSHP, VRF, Baseboard, EvaporativeCooler, Residential, WindowAC, GasUnitHeater> hvac) { if (hvac == null) { return(null); } if (hvac.Obj is IIDdBase) { return(Log((IIDdBase)hvac.Obj)); } return(null); }
public static Log Log(this AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, WindowConstructionShadeAbridged, AirBoundaryConstructionAbridged, OpaqueConstruction, WindowConstruction, WindowConstructionShade, WindowConstructionDynamicAbridged, WindowConstructionDynamic, AirBoundaryConstruction, ShadeConstruction> construction) { if (construction == null) { return(null); } if (construction.Obj is IIDdBase) { return(Log((IIDdBase)construction.Obj)); } return(null); }
public static List <Profile> ToSAM_Profiles(this ProgramType programType) { if (programType == null) { return(null); } List <Profile> result = new List <Profile>(); People people = programType.People; if (people != null) { AnyOf <ScheduleRuleset, ScheduleFixedInterval> occupancySchedule = people.OccupancySchedule; AnyOf <ScheduleRuleset, ScheduleFixedInterval> activitySchedule = people.ActivitySchedule; } Lighting lighting = programType.Lighting; if (lighting != null) { AnyOf <ScheduleRuleset, ScheduleFixedInterval> schedule = lighting.Schedule; } ElectricEquipment electricEquipment = programType.ElectricEquipment; if (electricEquipment != null) { AnyOf <ScheduleRuleset, ScheduleFixedInterval> schedule = electricEquipment.Schedule; } Infiltration infiltration = programType.Infiltration; if (infiltration != null) { AnyOf <ScheduleRuleset, ScheduleFixedInterval> schedule = infiltration.Schedule; } Setpoint setPoint = programType.Setpoint; if (setPoint != null) { AnyOf <ScheduleRuleset, ScheduleFixedInterval> coolingSchedule = setPoint.CoolingSchedule; AnyOf <ScheduleRuleset, ScheduleFixedInterval> heatingSchedule = setPoint.HeatingSchedule; } return(result); }
/// <summary> /// Add the provided JSON schema as an option for the anyOf property of this JSON schema. /// </summary> /// <param name="anyOfOption"></param> /// <returns></returns> public JsonSchema AddAnyOf(JsonSchema anyOfOption) { if (anyOfOption == null) { throw new ArgumentNullException(nameof(anyOfOption)); } if (AnyOf == null) { AnyOf = new List <JsonSchema>(); } AnyOf.Add(anyOfOption); return(this); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> public override int GetHashCode() { unchecked { var hashCode = Type.GetHashCode(); hashCode = (hashCode * 397) ^ (Id?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Schema?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Comment?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Title?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Description?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Default?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MultipleOf.GetHashCode(); hashCode = (hashCode * 397) ^ Maximum.GetHashCode(); hashCode = (hashCode * 397) ^ ExclusiveMaximum.GetHashCode(); hashCode = (hashCode * 397) ^ Minimum.GetHashCode(); hashCode = (hashCode * 397) ^ ExclusiveMinimum.GetHashCode(); hashCode = (hashCode * 397) ^ (MaxLength?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (MinLength?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Pattern?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AdditionalItems?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Items?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (MaxItems?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (MinItems?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (UniqueItems?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Contains?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AdditionalProperties?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Definitions?.GetCollectionHashCode().GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Properties?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (PatternProperties?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Dependencies?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Const?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Enum?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Format?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (ContentMediaType?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (ContentEncoding?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (If?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Then?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Else?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AllOf?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AnyOf?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (OneOf?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Not?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Required?.GetCollectionHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Examples?.GetCollectionHashCode() ?? 0); return(hashCode); } }
private IDictionary <string, JsonSchemaProperty> GetActualProperties(bool includeInherited) #endif { var ignoredSchema = includeInherited ? null : InheritedSchema; var properties = Properties .Union(AllOf.Where(s => s.ActualSchema != ignoredSchema).SelectMany(s => s.ActualSchema.GetActualProperties(false))) .Union(AnyOf.Where(s => s.ActualSchema != ignoredSchema).SelectMany(s => s.ActualSchema.GetActualProperties(true))) .Union(OneOf.Where(s => s.ActualSchema != ignoredSchema).SelectMany(s => s.ActualSchema.GetActualProperties(true))) .ToList(); // Collapse all duplicated properties, checking that the duplicated ones are compatible var duplicatedProperties = properties .GroupBy(p => p.Key) .Where(g => g.Count() > 1) .Select(g => g.ToList()) .ToList(); var invalidDuplicates = new List <string>(); foreach (var duped in duplicatedProperties) { // Make sure all the properties are the same type as each other so they are compatible primitive types var toKeep = duped[0].Value; if (duped.Any(dupe => dupe.Value.Type != toKeep.Type)) { invalidDuplicates.Add(duped[0].Key); continue; } // All good, so remove the duplicates here foreach (var c in duped.Skip(1)) { properties.Remove(c); } } if (invalidDuplicates.Count > 0) { throw new InvalidOperationException("The properties " + string.Join(", ", invalidDuplicates.Select(key => "'" + key + "'")) + " are defined multiple times and are not the same type."); } #if !LEGACY return(new ReadOnlyDictionary <string, JsonSchemaProperty>(properties.ToDictionary(p => p.Key, p => p.Value))); #else return(new Dictionary <string, JsonSchemaProperty>(properties.ToDictionary(p => p.Key, p => p.Value))); #endif }
public static DynamicLayout GetLayout(AnyOf boundaryCondition) { var bc = boundaryCondition.Obj; if (bc is Surface) { return(EmptyLayout); } else if (bc is Outdoors bcOutdoors) { return(CreateOutdoorLayout(bcOutdoors)); } else { return(EmptyLayout); } }
/// <exception cref="InvalidOperationException">Cyclic references detected.</exception> /// <exception cref="InvalidOperationException">The schema reference path has not been resolved.</exception> private JsonSchema GetActualSchema(IList <JsonSchema> checkedSchemas) { if (checkedSchemas.Contains(this)) { throw new InvalidOperationException("Cyclic references detected."); } if (((IJsonReferenceBase)this).ReferencePath != null && Reference == null) { throw new InvalidOperationException("The schema reference path '" + ((IJsonReferenceBase)this).ReferencePath + "' has not been resolved."); } if (HasReference) { checkedSchemas.Add(this); if (HasAllOfSchemaReference) { return(AllOf.First().GetActualSchema(checkedSchemas)); } if (HasOneOfSchemaReference) { return(OneOf.First().GetActualSchema(checkedSchemas)); } if (HasAnyOfSchemaReference) { return(AnyOf.First().GetActualSchema(checkedSchemas)); } return(Reference.GetActualSchema(checkedSchemas)); } return(this); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public virtual bool Equals(IJsonSchema other) { var schema = other as JsonSchema04; if (ReferenceEquals(null, schema)) { return(false); } if (ReferenceEquals(this, schema)) { return(true); } if (Id != schema.Id) { return(false); } if (Schema != schema.Schema) { return(false); } if (Title != schema.Title) { return(false); } if (Description != schema.Description) { return(false); } if (!Equals(Default, schema.Default)) { return(false); } if (MultipleOf != schema.MultipleOf) { return(false); } if (Maximum != schema.Maximum) { return(false); } if (ExclusiveMaximum != schema.ExclusiveMaximum) { return(false); } if (Minimum != schema.Minimum) { return(false); } if (ExclusiveMinimum != schema.ExclusiveMinimum) { return(false); } if (MaxLength != schema.MaxLength) { return(false); } if (MinLength != schema.MinLength) { return(false); } if (Pattern != schema.Pattern) { return(false); } if (!Equals(AdditionalItems, schema.AdditionalItems)) { return(false); } if (!Equals(Items, schema.Items)) { return(false); } if (MaxItems != schema.MaxItems) { return(false); } if (MinItems != schema.MinItems) { return(false); } if (UniqueItems != schema.UniqueItems) { return(false); } if (!Equals(AdditionalProperties, schema.AdditionalProperties)) { return(false); } if (!Definitions.ContentsEqual(schema.Definitions)) { return(false); } if (!Properties.ContentsEqual(schema.Properties)) { return(false); } if (!PatternProperties.ContentsEqual(PatternProperties)) { return(false); } if (!Dependencies.ContentsEqual(schema.Dependencies)) { return(false); } if (!Enum.ContentsEqual(schema.Enum)) { return(false); } if (!Equals(Type, schema.Type)) { return(false); } if (!AllOf.ContentsEqual(schema.AllOf)) { return(false); } if (!AnyOf.ContentsEqual(schema.AnyOf)) { return(false); } if (!OneOf.ContentsEqual(schema.OneOf)) { return(false); } if (!Equals(Not, schema.Not)) { return(false); } if (!Equals(Format, schema.Format)) { return(false); } if (!Required.ContentsEqual(schema.Required)) { return(false); } return(Dependencies.ContentsEqual(schema.Dependencies)); }
/// <summary> /// Converts an object to a <see cref="JsonValue"/>. /// </summary> /// <param name="serializer">The <see cref="JsonSerializer"/> instance to use for additional serialization of values.</param> /// <returns>The <see cref="JsonValue"/> representation of the object.</returns> public virtual JsonValue ToJson(JsonSerializer serializer) { var json = new JsonObject(); if (Id != null) { json["id"] = Id; } if (!string.IsNullOrWhiteSpace(Schema)) { json["$schema"] = Schema; } if (Title != null) { json["title"] = Title; } if (!string.IsNullOrWhiteSpace(Description)) { json["description"] = Description; } if (Default != null) { json["default"] = Default; } if (MultipleOf.HasValue) { json["multipleOf"] = MultipleOf; } if (Maximum.HasValue) { json["maximum"] = Maximum; } if (ExclusiveMaximum.HasValue) { json["exclusiveMaximum"] = ExclusiveMaximum; } if (Minimum.HasValue) { json["minimum"] = Minimum; } if (ExclusiveMinimum.HasValue) { json["exclusiveMinimum"] = ExclusiveMinimum; } if (MaxLength.HasValue) { json["maxLength"] = MaxLength; } if (MinLength.HasValue) { json["minLength"] = MinLength; } if (Pattern != null) { json["pattern"] = Pattern; } if (AdditionalItems != null) { json["additionalItems"] = AdditionalItems.ToJson(serializer); } if (Items != null) { json["items"] = Items.ToJson(serializer); } if (MaxItems.HasValue) { json["maxItems"] = MinItems; } if (MinItems.HasValue) { json["minItems"] = MinItems; } if (UniqueItems ?? false) { json["uniqueItems"] = UniqueItems; } if (MaxProperties.HasValue) { json["maxProperties"] = MaxProperties; } if (MinProperties.HasValue) { json["minProperties"] = MinProperties; } if (Required != null) { var array = Required.ToJson(); array.Array.EqualityStandard = ArrayEquality.ContentsEqual; json["required"] = array; } if (AdditionalProperties != null) { json["additionalProperties"] = AdditionalProperties.ToJson(serializer); } if (Definitions != null) { json["definitions"] = Definitions.ToJson(serializer); } if (Properties != null) { json["properties"] = Properties.ToJson(serializer); } if (PatternProperties != null && PatternProperties.Any()) { json["patternProperties"] = PatternProperties.ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value).ToJson(serializer); } if (Dependencies != null && Dependencies.Any()) { var jsonDependencies = new JsonObject(); foreach (var dependency in Dependencies) { jsonDependencies[dependency.PropertyName] = dependency.GetJsonData(); } json["dependencies"] = jsonDependencies; } if (Enum != null) { var array = Enum.ToJson(serializer); array.Array.EqualityStandard = ArrayEquality.ContentsEqual; json["enum"] = Enum.ToJson(serializer); } if (Type != JsonSchemaType.NotDefined) { var array = Type.ToJson(); if (array.Type == JsonValueType.Array) { array.Array.EqualityStandard = ArrayEquality.ContentsEqual; } json["type"] = array; } if (AllOf != null) { var array = AllOf.Select(s => s.ToJson(serializer)).ToJson(); array.EqualityStandard = ArrayEquality.ContentsEqual; json["allOf"] = array; } if (AnyOf != null) { var array = AnyOf.Select(s => s.ToJson(serializer)).ToJson(); array.EqualityStandard = ArrayEquality.ContentsEqual; json["anyOf"] = array; } if (OneOf != null) { var array = OneOf.Select(s => s.ToJson(serializer)).ToJson(); array.EqualityStandard = ArrayEquality.ContentsEqual; json["oneOf"] = array; } if (Not != null) { json["not"] = Not.ToJson(serializer); } if (Format != null) { json["format"] = Format.Key; } if (ExtraneousDetails != null) { foreach (var kvp in ExtraneousDetails.Where(kvp => !_definedProperties.Contains(kvp.Key))) { json[kvp.Key] = kvp.Value; } } return(json); }
/// <summary> /// Initializes a new instance of the <see cref="LinqMatcher"/> class. /// </summary> /// <param name="matchBehaviour">The match behaviour.</param> /// <param name="pattern">The pattern.</param> public LinqMatcher(MatchBehaviour matchBehaviour, [NotNull] AnyOf <string, StringPattern> pattern) : this(matchBehaviour, false, pattern) { }
public static Construction ToSAM_Construction(this AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> construction, Core.MaterialLibrary materialLibrary = null) { if (construction == null) { return(null); } string name = null; List <string> materialNames = null; if (construction.Obj is OpaqueConstructionAbridged) { name = ((OpaqueConstructionAbridged)construction.Obj).Identifier; materialNames = ((OpaqueConstructionAbridged)construction.Obj).Materials; } else if (construction.Obj is WindowConstructionAbridged) { name = ((WindowConstructionAbridged)construction.Obj).Identifier; materialNames = ((WindowConstructionAbridged)construction.Obj).Materials; } else if (construction.Obj is ShadeConstruction) { name = ((ShadeConstruction)construction.Obj).Identifier; } else if (construction.Obj is AirBoundaryConstructionAbridged) { name = ((AirBoundaryConstructionAbridged)construction.Obj).Identifier; } if (string.IsNullOrWhiteSpace(name)) { return(null); } List <ConstructionLayer> constructionLayers = null; if (materialNames != null) { constructionLayers = new List <ConstructionLayer>(); foreach (string materialName in materialNames) { double thickness = 0; AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGlazing, EnergyWindowMaterialGas> material_Honeybee = SAM.Core.LadybugTools.Query.DefaultMaterial(materialName); if (material_Honeybee != null) { if (material_Honeybee.Obj is EnergyMaterial) { thickness = ((EnergyMaterial)material_Honeybee.Obj).Thickness; } else if (material_Honeybee.Obj is EnergyMaterialNoMass) { } else if (material_Honeybee.Obj is EnergyWindowMaterialGlazing) { thickness = ((EnergyWindowMaterialGlazing)material_Honeybee.Obj).Thickness; } else if (material_Honeybee.Obj is EnergyWindowMaterialGas) { thickness = ((EnergyWindowMaterialGas)material_Honeybee.Obj).Thickness; } } constructionLayers.Add(new ConstructionLayer(materialName, thickness)); } } return(new Construction(name, constructionLayers)); }
public bool Equals(JsonSchema other) { if (other is null) { return(false); } return(Id == other.Id && (SchemaVersion == null ? other.SchemaVersion == null : SchemaVersion.EqualsWithFragments(other.SchemaVersion)) && string.Equals(Title, other.Title, StringComparison.Ordinal) && string.Equals(Description, other.Description, StringComparison.Ordinal) && Type.HasSameElementsAs(other.Type) && Enum.HasSameElementsAs(other.Enum) && (Items == null ? other.Items == null : Items.Equals(other.Items)) && (Properties == null ? other.Properties == null : Properties.HasSameElementsAs(other.Properties)) && Required.HasSameElementsAs(other.Required) && Definitions.HasSameElementsAs(other.Definitions) && (AdditionalItems == null ? other.AdditionalItems == null : AdditionalItems.Equals(other.AdditionalItems)) && (AdditionalProperties == null ? other.AdditionalProperties == null : AdditionalProperties.Equals(other.AdditionalProperties)) && (Dependencies == null ? other.Dependencies == null : Dependencies.HasSameElementsAs(other.Dependencies)) && (PatternProperties == null ? other.PatternProperties == null : PatternProperties.HasSameElementsAs(other.PatternProperties)) && (Reference == null ? other.Reference == null : Reference.Equals(other.Reference)) && Object.Equals(Default, other.Default) && Pattern == other.Pattern && MaxLength == other.MaxLength && MinLength == other.MinLength && MultipleOf == other.MultipleOf && Maximum == other.Maximum && ExclusiveMaximum == other.ExclusiveMaximum && MinItems == other.MinItems && MaxItems == other.MaxItems && UniqueItems == other.UniqueItems && string.Equals(Format, other.Format, StringComparison.Ordinal) && (AllOf == null ? other.AllOf == null : AllOf.HasSameElementsAs(other.AllOf)) && (AnyOf == null ? other.AnyOf == null : AnyOf.HasSameElementsAs(other.AnyOf)) && (OneOf == null ? other.OneOf == null : OneOf.HasSameElementsAs(other.OneOf)) && (Not == null ? other.Not == null : Not.Equals(other.Not))); }
public IElement GetInstance(Node node) { return(AnyOf.GetInstance(node)); }
public IElement GetInstance(string value) { return(AnyOf.GetInstance(value)); }
public static Face ToLadybugTools_Face(this IPartition partition, BuildingModel buildingModel, Space space) { Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(partition?.Face3D); if (face3D == null) { return(null); } FaceType?faceType = partition.FaceType(); if (faceType == null || !faceType.HasValue) { return(null); } int index = -1; int index_Adjacent = -1; bool reverse = true; List <Space> spaces = buildingModel.GetSpaces(partition); if (spaces != null && spaces.Count != 0) { index = spaces.FindIndex(x => x.Guid == space.Guid); index = buildingModel.UniqueIndex(spaces[index]); index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid); index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]); reverse = buildingModel.UniqueIndex(spaces[0]) != index; } AnyOf <Ground, Outdoors, Adiabatic, Surface> boundaryCondition = partition.ToLadybugTools_BoundaryCondition(buildingModel, space); FaceEnergyPropertiesAbridged faceEnergyPropertiesAbridged = new FaceEnergyPropertiesAbridged(); if (partition is IHostPartition) { faceEnergyPropertiesAbridged.Construction = Query.UniqueName(((IHostPartition)partition).Type(), reverse); } Face face = new Face(Query.UniqueName(partition, index), face3D, faceType.Value, boundaryCondition, new FacePropertiesAbridged(faceEnergyPropertiesAbridged), partition.Name); if (partition is IHostPartition) { List <IOpening> openings = ((IHostPartition)partition).GetOpenings(); if (openings != null && openings.Count != 0) { List <HoneybeeSchema.Aperture> apertures = new List <HoneybeeSchema.Aperture>(); List <HoneybeeSchema.Door> doors = new List <HoneybeeSchema.Door>(); foreach (IOpening opening in openings) { MaterialType materialType = MaterialType.Opaque; OpeningType openingType = opening.Type(); if (openingType != null) { materialType = buildingModel.GetMaterialType(openingType.PaneMaterialLayers); } if (opening is Window && materialType != MaterialType.Opaque) { HoneybeeSchema.Aperture aperture = ((Window)opening).ToLadybugTools(buildingModel, space); if (aperture != null) { apertures.Add(aperture); } } else { HoneybeeSchema.Door door = opening.ToLadybugTools(buildingModel, space); if (door != null) { doors.Add(door); } } } if (apertures != null && apertures.Count != 0) { face.Apertures = apertures; } if (doors != null && doors.Count != 0) { face.Doors = doors; } } } return(face); }
public static Aperture ToSAM(this HoneybeeSchema.Aperture aperture, bool @internal, IEnumerable <ApertureConstruction> apertureConstructions = null) { if (aperture == null) { return(null); } Geometry.Spatial.Face3D face3D = Geometry.LadybugTools.Convert.ToSAM(aperture.Geometry); if (face3D == null) { return(null); } ApertureConstruction apertureConstruction = null; if (apertureConstructions != null && aperture.Properties?.Energy?.Construction != null) { foreach (ApertureConstruction apertureConstruction_Temp in apertureConstructions) { if (apertureConstruction_Temp == null) { continue; } if (apertureConstruction_Temp.ApertureType != ApertureType.Window) { continue; } if (aperture.Properties.Energy.Construction == apertureConstruction_Temp.Name) { apertureConstruction = apertureConstruction_Temp; break; } } } if (apertureConstruction == null) { AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> construction_Honeybee = Query.DefaultApertureConstruction(ApertureType.Window, @internal); if (construction_Honeybee != null) { apertureConstruction = construction_Honeybee.ToSAM_ApertureConstruction(); } } if (apertureConstruction == null) { apertureConstruction = new ApertureConstruction(aperture.DisplayName, ApertureType.Window); } Aperture result = new Aperture(apertureConstruction, face3D, Analytical.Query.OpeningLocation(face3D)); return(result); }
public static Face ToLadybugTools_Face(this Panel panel, AnalyticalModel analyticalModel = null, int index = -1, bool reverse = true) { if (panel == null || panel.PanelType == PanelType.Shade) { return(null); } Face3D face3D = panel.PlanarBoundary3D.ToLadybugTools(); if (face3D == null) { return(null); } AdjacencyCluster adjacencyCluster = analyticalModel?.AdjacencyCluster; Space space_Adjacent = null; int index_Adjacent = -1; if (adjacencyCluster != null && index != -1) { List <Space> spaces = adjacencyCluster.GetSpaces(panel); if (spaces != null && spaces.Count != 0) { foreach (Space space in spaces) { int index_Temp = adjacencyCluster.GetIndex(space); if (!index_Temp.Equals(index)) { space_Adjacent = space; index_Adjacent = index_Temp; break; } } } } string adjacentPanelUniqueName = null; string adjacentSpaceUniqueName = null; if (space_Adjacent != null && index_Adjacent != -1) { adjacentPanelUniqueName = Query.UniqueName(panel, index_Adjacent); adjacentSpaceUniqueName = Query.UniqueName(space_Adjacent); } AnyOf <Ground, Outdoors, Adiabatic, Surface> boundaryCondition = panel.ToLadybugTools_BoundaryCondition(adjacentPanelUniqueName, adjacentSpaceUniqueName); FaceType faceType; PanelType panelType = panel.PanelType; PanelGroup panelGroup = panelType.PanelGroup(); if (panelGroup == PanelGroup.Floor && Analytical.Query.PanelType(panel.Normal) == PanelType.Roof) { faceType = FaceType.RoofCeiling; } else { faceType = Query.FaceTypeEnum(panelType); } FaceEnergyPropertiesAbridged faceEnergyPropertiesAbridged = new FaceEnergyPropertiesAbridged(); if (faceType != FaceType.AirBoundary) { faceEnergyPropertiesAbridged.Construction = Query.UniqueName(panel.Construction, reverse); } Face face = new Face(Query.UniqueName(panel, index), face3D, faceType, boundaryCondition, new FacePropertiesAbridged(faceEnergyPropertiesAbridged), panel.Name); List <Aperture> apertures = panel.Apertures;//Analytical.Query.OffsetAperturesOnEdge(panel, 0.1); if (apertures != null && apertures.Count > 0) { MaterialLibrary materialLibrary = analyticalModel?.MaterialLibrary; face.Apertures = apertures.ConvertAll(x => x.ToLadybugTools(materialLibrary, index, index_Adjacent, adjacentPanelUniqueName, adjacentSpaceUniqueName)).FindAll(x => x != null); face.Doors = apertures.ConvertAll(x => x.ToLadybugTools_Door(materialLibrary, index, index_Adjacent, adjacentPanelUniqueName, adjacentSpaceUniqueName)).FindAll(x => x != null); } return(face); }
/// <summary> /// Initializes a new instance of the <see cref="RegexMatcher"/> class. /// </summary> /// <param name="matchBehaviour">The match behaviour.</param> /// <param name="pattern">The pattern.</param> /// <param name="ignoreCase">Ignore the case from the pattern.</param> public RegexMatcher(MatchBehaviour matchBehaviour, [NotNull, RegexPattern] AnyOf <string, StringPattern> pattern, bool ignoreCase = false) : this(matchBehaviour, new[] { pattern }, ignoreCase) { }
/// <summary> /// Initializes a new instance of the <see cref="RegexMatcher"/> class. /// </summary> /// <param name="pattern">The pattern.</param> /// <param name="ignoreCase">Ignore the case from the pattern.</param> public RegexMatcher([NotNull, RegexPattern] AnyOf <string, StringPattern> pattern, bool ignoreCase = false) : this(new[] { pattern }, ignoreCase) { }
public static string GetPattern([NotNull] this AnyOf <string, StringPattern> value) { return(value.IsFirst ? value.First : value.Second.Pattern); }