├── .gitignore
├── LICENSE
├── NOTICE
├── README.md
├── straight_skeleton
├── README.md
├── StraightSkeletonNet.Tests
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SkeletonExtendedTest.cs
│ ├── SkeletonLevelEventsTest.cs
│ ├── SkeletonTest.cs
│ ├── SkeletonTestUtil.cs
│ ├── StraightSkeletonNet.Tests.csproj
│ └── packages.config
├── StraightSkeletonNet.sln
└── StraightSkeletonNet
│ ├── Circular
│ ├── CircularList.cs
│ ├── CircularNode.cs
│ ├── Edge.cs
│ └── Vertex.cs
│ ├── EdgeResult.cs
│ ├── Events
│ ├── Chains
│ │ ├── ChainType.cs
│ │ ├── EdgeChain.cs
│ │ ├── IChain.cs
│ │ ├── SingleEdgeChain.cs
│ │ └── SplitChain.cs
│ ├── EdgeEvent.cs
│ ├── MultiEdgeEvent.cs
│ ├── MultiSplitEvent.cs
│ ├── PickEvent.cs
│ ├── SkeletonEvent.cs
│ ├── SplitEvent.cs
│ └── VertexSplitEvent.cs
│ ├── LavUtil.cs
│ ├── Path
│ ├── FaceNode.cs
│ ├── FaceQueue.cs
│ ├── FaceQueueUtil.cs
│ ├── PathQueue.cs
│ └── PathQueueNode.cs
│ ├── Primitives
│ ├── LineLinear2d.cs
│ ├── LineParametric2d.cs
│ ├── PrimitiveUtils.cs
│ ├── PriorityQueue.cs
│ └── Vector2d.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Skeleton.cs
│ ├── SkeletonBuilder.cs
│ └── StraightSkeletonNet.csproj
├── utydepend
├── UtyDepend.Tests
│ ├── ContainerTests.cs
│ ├── InterceptionTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Stubs
│ │ ├── ClassA.cs
│ │ ├── CollectionDependencyClass.cs
│ │ ├── ConfigurableClass.cs
│ │ ├── DummyConfigSection.cs
│ │ └── PropertyClass.cs
│ ├── UtyDepend.Tests.csproj
│ └── packages.config
├── UtyDepend.sln
└── UtyDepend
│ ├── Component.cs
│ ├── ComponentExtensions.cs
│ ├── Config
│ ├── IConfigSection.cs
│ └── IConfigurable.cs
│ ├── Container.cs
│ ├── DependencyAttribute.cs
│ ├── DependencyException.cs
│ ├── IContainer.cs
│ ├── Interception
│ ├── Behaviors
│ │ ├── ExecuteBehavior.cs
│ │ └── IBehavior.cs
│ ├── IInterceptor.cs
│ ├── IMethodReturn.cs
│ ├── IProxy.cs
│ ├── InterceptionContext.cs
│ ├── InterfaceInterceptor.cs
│ ├── MethodInvocation.cs
│ ├── MethodReturn.cs
│ └── ProxyBase.cs
│ ├── Lifetime
│ ├── ContainerLifetimeManager.cs
│ ├── ExternalLifetimeManager.cs
│ ├── ILifetimeManager.cs
│ ├── SingletonLifetimeManager.cs
│ └── TransientLifetimeManager.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Utils
│ ├── Guard.cs
│ ├── ProxyGen.cs
│ └── TypeHelper.cs
│ ├── UtyDepend.csproj
│ └── packages.config
└── utyrx
├── README.md
├── UtyRx.Tests
├── Disposables
│ └── DisposableTest.cs
├── InternalUtil
│ ├── MicroCoroutineTest.cs
│ └── QueueWorkerTest.cs
├── Observable
│ ├── Observable.ConcatTest.cs
│ ├── Observable.ConcurrencyTest.cs
│ ├── Observable.ErrorHandlingTest.cs
│ ├── Observable.Events.cs
│ ├── Observable.GeneratorTest.cs
│ ├── Observable.PagingTest.cs
│ ├── Observable.TimeTest.cs
│ └── ObservableTest.cs
├── Operators
│ ├── AggregateTest.cs
│ ├── ContinueWithTest.cs
│ ├── ConversionTest.cs
│ ├── DoTest.cs
│ ├── DurabilityTest.cs
│ ├── RangeTest.cs
│ ├── SelectMany.cs
│ ├── TakeTest.cs
│ ├── ToTest.cs
│ └── WhenAllTest.cs
├── Properties
│ └── AssemblyInfo.cs
├── Schedulers
│ └── SchedulerTest.cs
├── Subjects
│ └── SubjectTest.cs
├── Utils
│ ├── ChainingAssertion.cs
│ └── TestUtil.cs
├── UtyRx.Tests.csproj
└── packages.config
├── UtyRx.sln
└── UtyRx
├── Asynchronous
└── WebRequestExtensions.cs
├── Disposables
├── BooleanDisposable.cs
├── CompositeDisposable.cs
├── DictionaryDisposable.cs
├── Disposable.cs
├── DisposableExtensions.cs
├── ICancelable.cs
├── MultipleAssignmentDisposable.cs
├── RefCountDisposable.cs
├── ScheduledDisposable.cs
├── SerialDisposable.cs
├── SingleAssignmentDisposable.cs
└── StableCompositeDisposable.cs
├── InternalUtil
├── AscynLock.cs
├── ImmutableList.cs
├── ListObserver.cs
├── MicroCoroutine.cs
├── PriorityQueue.cs
├── ReflectionAccessor.cs
├── ScheduledItem.cs
└── ThreadSafeQueueWorker.cs
├── Notifiers
├── BooleanNotifier.cs
├── CountNotifier.cs
├── MessageBroker.cs
└── ScheduledNotifier.cs
├── Observable
├── Observable.Aggregate.cs
├── Observable.Binding.cs
├── Observable.Blocking.cs
├── Observable.Concatenate.cs
├── Observable.Concurrency.cs
├── Observable.Conversions.cs
├── Observable.Creation.cs
├── Observable.ErrorHandling.cs
├── Observable.Events.cs
├── Observable.FromAsync.cs
├── Observable.Joins.cs
├── Observable.Paging.cs
├── Observable.Time.cs
└── Observable.cs
├── Operators
├── Aggregate.cs
├── Amb.cs
├── AsObservable.cs
├── AsSingleUnitObservable.cs
├── AsUnitObservable.cs
├── Buffer.cs
├── Cast.cs
├── Catch.cs
├── CombineLatest.cs
├── Concat.cs
├── ContinueWith.cs
├── Create.cs
├── DefaultIfEmpty.cs
├── Defer.cs
├── Delay.cs
├── DelaySubscription.cs
├── Dematerialize.cs
├── Distinct.cs
├── DistinctUntilChanged.cs
├── Do.cs
├── Empty.cs
├── Finally.cs
├── First.cs
├── ForEachAsync.cs
├── FromEvent.cs
├── GroupBy.cs
├── IgnoreElements.cs
├── Last.cs
├── Materialize.cs
├── Merge.cs
├── Never.cs
├── ObserveOn.cs
├── OfType.cs
├── OperatorObservableBase.cs
├── OperatorObserverBase.cs
├── PairWise.cs
├── Range.cs
├── RefCount.cs
├── Repeat.cs
├── RepeatSafe.cs
├── Return.cs
├── Sample.cs
├── Scan.cs
├── Select.cs
├── SelectMany.cs
├── Single.cs
├── Skip.cs
├── SkipUntil.cs
├── SkipWhile.cs
├── Start.cs
├── StartWith.cs
├── SubscribeOn.cs
├── Switch.cs
├── Synchronize.cs
├── SynchronizedObserver.cs
├── Take.cs
├── TakeLast.cs
├── TakeUntil.cs
├── TakeWhile.cs
├── Throttle.cs
├── ThrottleFirst.cs
├── Throw.cs
├── TimeInterval.cs
├── Timeout.cs
├── Timer.cs
├── Timestamp.cs
├── ToArray.cs
├── ToList.cs
├── ToObservable.cs
├── Wait.cs
├── WhenAll.cs
├── Where.cs
├── WithLatestFrom.cs
├── Zip.cs
└── ZipLatest.cs
├── Properties
└── AssemblyInfo.cs
├── Schedulers
├── IScheduler.cs
├── Scheduler.CurrentThread.cs
├── Scheduler.Immediate.cs
├── Scheduler.Main.cs
├── Scheduler.ThreadPool.cs
└── Scheduler.cs
├── Subjects
├── AsyncSubject.cs
├── BehaviorSubject.cs
├── ConnectableObservable.cs
├── ISubject.cs
├── ReplaySubject.cs
├── Subject.cs
└── SubjectExtensions.cs
├── System
├── CancellationToken.cs
├── EventPattern.cs
├── IObservable.cs
├── IObserver.cs
├── IOptimizedObservable.cs
├── IProgress.cs
├── Notification.cs
├── Observer.cs
├── Pair.cs
├── TimeInterval.cs
├── Timestamped.cs
├── Tuple.cs
└── Unit.cs
└── UtyRx.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | #*.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.log
36 | *.vspscc
37 | *.vssscc
38 | .builds
39 |
40 | # Visual C++ cache files
41 | ipch/
42 | *.aps
43 | *.ncb
44 | *.opensdf
45 | *.sdf
46 |
47 | # Visual Studio profiler
48 | *.psess
49 | *.vsp
50 | *.vspx
51 |
52 | # Guidance Automation Toolkit
53 | *.gpState
54 |
55 | # ReSharper is a .NET coding add-in
56 | _ReSharper*
57 |
58 | # NCrunch
59 | *.ncrunch*
60 | .*crunch*.local.xml
61 |
62 | # Installshield output folder
63 | [Ee]xpress
64 |
65 | # DocProject is a documentation generator add-in
66 | DocProject/buildhelp/
67 | DocProject/Help/*.HxT
68 | DocProject/Help/*.HxC
69 | DocProject/Help/*.hhc
70 | DocProject/Help/*.hhk
71 | DocProject/Help/*.hhp
72 | DocProject/Help/Html2
73 | DocProject/Help/html
74 |
75 | #Unity
76 | Library/
77 | Temp/
78 |
79 | # Click-Once directory
80 | publish
81 |
82 | # Publish Web Output
83 | *.Publish.xml
84 |
85 | # NuGet Packages Directory
86 | packages
87 |
88 | # Windows Azure Build Output
89 | csx
90 | *.build.csdef
91 |
92 | # Windows Store app package directory
93 | AppPackages/
94 |
95 | # Others
96 | [Bb]in
97 | [Oo]bj
98 | sql
99 | TestResults
100 | [Tt]est[Rr]esult*
101 | *.Cache
102 | ClientBin
103 | [Ss]tyle[Cc]op.*
104 | ~$*
105 | *.dbmdl
106 | Generated_Code #added for RIA/Silverlight projects
107 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Description
2 |
3 | This repository contains different C# libraries which I use in different projects:
4 |
5 | * utydepend - dependency injection container
6 | * utyrx - reactive extensions fork which is based on unirx fork.
7 | * straight_skeleton - straight skeleton implementation which is port of kendzi's implementation
8 |
--------------------------------------------------------------------------------
/straight_skeleton/README.md:
--------------------------------------------------------------------------------
1 | # StraightSkeletonNet
2 |
3 | Implementation of straight skeleton algorithm for polygons with holes. It is based on concept of tracking bisector intersection with queue of events to process and circular list with processed events called lavs. This implementation is highly modified concept described by Petr Felkel and Stepan Obdrzalek. In compare to original this algorithm has new kind of event and support for multiple events which appear in the same distance from edges. It is common when processing degenerate cases caused by polygon with right angles.
4 |
5 | This port has no external dependencies: all needed classes are ported. Original Java code depends on external libraries which provide some primitives: vector, line, ray, etc. It can be found here:
6 | https://github.com/kendzi/kendzi-math/tree/master/kendzi-straight-skeleton
7 |
8 | You can read more about this implementation at blog:
9 | http://reinterpretcat.blogspot.de/2016/02/straight-skeleton-on-net.html
10 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("StraightSkeletonNet.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("StraightSkeletonNet.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("11f01a71-1332-4e7f-9cfd-f963f72c36b8")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet.Tests/SkeletonTestUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using StraightSkeletonNet.Primitives;
6 |
7 | namespace StraightSkeletonNet.Tests
8 | {
9 | internal class SkeletonTestUtil
10 | {
11 | public static List GetFacePoints(Skeleton sk)
12 | {
13 | List ret = new List();
14 |
15 | foreach (EdgeResult edgeOutput in sk.Edges)
16 | {
17 | List points = edgeOutput.Polygon;
18 | foreach (Vector2d vector2d in points)
19 | {
20 | if (!ContainsEpsilon(ret, vector2d))
21 | ret.Add(vector2d);
22 | }
23 | }
24 | return ret;
25 | }
26 |
27 | public static void AssertExpectedPoints(List expectedList, List givenList)
28 | {
29 | StringBuilder sb = new StringBuilder();
30 | foreach (Vector2d expected in expectedList)
31 | {
32 | if (!ContainsEpsilon(givenList, expected))
33 | sb.AppendFormat("Can't find expected point ({0}, {1}) in given list\n", expected.X, expected.Y);
34 | }
35 |
36 | foreach (Vector2d given in givenList)
37 | {
38 | if (!ContainsEpsilon(expectedList, given))
39 | sb.AppendFormat("Can't find given point ({0}, {1}) in expected list\n", given.X, given.Y);
40 | }
41 |
42 | if (sb.Length > 0)
43 | throw new InvalidOperationException(sb.ToString());
44 | }
45 |
46 | public static bool ContainsEpsilon(List list, Vector2d p)
47 | {
48 | return list.Any(l => EqualEpsilon(l.X, p.X) && EqualEpsilon(l.Y, p.Y));
49 | }
50 |
51 | public static bool EqualEpsilon(double d1, double d2)
52 | {
53 | return Math.Abs(d1 - d2) < 5E-6;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet.Tests/StraightSkeletonNet.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3898AF36-98E4-4EBF-BB2C-06EC91F1EC8E}
8 | Library
9 | Properties
10 | StraightSkeletonNet.Tests
11 | StraightSkeletonNet.Tests
12 | v3.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\NUnit.2.6.3\lib\nunit.framework.dll
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | {4b85469b-a41f-4e31-a7f1-c7337a78dc6a}
51 | StraightSkeletonNet
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30324.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StraightSkeletonNet", "StraightSkeletonNet\StraightSkeletonNet.csproj", "{4B85469B-A41F-4E31-A7F1-C7337A78DC6A}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StraightSkeletonNet.Tests", "StraightSkeletonNet.Tests\StraightSkeletonNet.Tests.csproj", "{3898AF36-98E4-4EBF-BB2C-06EC91F1EC8E}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {4B85469B-A41F-4E31-A7F1-C7337A78DC6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {4B85469B-A41F-4E31-A7F1-C7337A78DC6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {4B85469B-A41F-4E31-A7F1-C7337A78DC6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {4B85469B-A41F-4E31-A7F1-C7337A78DC6A}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {3898AF36-98E4-4EBF-BB2C-06EC91F1EC8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {3898AF36-98E4-4EBF-BB2C-06EC91F1EC8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {3898AF36-98E4-4EBF-BB2C-06EC91F1EC8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {3898AF36-98E4-4EBF-BB2C-06EC91F1EC8E}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Circular/CircularNode.cs:
--------------------------------------------------------------------------------
1 | namespace StraightSkeletonNet.Circular
2 | {
3 | public class CircularNode
4 | {
5 | internal ICircularList List;
6 |
7 | public CircularNode Next;
8 | public CircularNode Previous;
9 |
10 | public void AddNext(CircularNode node)
11 | {
12 | List.AddNext(this, node);
13 | }
14 |
15 | public void AddPrevious(CircularNode node)
16 | {
17 | List.AddPrevious(this, node);
18 | }
19 |
20 | public void Remove()
21 | {
22 | List.Remove(this);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Circular/Edge.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Primitives;
2 |
3 | namespace StraightSkeletonNet.Circular
4 | {
5 | public class Edge : CircularNode
6 | {
7 | public readonly Vector2d Begin;
8 | public readonly Vector2d End;
9 | public readonly Vector2d Norm;
10 |
11 | internal readonly LineLinear2d LineLinear2d;
12 | internal LineParametric2d BisectorNext;
13 | internal LineParametric2d BisectorPrevious;
14 |
15 | public Edge(Vector2d begin, Vector2d end)
16 | {
17 | Begin = begin;
18 | End = end;
19 |
20 | LineLinear2d = new LineLinear2d(begin, end);
21 | Norm = (end - begin).Normalized();
22 | }
23 |
24 | public override string ToString()
25 | {
26 | return "Edge [p1=" + Begin + ", p2=" + End + "]";
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Circular/Vertex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using StraightSkeletonNet.Path;
3 | using StraightSkeletonNet.Primitives;
4 |
5 | namespace StraightSkeletonNet.Circular
6 | {
7 | internal class Vertex : CircularNode
8 | {
9 | const int RoundDigitCount = 5;
10 |
11 | public Vector2d Point;
12 | public readonly double Distance;
13 | public readonly LineParametric2d Bisector;
14 |
15 | public readonly Edge NextEdge;
16 | public readonly Edge PreviousEdge;
17 |
18 | public FaceNode LeftFace;
19 | public FaceNode RightFace;
20 |
21 | public bool IsProcessed;
22 |
23 | public Vertex(Vector2d point, double distance, LineParametric2d bisector,
24 | Edge previousEdge, Edge nextEdge)
25 | {
26 | Point = point;
27 | Distance = Math.Round(distance, RoundDigitCount);
28 | Bisector = bisector;
29 | PreviousEdge = previousEdge;
30 | NextEdge = nextEdge;
31 |
32 | IsProcessed = false;
33 | }
34 |
35 | public override string ToString()
36 | {
37 | return "Vertex [v=" + Point + ", IsProcessed=" + IsProcessed +
38 | ", Bisector=" + Bisector + ", PreviousEdge=" + PreviousEdge +
39 | ", NextEdge=" + NextEdge;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/EdgeResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using StraightSkeletonNet.Circular;
3 | using StraightSkeletonNet.Primitives;
4 |
5 | namespace StraightSkeletonNet
6 | {
7 | public class EdgeResult
8 | {
9 | public readonly Edge Edge;
10 | public readonly List Polygon;
11 |
12 | public EdgeResult(Edge edge, List polygon)
13 | {
14 | Edge = edge;
15 | Polygon = polygon;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/Chains/ChainType.cs:
--------------------------------------------------------------------------------
1 | namespace StraightSkeletonNet.Events.Chains
2 | {
3 | internal enum ChainType
4 | {
5 | Edge,
6 | ClosedEdge,
7 | Split
8 | }
9 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/Chains/EdgeChain.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using StraightSkeletonNet.Circular;
3 |
4 | namespace StraightSkeletonNet.Events.Chains
5 | {
6 | internal class EdgeChain : IChain
7 | {
8 | private readonly bool _closed;
9 |
10 | public EdgeChain(List edgeList)
11 | {
12 | EdgeList = edgeList;
13 | _closed = PreviousVertex == NextVertex;
14 | }
15 |
16 | public List EdgeList { get; private set; }
17 |
18 | public Edge PreviousEdge
19 | {
20 | get { return EdgeList[0].PreviousVertex.PreviousEdge; }
21 | }
22 |
23 | public Edge NextEdge
24 | {
25 | get { return EdgeList[EdgeList.Count - 1].NextVertex.NextEdge; }
26 | }
27 |
28 | public Vertex PreviousVertex
29 | {
30 | get { return EdgeList[0].PreviousVertex; }
31 | }
32 |
33 | public Vertex NextVertex
34 | {
35 | get { return EdgeList[EdgeList.Count - 1].NextVertex; }
36 | }
37 |
38 | public Vertex CurrentVertex
39 | {
40 | get { return null; }
41 | }
42 |
43 | public ChainType ChainType
44 | {
45 | get { return _closed ? ChainType.ClosedEdge : ChainType.Edge; }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/Chains/IChain.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Circular;
2 |
3 | namespace StraightSkeletonNet.Events.Chains
4 | {
5 | internal interface IChain
6 | {
7 | Edge PreviousEdge { get; }
8 | Edge NextEdge { get; }
9 | Vertex PreviousVertex { get; }
10 | Vertex NextVertex { get; }
11 | Vertex CurrentVertex { get; }
12 | ChainType ChainType { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/Chains/SingleEdgeChain.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Circular;
2 |
3 | namespace StraightSkeletonNet.Events.Chains
4 | {
5 | internal class SingleEdgeChain : IChain
6 | {
7 | private readonly Vertex _nextVertex;
8 | private readonly Edge _oppositeEdge;
9 | private readonly Vertex _previousVertex;
10 |
11 | public SingleEdgeChain(Edge oppositeEdge, Vertex nextVertex)
12 | {
13 | _oppositeEdge = oppositeEdge;
14 | _nextVertex = nextVertex;
15 |
16 | // previous vertex for opposite edge event is valid only before
17 | // processing of multi split event start. We need to store vertex before
18 | // processing starts.
19 | _previousVertex = nextVertex.Previous as Vertex;
20 | }
21 |
22 | public Edge PreviousEdge { get { return _oppositeEdge; } }
23 |
24 | public Edge NextEdge { get { return _oppositeEdge; } }
25 |
26 | public Vertex PreviousVertex { get { return _previousVertex; } }
27 |
28 | public Vertex NextVertex { get { return _nextVertex; } }
29 |
30 | public Vertex CurrentVertex { get { return null; } }
31 |
32 | public ChainType ChainType { get { return ChainType.Split; } }
33 | }
34 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/Chains/SplitChain.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Circular;
2 |
3 | namespace StraightSkeletonNet.Events.Chains
4 | {
5 | internal class SplitChain : IChain
6 | {
7 | private readonly SplitEvent _splitEvent;
8 |
9 | public SplitChain(SplitEvent @event)
10 | {
11 | _splitEvent = @event;
12 | }
13 |
14 | public Edge OppositeEdge
15 | {
16 | get
17 | {
18 | if (!(_splitEvent is VertexSplitEvent))
19 | return _splitEvent.OppositeEdge;
20 |
21 | return null;
22 | }
23 | }
24 |
25 | public Edge PreviousEdge
26 | {
27 | get { return _splitEvent.Parent.PreviousEdge; }
28 | }
29 |
30 | public Edge NextEdge
31 | {
32 | get { return _splitEvent.Parent.NextEdge; }
33 | }
34 |
35 | public Vertex PreviousVertex
36 | {
37 | get { return _splitEvent.Parent.Previous as Vertex; }
38 | }
39 |
40 | public Vertex NextVertex
41 | {
42 | get { return _splitEvent.Parent.Next as Vertex; }
43 | }
44 |
45 | public Vertex CurrentVertex
46 | {
47 | get { return _splitEvent.Parent; }
48 | }
49 |
50 | public ChainType ChainType
51 | {
52 | get { return ChainType.Split; }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/EdgeEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using StraightSkeletonNet.Circular;
3 | using StraightSkeletonNet.Primitives;
4 |
5 | namespace StraightSkeletonNet.Events
6 | {
7 | internal class EdgeEvent : SkeletonEvent
8 | {
9 | public readonly Vertex NextVertex;
10 | public readonly Vertex PreviousVertex;
11 |
12 | public override bool IsObsolete
13 | {
14 | get { return PreviousVertex.IsProcessed || NextVertex.IsProcessed; }
15 | }
16 |
17 | public EdgeEvent(Vector2d point, double distance, Vertex previousVertex, Vertex nextVertex) :
18 | base(point, distance)
19 | {
20 | PreviousVertex = previousVertex;
21 | NextVertex = nextVertex;
22 | }
23 |
24 | public override String ToString()
25 | {
26 | return "EdgeEvent [V=" + V + ", PreviousVertex="
27 | + (PreviousVertex != null ? PreviousVertex.Point.ToString() : "null") +
28 | ", NextVertex="
29 | + (NextVertex != null ? NextVertex.Point.ToString() : "null") + ", Distance=" +
30 | Distance + "]";
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/MultiEdgeEvent.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Events.Chains;
2 | using StraightSkeletonNet.Primitives;
3 |
4 | namespace StraightSkeletonNet.Events
5 | {
6 | internal class MultiEdgeEvent : SkeletonEvent
7 | {
8 | public readonly EdgeChain Chain;
9 |
10 | public override bool IsObsolete { get { return false; } }
11 |
12 | public MultiEdgeEvent(Vector2d point, double distance, EdgeChain chain) : base(point, distance)
13 | {
14 | Chain = chain;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/MultiSplitEvent.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using StraightSkeletonNet.Events.Chains;
3 | using StraightSkeletonNet.Primitives;
4 |
5 | namespace StraightSkeletonNet.Events
6 | {
7 | internal class MultiSplitEvent : SkeletonEvent
8 | {
9 | public readonly List Chains;
10 |
11 | public override bool IsObsolete { get { return false; } }
12 |
13 | public MultiSplitEvent(Vector2d point, double distance, List chains)
14 | : base(point, distance)
15 | {
16 | Chains = chains;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/PickEvent.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Events.Chains;
2 | using StraightSkeletonNet.Primitives;
3 |
4 | namespace StraightSkeletonNet.Events
5 | {
6 | internal class PickEvent : SkeletonEvent
7 | {
8 | public readonly EdgeChain Chain;
9 |
10 | public override bool IsObsolete { get { return false; } }
11 |
12 | public PickEvent(Vector2d point, double distance, EdgeChain chain) : base(point, distance)
13 | {
14 | Chain = chain;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/SkeletonEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using StraightSkeletonNet.Primitives;
3 |
4 | namespace StraightSkeletonNet.Events
5 | {
6 | internal abstract class SkeletonEvent
7 | {
8 | public Vector2d V;
9 |
10 | public double Distance { get; protected set; }
11 | public abstract bool IsObsolete { get; }
12 |
13 | protected SkeletonEvent(Vector2d point, double distance)
14 | {
15 | V = point;
16 | Distance = distance;
17 | }
18 |
19 | public override String ToString()
20 | {
21 | return "IntersectEntry [V=" + V + ", Distance=" + Distance + "]";
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/SplitEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using StraightSkeletonNet.Circular;
3 | using StraightSkeletonNet.Primitives;
4 |
5 | namespace StraightSkeletonNet.Events
6 | {
7 | internal class SplitEvent : SkeletonEvent
8 | {
9 | public readonly Edge OppositeEdge;
10 | public readonly Vertex Parent;
11 |
12 | public SplitEvent(Vector2d point, double distance, Vertex parent, Edge oppositeEdge)
13 | : base(point, distance)
14 | {
15 | Parent = parent;
16 | OppositeEdge = oppositeEdge;
17 | }
18 |
19 | public override bool IsObsolete { get { return Parent.IsProcessed; } }
20 |
21 |
22 | public override String ToString()
23 | {
24 | return "SplitEvent [V=" + V + ", Parent=" + (Parent != null ? Parent.Point.ToString() : "null") +
25 | ", Distance=" + Distance + "]";
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Events/VertexSplitEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using StraightSkeletonNet.Circular;
3 | using StraightSkeletonNet.Primitives;
4 |
5 | namespace StraightSkeletonNet.Events
6 | {
7 | internal class VertexSplitEvent : SplitEvent
8 | {
9 | public VertexSplitEvent(Vector2d point, double distance, Vertex parent) :
10 | base(point, distance, parent, null)
11 | {
12 | }
13 |
14 | public override String ToString()
15 | {
16 | return "VertexSplitEvent [V=" + V + ", Parent=" +
17 | (Parent != null ? Parent.Point.ToString() : "null")
18 | + ", Distance=" + Distance + "]";
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Path/FaceNode.cs:
--------------------------------------------------------------------------------
1 | using StraightSkeletonNet.Circular;
2 |
3 | namespace StraightSkeletonNet.Path
4 | {
5 | internal class FaceNode : PathQueueNode
6 | {
7 | public readonly Vertex Vertex;
8 |
9 | public FaceNode(Vertex vertex)
10 | {
11 | Vertex = vertex;
12 | }
13 |
14 | public FaceQueue FaceQueue { get { return (FaceQueue) List; } }
15 |
16 | public bool IsQueueUnconnected { get { return FaceQueue.IsUnconnected; } }
17 |
18 | public void QueueClose()
19 | {
20 | FaceQueue.Close();
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Path/FaceQueue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using StraightSkeletonNet.Circular;
3 |
4 | namespace StraightSkeletonNet.Path
5 | {
6 | internal class FaceQueue : PathQueue
7 | {
8 | /// Edge for given queue.
9 | public Edge Edge;
10 |
11 | /// Flag if queue is closed. After closing can't be modify.
12 | public bool Closed { get; private set; }
13 |
14 | /// Flag if queue is connected to edges.
15 | public bool IsUnconnected
16 | {
17 | get { return Edge == null; }
18 | }
19 |
20 | public override void AddPush(PathQueueNode node, PathQueueNode newNode)
21 | {
22 | if (Closed)
23 | throw new InvalidOperationException("Can't add node to closed FaceQueue");
24 |
25 | base.AddPush(node, newNode);
26 | }
27 |
28 | /// Mark queue as closed. After closing can't be modify.
29 | public void Close()
30 | {
31 | Closed = true;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Path/FaceQueueUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace StraightSkeletonNet.Path
4 | {
5 | internal class FaceQueueUtil
6 | {
7 | ///
8 | /// Connect two nodes queue. Id both nodes comes from the same queue, queue
9 | /// is closed. If nodes are from different queues nodes are moved to one of
10 | /// them.
11 | ///
12 | /// First face queue.
13 | /// Second face queue.
14 | public static void ConnectQueues(FaceNode firstFace, FaceNode secondFace)
15 | {
16 | if (firstFace.List == null)
17 | throw new ArgumentException("firstFace.list cannot be null.");
18 | if (secondFace.List == null)
19 | throw new ArgumentException("secondFace.list cannot be null.");
20 |
21 | if (firstFace.List == secondFace.List)
22 | {
23 | if (!firstFace.IsEnd || !secondFace.IsEnd)
24 | throw new InvalidOperationException("try to connect the same list not on end nodes");
25 |
26 | if (firstFace.IsQueueUnconnected || secondFace.IsQueueUnconnected)
27 | throw new InvalidOperationException("can't close node queue not conected with edges");
28 |
29 | firstFace.QueueClose();
30 | return;
31 | }
32 |
33 | if (!firstFace.IsQueueUnconnected && !secondFace.IsQueueUnconnected)
34 | throw new InvalidOperationException(
35 | "can't connect two diffrent queues if each of them is connected to edge");
36 |
37 | if (!firstFace.IsQueueUnconnected)
38 | {
39 | var qLeft = secondFace.FaceQueue;
40 | MoveNodes(firstFace, secondFace);
41 | qLeft.Close();
42 | }
43 | else
44 | {
45 | var qRight = firstFace.FaceQueue;
46 | MoveNodes(secondFace, firstFace);
47 | qRight.Close();
48 | }
49 | }
50 |
51 | private static void MoveNodes(FaceNode firstFace, FaceNode secondFace)
52 | {
53 | firstFace.AddQueue(secondFace);
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Path/PathQueueNode.cs:
--------------------------------------------------------------------------------
1 | namespace StraightSkeletonNet.Path
2 | {
3 | internal class PathQueueNode where T : PathQueueNode
4 | {
5 | public PathQueue List;
6 | public PathQueueNode Next;
7 | public PathQueueNode Previous;
8 |
9 | public bool IsEnd
10 | {
11 | get { return Next == null || Previous == null; }
12 | }
13 |
14 | public void AddPush(PathQueueNode node)
15 | {
16 | List.AddPush(this, node);
17 | }
18 |
19 | public PathQueueNode AddQueue(PathQueueNode queue)
20 | {
21 | if (List == queue.List)
22 | return null;
23 |
24 | var currentQueue = this;
25 |
26 | var current = queue;
27 |
28 | while (current != null)
29 | {
30 | var next = current.Pop();
31 | currentQueue.AddPush(current);
32 | currentQueue = current;
33 |
34 | current = next;
35 | }
36 |
37 | return currentQueue;
38 | }
39 |
40 | public PathQueueNode FindEnd()
41 | {
42 | if (IsEnd)
43 | return this;
44 |
45 | var current = this;
46 | while (current.Previous != null)
47 | current = current.Previous;
48 |
49 | return current;
50 | }
51 |
52 | public PathQueueNode Pop()
53 | {
54 | return List.Pop(this);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Primitives/LineLinear2d.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace StraightSkeletonNet.Primitives
4 | {
5 | ///
6 | /// Geometry line in linear form. General form:
7 | /// Ax + By + C = 0;
8 | ///
9 | ///
10 | internal struct LineLinear2d
11 | {
12 | public double A;
13 | public double B;
14 | public double C;
15 |
16 | /// Linear line from two points on line.
17 | public LineLinear2d(Vector2d pP1, Vector2d pP2)
18 | {
19 | A = pP1.Y - pP2.Y;
20 | B = pP2.X - pP1.X;
21 | C = pP1.X*pP2.Y - pP2.X*pP1.Y;
22 | }
23 |
24 | /// Linear line.
25 | public LineLinear2d(double pA, double pB, double pC)
26 | {
27 | A = pA;
28 | B = pB;
29 | C = pC;
30 | }
31 |
32 | /// Collision point of two lines.
33 | /// Line to collision.
34 | /// Collision point.
35 | public Vector2d Collide(LineLinear2d pLine)
36 | {
37 | return Collide(this, pLine);
38 | }
39 |
40 | /// Collision point of two lines.
41 | public static Vector2d Collide(LineLinear2d pLine1, LineLinear2d pLine2)
42 | {
43 | return Collide(pLine1.A, pLine1.B, pLine1.C, pLine2.A, pLine2.B, pLine2.C);
44 | }
45 |
46 | /// Collision point of two lines.
47 | public static Vector2d Collide(double A1, double B1, double C1, double A2, double B2, double C2)
48 | {
49 | var WAB = A1*B2 - A2*B1;
50 | var WBC = B1*C2 - B2*C1;
51 | var WCA = C1*A2 - C2*A1;
52 |
53 | return WAB == 0 ? Vector2d.Empty : new Vector2d(WBC / WAB, WCA / WAB);
54 | }
55 |
56 | /// Check whether point belongs to line.
57 | public bool Contains(Vector2d point)
58 | {
59 | return Math.Abs((point.X * A + point.Y * B + C)) < double.Epsilon;
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Primitives/LineParametric2d.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace StraightSkeletonNet.Primitives
3 | {
4 | ///
5 | /// Geometry line in parametric form:
6 | /// x = x_A + t * u_x;
7 | /// y = y_A + t * u_y;
8 | /// where t in R
9 | ///
10 | ///
11 | internal struct LineParametric2d
12 | {
13 | public static readonly LineParametric2d Empty = new LineParametric2d(Vector2d.Empty, Vector2d.Empty);
14 | public Vector2d A;
15 | public Vector2d U;
16 |
17 | public LineParametric2d(Vector2d pA, Vector2d pU)
18 | {
19 | A = pA;
20 | U = pU;
21 | }
22 |
23 | public LineLinear2d CreateLinearForm()
24 | {
25 | var x = this.A.X;
26 | var y = this.A.Y;
27 |
28 | var B = -U.X;
29 | var A = U.Y;
30 |
31 | var C = -(A*x + B*y);
32 | return new LineLinear2d(A, B, C);
33 | }
34 |
35 | public static Vector2d Collide(LineParametric2d ray, LineLinear2d line, double epsilon)
36 | {
37 | var collide = LineLinear2d.Collide(ray.CreateLinearForm(), line);
38 | if (collide.Equals(Vector2d.Empty))
39 | return Vector2d.Empty;
40 |
41 | var collideVector = collide - ray.A;
42 | return ray.U.Dot(collideVector) < epsilon ? Vector2d.Empty : collide;
43 | }
44 |
45 | public bool IsOnLeftSite(Vector2d point, double epsilon)
46 | {
47 | var direction = point - A;
48 | return PrimitiveUtils.OrthogonalRight(U).Dot(direction) < epsilon;
49 | }
50 |
51 | public bool IsOnRightSite(Vector2d point, double epsilon)
52 | {
53 | var direction = point - A;
54 | return PrimitiveUtils.OrthogonalRight(U).Dot(direction) > -epsilon;
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Primitives/Vector2d.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace StraightSkeletonNet.Primitives
4 | {
5 | /// Represents point or vector in 2D space.
6 | public struct Vector2d
7 | {
8 | public static Vector2d Empty = new Vector2d(double.MinValue, double.MinValue);
9 |
10 | public double X;
11 | public double Y;
12 |
13 | public Vector2d(Vector2d var1)
14 | {
15 | X = var1.X;
16 | Y = var1.Y;
17 | }
18 |
19 | public Vector2d(double var1, double var3)
20 | {
21 | X = var1;
22 | Y = var3;
23 | }
24 |
25 | public void Negate()
26 | {
27 | X = -X;
28 | Y = -Y;
29 | }
30 |
31 | public double DistanceTo(Vector2d var1)
32 | {
33 | var var2 = X - var1.X;
34 | var var4 = Y - var1.Y;
35 | return Math.Sqrt(var2 * var2 + var4 * var4);
36 | }
37 |
38 | public Vector2d Normalized()
39 | {
40 | var var1 = 1.0D/Math.Sqrt(X*X + Y*Y);
41 | return new Vector2d(X *= var1, Y *= var1);
42 | }
43 |
44 | public double Dot(Vector2d var1)
45 | {
46 | return X*var1.X + Y*var1.Y;
47 | }
48 |
49 | public double DistanceSquared(Vector2d var1)
50 | {
51 | var var2 = X - var1.X;
52 | var var4 = Y - var1.Y;
53 | return var2*var2 + var4*var4;
54 | }
55 |
56 | public static Vector2d operator -(Vector2d left, Vector2d right)
57 | {
58 | return new Vector2d(left.X - right.X, left.Y - right.Y);
59 | }
60 |
61 | public static Vector2d operator +(Vector2d left, Vector2d right)
62 | {
63 | return new Vector2d(left.X + right.X, left.Y + right.Y);
64 | }
65 |
66 | public static Vector2d operator *(Vector2d left, double scale)
67 | {
68 | return new Vector2d(left.X * scale, left.Y * scale);
69 | }
70 |
71 | public static bool operator ==(Vector2d left, Vector2d right)
72 | {
73 | return left.Equals(right);
74 | }
75 |
76 | public static bool operator !=(Vector2d left, Vector2d right)
77 | {
78 | return !(left == right);
79 | }
80 |
81 | public bool Equals(Vector2d obj)
82 | {
83 | return X.Equals(obj.X) && Y.Equals(obj.Y);
84 | }
85 |
86 | public override bool Equals(object obj)
87 | {
88 | if (ReferenceEquals(null, obj)) return false;
89 | return obj is Vector2d && Equals((Vector2d)obj);
90 | }
91 |
92 | public override int GetHashCode()
93 | {
94 | unchecked
95 | {
96 | return (X.GetHashCode()*397) ^ Y.GetHashCode();
97 | }
98 | }
99 |
100 | public override string ToString()
101 | {
102 | return string.Format("({0}, {1})", X, Y);
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("StraightSkeletonNet")]
6 | [assembly: AssemblyDescription("Straight Skeleton implementation.")]
7 | [assembly: AssemblyProduct("StraightSkeletonNet")]
8 | [assembly: AssemblyCopyright("Copyright © Ilya Builuk, 2016")]
9 |
10 | [assembly: ComVisible(false)]
11 | [assembly: Guid("8be8b2be-6c02-41b6-bbb6-5c69f2d5e987")]
12 |
13 | [assembly: AssemblyVersion("1.0.*")]
14 | [assembly: AssemblyFileVersion("1.0.*")]
15 | [assembly: InternalsVisibleTo("StraightSkeletonNet.Tests")]
16 |
--------------------------------------------------------------------------------
/straight_skeleton/StraightSkeletonNet/Skeleton.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using StraightSkeletonNet.Primitives;
3 |
4 | namespace StraightSkeletonNet
5 | {
6 | /// Represents skeleton algorithm results.
7 | public class Skeleton
8 | {
9 | /// Result of skeleton algorithm for edge.
10 | public readonly List Edges;
11 |
12 | /// Distance points from edges.
13 | public readonly Dictionary Distances;
14 |
15 | /// Creates instance of .
16 | public Skeleton(List edges, Dictionary distances)
17 | {
18 | Edges = edges;
19 | Distances = distances;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UtyDepend.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UtyDepend.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("60ef5fe5-d2a5-46e8-aa41-d57938265ed2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/Stubs/ClassA.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using UtyDepend.Interception;
4 |
5 | namespace UtyDepend.Tests.Stubs
6 | {
7 | public interface IClassA
8 | {
9 | int Add(int a, int b);
10 | string SayHello(string name);
11 | }
12 |
13 | public class ClassA1: IClassA
14 | {
15 |
16 | public int Add(int a, int b)
17 | {
18 | return a + b;
19 | }
20 |
21 | public string SayHello(string name)
22 | {
23 | return String.Format("Hello from A1, {0}", name);
24 | }
25 | }
26 |
27 | public class ClassA2 : IClassA
28 | {
29 |
30 | public int Add(int a, int b)
31 | {
32 | return a + b;
33 | }
34 |
35 | public string SayHello(string name)
36 | {
37 | return String.Format("Hello from A2, {0}", name);
38 | }
39 | }
40 |
41 | public class ClassA3 : IClassA
42 | {
43 |
44 | public int Add(int a, int b)
45 | {
46 | return a + b;
47 | }
48 |
49 | public string SayHello(string name)
50 | {
51 | return String.Format("Hello from A3, {0}", name);
52 | }
53 | }
54 |
55 |
56 | public class ClassAProxy : ProxyBase, IClassA
57 | {
58 | public System.Int32 Add(System.Int32 a, System.Int32 b)
59 | {
60 | var methodInvocation = BuildMethodInvocation(MethodBase.GetCurrentMethod(), a, b);
61 | return (int) RunBehaviors(methodInvocation).GetReturnValue();
62 | }
63 |
64 | public System.String SayHello(System.String name)
65 | {
66 | var methodInvocation = BuildMethodInvocation(MethodBase.GetCurrentMethod(), name);
67 | return (string) RunBehaviors(methodInvocation).GetReturnValue();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/Stubs/CollectionDependencyClass.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace UtyDepend.Tests.Stubs
4 | {
5 | public class CollectionDependencyClass
6 | {
7 | public IEnumerable Classes { get; private set; }
8 |
9 | [Dependency]
10 | public CollectionDependencyClass(IEnumerable classes)
11 | {
12 | Classes = classes;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/Stubs/ConfigurableClass.cs:
--------------------------------------------------------------------------------
1 | using UtyDepend.Config;
2 |
3 | namespace UtyDepend.Tests.Stubs
4 | {
5 | class ConfigurableClass: IConfigurable
6 | {
7 | public IConfigSection ConfigSection { get; set; }
8 | public void Configure(IConfigSection config)
9 | {
10 | ConfigSection = config;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/Stubs/DummyConfigSection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UtyDepend.Config;
4 |
5 | namespace UtyDepend.Tests.Stubs
6 | {
7 | public class DummyConfigSection : IConfigSection
8 | {
9 | public IEnumerable GetSections(string xpath)
10 | {
11 | throw new NotImplementedException();
12 | }
13 |
14 | public IConfigSection GetSection(string xpath)
15 | {
16 | throw new NotImplementedException();
17 | }
18 |
19 | public string GetString(string xpath, string defaultValue = "")
20 | {
21 | throw new NotImplementedException();
22 | }
23 |
24 | public int GetInt(string xpath, int defaultValue)
25 | {
26 | throw new NotImplementedException();
27 | }
28 |
29 | public float GetFloat(string xpath, float defaultValue)
30 | {
31 | throw new NotImplementedException();
32 | }
33 |
34 | public bool GetBool(string xpath, bool defaultValue)
35 | {
36 | throw new NotImplementedException();
37 | }
38 |
39 | public Type GetType(string xpath)
40 | {
41 | throw new NotImplementedException();
42 | }
43 |
44 | public T GetInstance(string xpath)
45 | {
46 | throw new NotImplementedException();
47 | }
48 |
49 | public T GetInstance(string xpath, params object[] args)
50 | {
51 | throw new NotImplementedException();
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/Stubs/PropertyClass.cs:
--------------------------------------------------------------------------------
1 | namespace UtyDepend.Tests.Stubs
2 | {
3 | public interface ITestInterface
4 | {
5 | }
6 |
7 | public class TestInterface : ITestInterface
8 | {
9 | }
10 |
11 | public interface IPropertyClass
12 | {
13 | }
14 |
15 | public class PropertyClass : IPropertyClass
16 | {
17 | [Dependency]
18 | public ITestInterface Test { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/UtyDepend.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {83449520-C81A-4D7A-AE0F-33F285571AFF}
8 | Library
9 | Properties
10 | UtyDepend.Tests
11 | UtyDepend.Tests
12 | v3.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\NUnit.2.6.3\lib\nunit.framework.dll
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | {72ee10a7-bdb1-4a33-990d-62ea88e2496e}
54 | DependencyNet
55 |
56 |
57 |
58 |
65 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30324.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UtyDepend", "UtyDepend\UtyDepend.csproj", "{72EE10A7-BDB1-4A33-990D-62EA88E2496E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UtyDepend.Tests", "UtyDepend.Tests\UtyDepend.Tests.csproj", "{83449520-C81A-4D7A-AE0F-33F285571AFF}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {72EE10A7-BDB1-4A33-990D-62EA88E2496E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {72EE10A7-BDB1-4A33-990D-62EA88E2496E}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {72EE10A7-BDB1-4A33-990D-62EA88E2496E}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {72EE10A7-BDB1-4A33-990D-62EA88E2496E}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {83449520-C81A-4D7A-AE0F-33F285571AFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {83449520-C81A-4D7A-AE0F-33F285571AFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {83449520-C81A-4D7A-AE0F-33F285571AFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {83449520-C81A-4D7A-AE0F-33F285571AFF}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend/ComponentExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UtyDepend.Lifetime;
3 |
4 | namespace UtyDepend
5 | {
6 | /// Defines the extension methods for Component class.
7 | public static class ComponentExtensions
8 | {
9 | /// Defines singleton lifetime manager for component.
10 | public static Component Singleton(this Component component)
11 | {
12 | component.LifetimeManager = Activator.CreateInstance(typeof (SingletonLifetimeManager)) as ILifetimeManager;
13 | return component;
14 | }
15 |
16 | /// Defines Transient lifetime manager for component.
17 | public static Component Transient(this Component component)
18 | {
19 | component.LifetimeManager = Activator.CreateInstance(typeof (TransientLifetimeManager)) as ILifetimeManager;
20 | return component;
21 | }
22 |
23 | /// Uses custom LifetimeManager.
24 | public static Component CustomLifetime(this Component component, ILifetimeManager lifetimeManager)
25 | {
26 | component.LifetimeManager = lifetimeManager;
27 | return component;
28 | }
29 |
30 | /// Defines singleton lifetime manager for component.
31 | public static Component External(this Component component)
32 | {
33 | component.LifetimeManager = Activator.CreateInstance(typeof (ExternalLifetimeManager)) as ILifetimeManager;
34 | return component;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Config/IConfigSection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace UtyDepend.Config
5 | {
6 | /// Represens a config entry.
7 | public interface IConfigSection
8 | {
9 | /// Returns the set of ConfigSections.
10 | /// xpath
11 | IEnumerable GetSections(string xpath);
12 |
13 | /// Returns JsonConfigSection.
14 | /// xpath
15 | /// IConfigSection.
16 | IConfigSection GetSection(string xpath);
17 |
18 | /// Returns string.
19 | /// xpath.
20 | ///
21 | /// String value.
22 | string GetString(string xpath, string defaultValue = "");
23 |
24 | /// Returns int.
25 | ///
26 | ///
27 | /// Int value.
28 | int GetInt(string xpath, int defaultValue);
29 |
30 | /// Returns float.
31 | /// xpath
32 | /// Default value.
33 | /// Float value.
34 | float GetFloat(string xpath, float defaultValue);
35 |
36 | /// Returns bool.
37 | /// xpath
38 | /// Default value.
39 | /// Boolean.
40 | bool GetBool(string xpath, bool defaultValue);
41 |
42 | /// Returns type object.
43 | /// xpath.
44 | /// Type.
45 | Type GetType(string xpath);
46 |
47 | /// Returns the instance of T.
48 | /// Type of instance.
49 | /// xpath.
50 | /// Instance.
51 | T GetInstance(string xpath);
52 |
53 | /// Returns the instance of T.
54 | /// Instance type.
55 | /// xpath
56 | /// Constructor parameters.
57 | /// Instance.
58 | T GetInstance(string xpath, params object[] args);
59 | }
60 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Config/IConfigurable.cs:
--------------------------------------------------------------------------------
1 | namespace UtyDepend.Config
2 | {
3 | /// Defines configurable class behaviour.
4 | public interface IConfigurable
5 | {
6 | /// Configures object using configuration section.
7 | /// Configuration section.
8 | void Configure(IConfigSection configSection);
9 | }
10 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/DependencyAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UtyDepend
4 | {
5 | /// Allows automatical resolving of constructor/property dependency.
6 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Constructor)]
7 | public class DependencyAttribute : Attribute
8 | {
9 | /// Named type/instance in container.
10 | public string Name { get; private set; }
11 |
12 | /// Creates attribute.
13 | public DependencyAttribute()
14 | {
15 | }
16 |
17 | /// Allows definition of name of registered type. Used only for property injection.
18 | public DependencyAttribute(string name)
19 | {
20 | Name = name;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/DependencyException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UtyDepend
4 | {
5 | /// Used to highlight issues related to DI container flow.
6 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2240:ImplementISerializableCorrectly")]
7 | [Serializable]
8 | public class DependencyException : Exception
9 | {
10 | /// Creates .
11 | /// Exception message.
12 | /// Inner exception.
13 | public DependencyException(string message, Exception innerException)
14 | : base(message, innerException) { }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/Behaviors/ExecuteBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using UtyDepend.Utils;
3 |
4 | namespace UtyDepend.Interception.Behaviors
5 | {
6 | /// Executes method source method.
7 | public class ExecuteBehavior : IBehavior
8 | {
9 | /// Creates ExecuteBehavior.
10 | public ExecuteBehavior()
11 | {
12 | Name = "execute";
13 | }
14 |
15 | ///
16 | public string Name { get; protected set; }
17 |
18 | ///
19 | public virtual IMethodReturn Invoke(MethodInvocation methodInvocation)
20 | {
21 | if (!methodInvocation.IsInvoked)
22 | {
23 | var methodBase = TypeHelper.GetMethodBySign(methodInvocation.Target.GetType(),
24 | methodInvocation.MethodBase, methodInvocation.GenericTypes.ToArray());
25 | var result = methodBase.Invoke(methodInvocation.Target, methodInvocation.Parameters.Values.ToArray());
26 | methodInvocation.IsInvoked = true;
27 | return methodInvocation.Return = new MethodReturn(result);
28 | }
29 | return methodInvocation.Return;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/Behaviors/IBehavior.cs:
--------------------------------------------------------------------------------
1 | namespace UtyDepend.Interception.Behaviors
2 | {
3 | /// Represents an additional behavior of method invocation.
4 | public interface IBehavior
5 | {
6 | /// The name of behavior.
7 | string Name { get; }
8 |
9 | /// Provides the way to attach additional behavior to method.
10 | IMethodReturn Invoke(MethodInvocation methodInvocation);
11 | }
12 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/IInterceptor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UtyDepend.Interception
4 | {
5 | /// Defines behavior of method interception.
6 | public interface IInterceptor
7 | {
8 | /// True, if type can be intercepted.
9 | bool CanIntercept(Type type);
10 |
11 | /// Return proxy for the type.
12 | IProxy CreateProxy(Type type, object instance);
13 |
14 | /// Registers component.
15 | void Register(Type type, Component component);
16 |
17 | /// Registers type.
18 | /// Type.
19 | void Register(Type type);
20 |
21 | /// Resolves component.
22 | Component Resolve(Type type);
23 | }
24 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/IMethodReturn.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UtyDepend.Interception
4 | {
5 | /// Represents a result of method invocation.
6 | public interface IMethodReturn
7 | {
8 | /// Returns return value of method.
9 | object GetReturnValue();
10 |
11 | /// Exception which occured during method invocation.
12 | Exception Exception { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/IProxy.cs:
--------------------------------------------------------------------------------
1 | using UtyDepend.Interception.Behaviors;
2 |
3 | namespace UtyDepend.Interception
4 | {
5 | /// Represents a behavior of proxy.
6 | public interface IProxy
7 | {
8 | /// Returns wrapped instance.
9 | object Instance { get; set; }
10 |
11 | /// Adds new behavior to wrapped instance.
12 | void AddBehavior(IBehavior behavior);
13 |
14 | /// Clear list of behaviors.
15 | void ClearBehaviors();
16 | }
17 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/InterceptionContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace UtyDepend.Interception
6 | {
7 | /// Represents interception context which provide the way create proxy objects and interact with interceptors.
8 | internal static class InterceptionContext
9 | {
10 | private static readonly List Interceptors = new List();
11 |
12 | static InterceptionContext()
13 | {
14 | Interceptors.Add(new InterfaceInterceptor());
15 | }
16 |
17 | /// Creates proxy from interface type and instance.
18 | /// Interface type.
19 | /// Instance of implementation type.
20 | public static IProxy CreateProxy(Type type, object instance)
21 | {
22 | var interceptor = GetInterceptor(type);
23 | return interceptor != null ? interceptor.CreateProxy(type, instance) : null;
24 | }
25 |
26 | /// Gets first interceptor which can intercept type.
27 | public static IInterceptor GetInterceptor(Type type)
28 | {
29 | return Interceptors.SingleOrDefault(i => i.CanIntercept(type));
30 | }
31 |
32 | /// Gets component for type from interceptor.
33 | public static Component GetComponent(Type type)
34 | {
35 | var interceptor = GetInterceptor(type);
36 | return interceptor != null ? interceptor.Resolve(type) : null;
37 | }
38 |
39 | /// Gets default interceptor.
40 | public static IInterceptor GetInterceptor()
41 | {
42 | return Interceptors.First();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/InterfaceInterceptor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UtyDepend.Interception.Behaviors;
4 |
5 | namespace UtyDepend.Interception
6 | {
7 | /// Represents interceptor which is able to intercept interface.
8 | internal class InterfaceInterceptor : IInterceptor
9 | {
10 | protected readonly Dictionary ProxyComponentMapping = new Dictionary();
11 | protected readonly List Behaviors = new List();
12 |
13 | ///
14 | public bool CanIntercept(Type type)
15 | {
16 | if (type == null)
17 | return false;
18 | return ProxyComponentMapping.ContainsKey(type) && ProxyComponentMapping[type].CanCreateProxy;
19 | }
20 |
21 | ///
22 | public Component Resolve(Type type)
23 | {
24 | //Resolve from mapping
25 | return ProxyComponentMapping[type];
26 | }
27 |
28 | ///
29 | public IProxy CreateProxy(Type type, object instance)
30 | {
31 | var component = Resolve(type);
32 | var proxy = component.CreateProxy(instance, Behaviors);
33 | return proxy;
34 | }
35 |
36 | ///
37 | public void Register(Type type, Component component)
38 | {
39 | ProxyComponentMapping.Add(type, component);
40 | }
41 |
42 | ///
43 | public void Register(Type type)
44 | {
45 | throw new NotSupportedException("Platform specific feature is disabled.");
46 | //if (!ProxyComponentMapping.ContainsKey(type))
47 | // ProxyComponentMapping.Add(type, new Component(type, ProxyGen.Generate(type)));
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/MethodInvocation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 |
5 | namespace UtyDepend.Interception
6 | {
7 | /// Represents a call of method.
8 | public class MethodInvocation
9 | {
10 | /// Creates MethodInvocation.
11 | public MethodInvocation()
12 | {
13 | Parameters = new Dictionary();
14 | InvocationContext = new Dictionary();
15 | GenericTypes = new List();
16 | }
17 |
18 | /// Executed method.
19 | public MethodBase MethodBase { get; set; }
20 |
21 | /// Input parameters.
22 | public IDictionary Parameters { get; private set; }
23 |
24 | /// Invocation context which can be used for passing parameters through bahavior chain.
25 | public IDictionary InvocationContext { get; private set; }
26 |
27 | /// Target instance.
28 | public object Target { get; set; }
29 |
30 | /// Should be set to true if method has been invoked.
31 | public bool IsInvoked { get; set; }
32 |
33 | /// Generic type list.
34 | public IList GenericTypes { get; set; }
35 |
36 | /// Wrapped return value.
37 | public IMethodReturn Return { get; set; }
38 | }
39 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/MethodReturn.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UtyDepend.Interception
4 | {
5 | /// Represents a result of method invocation.
6 | public class MethodReturn : IMethodReturn
7 | {
8 | private readonly object _returnValue;
9 |
10 | /// Creates .
11 | /// Return value.
12 | public MethodReturn(object returnValue)
13 | {
14 | _returnValue = returnValue;
15 | }
16 |
17 | /// Returns return value of method.
18 | public object GetReturnValue()
19 | {
20 | return _returnValue;
21 | }
22 |
23 | /// Exception which occured during method invocation.
24 | public Exception Exception { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Interception/ProxyBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Reflection;
4 | using UtyDepend.Interception.Behaviors;
5 |
6 | namespace UtyDepend.Interception
7 | {
8 | /// Provides base functionality to proxy object.
9 | public class ProxyBase : IProxy
10 | {
11 | private readonly LinkedList _behaviors = new LinkedList();
12 |
13 | ///
14 | public object Instance { get; set; }
15 |
16 | /// Adds behavior to behaviors' chain.
17 | ///
18 | public void AddBehavior(IBehavior behavior)
19 | {
20 | // NOTE due to the current IContainer implementation we should check this
21 | if (!_behaviors.Contains(behavior))
22 | _behaviors.AddLast(behavior);
23 | }
24 |
25 | /// Build object from executed method.
26 | ///
27 | ///
28 | protected MethodInvocation BuildMethodInvocation(MethodBase methodBase, params object[] args)
29 | {
30 | MethodInvocation methodInvocation = new MethodInvocation {MethodBase = methodBase, Target = Instance};
31 | var parameters = methodBase.GetParameters();
32 | for (int i = 0; i < parameters.Length; i++)
33 | methodInvocation.Parameters.Add(parameters[i], args[i]);
34 | return methodInvocation;
35 | }
36 |
37 | /// Run behaviors' chain.
38 | ///
39 | ///
40 | protected IMethodReturn RunBehaviors(MethodInvocation methodInvocation)
41 | {
42 | IMethodReturn methodReturn = null;
43 | return _behaviors.Aggregate(methodReturn, (ac, b) => b.Invoke(methodInvocation));
44 | }
45 |
46 | /// Clears list of behaviors.
47 | public void ClearBehaviors()
48 | {
49 | _behaviors.Clear();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Lifetime/ContainerLifetimeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using UtyDepend.Config;
4 |
5 | namespace UtyDepend.Lifetime
6 | {
7 | /// Keeps instance as long as container exists.
8 | internal class ContainerLifetimeManager : ILifetimeManager
9 | {
10 | private object _instance;
11 |
12 | public ContainerLifetimeManager(object instance)
13 | {
14 | _instance = instance;
15 | TargetType = instance.GetType();
16 | }
17 |
18 | ///
19 | public Type InterfaceType { get; set; }
20 |
21 | ///
22 | public Type TargetType { get; set; }
23 |
24 | ///
25 | public bool NeedResolveCstorArgs { get; set; }
26 |
27 | ///
28 | public IConfigSection ConfigSection { get; set; }
29 |
30 | ///
31 | public object[] CstorArgs { get; set; }
32 |
33 | ///
34 | public ConstructorInfo Constructor { get; set; }
35 |
36 | /// Returns instance.
37 | public object GetInstance()
38 | {
39 | return _instance;
40 | }
41 |
42 | public object GetInstance(string name)
43 | {
44 | return GetInstance();
45 | }
46 |
47 | ///
48 | public void Dispose()
49 | {
50 | Dispose(true);
51 | }
52 |
53 | ///
54 | protected virtual void Dispose(bool disposing)
55 | {
56 | if (disposing)
57 | _instance = null;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Lifetime/ExternalLifetimeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UtyDepend.Config;
3 |
4 | namespace UtyDepend.Lifetime
5 | {
6 | /// Wraps already created instance using WeakReference object.
7 | internal class ExternalLifetimeManager : ILifetimeManager
8 | {
9 | private readonly WeakReference _reference;
10 |
11 | public ExternalLifetimeManager(object instance)
12 | {
13 | _reference = new WeakReference(instance);
14 | TargetType = instance.GetType();
15 | }
16 |
17 | ///
18 | public Type InterfaceType { get; set; }
19 |
20 | ///
21 | public Type TargetType { get; set; }
22 |
23 | ///
24 | public bool NeedResolveCstorArgs { get; set; }
25 |
26 | ///
27 | public IConfigSection ConfigSection { get; set; }
28 |
29 | ///
30 | public object[] CstorArgs { get; set; }
31 |
32 | ///
33 | public System.Reflection.ConstructorInfo Constructor { get; set; }
34 |
35 | /// Returns instance if it exists.
36 | public object GetInstance()
37 | {
38 | if (_reference.IsAlive)
39 | return _reference.Target;
40 | throw new InvalidOperationException(
41 | String.Format("Registered object is dead! Type: {0}, interface: {1}", TargetType, InterfaceType));
42 | }
43 |
44 | public object GetInstance(string name)
45 | {
46 | return GetInstance();
47 | }
48 |
49 | public void Dispose()
50 | {
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Lifetime/ILifetimeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using UtyDepend.Config;
4 |
5 | namespace UtyDepend.Lifetime
6 | {
7 | ///
8 | /// Manages lifetime of object creation.
9 | ///
10 | public interface ILifetimeManager : IDisposable
11 | {
12 | ///
13 | /// Interface type.
14 | ///
15 | Type InterfaceType { get; set; }
16 |
17 | ///
18 | /// Target type.
19 | ///
20 | Type TargetType { get; set; }
21 |
22 | ///
23 | /// Constructor's signature.
24 | ///
25 | ConstructorInfo Constructor { get; set; }
26 |
27 | ///
28 | /// True if cstor args are types which should be resolved.
29 | ///
30 | bool NeedResolveCstorArgs { get; set; }
31 |
32 | ///
33 | /// Config section of object.
34 | ///
35 | IConfigSection ConfigSection { get; set; }
36 |
37 | ///
38 | /// Constructor's parameters.
39 | ///
40 | object[] CstorArgs { get; set; }
41 |
42 | ///
43 | /// Returns instance of the target type.
44 | ///
45 | object GetInstance();
46 |
47 | ///
48 | /// Returns instance of the target type using name provided.
49 | ///
50 | object GetInstance(string name);
51 | }
52 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Lifetime/SingletonLifetimeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UtyDepend.Config;
3 | using UtyDepend.Interception;
4 | using UtyDepend.Utils;
5 |
6 | namespace UtyDepend.Lifetime
7 | {
8 | /// Creates singleton instance for wrapped type.
9 | internal class SingletonLifetimeManager : ILifetimeManager
10 | {
11 | ///
12 | public Type InterfaceType { get; set; }
13 |
14 | ///
15 | public Type TargetType { get; set; }
16 |
17 | ///
18 | public bool NeedResolveCstorArgs { get; set; }
19 |
20 | ///
21 | public IConfigSection ConfigSection { get; set; }
22 |
23 | ///
24 | public object[] CstorArgs { get; set; }
25 |
26 | ///
27 | public System.Reflection.ConstructorInfo Constructor { get; set; }
28 |
29 | private object _instance;
30 | private IProxy _proxy;
31 |
32 | ///
33 | public object GetInstance()
34 | {
35 | return GetInstance(String.Empty);
36 | }
37 |
38 | ///
39 | public object GetInstance(string name)
40 | {
41 | object target = _proxy ?? _instance;
42 | if (_instance == null)
43 | {
44 | _instance = (Constructor ?? TypeHelper.GetConstructor(TargetType, CstorArgs))
45 | .Invoke(CstorArgs);
46 | _proxy = InterceptionContext.CreateProxy(InterfaceType, _instance);
47 |
48 | var configurable = _instance as IConfigurable;
49 | if (configurable != null && ConfigSection != null)
50 | configurable.Configure(ConfigSection);
51 | target = _proxy ?? _instance;
52 | // no need in this data anymore
53 | ConfigSection = null;
54 | CstorArgs = null;
55 | Constructor = null;
56 | }
57 |
58 | return target;
59 | }
60 |
61 | ///
62 | public void Dispose()
63 | {
64 | Dispose(true);
65 | }
66 |
67 | ///
68 | protected virtual void Dispose(bool disposing)
69 | {
70 | if (disposing)
71 | {
72 | var instance = _instance as IDisposable;
73 | if (instance != null)
74 | instance.Dispose();
75 | _instance = null;
76 | }
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Lifetime/TransientLifetimeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using UtyDepend.Config;
4 | using UtyDepend.Interception;
5 | using UtyDepend.Utils;
6 |
7 | namespace UtyDepend.Lifetime
8 | {
9 | /// Every time build a new instance.
10 | internal class TransientLifetimeManager : ILifetimeManager
11 | {
12 | ///
13 | public Type InterfaceType { get; set; }
14 |
15 | ///
16 | public Type TargetType { get; set; }
17 |
18 | ///
19 | public bool NeedResolveCstorArgs { get; set; }
20 |
21 | ///
22 | public IConfigSection ConfigSection { get; set; }
23 |
24 | ///
25 | public object[] CstorArgs { get; set; }
26 |
27 | ///
28 | public ConstructorInfo Constructor { get; set; }
29 |
30 | private ConstructorInfo _constructor;
31 |
32 | private ConstructorInfo ConstructorInstance
33 | {
34 | get
35 | {
36 | return _constructor = _constructor ?? (Constructor ?? TypeHelper.GetConstructor(TargetType, CstorArgs));
37 | }
38 | }
39 |
40 | /// Returns new instance of the target type.
41 | public object GetInstance()
42 | {
43 | var instance = ConstructorInstance.Invoke(CstorArgs);
44 | var proxy = InterceptionContext.CreateProxy(InterfaceType, instance);
45 |
46 | var target = proxy ?? instance;
47 | var configurable = target as IConfigurable;
48 | if (configurable != null && ConfigSection != null)
49 | configurable.Configure(ConfigSection);
50 | return target;
51 | }
52 |
53 | /// Returns new instance of the target type. The name parameters isn't used.
54 | public object GetInstance(string name)
55 | {
56 | return GetInstance();
57 | }
58 |
59 | public void Dispose()
60 | {
61 | Dispose(true);
62 | }
63 |
64 | protected virtual void Dispose(bool disposing)
65 | {
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UtyDepend")]
9 | [assembly: AssemblyDescription("Simple dependency injection container.")]
10 | [assembly: AssemblyProduct("UtyDepend")]
11 | [assembly: AssemblyCopyright("Copyright © Ilya Builuk, 2011-2016")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("641536c5-40dd-471e-b7c2-115ed900cbe2")]
20 |
21 | [assembly: AssemblyVersion("1.0.*")]
22 | [assembly: AssemblyFileVersion("1.0.*")]
23 |
24 | [assembly: InternalsVisibleTo("UtyDepend.Tests")]
25 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Utils/Guard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UtyDepend.Utils
4 | {
5 | internal static class Guard
6 | {
7 | public static void IsNotNull(object o, string name, string message)
8 | {
9 | if (o == null)
10 | throw new ArgumentException(message, name);
11 | }
12 |
13 | public static void IsNull(object o, string name, string message)
14 | {
15 | if (o != null)
16 | throw new ArgumentNullException(message, name);
17 | }
18 |
19 | public static void IsAssignableFrom(Type baseType, Type targetType)
20 | {
21 | if (!baseType.IsAssignableFrom(targetType))
22 | throw new InvalidOperationException(String.Format("{0} cannot be assigned from {1}",
23 | targetType == null ? "" : targetType.ToString(), baseType));
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend/Utils/TypeHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 |
5 | namespace UtyDepend.Utils
6 | {
7 | internal static class TypeHelper
8 | {
9 | public static ConstructorInfo GetConstructor(Type type, object[] cstorArgs)
10 | {
11 | var constructor = type.GetConstructor(cstorArgs.Select(a => a.GetType()).ToArray());
12 | Guard.IsNotNull(constructor, "constructor",
13 | String.Format("Unable to find appropriate constructor of type: {0}", type));
14 | return constructor;
15 | }
16 |
17 | public static ConstructorInfo GetConstructor(Type type, Type[] cstorSignature)
18 | {
19 | var constructor = type.GetConstructor(cstorSignature);
20 | //Guard.IsNotNull(constructor, "constructor",
21 | // String.Format("Unable to find appropriate constructor of type: {0}", type));
22 | return constructor;
23 | }
24 |
25 | public static ConstructorInfo GetConstructor(Type type, Type attribute)
26 | {
27 | if (type.GetConstructors().Any(c => c.GetCustomAttributes(attribute, true).Any()))
28 |
29 | return type.GetConstructors().Single(
30 | c => c.GetCustomAttributes(typeof(DependencyAttribute), true).Any());
31 | return null;
32 | }
33 |
34 | public static MethodBase GetMethodBySign(Type target, MethodBase sign, params Type[] genericTypes)
35 | {
36 | var signParameters = sign.GetParameters();
37 | foreach (var methodInfo in target.GetMethods())
38 | {
39 | if (methodInfo.Name == sign.Name)
40 | {
41 | var parameters = methodInfo.GetParameters();
42 | if (signParameters.Length == parameters.Length)
43 | {
44 | var found = !signParameters.Where((t, i) => t.ParameterType != parameters[i].ParameterType).Any();
45 | if (found)
46 | {
47 | if(methodInfo.IsGenericMethod)
48 | return GetGenericMethod(methodInfo, genericTypes);
49 | return methodInfo;
50 | }
51 | }
52 | }
53 | }
54 |
55 | return null;
56 | }
57 |
58 | public static MethodBase GetGenericMethod(MethodInfo method, params Type[] genericTypes)
59 | {
60 | return method.MakeGenericMethod(genericTypes);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/utydepend/UtyDepend/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/utyrx/README.md:
--------------------------------------------------------------------------------
1 | UtyRx: a Reactive Extensions fork
2 |
3 | The fork is based on UniRx project which is Unity3D specific fork.
4 |
--------------------------------------------------------------------------------
/utyrx/UtyRx.Tests/Observable/Observable.ErrorHandlingTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using NUnit.Framework;
4 |
5 | namespace UtyRx.Tests.Observable
6 | {
7 | [TestFixture]
8 | public class ErrorHandlingTest
9 | {
10 | [Test]
11 | public void Finally()
12 | {
13 | var called = false;
14 | try
15 | {
16 | UtyRx.Observable.Range(1, 10, Scheduler.Immediate)
17 | .Do(x => { throw new Exception(); })
18 | .Finally(() => called = true)
19 | .Subscribe();
20 | }
21 | catch
22 | {
23 | }
24 | finally
25 | {
26 | called.IsTrue();
27 | }
28 | }
29 |
30 | [Test]
31 | public void Catch()
32 | {
33 | var xs = UtyRx.Observable.Return(2, Scheduler.ThreadPool).Concat(UtyRx.Observable.Throw(new InvalidOperationException()))
34 | .Catch((InvalidOperationException ex) =>
35 | {
36 | return UtyRx.Observable.Range(1, 3);
37 | })
38 | .ToArrayWait();
39 |
40 | xs.IsCollection(2, 1, 2, 3);
41 | }
42 |
43 | [Test]
44 | public void CatchEnumerable()
45 | {
46 | {
47 | var xs = new[]
48 | {
49 | UtyRx.Observable.Return(2).Concat(UtyRx.Observable.Throw(new Exception())),
50 | UtyRx.Observable.Return(99).Concat(UtyRx.Observable.Throw(new Exception())),
51 | UtyRx.Observable.Range(10,2)
52 | }
53 | .Catch()
54 | .Materialize()
55 | .ToArrayWait();
56 |
57 | xs[0].Value.Is(2);
58 | xs[1].Value.Is(99);
59 | xs[2].Value.Is(10);
60 | xs[3].Value.Is(11);
61 | xs[4].Kind.Is(NotificationKind.OnCompleted);
62 | }
63 | {
64 | var xs = new[]
65 | {
66 | UtyRx.Observable.Return(2).Concat(UtyRx.Observable.Throw(new Exception())),
67 | UtyRx.Observable.Return(99).Concat(UtyRx.Observable.Throw(new Exception()))
68 | }
69 | .Catch()
70 | .Materialize()
71 | .ToArrayWait();
72 |
73 | xs[0].Value.Is(2);
74 | xs[1].Value.Is(99);
75 | xs[2].Kind.Is(NotificationKind.OnError);
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/utyrx/UtyRx.Tests/Operators/AggregateTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using NUnit.Framework;
4 |
5 | namespace UtyRx.Tests.Operators
6 | {
7 | [TestFixture]
8 | public class AggregateTest
9 | {
10 | [Test]
11 | public void Scan()
12 | {
13 | var range = UtyRx.Observable.Range(1, 5);
14 |
15 | range.Scan((x, y) => x + y).ToArrayWait().IsCollection(1, 3, 6, 10, 15);
16 | range.Scan(100, (x, y) => x + y).ToArrayWait().IsCollection(101, 103, 106, 110, 115);
17 |
18 | UtyRx.Observable.Empty().Scan((x, y) => x + y).ToArrayWait().IsCollection();
19 | UtyRx.Observable.Empty().Scan(100, (x, y) => x + y).ToArrayWait().IsCollection();
20 | }
21 |
22 | [Test]
23 | public void Aggregate()
24 | {
25 | AssertEx.Throws(() => UtyRx.Observable.Empty().Aggregate((x, y) => x + y).Wait());
26 | UtyRx.Observable.Range(1, 5).Aggregate((x, y) => x + y).Wait().Is(15);
27 |
28 | UtyRx.Observable.Empty().Aggregate(100, (x, y) => x + y).Wait().Is(100);
29 | UtyRx.Observable.Range(1, 5).Aggregate(100, (x, y) => x + y).Wait().Is(115);
30 |
31 | UtyRx.Observable.Empty().Aggregate(100, (x, y) => x + y, x => x + x).Wait().Is(200);
32 | UtyRx.Observable.Range(1, 5).Aggregate(100, (x, y) => x + y, x => x + x).Wait().Is(230);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/utyrx/UtyRx.Tests/Operators/ContinueWithTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using NUnit.Framework;
6 |
7 | namespace UtyRx.Tests.Operators
8 | {
9 | [TestFixture]
10 | public class ContinueWithTest
11 | {
12 | [TestFixtureSetUp]
13 | public void SetUp()
14 | {
15 | Scheduler.MainThread = Scheduler.CurrentThread;
16 | }
17 |
18 | [Test]
19 | public void ContinueWith()
20 | {
21 | var subject = new Subject();
22 |
23 | var record = subject.ContinueWith(x => UtyRx.Observable.Return(x)).Record();
24 |
25 | subject.OnNext(10);
26 | record.Values.Count.Is(0);
27 |
28 | subject.OnNext(100);
29 | record.Values.Count.Is(0);
30 |
31 | subject.OnCompleted();
32 | record.Values[0].Is(100);
33 | record.Notifications.Last().Kind.Is(NotificationKind.OnCompleted);
34 | }
35 |
36 | [Test]
37 | public void ContinueWith2()
38 | {
39 | var subject = new Subject();
40 |
41 | var record = subject.ContinueWith(x => UtyRx.Observable.Return(x).Delay(TimeSpan.FromMilliseconds(100))).Record();
42 |
43 | subject.OnNext(10);
44 | record.Values.Count.Is(0);
45 |
46 | subject.OnNext(100);
47 | record.Values.Count.Is(0);
48 |
49 | subject.OnCompleted();
50 | Thread.Sleep(TimeSpan.FromMilliseconds(200));
51 | record.Values[0].Is(100);
52 | record.Notifications.Last().Kind.Is(NotificationKind.OnCompleted);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/utyrx/UtyRx.Tests/Operators/ConversionTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 | using NUnit.Framework;
5 |
6 | namespace UtyRx.Tests.Operators
7 | {
8 | [TestFixture]
9 | public class ConversionTest
10 | {
11 | [Test]
12 | public void AsObservable()
13 | {
14 | UtyRx.Observable.Range(1, 10).AsObservable().ToArrayWait().IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
15 | }
16 |
17 | [Test]
18 | public void AsSingleUnitObservable()
19 | {
20 | var subject = new Subject();
21 |
22 | var done = false;
23 | subject.AsSingleUnitObservable().Subscribe(_ => done = true);
24 |
25 | subject.OnNext(1);
26 | done.IsFalse();
27 | subject.OnNext(100);
28 | done.IsFalse();
29 | subject.OnCompleted();
30 | done.IsTrue();
31 | }
32 |
33 | [Test]
34 | public void AsUnitObservable()
35 | {
36 | UtyRx.Observable.Range(1, 3)
37 | .AsUnitObservable()
38 | .ToArrayWait()
39 | .IsCollection(Unit.Default, Unit.Default, Unit.Default);
40 | }
41 |
42 | [Test]
43 | public void Cast()
44 | {
45 | UtyRx.Observable.Range(1, 3).Cast().ToArrayWait().IsCollection(1, 2, 3);
46 | }
47 |
48 | [Test]
49 | public void OfType()
50 | {
51 | var subject = new Subject