Skip to content

Commit

Permalink
After code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phliberato committed Apr 25, 2023
1 parent d7c27f5 commit d157c9a
Show file tree
Hide file tree
Showing 118 changed files with 21,753 additions and 21,719 deletions.
3 changes: 0 additions & 3 deletions ConnectorAutocadCivil/AdvanceSteelAddinRegistrator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace AdvanceSteelAddinRegistrator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Document = Autodesk.AutoCAD.ApplicationServices.Document;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Runtime.InteropServices;
using System.Threading;

using Autodesk.AutoCAD.ApplicationServices;

#if ADVANCESTEEL2023
using Autodesk.AdvanceSteel.Runtime;
#else
Expand All @@ -16,8 +14,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.ReactiveUI;

using DesktopUI2;
using DesktopUI2.ViewModels;
using DesktopUI2.Views;
using Speckle.ConnectorAutocadCivil.UI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ public override async Task<StreamState> PreviewReceive(StreamState state, Progre
public override async Task<StreamState> ReceiveStream(StreamState state, ProgressViewModel progress)
{
if (Doc == null) throw new InvalidOperationException("No Document is open");

var converter = KitManager.GetDefaultKit().LoadConverter(Utils.VersionedAppName);

var stream = await state.Client.StreamGet(state.StreamId);

Commit commit = await ConnectorHelpers.GetCommitFromState(progress.CancellationToken, state);
state.LastCommit = commit;

Expand Down Expand Up @@ -890,9 +890,9 @@ public override async Task<string> SendStream(StreamState state, ProgressViewMod
onErrorAction: ConnectorHelpers.DefaultSendErrorHandler,
disposeTransports: true
);

progress.CancellationToken.ThrowIfCancellationRequested();

var actualCommit = new CommitCreateInput
{
streamId = streamId,
Expand All @@ -901,7 +901,7 @@ public override async Task<string> SendStream(StreamState state, ProgressViewMod
message = state.CommitMessage ?? $"Pushed {convertedCount} elements from {Utils.AppName}.",
sourceApplication = Utils.VersionedAppName
};

if (state.PreviousCommitId != null) { actualCommit.parents = new List<string>() { state.PreviousCommitId }; }

var commitId = await ConnectorHelpers.CreateCommit(progress.CancellationToken, client, actualCommit);
Expand Down
10 changes: 4 additions & 6 deletions ConnectorAutocadCivil/ConnectorAutocadCivil/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Reflection;

using System.Text.RegularExpressions;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Colors;

using Speckle.ConnectorAutocadCivil.DocumentUtils;
using Speckle.Core.Kits;
using Speckle.Core.Models;
using Speckle.ConnectorAutocadCivil.DocumentUtils;

#if CIVIL2021 || CIVIL2022 || CIVIL2023
using Autodesk.Aec.ApplicationServices;
Expand Down Expand Up @@ -632,7 +630,7 @@ public static void SetStyle(Base styleBase, Entity entity, Dictionary<string, Ob
{
var systemColor = System.Drawing.Color.FromArgb((int)color);
entity.Color = Color.FromRgb(systemColor.R, systemColor.G, systemColor.B);
var alpha = transparency != null
var alpha = transparency != null
? (byte)(transparency * 255d) //render material
: systemColor.A; //display style
entity.Transparency = new Transparency(alpha);
Expand Down
6 changes: 4 additions & 2 deletions Core/Core/Helpers/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static AsyncRetryPolicy<HttpResponseMessage> HttpAsyncPolicy(IEnumerable<
.HandleTransientHttpError()
.WaitAndRetryAsync(
delay ?? DefaultDelay(),
(ex, timeSpan, retryAttempt, context) => {
(ex, timeSpan, retryAttempt, context) =>
{
//context.Remove("retryCount");
//context.Add("retryCount", retryAttempt);
//Log.Information(
Expand Down Expand Up @@ -118,7 +119,8 @@ public static async Task<bool> Ping(string hostnameOrAddress)
.Or<SocketException>()
.WaitAndRetryAsync(
DefaultDelay(),
(ex, timeSpan, retryAttempt, context) => {
(ex, timeSpan, retryAttempt, context) =>
{
//Log.Information(
// ex,
// "The http request failed with {exceptionType} exception retrying after {cooldown} milliseconds. This is retry attempt {retryAttempt}",
Expand Down
56 changes: 28 additions & 28 deletions Core/Core/Models/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,35 +189,35 @@ private static long HandleObjectCount(object value, HashSet<int> parsed)
count += CountDescendants(b, parsed);
return count;
case IDictionary d:
{
foreach (DictionaryEntry kvp in d)
if (kvp.Value is Base)
{
count++;
count += CountDescendants(kvp.Value as Base, parsed);
}
else
{
count += HandleObjectCount(kvp.Value, parsed);
}

return count;
}
{
foreach (DictionaryEntry kvp in d)
if (kvp.Value is Base)
{
count++;
count += CountDescendants(kvp.Value as Base, parsed);
}
else
{
count += HandleObjectCount(kvp.Value, parsed);
}

return count;
}
case IEnumerable e when !(value is string):
{
foreach (var arrValue in e)
if (arrValue is Base)
{
count++;
count += CountDescendants(arrValue as Base, parsed);
}
else
{
count += HandleObjectCount(arrValue, parsed);
}

return count;
}
{
foreach (var arrValue in e)
if (arrValue is Base)
{
count++;
count += CountDescendants(arrValue as Base, parsed);
}
else
{
count += HandleObjectCount(arrValue, parsed);
}

return count;
}
default:
return count;
}
Expand Down
24 changes: 12 additions & 12 deletions Core/Core/Models/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ public static IEnumerable<Base> Traverse(this Base root, BaseRecursionBreaker re
stack.Push(o);
break;
case IDictionary dictionary:
{
foreach (object obj in dictionary.Keys)
if (obj is Base b)
stack.Push(b);
break;
}
{
foreach (object obj in dictionary.Keys)
if (obj is Base b)
stack.Push(b);
break;
}
case IList collection:
{
foreach (object obj in collection)
if (obj is Base b)
stack.Push(b);
break;
}
{
foreach (object obj in collection)
if (obj is Base b)
stack.Push(b);
break;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Core/Models/GraphTraversal/DefaultTraversal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static GraphTraversal CreateRevitTraversalFunc(ISpeckleConverter converte
}
);

//WORKAROUND: ideally, traversal rules would not have Objects specific rules.
//WORKAROUND: ideally, traversal rules would not have Objects specific rules.
var ignoreResultsRule = TraversalRule
.NewTraversalRule()
.When(o => o.speckle_type.Contains("Objects.Structural.Results"))
Expand Down
44 changes: 22 additions & 22 deletions Core/Core/Models/GraphTraversal/GraphTraversal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ public IEnumerable<TraversalContext> Traverse(Base root)
stack.Add(new TraversalContext(o, memberName, parent));
break;
case IList list:
{
foreach (object? obj in list)
TraverseMemberToStack(stack, obj, memberName, parent);
break;
}
{
foreach (object? obj in list)
TraverseMemberToStack(stack, obj, memberName, parent);
break;
}
case IDictionary dictionary:
{
foreach (object? obj in dictionary.Values)
TraverseMemberToStack(stack, obj, memberName, parent);
break;
}
{
foreach (object? obj in dictionary.Values)
TraverseMemberToStack(stack, obj, memberName, parent);
break;
}
}
}

Expand All @@ -94,23 +94,23 @@ public static IEnumerable<Base> TraverseMember(object? value)
yield return o;
break;
case IList list:
{
foreach (object? obj in list)
{
foreach (Base o in TraverseMember(obj))
yield return o;
foreach (object? obj in list)
{
foreach (Base o in TraverseMember(obj))
yield return o;
}
break;
}
break;
}
case IDictionary dictionary:
{
foreach (object? obj in dictionary.Values)
{
foreach (Base o in TraverseMember(obj))
yield return o;
foreach (object? obj in dictionary.Values)
{
foreach (Base o in TraverseMember(obj))
yield return o;
}
break;
}
break;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Core/Core/Serialisation/ValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static bool ConvertValue(Type type, object value, out object convertedVal

return false;

#endregion
#endregion
}

// Handle List<?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;

using Autodesk.AdvanceSteel.DocumentManagement;
using Autodesk.AdvanceSteel.DotNetRoots.Units;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.PlottingServices;
using MathNet.Spatial.Euclidean;
using Speckle.Newtonsoft.Json.Linq;
using static Autodesk.AdvanceSteel.DotNetRoots.Units.Unit;
using AcadGeo = Autodesk.AutoCAD.Geometry;

using Arc = Objects.Geometry.Arc;
using ASBoundBlock3d = Autodesk.AdvanceSteel.Geometry.BoundBlock3d;
using ASCircArc3d = Autodesk.AdvanceSteel.Geometry.CircArc3d;
using ASCurve3d = Autodesk.AdvanceSteel.Geometry.Curve3d;
using ASExtents = Autodesk.AdvanceSteel.Geometry.Extents;
using ASLineSeg3d = Autodesk.AdvanceSteel.Geometry.LineSeg3d;
using ASPlane = Autodesk.AdvanceSteel.Geometry.Plane;
using ASPoint3d = Autodesk.AdvanceSteel.Geometry.Point3d;
using ASPolyline3d = Autodesk.AdvanceSteel.Geometry.Polyline3d;
using ASVector3d = Autodesk.AdvanceSteel.Geometry.Vector3d;
using Box = Objects.Geometry.Box;
using Interval = Objects.Primitive.Interval;
using Line = Objects.Geometry.Line;
Expand All @@ -16,24 +29,6 @@
using Polycurve = Objects.Geometry.Polycurve;
using Vector = Objects.Geometry.Vector;

using MathNet.Spatial.Euclidean;

using ASPolyline3d = Autodesk.AdvanceSteel.Geometry.Polyline3d;
using ASCurve3d = Autodesk.AdvanceSteel.Geometry.Curve3d;
using ASLineSeg3d = Autodesk.AdvanceSteel.Geometry.LineSeg3d;
using ASCircArc3d = Autodesk.AdvanceSteel.Geometry.CircArc3d;
using ASPoint3d = Autodesk.AdvanceSteel.Geometry.Point3d;
using ASVector3d = Autodesk.AdvanceSteel.Geometry.Vector3d;
using ASExtents = Autodesk.AdvanceSteel.Geometry.Extents;
using ASPlane = Autodesk.AdvanceSteel.Geometry.Plane;
using ASBoundBlock3d = Autodesk.AdvanceSteel.Geometry.BoundBlock3d;

using static Autodesk.AdvanceSteel.DotNetRoots.Units.Unit;
using Autodesk.AdvanceSteel.DocumentManagement;
using Autodesk.AdvanceSteel.DotNetRoots.Units;
using Autodesk.AutoCAD.PlottingServices;
using Speckle.Newtonsoft.Json.Linq;

namespace Objects.Converter.AutocadCivil
{
public partial class ConverterAutocadCivil
Expand Down Expand Up @@ -263,7 +258,7 @@ private object ConvertValueToSpeckle(object @object, eUnitType? unitType, out bo
}
else
{
if(unitType.HasValue && @object is double)
if (unitType.HasValue && @object is double)
{
@object = FromInternalUnits((double)@object, unitType.Value);
}
Expand Down

0 comments on commit d157c9a

Please sign in to comment.