Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Instance registration via IContainer.

NullLoggerAdapter added.
  • Loading branch information...
commit 67200338f5d1acea2789e13be0937bc33296d5b7 1 parent 89e9c31
@Kostassoid authored
View
2  src/main/Anodyne-Node/Anodyne-Node.csproj
@@ -62,6 +62,8 @@
<Compile Include="Dependency\Registration\IDependencyOption.cs" />
<Compile Include="Dependency\Registration\ITypePickingSyntax.cs" />
<Compile Include="IConfigurationAction.cs" />
+ <Compile Include="Logging\NullLog.cs" />
+ <Compile Include="Logging\NullLoggerAdapter.cs" />
<Compile Include="Node.cs" />
<Compile Include="Configuration\Configured.cs" />
<Compile Include="Configuration\IConfigurationBuilder.cs" />
View
1  src/main/Anodyne-Node/Configuration/IConfiguration.cs
@@ -21,6 +21,7 @@ namespace Kostassoid.Anodyne.Node.Configuration
public interface IConfiguration : ISyntax
{
+
/* not sure
void ActAsApplicationServer();
void ActAsClient();
View
2  src/main/Anodyne-Node/Configuration/NodeInstance.cs
@@ -40,6 +40,8 @@ public class NodeInstance : IConfiguration, IConfigurationBuilder, INodeInstance
public NodeInstance()
{
_runtimeMode = RuntimeMode.Production;
+
+ (this as IConfigurationBuilder).SetLoggerAdapter(new NullLoggerAdapter());
}
bool IConfigurationBuilder.IsValid
View
1  src/main/Anodyne-Node/Dependency/Registration/IBindingSyntax.cs
@@ -22,5 +22,6 @@ public interface IBindingSyntax<in TService> : ISyntax where TService : class
void Use<TImpl>(Lifestyle lifestyle = Lifestyle.Singleton, string name = null) where TImpl : TService;
void Use(Func<TService> bindingFunc, Lifestyle lifestyle = Lifestyle.Singleton, string name = null);
void UseSelf(Lifestyle lifestyle = Lifestyle.Singleton, string name = null);
+ void UseInstance<TImpl>(TImpl implementation, string name = null) where TImpl : class, TService;
}
}
View
144 src/main/Anodyne-Node/Logging/NullLog.cs
@@ -0,0 +1,144 @@
+// Copyright 2011-2012 Anodyne.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+// this file except in compliance with the License. You may obtain a copy of the
+// License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+
+namespace Kostassoid.Anodyne.Node.Logging
+{
+ using System;
+
+ public class NullLog : ILog
+ {
+ public NullLog(string source)
+ {
+ }
+
+ public void Debug(object message)
+ {
+ }
+
+ public void Debug(object message, Exception exception)
+ {
+ }
+
+ public void DebugFormat(string format, params object[] args)
+ {
+ }
+
+ public void DebugFormat(string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args)
+ {
+ }
+
+ public void DebugFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void Info(object message)
+ {
+ }
+
+ public void Info(object message, Exception exception)
+ {
+ }
+
+ public void InfoFormat(string format, params object[] args)
+ {
+ }
+
+ public void InfoFormat(string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args)
+ {
+ }
+
+ public void InfoFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void Warn(object message)
+ {
+ }
+
+ public void Warn(object message, Exception exception)
+ {
+ }
+
+ public void WarnFormat(string format, params object[] args)
+ {
+ }
+
+ public void WarnFormat(string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args)
+ {
+ }
+
+ public void WarnFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void Error(object message)
+ {
+ }
+
+ public void Error(object message, Exception exception)
+ {
+ }
+
+ public void ErrorFormat(string format, params object[] args)
+ {
+ }
+
+ public void ErrorFormat(string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args)
+ {
+ }
+
+ public void ErrorFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void Fatal(object message)
+ {
+ }
+
+ public void Fatal(object message, Exception exception)
+ {
+ }
+
+ public void FatalFormat(string format, params object[] args)
+ {
+ }
+
+ public void FatalFormat(string format, Exception exception, params object[] args)
+ {
+ }
+
+ public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args)
+ {
+ }
+
+ public void FatalFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
+ {
+ }
+ }
+}
View
30 src/main/Anodyne-Node/Logging/NullLoggerAdapter.cs
@@ -0,0 +1,30 @@
+// Copyright 2011-2012 Anodyne.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+// this file except in compliance with the License. You may obtain a copy of the
+// License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+
+namespace Kostassoid.Anodyne.Node.Logging
+{
+ using System;
+
+ public class NullLoggerAdapter : ILoggerAdapter
+ {
+ public ILog GetLogger(Type type)
+ {
+ return GetLogger(type.Name);
+ }
+
+ public ILog GetLogger(string source)
+ {
+ return new NullLog(source);
+ }
+ }
+}
View
5 src/main/Anodyne-Node/Node.cs
@@ -32,6 +32,11 @@ public abstract class Node
public virtual void OnStart() {}
public virtual void OnShutdown() {}
+ public bool IsIn(RuntimeMode runtimeMode)
+ {
+ return Cfg.RuntimeMode == runtimeMode;
+ }
+
//private IList<ISubsystem> _subsystems = new List<ISubsystem>();
public void Start()
View
8 src/main/Anodyne-Windsor/Registration/BindingSyntax.cs
@@ -64,6 +64,14 @@ public void UseSelf(Lifestyle lifestyle = Lifestyle.Singleton, string name = nul
_container.Register(ApplyOptions(componentRegistration, lifestyle, name));
}
+ public void UseInstance<TImpl>(TImpl implementation, string name = null) where TImpl : class, TService
+ {
+ var componentRegistration = Component
+ .For<TService>().Instance(implementation);
+
+ _container.Register(ApplyOptions(componentRegistration, Lifestyle.Singleton, name));
+ }
+
private static Castle.Core.LifestyleType GetLifestyle(Lifestyle lifestyle)
{
switch (lifestyle)
Please sign in to comment.
Something went wrong with that request. Please try again.