Skip to content

Commit

Permalink
[Remove] duplicate Class.QueryAllContainedNonDerivedNonRedefinedPrope…
Browse files Browse the repository at this point in the history
…rties

[Refactor] PropertyExtensions.QueryIsBool and TryQueryRedefinedByProperty
  • Loading branch information
samatstariongroup committed Dec 29, 2024
1 parent fc3f031 commit 6fe828d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
17 changes: 4 additions & 13 deletions uml4net.Extensions/PropertyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static bool QueryIsBool(this IProperty property)
throw new ArgumentNullException(nameof(property));
}

return property?.Type?.Name?.IndexOf("bool", StringComparison.InvariantCultureIgnoreCase) >= 0;
return property.Type?.Name?.IndexOf("bool", StringComparison.InvariantCultureIgnoreCase) >= 0;
}

/// <summary>
Expand Down Expand Up @@ -472,19 +472,10 @@ public static bool TryQueryRedefinedByProperty(this IProperty property, IClass c
throw new ArgumentNullException(nameof(context));
}

var properties = context.QueryAllProperties();
redefinedByProperty = context.QueryAllProperties()
.FirstOrDefault(prop => prop.RedefinedProperty.Any(x => x.XmiId == property.XmiId));

foreach (var prop in properties)
{
if (prop.RedefinedProperty.Any(x => x.XmiId == property.XmiId))
{
redefinedByProperty = prop;
return true;
}
}

redefinedByProperty = null;
return false;
return redefinedByProperty != null;
}
}
}
29 changes: 0 additions & 29 deletions uml4net.HandleBars/ClassHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,6 @@ public static void RegisterClassHelper(this IHandlebars handlebars)
return nonRedefinedProperties;
});

handlebars.RegisterHelper("Class.QueryAllContainedNonDerivedNonRedefinedProperties", (context, parameters) =>
{
if (!(context.Value is IClass @class))
{
throw new ArgumentException("supposed to be IClass");
}

var properties = @class.QueryAllProperties()
.Where(x => x.IsComposite)
.Where(x => !x.IsDerived)
.OrderBy(x => x.Name)
.ToList();

var nonRedefinedProperties = properties.ToList();

foreach (var property in properties)
{
foreach (var redefinedProperty in property.RedefinedProperty)
{
if (nonRedefinedProperties.Contains(redefinedProperty))
{
nonRedefinedProperties.Remove(redefinedProperty);
}
}
}

return nonRedefinedProperties;
});

handlebars.RegisterHelper("Class.QueryAllNonDerivedProperties", (context, parameters) =>
{
if (!(context.Value is IClass @class))
Expand Down
3 changes: 2 additions & 1 deletion uml4net/Extend/ActionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public static IClassifier QueryContext(this IAction action)
/// The subject <see cref="IAction"/>
/// </param>
/// <returns>
///
/// The ordered set of InputPins representing the inputs to the Action.
/// </returns>
public static IContainerList<IInputPin> QueryInput(this IAction action)
{

throw new NotSupportedException();
}

Expand Down

0 comments on commit 6fe828d

Please sign in to comment.