Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Aug 13, 2016
1 parent dd06483 commit 7c55907
Show file tree
Hide file tree
Showing 193 changed files with 4,934 additions and 5,319 deletions.
178 changes: 9 additions & 169 deletions Ninject.sln

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions global.json
@@ -0,0 +1,6 @@
{
"projects": [ "src" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Binary file not shown.
22 changes: 22 additions & 0 deletions src/Ninject.Test/Ninject.Tests.xproj
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>7e7de343-8dbd-42ee-94ed-036e9e0f5411</ProjectGuid>
<RootNamespace>Ninject.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
29 changes: 0 additions & 29 deletions src/Ninject.Test/Package.appxmanifest

This file was deleted.

19 changes: 0 additions & 19 deletions src/Ninject.Test/Settings.StyleCop

This file was deleted.

18 changes: 18 additions & 0 deletions src/Ninject.Test/project.json
@@ -0,0 +1,18 @@
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"Moq": "4.5.8",
"Ninject": "4.0.0-beta",
"TestAssembly": "1.0.0",
"TestModules": "1.0.0",
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"FluentAssertions": "4.6.3"
},
"buildOptions": { "copyToOutput": "TestModules\\*" },
"frameworks": {
"net451": {
}
}
}
96 changes: 42 additions & 54 deletions src/Ninject/Activation/Blocks/ActivationBlock.cs
@@ -1,67 +1,56 @@
#region License
//
// Author: Nate Kohari <nate@enkari.com>
// Copyright (c) 2007-2010, Enkari, Ltd.
//
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
// See the file LICENSE.txt for details.
//
#endregion
#region Using Directives
using System;
using System.Collections.Generic;
using Ninject.Infrastructure;
using Ninject.Infrastructure.Disposal;
using Ninject.Parameters;
using Ninject.Planning.Bindings;
using Ninject.Syntax;
#endregion
//-------------------------------------------------------------------------------------------------
// <copyright file="ActivationBlock.cs" company="Ninject Project Contributors">
// Copyright (c) 2007-2010, Enkari, Ltd.
// Copyright (c) 2010-2016, Ninject Project Contributors
// Authors: Nate Kohari (nate@enkari.com)
// Remo Gloor (remo.gloor@gmail.com)
//
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
// you may not use this file except in compliance with one of the Licenses.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// or
// http://www.microsoft.com/opensource/licenses.mspx
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//-------------------------------------------------------------------------------------------------

namespace Ninject.Activation.Blocks
{
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Ninject.Infrastructure.Disposal;
using Ninject.Parameters;
using Ninject.Planning.Bindings;
using Ninject.Syntax;

/// <summary>
/// A block used for deterministic disposal of activated instances. When the block is
/// disposed, all instances activated via it will be deactivated.
/// </summary>
public class ActivationBlock : DisposableObject, IActivationBlock
{
/// <summary>
/// Gets or sets the parent resolution root (usually the kernel).
/// </summary>
public IResolutionRoot Parent { get; private set; }

/// <summary>
/// Occurs when the object is disposed.
/// </summary>
public event EventHandler Disposed;

/// <summary>
/// Initializes a new instance of the <see cref="ActivationBlock"/> class.
/// </summary>
/// <param name="parent">The parent resolution root.</param>
public ActivationBlock(IResolutionRoot parent)
{
Ensure.ArgumentNotNull(parent, "parent");
Parent = parent;
Contract.Requires(parent != null);
this.Parent = parent;
}

/// <summary>
/// Releases resources held by the object.
/// Gets the parent resolution root (usually the kernel).
/// </summary>
public override void Dispose(bool disposing)
{
lock (this)
{
if (disposing && !IsDisposed)
{
var evt = Disposed;
if (evt != null) evt(this, EventArgs.Empty);
Disposed = null;
}

base.Dispose(disposing);
}
}
public IResolutionRoot Parent { get; private set; }

/// <summary>
/// Injects the specified existing instance, without managing its lifecycle.
Expand All @@ -70,7 +59,7 @@ public override void Dispose(bool disposing)
/// <param name="parameters">The parameters to pass to the request.</param>
public void Inject(object instance, params IParameter[] parameters)
{
Parent.Inject(instance, parameters);
this.Parent.Inject(instance, parameters);
}

/// <summary>
Expand All @@ -80,7 +69,7 @@ public void Inject(object instance, params IParameter[] parameters)
/// <returns><c>True</c> if the request can be resolved; otherwise, <c>false</c>.</returns>
public bool CanResolve(IRequest request)
{
Ensure.ArgumentNotNull(request, "request");
Contract.Requires(request != null);
return this.Parent.CanResolve(request);
}

Expand All @@ -94,7 +83,7 @@ public bool CanResolve(IRequest request)
/// </returns>
public bool CanResolve(IRequest request, bool ignoreImplicitBindings)
{
Ensure.ArgumentNotNull(request, "request");
Contract.Requires(request != null);
return this.Parent.CanResolve(request, ignoreImplicitBindings);
}

Expand All @@ -106,8 +95,8 @@ public bool CanResolve(IRequest request, bool ignoreImplicitBindings)
/// <returns>An enumerator of instances that match the request.</returns>
public IEnumerable<object> Resolve(IRequest request)
{
Ensure.ArgumentNotNull(request, "request");
return Parent.Resolve(request);
Contract.Requires(request != null);
return this.Parent.Resolve(request);
}

/// <summary>
Expand All @@ -121,8 +110,8 @@ public IEnumerable<object> Resolve(IRequest request)
/// <returns>The created request.</returns>
public virtual IRequest CreateRequest(Type service, Func<IBindingMetadata, bool> constraint, IEnumerable<IParameter> parameters, bool isOptional, bool isUnique)
{
Ensure.ArgumentNotNull(service, "service");
Ensure.ArgumentNotNull(parameters, "parameters");
Contract.Requires(service != null);
Contract.Requires(parameters != null);
return new Request(service, constraint, parameters, () => this, isOptional, isUnique);
}

Expand All @@ -131,10 +120,9 @@ public virtual IRequest CreateRequest(Type service, Func<IBindingMetadata, bool>
/// </summary>
/// <param name="instance">The instance to release.</param>
/// <returns><see langword="True"/> if the instance was found and released; otherwise <see langword="false"/>.</returns>
/// <remarks></remarks>
public bool Release(object instance)
{
return Parent.Release(instance);
return this.Parent.Release(instance);
}
}
}
43 changes: 28 additions & 15 deletions src/Ninject/Activation/Blocks/IActivationBlock.cs
@@ -1,23 +1,36 @@
#region License
//
// Author: Nate Kohari <nate@enkari.com>
// Copyright (c) 2007-2010, Enkari, Ltd.
//
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
// See the file LICENSE.txt for details.
//
#endregion
#region Using Directives
using System;
using Ninject.Infrastructure.Disposal;
using Ninject.Syntax;
#endregion
//-------------------------------------------------------------------------------------------------
// <copyright file="IActivationBlock.cs" company="Ninject Project Contributors">
// Copyright (c) 2007-2010, Enkari, Ltd.
// Copyright (c) 2010-2016, Ninject Project Contributors
// Authors: Nate Kohari (nate@enkari.com)
// Remo Gloor (remo.gloor@gmail.com)
//
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
// you may not use this file except in compliance with one of the Licenses.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// or
// http://www.microsoft.com/opensource/licenses.mspx
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//-------------------------------------------------------------------------------------------------

namespace Ninject.Activation.Blocks
{
using Ninject.Infrastructure.Disposal;
using Ninject.Syntax;

/// <summary>
/// A block used for deterministic disposal of activated instances. When the block is
/// disposed, all instances activated via it will be deactivated.
/// </summary>
public interface IActivationBlock : IResolutionRoot, INotifyWhenDisposed { }
public interface IActivationBlock : IResolutionRoot, IDisposableObject
{
}
}

0 comments on commit 7c55907

Please sign in to comment.