Skip to content

Commit

Permalink
[FIX] Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanael smiechowski committed Oct 28, 2024
1 parent 3ce5f42 commit e77445f
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 40 deletions.
1 change: 0 additions & 1 deletion uml4net.xmi.Tests/UMLXmiReaderTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace uml4net.xmi.Tests
using Microsoft.Extensions.Logging;

using NUnit.Framework;
using NUnit.Framework.Constraints;
using uml4net.POCO.Values;
using uml4net.POCO.Packages;
using uml4net.POCO.SimpleClassifiers;
Expand Down
1 change: 0 additions & 1 deletion uml4net.xmireader/Cache/Assembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace uml4net.xmi.Cache
using System.Reflection;
using Decorators;
using POCO;
using DocumentFormat.OpenXml.InkML;

/// <summary>
/// The purpose of the Assembler is to resolve all the reference properties of the objects
Expand Down
3 changes: 0 additions & 3 deletions uml4net.xmireader/Cache/IAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

namespace uml4net.xmi.Cache
{
using System.Collections.Generic;
using uml4net.POCO;

/// <summary>
/// The <see cref="IAssembler"/> is the interface definition for the <see cref="Assembler"/>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion uml4net.xmireader/Cache/IXmiReaderCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface IXmiReaderCache
Dictionary<string, IXmiElement> Cache { get; }

/// <summary>
/// Switches the current context to a new XMI file or section, allowing elements to be stored
/// Switches the current context to a new XMI file, allowing elements to be stored
/// under a distinct key in the cache. Initializes an empty dictionary in <see cref="XmiReaderCache.Cache"/>
/// for the specified context if it does not exist.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion uml4net.xmireader/Cache/XmiReaderCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public bool TryGetValue(string context, string key, out IXmiElement value)
}

/// <summary>
/// Switches the current context to a new XMI file or section, allowing elements to be stored
/// Switches the current context to a new XMI file, allowing elements to be stored
/// under a distinct key in the cache. Initializes an empty dictionary in <see cref="Cache"/>
/// for the specified context if it does not exist.
/// </summary>
Expand All @@ -138,6 +138,7 @@ public void Add(string id, IXmiElement element)
if (this.Cache.ContainsKey(id))
{
logger.LogError("Failed to add element type [{element}] with id [{id}]", element.GetType().Name, id);
return;
}

this.Cache[id] = element;
Expand Down
1 change: 0 additions & 1 deletion uml4net.xmireader/Readers/CommonStructure/CommentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace uml4net.xmi.Readers.CommonStructure

using Microsoft.Extensions.Logging;
using POCO;
using uml4net.POCO.Classification;
using uml4net.POCO.CommonStructure;
using Cache;
using Readers;
Expand Down
1 change: 0 additions & 1 deletion uml4net.xmireader/Readers/IXmiReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace uml4net.xmi.Readers
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using uml4net.POCO.Packages;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions uml4net.xmireader/Readers/Values/OpaqueExpressionReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
namespace uml4net.xmi.Readers.Values
{
using System;
using System.Collections.Generic;
using System.Xml;

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

using POCO;
using uml4net.POCO.CommonStructure;
using uml4net.POCO.Values;
Expand Down
39 changes: 16 additions & 23 deletions uml4net.xmireader/Readers/XmiReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ namespace uml4net.xmi.Readers
using System.Xml;

using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using uml4net.POCO.Packages;

using uml4net;
using xmi;

/// <summary>
Expand All @@ -48,17 +45,7 @@ public class XmiReader : IXmiReader
/// The <see cref="ILogger"/> used to log
/// </summary>
private readonly ILogger<XmiReader> logger;

/// <summary>
/// The <see cref="IXmiElementReader{T}"/>of <see cref="IPackage"/>
/// </summary>
private readonly IXmiElementReader<IPackage> packageReader;

/// <summary>
/// The <see cref="IXmiElementReader{T}"/>of <see cref="IModel"/>
/// </summary>
private readonly IXmiElementReader<IModel> modelReader;


/// <summary>
/// The <see cref="IExternalReferenceResolver"/>
/// </summary>
Expand All @@ -74,6 +61,16 @@ public class XmiReader : IXmiReader
/// </summary>
private readonly IXmiReaderCache cache;

/// <summary>
/// The <see cref="IXmiElementReader{T}"/>of <see cref="IPackage"/>
/// </summary>
public IXmiElementReader<IPackage> PackageReader { get; set; }

/// <summary>
/// The <see cref="IXmiElementReader{T}"/>of <see cref="IModel"/>
/// </summary>
public IXmiElementReader<IModel> ModelReader { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="XmiReader"/> class.
/// </summary>
Expand All @@ -82,18 +79,14 @@ public class XmiReader : IXmiReader
/// <param name="logger">
/// The (injected) <see cref="ILogger{T}"/> used to setup logging
/// </param>
/// <param name="packageReader">The <see cref="IXmiElementReader{T}"/>of <see cref="IPackage"/></param>
/// <param name="modelReader">The <see cref="IXmiElementReader{T}"/>of <see cref="IModel"/></param>
/// <param name="externalReferenceResolver">The <see cref="IExternalReferenceResolver"/></param>
/// <param name="scope">The <see cref="IXmiReaderScope"/></param>
public XmiReader(IAssembler assembler, IXmiReaderCache cache, ILogger<XmiReader> logger, IXmiElementReader<IPackage> packageReader,
IXmiElementReader<IModel> modelReader, IExternalReferenceResolver externalReferenceResolver, IXmiReaderScope scope)
public XmiReader(IAssembler assembler, IXmiReaderCache cache, ILogger<XmiReader> logger,
IExternalReferenceResolver externalReferenceResolver, IXmiReaderScope scope)
{
this.assembler = assembler;
this.cache = cache;
this.logger = logger;
this.packageReader = packageReader;
this.modelReader = modelReader;
this.externalReferenceResolver = externalReferenceResolver;
this.scope = scope;
}
Expand Down Expand Up @@ -171,15 +164,15 @@ private IEnumerable<IPackage> Read(Stream stream, bool isRoot)
case "uml:Package":
using (var packageXmlReader = xmlReader.ReadSubtree())
{
var package = this.packageReader.Read(packageXmlReader);
var package = this.PackageReader.Read(packageXmlReader);
packages.Add(package);
}

break;
case "uml:Model":
using (var modelXmlReader = xmlReader.ReadSubtree())
{
var model = this.modelReader.Read(modelXmlReader);
var model = this.ModelReader.Read(modelXmlReader);
packages.Add(model);
}

Expand Down Expand Up @@ -217,7 +210,7 @@ private void TryResolveExternalReferences()
this.Read(externalResource, false);
}

this.logger.LogTrace("External eferences synchronized in {time}", stopwatch.ElapsedMilliseconds);
this.logger.LogTrace("External references synchronized in {time}", stopwatch.ElapsedMilliseconds);
stopwatch.Stop();
}

Expand Down
3 changes: 0 additions & 3 deletions uml4net.xmireader/XmiReaderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
namespace uml4net.xmi
{
using Autofac;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Settings;
using System;
using System.Net.Http;
using Readers;

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions uml4net.xmireader/XmiReaderScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace uml4net.xmi
using Readers.StructuredClassifiers;
using Readers.Values;
using Settings;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Represents the scope for configuring and managing services used by the XMI reader.
Expand Down Expand Up @@ -81,12 +80,12 @@ internal XmiReaderScope()
// Required services
this.ContainerBuilder.RegisterGeneric(typeof(Logger<>)).As(typeof(ILogger<>));
this.ContainerBuilder.RegisterInstance(this).As<IXmiReaderScope>().SingleInstance();
this.ContainerBuilder.RegisterType<XmiReader>().As<IXmiReader>();
this.ContainerBuilder.RegisterType<Assembler>().As<IAssembler>();
this.ContainerBuilder.RegisterType<XmiReaderCache>().As<IXmiReaderCache>().SingleInstance();
this.ContainerBuilder.RegisterType<ExternalReferenceResolver>().As<IExternalReferenceResolver>().SingleInstance();

// Readers
this.ContainerBuilder.RegisterType<XmiReader>().As<IXmiReader>().PropertiesAutowired();
this.ContainerBuilder.RegisterType<GeneralizationReader>().As<IXmiElementReader<IGeneralization>>().PropertiesAutowired();
this.ContainerBuilder.RegisterType<PropertyReader>().As<IXmiElementReader<IProperty>>().PropertiesAutowired();
this.ContainerBuilder.RegisterType<CommentReader>().As<IXmiElementReader<IComment>>().PropertiesAutowired();
Expand Down

0 comments on commit e77445f

Please sign in to comment.