public ExchangeRequirements_TfNSW_Drainage(List <IfcPropertySetTemplate> propertyTemplates) : base() { PropertyTemplates.AddRange(propertyTemplates); IfcClassification classification = new IfcClassification(new DatabaseIfc(ModelView.Ifc4NotAssigned), "Uniclass2015"); //Indicitive/candidate sender, receiver, activity, process... ApplicableProcess.Add(new IfcClassificationReference(classification) { Identification = "PM_40_30", Name = "Design information" }); Senders.Add(new IfcClassificationReference(classification) { Identification = "Ro_50_20_28", Name = "Drainage engineer (D)" }); Receivers.Add(new IfcClassificationReference(classification) { Identification = "Ro_10_30", Name = "Asset management roles" }); Activities.Add(new IfcClassificationReference(classification) { Identification = "Ac_05_40", Name = "Design stage activities" }); Activities.Add(new IfcClassificationReference(classification) { Identification = "Ac_05_60", Name = "Handover and close-out stage activities" }); //Exchange Requirements Concepts.Add(new Concept_TfNSW_AllDistributionElements()); // No building element proxies, all elements distribution element Concepts.Add(new Concept_TfNSW_StormWaterPipeSingleSweep()); // Future might force pipe axis definition with attributes // Validate all Systems are drainage // Validate Distribution System is assigned to all elements // To be advanced further }
private static void HandlePublicSetter(bool isMake, bool hasEvents, PropertyInfo baseProperty, List <string> propertyImplementations) { var setMethod = baseProperty.SetMethod; var setVisibility = setMethod.IsPublic ? string.Empty : CodeTemplates.GetVisibility(setMethod.IsFamily, setMethod.IsFamilyOrAssembly); if (isMake) { propertyImplementations.Add(PropertyTemplates.GetPropertySetForMake(setVisibility)); } else if (setMethod.GetParameters()[0].ParameterType.IsSpanLike()) { propertyImplementations.Add(PropertyTemplates.GetPropertySetForSpanLike(setVisibility)); } else { var setArgumentNameList = setMethod.GetArgumentNameList(); var setDelegateCast = setMethod.GetDelegateCast(); if (setMethod.GetParameters().Length > 0) { var setExpectationChecks = setMethod.GetExpectationChecks(); var setExpectationExceptionMessage = setMethod.GetExpectationExceptionMessage(); propertyImplementations.Add(PropertyTemplates.GetPropertySet( setMethod.MetadataToken, setArgumentNameList, setExpectationChecks, setDelegateCast, setExpectationExceptionMessage, setVisibility, hasEvents)); } else { propertyImplementations.Add(PropertyTemplates.GetPropertySetAndNoIndexers( setMethod.MetadataToken, setArgumentNameList, setDelegateCast, setVisibility, hasEvents)); } } }
public static void GetPropertySetAndHasEventsIsFalse() => Assert.That(PropertyTemplates.GetPropertySet(1, "b", "c", "d", "e", "f", false), Is.EqualTo( @"f set { if (this.handlers.TryGetValue(1, out var methodHandlers)) { var foundMatch = false; foreach(var methodHandler in methodHandlers) { if(c) { foundMatch = true; if(methodHandler.Method != null) { ((d)methodHandler.Method)(b); } methodHandler.IncrementCallCount(); break; } } if(!foundMatch) { throw new RE.ExpectationException($""No handlers were found for e""); } } else { throw new RE.ExpectationException($""No handlers were found for e""); } }"));
private string PropertyTemplateFor(string propertyName) { if (string.IsNullOrEmpty(propertyName)) { return(string.Empty); } return(PropertyTemplates.ContainsKey(propertyName) ? PropertyTemplates[propertyName] : string.Empty); }
private static bool HandleNonPrivateAbstractProperty(SortedSet <string> namespaces, bool requiresObsoleteSuppression, List <string> generatedProperties, PropertyMockableResult property, PropertyInfo baseProperty, ParameterInfo[] indexers, MethodInfo propertyMethod) { var propertyImplementations = new List <string>(); var visibility = property.RequiresExplicitInterfaceImplementation == RequiresExplicitInterfaceImplementation.Yes ? string.Empty : CodeTemplates.GetVisibility(propertyMethod.IsFamily, propertyMethod.IsFamilyOrAssembly); if (property.Accessors == PropertyAccessors.Get || property.Accessors == PropertyAccessors.GetAndSet) { var getVisibility = CodeTemplates.GetVisibility(baseProperty.GetMethod.IsFamily, baseProperty.GetMethod.IsFamilyOrAssembly); if (getVisibility == visibility) { getVisibility = string.Empty; } propertyImplementations.Add(PropertyTemplates.GetNonPublicPropertyGet(getVisibility)); } if (property.Accessors == PropertyAccessors.Set || property.Accessors == PropertyAccessors.GetAndSet) { var setVisibility = CodeTemplates.GetVisibility(baseProperty.SetMethod.IsFamily, baseProperty.SetMethod.IsFamilyOrAssembly); if (setVisibility == visibility) { setVisibility = string.Empty; } propertyImplementations.Add(PropertyTemplates.GetNonPublicPropertySet(setVisibility)); } var explicitInterfaceName = property.RequiresExplicitInterfaceImplementation == RequiresExplicitInterfaceImplementation.Yes ? $"{property.Value.DeclaringType.GetFullName(namespaces)}." : string.Empty; if (indexers.Length > 0) { var parameters = string.Join(", ", from indexer in indexers let _ = namespaces.Add(indexer.ParameterType.Namespace) select $"{indexer.ParameterType.Name} {indexer.Name}"); // Indexer generatedProperties.Add(PropertyTemplates.GetNonPublicPropertyIndexer(visibility, $"{baseProperty.PropertyType.GetFullName(namespaces)}", parameters, string.Join(Environment.NewLine, propertyImplementations), explicitInterfaceName)); } else { // Normal generatedProperties.Add(PropertyTemplates.GetNonPublicProperty(visibility, $"{baseProperty.PropertyType.GetFullName(namespaces)}", baseProperty.Name, string.Join(Environment.NewLine, propertyImplementations), explicitInterfaceName)); } requiresObsoleteSuppression |= baseProperty.GetCustomAttribute <ObsoleteAttribute>() != null; return(requiresObsoleteSuppression); }
protected virtual string GenerateInvalidProperties(T info) { var errorMessage = GetErrorMessage(info); if (errorMessage?.Length > 0) { return(PropertyTemplates.Invalid(GetPropertyName(info), GetModuleName(info), errorMessage)); } return(PropertyTemplates.Invalid(GetPropertyName(info), GetModuleName(info))); }
protected virtual string GenerateBrowseFields(T info, string type) { var pipe = type == TypeScript.Types.Datetime ? TypeScript.Pipes.MsDate : string.Empty; var referenceType = GetReferenceType(info); if (!string.IsNullOrWhiteSpace(referenceType)) { return(PropertyTemplates.BrowseReferenceFields(info.Name, type, PropertyNameSuffix, pipe, referenceType)); } return(PropertyTemplates.BrowseFields(info.Name, type, pipe)); }
protected virtual string GenerateDefinition(T info, string type) { switch (type) { case TypeScript.Types.Datetime: case TypeScript.Types.LongString: return(PropertyTemplates.Definition(info.Name, TypeScript.Types.String, PropertyNameSuffix)); case TypeScript.Types.Binary: return(PropertyTemplates.Definition(info.Name, TypeScript.Types.Any, PropertyNameSuffix)); } return(PropertyTemplates.Definition(info.Name, type, PropertyNameSuffix)); }
private static bool HandlePublicProperty(SortedSet <string> namespaces, bool isMake, bool hasEvents, bool requiresObsoleteSuppression, List <string> generatedProperties, PropertyMockableResult property, PropertyInfo baseProperty, ParameterInfo[] indexers, string @override) { var propertyImplementations = new List <string>(); var parameter = property.Accessors == PropertyAccessors.Get || property.Accessors == PropertyAccessors.GetAndSet ? baseProperty.GetGetMethod().ReturnParameter : baseProperty.GetSetMethod().GetParameters()[0]; if (property.Accessors == PropertyAccessors.Get || property.Accessors == PropertyAccessors.GetAndSet) { PropertiesGenerator.HandlePublicGetter(namespaces, isMake, hasEvents, baseProperty, propertyImplementations); } if (property.Accessors == PropertyAccessors.Set || property.Accessors == PropertyAccessors.GetAndSet) { PropertiesGenerator.HandlePublicSetter(isMake, hasEvents, baseProperty, propertyImplementations); } var visibility = property.RequiresExplicitInterfaceImplementation == RequiresExplicitInterfaceImplementation.Yes ? string.Empty : CodeTemplates.Public; var explicitInterfaceName = property.RequiresExplicitInterfaceImplementation == RequiresExplicitInterfaceImplementation.Yes ? $"{property.Value.DeclaringType.GetFullName(namespaces)}." : string.Empty; if (indexers.Length > 0) { var parameters = string.Join(", ", from indexer in indexers let _ = namespaces.Add(indexer.ParameterType.Namespace) select $"{indexer.ParameterType.Name} {indexer.Name}"); // Indexer generatedProperties.Add(PropertyTemplates.GetPropertyIndexer( $"{@override}{baseProperty.PropertyType.GetFullName(namespaces, parameter)}", parameters, string.Join(Environment.NewLine, propertyImplementations), visibility, explicitInterfaceName)); } else { // Normal generatedProperties.Add(PropertyTemplates.GetProperty( $"{@override}{baseProperty.PropertyType.GetFullName(namespaces, parameter)}", baseProperty.Name, string.Join(Environment.NewLine, propertyImplementations), visibility, explicitInterfaceName)); } requiresObsoleteSuppression |= baseProperty.GetCustomAttribute <ObsoleteAttribute>() != null; return(requiresObsoleteSuppression); }
public static void GetPropertyGetWithReferenceTypeReturnValueAndNoIndexersAndHasEventsIsFalse() => Assert.That(PropertyTemplates.GetPropertyGetWithReferenceTypeReturnValueAndNoIndexers(1, "b", "c", "d", "e", false), Is.EqualTo( @"e get { if (this.handlers.TryGetValue(1, out var methodHandlers)) { var methodHandler = methodHandlers[0]; var result = methodHandler.Method != null ? (c)((d)methodHandler.Method)(b) : ((R.HandlerInformation<c>)methodHandler).ReturnValue; methodHandler.IncrementCallCount(); return result; } throw new RE.ExpectationException(""No handlers were found.""); }"));
public static void GetPropertyGetWithValueTypeReturnValueAndNoIndexersAndHasEventsIsTrue() => Assert.That(PropertyTemplates.GetPropertyGetWithValueTypeReturnValueAndNoIndexers(1, "b", "c", "d", "e", true), Is.EqualTo( @"e get { if (this.handlers.TryGetValue(1, out var methodHandlers)) { var methodHandler = methodHandlers[0]; #pragma warning disable CS8604 var result = methodHandler.Method != null ? (c)((d)methodHandler.Method)(b) : ((R.HandlerInformation<c>)methodHandler).ReturnValue; #pragma warning restore CS8604 methodHandler.RaiseEvents(this); methodHandler.IncrementCallCount(); return result; } throw new RE.ExpectationException(""No handlers were found.""); }"));
private static void HandlePublicGetter(SortedSet <string> namespaces, bool isMake, bool hasEvents, PropertyInfo baseProperty, List <string> propertyImplementations) { var getMethod = baseProperty.GetMethod; var getVisibility = getMethod.IsPublic ? string.Empty : CodeTemplates.GetVisibility(getMethod.IsFamily, getMethod.IsFamilyOrAssembly); var returnType = $"{getMethod.ReturnType.GetFullName(namespaces, getMethod.ReturnParameter)}"; if (isMake) { propertyImplementations.Add(PropertyTemplates.GetPropertyGetForMake(getVisibility)); } else if (getMethod.ReturnType.IsSpanLike()) { propertyImplementations.Add(PropertyTemplates.GetPropertyGetForSpanLike(getVisibility)); } else { var getArgumentNameList = getMethod.GetArgumentNameList(); var getDelegateCast = getMethod.GetDelegateCast(); if (getMethod.GetParameters().Length > 0) { var getExpectationChecks = getMethod.GetExpectationChecks(); var getExpectationExceptionMessage = getMethod.GetExpectationExceptionMessage(); propertyImplementations.Add(getMethod.ReturnType.RequiresExplicitCast() ? PropertyTemplates.GetPropertyGetWithValueTypeReturnValue( getMethod.MetadataToken, getArgumentNameList, returnType, getExpectationChecks, getDelegateCast, getExpectationExceptionMessage, getVisibility, hasEvents) : PropertyTemplates.GetPropertyGetWithReferenceTypeReturnValue( getMethod.MetadataToken, getArgumentNameList, returnType, getExpectationChecks, getDelegateCast, getExpectationExceptionMessage, getVisibility, hasEvents)); } else { propertyImplementations.Add(getMethod.ReturnType.RequiresExplicitCast() ? PropertyTemplates.GetPropertyGetWithValueTypeReturnValueAndNoIndexers( getMethod.MetadataToken, getArgumentNameList, returnType, getDelegateCast, getVisibility, hasEvents) : PropertyTemplates.GetPropertyGetWithReferenceTypeReturnValueAndNoIndexers( getMethod.MetadataToken, getArgumentNameList, returnType, getDelegateCast, getVisibility, hasEvents)); } } }
public static void GetPropertySetAndNoIndexersAndHasEventsIsFalse() => Assert.That(PropertyTemplates.GetPropertySetAndNoIndexers(1, "b", "c", "d", false), Is.EqualTo( @"d set { if (this.handlers.TryGetValue(1, out var methodHandlers)) { var methodHandler = methodHandlers[0]; if(methodHandler.Method != null) { ((c)methodHandler.Method)(b); } methodHandler.IncrementCallCount(); } else { throw new RE.ExpectationException(""No handlers were found.""); } }"));
public static void GetPropertyGetWithReferenceTypeReturnValueAndHasEventsIsTrue() => Assert.That(PropertyTemplates.GetPropertyGetWithReferenceTypeReturnValue(1, "b", "c", "d", "e", "f", "g", true), Is.EqualTo( @"g get { if (this.handlers.TryGetValue(1, out var methodHandlers)) { foreach(var methodHandler in methodHandlers) { if(d) { var result = methodHandler.Method != null ? (c)((e)methodHandler.Method)(b) : ((R.HandlerInformation<c>)methodHandler).ReturnValue; methodHandler.RaiseEvents(this); methodHandler.IncrementCallCount(); return result; } } } throw new RE.ExpectationException($""No handlers were found for f""); }"));
public static void GetPropertySetAndNoIndexersAndHasEventsIsTrue() => Assert.That(PropertyTemplates.GetPropertySetAndNoIndexers(1, "b", "c", "d", true), Is.EqualTo( @"d set { if (this.handlers.TryGetValue(1, out var methodHandlers)) { var methodHandler = methodHandlers[0]; if(methodHandler.Method != null) { #pragma warning disable CS8604 ((c)methodHandler.Method)(b); #pragma warning restore CS8604 } methodHandler.RaiseEvents(this); methodHandler.IncrementCallCount(); } else { throw new RE.ExpectationException(""No handlers were found.""); } }"));
private void AssociatedObjectDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (container == null) { return; } container.Items.Clear(); var props = e.NewValue.GetType().GetProperties(); foreach (var prop in props) { foreach (var attr in prop.GetCustomAttributes()) { if (!PropertyTemplates.ContainsKey(attr.GetType())) { continue; } var templ = PropertyTemplates[attr.GetType()]; var element = Activator.CreateInstance(templ.Item1) as FrameworkElement; var binding = new Binding { Path = new PropertyPath(prop.Name), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; BindingOperations.SetBinding(element, templ.Item2, binding); container.Items.Add(element); } } }
public ImageTemplate Subscribe(ISubscription subscription) { IProperty existingProperty = Properties.FirstOrDefault(p => p.Subscription.UaTypeMetadata.Equals(subscription.UaTypeMetadata)); if (existingProperty != null) { existingProperty.Subscription = subscription; return(this); } else if (PropertyTemplates .Where(template => template.Name.Equals(subscription.UaTypeMetadata.TypeName)) .FirstOrDefault() is PropertyTemplate propertyTemplate) { Properties.Add(new DrawableProperty(subscription, propertyTemplate)); } else { Properties.Add(new PrintableProperty( subscription, new PropertyTemplate(subscription.UaTypeMetadata.TypeName, null, "#ffffff") )); } return(this); }
public static void GetPropertyGetWithValueTypeReturnValueAndHasEventsIsFalse() => Assert.That(PropertyTemplates.GetPropertyGetWithValueTypeReturnValue(1, "b", "c", "d", "e", "f", "g", false), Is.EqualTo( @"g get { if (this.handlers.TryGetValue(1, out var methodHandlers)) { foreach(var methodHandler in methodHandlers) { if(d) { #pragma warning disable CS8604 var result = methodHandler.Method != null ? (c)((e)methodHandler.Method)(b) : ((R.HandlerInformation<c>)methodHandler).ReturnValue; #pragma warning restore CS8604 methodHandler.IncrementCallCount(); return result; } } } throw new RE.ExpectationException($""No handlers were found for f""); }"));
public static void GetProperty() => Assert.That(PropertyTemplates.GetProperty("a", "b", "c", "d", "e"), Is.EqualTo("d a eb { c }"));
public static void GetPropertySetForMake() => Assert.That(PropertyTemplates.GetPropertySetForMake("a"), Is.EqualTo("a set { }"));
protected virtual string GenerateInitialization(T info, string type) { return(PropertyTemplates.Initialization(info.Name, PropertyNameSuffix)); }
public static void GetPropertyGetForMake() => Assert.That(PropertyTemplates.GetPropertyGetForMake("a"), Is.EqualTo( @"a get => default;"));
protected virtual string GenerateReturnValues(T info, string type) { return(PropertyTemplates.ReturnValues(info.Name, PropertyNameSuffix, CsTagsManager.Instance.Get <PropertyInfo>(CsTagNames.Return).Evaluate(info))); }
public static void GetPropertyIndexer() => Assert.That(PropertyTemplates.GetPropertyIndexer("a", "b", "c", "d", "e"), Is.EqualTo("d a ethis[b] { c }"));