Skip to content

Commit 6007652

Browse files
author
maximv
committed
#326: more wips
1 parent 2985815 commit 6007652

File tree

4 files changed

+181
-5
lines changed

4 files changed

+181
-5
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
</PropertyGroup>
6-
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<ProjectReference Include="..\DryIoc.Syntax.Ninject\DryIoc.Syntax.Ninject.csproj" />
7+
</ItemGroup>
78
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>

src/DryIoc.Syntax.Ninject/Ninject.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="DisposableObject.cs" company="Ninject Project Contributors">
3+
// Copyright (c) 2007-2010 Enkari, Ltd. All rights reserved.
4+
// Copyright (c) 2010-2020 Ninject Project Contributors. All rights reserved.
5+
//
6+
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
7+
// You may not use this file except in compliance with one of the Licenses.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
// or
12+
// http://www.microsoft.com/opensource/licenses.mspx
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
// </copyright>
20+
// -------------------------------------------------------------------------------------------------
21+
22+
23+
24+
namespace Ninject.Infrastructure
25+
{
26+
/// <summary>Indicates that the object has a reference to an <see cref="IKernel"/>.</summary>
27+
public interface IHaveKernel
28+
{
29+
/// <summary>Gets the kernel.</summary>
30+
IKernel Kernel { get; }
31+
}
32+
}
33+
34+
namespace Ninject
35+
{
36+
using System;
37+
using System.Collections.Generic;
38+
using System.Reflection;
39+
40+
using Ninject.Modules;
41+
using Ninject.Planning.Bindings;
42+
using Ninject.Syntax;
43+
44+
/// <summary>Provides the access to the everything</summary>
45+
public interface IKernel : IKernelConfiguration, IReadOnlyKernel {}
46+
47+
/// <summary>A kernel that is used to resolve instances and has a configuration that can't be changed anymore.</summary>
48+
public interface IReadOnlyKernel : IResolutionRoot, IServiceProvider
49+
{
50+
/// <summary>Gets the bindings registered for the specified service.</summary>
51+
IBinding[] GetBindings(Type service);
52+
}
53+
54+
public interface IKernelConfiguration : IBindingRoot, IDisposable
55+
{
56+
/// <summary>Gets the modules that have been loaded into the kernel.</summary>
57+
IEnumerable<INinjectModule> GetModules();
58+
59+
/// <summary>Determines whether a module with the specified name has been loaded in the kernel.</summary>
60+
bool HasModule(string name);
61+
62+
/// <summary>Loads the module(s) into the kernel.</summary>
63+
void Load(IEnumerable<INinjectModule> modules);
64+
65+
/// <summary>Loads modules from the files that match the specified pattern(s).</summary>
66+
/// <param name="filePatterns">The file patterns (i.e. "*.dll", "modules/*.rb") to match.</param>
67+
void Load(IEnumerable<string> filePatterns); // todo: @feature won't be supported initially
68+
69+
/// <summary>Loads modules defined in the specified assemblies.</summary>
70+
void Load(IEnumerable<Assembly> assemblies);
71+
72+
/// <summary>Unloads the plugin with the specified name.</summary>
73+
/// <param name="name">The plugin's name.</param>
74+
void Unload(string name);
75+
76+
/// <summary>Gets the bindings registered for the specified service.</summary>
77+
IBinding[] GetBindings(Type service);
78+
79+
/// <summary>Creates the readonly kernel.</summary>
80+
IReadOnlyKernel BuildReadOnlyKernel();
81+
}
82+
}

src/DryIoc.Syntax.Ninject/Syntax.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="IResolutionRoot.cs" company="Ninject Project Contributors">
3+
// Copyright (c) 2007-2010 Enkari, Ltd. All rights reserved.
4+
// Copyright (c) 2010-2020 Ninject Project Contributors. All rights reserved.
5+
//
6+
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
7+
// You may not use this file except in compliance with one of the Licenses.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
// or
12+
// http://www.microsoft.com/opensource/licenses.mspx
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
// </copyright>
20+
// -------------------------------------------------------------------------------------------------
21+
22+
namespace Ninject.Syntax
23+
{
24+
using System;
25+
using System.Collections.Generic;
26+
27+
using Ninject.Activation;
28+
using Ninject.Parameters;
29+
using Ninject.Planning.Bindings;
30+
31+
/// <summary>Provides a path to resolve instances.</summary>
32+
public interface IResolutionRoot : IFluentSyntax
33+
{
34+
/// <summary>Injects the specified existing instance, without managing its lifecycle.</summary>
35+
void Inject(object instance, params IParameter[] parameters);
36+
37+
/// <summary>Determines whether the specified request can be resolved.</summary>
38+
bool CanResolve(IRequest request);
39+
40+
/// <summary>Determines whether the specified request can be resolved.</summary>
41+
bool CanResolve(IRequest request, bool ignoreImplicitBindings);
42+
43+
/// <summary>Resolves instances for the specified request. The instances are not actually resolved
44+
/// until a consumer iterates over the enumerator.</summary>
45+
IEnumerable<object> Resolve(IRequest request);
46+
47+
/// <summary>Resolves an instance for the specified request.</summary>
48+
object ResolveSingle(IRequest request);
49+
50+
/// <summary>Creates a request for the specified service.</summary>
51+
/// <param name="service">The service that is being requested.</param>
52+
/// <param name="constraint">The constraint to apply to the bindings to determine if they match the request.</param>
53+
/// <param name="parameters">The parameters to pass to the resolution.</param>
54+
/// <param name="isOptional"><see langword="true"/> if the request is optional; otherwise, <see langword="false"/>.</param>
55+
/// <param name="isUnique"><see langword="true"/> if the request should return a unique result; otherwise, <see langword="false"/>.</param>
56+
/// <returns>The request for the specified service.</returns>
57+
IRequest CreateRequest(Type service, Func<IBindingMetadata, bool> constraint, IReadOnlyList<IParameter> parameters, bool isOptional, bool isUnique);
58+
59+
/// <summary>Deactivates and releases the specified instance if it is currently managed by Ninject.</summary>
60+
bool Release(object instance);
61+
}
62+
63+
/// <summary>The marker</summary>
64+
public interface IFluentSyntax {}
65+
}
66+
67+
namespace Ninject.Parameters
68+
{
69+
using System;
70+
71+
using Ninject.Activation;
72+
using Ninject.Planning.Targets;
73+
74+
/// <summary>Modifies an activation process in some way.</summary>
75+
public interface IParameter : IEquatable<IParameter>
76+
{
77+
/// <summary>Gets the name of the parameter.</summary>
78+
string Name { get; }
79+
80+
/// <summary>Gets a value indicating whether the parameter should be inherited into child requests.</summary>
81+
bool ShouldInherit { get; }
82+
83+
/// <summary>Gets the value for the parameter within the specified context.</summary>
84+
object GetValue(IContext context, ITarget target);
85+
}
86+
}

0 commit comments

Comments
 (0)