You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2015/01/29 21:42:45 UTC

[01/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Repository: incubator-reef
Updated Branches:
  refs/heads/master 5cc607158 -> 2ae282de1


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/TangTests.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/TangTests.csproj b/lang/cs/Tests/TangTests/TangTests.csproj
new file mode 100644
index 0000000..ee925b8
--- /dev/null
+++ b/lang/cs/Tests/TangTests/TangTests.csproj
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{D5EB94D0-3ABA-4853-9050-E36B196E17D2}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Tang.Test</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Tang.Test</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\bin\Debug\Org.Apache.Reef.Tang.Test\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\bin\Release\Microsoft.Tang.Tests\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ClassHierarchy\TestAnonymousType.cs" />
+    <Compile Include="ClassHierarchy\TestClassHierarchy.cs" />
+    <Compile Include="ClassHierarchy\TestClassHierarchyRoundTrip.cs" />
+    <Compile Include="ClassHierarchy\TestGeneric.cs" />
+    <Compile Include="ClassHierarchy\TestMultipleInterface.cs" />
+    <Compile Include="ClassHierarchy\TestParameterParser.cs" />
+    <Compile Include="ClassHierarchy\TestSerilization.cs" />
+    <Compile Include="Configuration\TestAvroConfiguration.cs" />
+    <Compile Include="Configuration\TestAvroSerializerRoundTrip.cs" />
+    <Compile Include="Configuration\TestConfiguration.cs" />
+    <Compile Include="Configuration\TestCsConfigurationBuilderExtension.cs" />
+    <Compile Include="Format\TestConfigurationModule.cs" />
+    <Compile Include="Format\TestConfigurationModuleForList.cs" />
+    <Compile Include="Format\TestTaskConfiguration.cs" />
+    <Compile Include="Injection\TestAmbigousConstructors.cs" />
+    <Compile Include="Injection\TestForkInjection.cs" />
+    <Compile Include="Injection\TestInjection.cs" />
+    <Compile Include="Injection\TestInjectionFuture.cs" />
+    <Compile Include="Injection\TestListInjection.cs" />
+    <Compile Include="Injection\TestMissingParameters.cs" />
+    <Compile Include="Injection\TestMissingParamtersInNested.cs" />
+    <Compile Include="Injection\TestMultipleConstructors.cs" />
+    <Compile Include="Injection\TestNamedParameter.cs" />
+    <Compile Include="Injection\TestSetInjection.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ScenarioTest\HttpHandlerConfiguration.cs" />
+    <Compile Include="ScenarioTest\HttpRuntimeConfiguration.cs" />
+    <Compile Include="ScenarioTest\HttpRuntimeStartHandler.cs" />
+    <Compile Include="ScenarioTest\HttpRuntimeStopHandler.cs" />
+    <Compile Include="ScenarioTest\HttpServer.cs" />
+    <Compile Include="ScenarioTest\IHttpHandler.cs" />
+    <Compile Include="ScenarioTest\JettyHandler.cs" />
+    <Compile Include="ScenarioTest\TestDefaultConstructor.cs" />
+    <Compile Include="ScenarioTest\TestHttpService.cs" />
+    <Compile Include="ScenarioTest\TestRuntimeClock.cs" />
+    <Compile Include="ScenarioTest\TestTrackingURIProvider.cs" />
+    <Compile Include="ScenarioTest\TrackingURIProvider.cs" />
+    <Compile Include="ScenarioTest\TrackingYRIProvider.cs" />
+    <Compile Include="SmokeTest\AnInterface.cs" />
+    <Compile Include="SmokeTest\AnInterfaceImplementation.cs" />
+    <Compile Include="SmokeTest\CyclicDependency.cs" />
+    <Compile Include="SmokeTest\CyclicDependencyClassOne.cs" />
+    <Compile Include="SmokeTest\CyclicDependencyClassTwo.cs" />
+    <Compile Include="SmokeTest\Handler.cs" />
+    <Compile Include="SmokeTest\InjectableClass.cs" />
+    <Compile Include="SmokeTest\ListOfBaseTypes.cs" />
+    <Compile Include="SmokeTest\ObjectTreeTest.cs" />
+    <Compile Include="SmokeTest\RootImplementation.cs" />
+    <Compile Include="SmokeTest\RootInterface.cs" />
+    <Compile Include="SmokeTest\RoundTripTest.cs" />
+    <Compile Include="SmokeTest\SetInterface.cs" />
+    <Compile Include="SmokeTest\SetInterfaceImplOne.cs" />
+    <Compile Include="SmokeTest\SetInterfaceImplTwo.cs" />
+    <Compile Include="SmokeTest\SetOfBaseTypes.cs" />
+    <Compile Include="SmokeTest\SetOfImplementations.cs" />
+    <Compile Include="SmokeTest\TestConfigurationModuleBuilder.cs" />
+    <Compile Include="Tang\TestDefaultImpementaion.cs" />
+    <Compile Include="Tang\TestExternalConstructors.cs" />
+    <Compile Include="Tang\TestLegacyConstructors.cs" />
+    <Compile Include="Tang\TestTang.cs" />
+    <Compile Include="Utilities\TestUtilities.cs" />
+    <Compile Include="Utilities\Utilities.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="evaluator.conf">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Include="packages.config" />
+    <None Include="simpleConstructorJavaProto.bin">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Source\REEF\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-tasks\Tasks\Tasks.csproj">
+      <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+      <Name>Tasks</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\TANG\Examples\Examples.csproj">
+      <Project>{31b4389e-925a-4181-a1f6-21a1a0ad8a1c}</Project>
+      <Name>Examples</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\TANG\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Utilities/TestUtilities.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Utilities/TestUtilities.cs b/lang/cs/Tests/TangTests/Utilities/TestUtilities.cs
new file mode 100644
index 0000000..8d81738
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Utilities/TestUtilities.cs
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Examples;
+
+namespace Org.Apache.Reef.Tang.Test.Utilities
+{
+    [TestClass]
+    public class TestUtilities
+    {
+        [TestMethod]
+        public void TestIsAssignableFromIgnoreGeneric()
+        {
+            var result = ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof(IExternalConstructor<>), typeof(Foo));
+            Assert.IsTrue(result);
+        }
+
+        [TestMethod]
+        public void TestIsAssignableFromIgnoreGenericNegtive()
+        {
+            var result = ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof(ISet<>), typeof(Foo));
+            Assert.IsFalse(result);
+        }
+
+        [TestMethod]
+        public void TestIsInstanceOfGeneric()
+        {
+            var p1 = new OptionalParameter<int>();
+            bool r1 = ReflectionUtilities.IsInstanceOfGeneric(p1, typeof(OptionalParameter<>));
+            var p2 = new RequiredParameter<string>();
+            bool r2 = ReflectionUtilities.IsInstanceOfGeneric(p2, typeof(RequiredParameter<>));
+            Assert.IsTrue(r1);
+            Assert.IsTrue(r2);
+        }
+
+        [TestMethod]
+        public void TestGetInterfaceTargetForTypeInheritFromGeneric()
+        {
+            Type result = ReflectionUtilities.GetInterfaceTarget(typeof(IExternalConstructor<>), typeof(Foo));
+            Assert.AreEqual(result, typeof(Int32));
+        }
+
+        class Foo : IExternalConstructor<Int32>
+        {
+            public Int32 NewInstance()
+            {
+                return 3;
+            }
+        }
+
+        [TestMethod]
+        public void TestGetEnclosingClassShortNameByType()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type seconds = asm.GetType(FileNames.Seconds);
+            Type timer = asm.GetType(FileNames.Timer);
+
+            string[] pathSeconds = ReflectionUtilities.GetEnclosingClassNames(seconds);
+            Assert.AreEqual(pathSeconds[0], timer.AssemblyQualifiedName);
+            Assert.AreEqual(pathSeconds[1], seconds.AssemblyQualifiedName);
+
+            string[] pathTime = ReflectionUtilities.GetEnclosingClassNames(timer);
+            Assert.AreEqual(pathTime[0], timer.AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestGetName()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type B2 = asm.GetType(FileNames.B2);
+
+            string n = ReflectionUtilities.GetName(B2);
+            Assert.AreEqual(n, B2.FullName);
+        }
+
+        [TestMethod]
+        public void TestGetEnclosingTypesInclusive()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type B2 = asm.GetType(FileNames.B2);
+            Type[] ts = ReflectionUtilities.GetEnclosingClasses(B2);
+            Assert.AreEqual(ts[0], asm.GetType(FileNames.B));
+            Assert.AreEqual(ts[1], asm.GetType(FileNames.B1));
+            Assert.AreEqual(ts[2], asm.GetType(FileNames.B2));
+        }
+
+        [TestMethod]
+        public void TestGetEnclosingClassShortNameByName()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type b = asm.GetType(FileNames.B);
+            Type b1 = asm.GetType(FileNames.B1);
+            Type b2 = asm.GetType(FileNames.B2);
+
+            string[] path = ReflectionUtilities.GetEnclosingClassNames(FileNames.B2);
+            Assert.AreEqual(path[0], b.AssemblyQualifiedName);
+            Assert.AreEqual(path[1], b1.AssemblyQualifiedName);
+            Assert.AreEqual(path[2], b2.AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestGetEnclosingClassShortNameByFullName()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type c = asm.GetType(FileNames.B2);
+            Type b = asm.GetType(FileNames.B);
+            Type b1 = asm.GetType(FileNames.B1);
+            Type b2 = asm.GetType(FileNames.B2);
+            string[] path = ReflectionUtilities.GetEnclosingClassNames(c.FullName);
+            Assert.AreEqual(path[0], b.AssemblyQualifiedName);
+            Assert.AreEqual(path[1], b1.AssemblyQualifiedName);
+            Assert.AreEqual(path[2], b2.AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestGetEnclosingClassShortNameByAssemblyQualifiedName()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type c = asm.GetType(FileNames.B2);
+            Type b = asm.GetType(FileNames.B);
+            Type b1 = asm.GetType(FileNames.B1);
+            Type b2 = asm.GetType(FileNames.B2);
+
+            string[] path = ReflectionUtilities.GetEnclosingClassNames(c.AssemblyQualifiedName);
+
+            Assert.AreEqual(path[0], b.AssemblyQualifiedName);
+            Assert.AreEqual(path[1], b1.AssemblyQualifiedName);
+            Assert.AreEqual(path[2], b2.AssemblyQualifiedName);
+        }
+        
+        [TestMethod]
+        public void AssemblyNamesTest()
+        {
+            var asm = Assembly.Load(FileNames.Examples);
+            Type seconds = asm.GetType(FileNames.Seconds);
+
+            var name = seconds.Name;
+            var fullName = seconds.FullName;
+            var assemblyName = seconds.AssemblyQualifiedName;
+
+            Type[] i = seconds.GetInterfaces();
+
+            foreach (Type t in i)
+            {
+                var name1 = t.Name;
+                var fullName1 = t.FullName;
+                var assemblyName1 = t.AssemblyQualifiedName;
+            }
+        }
+
+        [TestMethod]
+        public void TestGetInterfaceTargetForGenericType()
+        {
+            Type iface = typeof(ISet<>);
+            Type type = typeof(MySet<string>);
+            Type p = ReflectionUtilities.GetInterfaceTarget(iface, type);
+            Assert.IsTrue(p.Equals(typeof (string)));
+        }
+
+        [TestMethod]
+        public void TestGetInterfaceTargetForSystemGenericType()
+        {
+            Type iface = typeof(ISet<>);
+            Type type = typeof(ISet<int>);
+            Type p = ReflectionUtilities.GetInterfaceTarget(iface, type);
+            Assert.IsTrue(p.Equals(typeof(int)));
+        }
+    }
+
+    public class MySet<T> : ISet<T>
+    {
+        public bool Add(T item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void ExceptWith(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void IntersectWith(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool IsProperSubsetOf(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool IsProperSupersetOf(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool IsSubsetOf(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool IsSupersetOf(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool Overlaps(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool SetEquals(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void SymmetricExceptWith(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void UnionWith(IEnumerable<T> other)
+        {
+            throw new NotImplementedException();
+        }
+
+        void ICollection<T>.Add(T item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Clear()
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool Contains(T item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void CopyTo(T[] array, int arrayIndex)
+        {
+            throw new NotImplementedException();
+        }
+
+        public int Count
+        {
+            get { throw new NotImplementedException(); }
+        }
+
+        public bool IsReadOnly
+        {
+            get { throw new NotImplementedException(); }
+        }
+
+        public bool Remove(T item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IEnumerator<T> GetEnumerator()
+        {
+            throw new NotImplementedException();
+        }
+
+        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Utilities/Utilities.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Utilities/Utilities.cs b/lang/cs/Tests/TangTests/Utilities/Utilities.cs
new file mode 100644
index 0000000..eb31d6a
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Utilities/Utilities.cs
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Test.Utilities
+{
+    public class Utilities
+    {
+        public static bool Equals<T>(ICollection<T> s1, ISet<T> s2)
+        {
+            if (s1 == s2)
+            {
+                return true;
+            }
+            if (s1 == null || s2 == null)
+            {
+                return false;
+            }
+            if (s1.Count != s2.Count)
+            {
+                return false;
+            }
+            foreach (T t in s1)
+            {
+                if (!Contains<T>(s2, t))
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        public static bool Contains<T>(ICollection<T> s, T t)
+        {
+            foreach (T t1 in s)
+            {
+                if (t1.Equals(t))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/evaluator.conf
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/evaluator.conf b/lang/cs/Tests/TangTests/evaluator.conf
new file mode 100644
index 0000000..67256f5
Binary files /dev/null and b/lang/cs/Tests/TangTests/evaluator.conf differ

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/packages.config b/lang/cs/Tests/TangTests/packages.config
new file mode 100644
index 0000000..933b7e1
--- /dev/null
+++ b/lang/cs/Tests/TangTests/packages.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/simpleConstructorJavaProto.bin
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/simpleConstructorJavaProto.bin b/lang/cs/Tests/TangTests/simpleConstructorJavaProto.bin
new file mode 100644
index 0000000..f7bb871
Binary files /dev/null and b/lang/cs/Tests/TangTests/simpleConstructorJavaProto.bin differ

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/ClockTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/ClockTest.cs b/lang/cs/Tests/WakeTests/ClockTest.cs
new file mode 100644
index 0000000..d401235
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/ClockTest.cs
@@ -0,0 +1,183 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive;
+using System.Reactive.Subjects;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.Time;
+using Org.Apache.Reef.Wake.Time.Runtime;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+
+namespace Org.Apache.Reef.Wake.Test
+{
+    [TestClass]
+    public class ClockTest
+    {
+        [TestMethod]
+        public void TestClock()
+        {
+            using (RuntimeClock clock = BuildClock())
+            {
+                Task.Run(new Action(clock.Run));
+
+                var heartBeat = new HeartbeatObserver(clock);
+                heartBeat.OnNext(null);
+                Thread.Sleep(5000);
+
+                Assert.AreEqual(100, heartBeat.EventCount);
+            }
+        }
+
+        [TestMethod]
+        public void TestAlarmRegistrationRaceConditions()
+        {
+            using (RuntimeClock clock = BuildClock())
+            {
+                Task.Run(new Action(clock.Run));
+
+                List<Alarm> events1 = new List<Alarm>();
+                List<Alarm> events2 = new List<Alarm>();
+
+                // Observers to record events that they have processed
+                IObserver<Alarm> earlierRecorder = Observer.Create<Alarm>(events1.Add);
+                IObserver<Alarm> laterRecorder = Observer.Create<Alarm>(events2.Add);
+
+                // Schedule a later alarm in the future
+                clock.ScheduleAlarm(5000, laterRecorder);
+
+                // After 1 second, schedule an earlier alarm that will fire before the later alarm
+                Thread.Sleep(1000);
+                clock.ScheduleAlarm(2000, earlierRecorder);
+
+                // The earlier alarm should not have fired after 1 second
+                Thread.Sleep(1000);
+                Assert.AreEqual(0, events1.Count);
+
+                // The earlier alarm will have fired after another 1.5 seconds, but the later will have not
+                Thread.Sleep(1500);
+                Assert.AreEqual(1, events1.Count);
+                Assert.AreEqual(0, events2.Count);
+
+                // The later alarm will have fired after 2 seconds
+                Thread.Sleep(2000);
+                Assert.AreEqual(1, events1.Count);
+            }
+        }
+
+        [TestMethod]
+        public void TestSimulatenousAlarms()
+        {
+            using (RuntimeClock clock = BuildClock())
+            {
+                Task.Run(new Action(clock.Run));
+
+                List<Alarm> events = new List<Alarm>();
+                IObserver<Alarm> eventRecorder = Observer.Create<Alarm>(events.Add);
+
+                clock.ScheduleAlarm(1000, eventRecorder);
+                clock.ScheduleAlarm(1000, eventRecorder);
+                clock.ScheduleAlarm(1000, eventRecorder);
+
+                Thread.Sleep(1500);
+                Assert.AreEqual(3, events.Count);
+            }
+        }
+
+        [TestMethod]
+        public void TestAlarmOrder()
+        {
+            using (RuntimeClock clock = BuildLogicalClock())
+            {
+                Task.Run(new Action(clock.Run));
+
+                // Event handler to record event time stamps
+                List<long> recordedTimestamps = new List<long>();
+                IObserver<Alarm> eventRecorder = Observer.Create<Alarm>(alarm => recordedTimestamps.Add(alarm.TimeStamp));
+
+                //  Schedule 10 alarms every 100 ms 
+                List<long> expectedTimestamps = Enumerable.Range(0, 10).Select(offset => (long)offset * 100).ToList();
+                expectedTimestamps.ForEach(offset => clock.ScheduleAlarm(offset, eventRecorder));
+    
+                // Check that the recorded timestamps are in the same order that they were scheduled
+                Thread.Sleep(1500);
+                Assert.IsTrue(expectedTimestamps.SequenceEqual(recordedTimestamps));
+            }
+        }
+
+        private RuntimeClock BuildClock()
+        {
+            var builder = TangFactory.GetTang().NewConfigurationBuilder();
+
+            return TangFactory.GetTang()
+                              .NewInjector(builder.Build())
+                              .GetInstance<RuntimeClock>();
+        }
+
+        private RuntimeClock BuildLogicalClock()
+        {
+            var builder = TangFactory.GetTang().NewConfigurationBuilder();
+            builder.BindImplementation(GenericType<ITimer>.Class, GenericType<LogicalTimer>.Class);
+
+            return TangFactory.GetTang()
+                              .NewInjector(builder.Build())
+                              .GetInstance<RuntimeClock>();
+        }
+
+        private class HeartbeatObserver : IObserver<Alarm>
+        {
+            private RuntimeClock _clock;
+
+            public HeartbeatObserver(RuntimeClock clock)
+            {
+                _clock = clock;
+                EventCount = 0;
+            }
+
+            public int EventCount { get; set; }
+
+            public void OnNext(Alarm value)
+            {
+                EventCount++;
+                if (EventCount < 100)
+                {
+                    _clock.ScheduleAlarm(10, this);
+                }
+            }
+
+            public void OnError(Exception error)
+            {
+                throw new NotImplementedException();
+            }
+
+            public void OnCompleted()
+            {
+                throw new NotImplementedException();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/MultiCodecTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/MultiCodecTest.cs b/lang/cs/Tests/WakeTests/MultiCodecTest.cs
new file mode 100644
index 0000000..0a3240f
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/MultiCodecTest.cs
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+
+namespace Org.Apache.Reef.Wake.Test
+{
+    [TestClass]
+    public class MultiCodecTest
+    {
+        [TestMethod]
+        public void TestMultiCodec()
+        {
+            MultiCodec<BaseEvent> codec = new MultiCodec<BaseEvent>();
+            codec.Register(new Event1Codec());
+            codec.Register(new Event2Codec());
+
+            byte[] d1Data = codec.Encode(new Event1(42));
+            byte[] d2Data = codec.Encode(new Event2("Tony"));
+
+            Event1 e1 = (Event1)codec.Decode(d1Data);
+            Event2 e2 = (Event2)codec.Decode(d2Data);
+
+            Assert.AreEqual(42, e1.Number);
+            Assert.AreEqual("Tony", e2.Name);
+        }
+
+        private class BaseEvent
+        {
+        }
+
+        private class Event1 : BaseEvent
+        {
+            public Event1(int number)
+            {
+                Number = number;
+            }
+
+            public int Number { get; set; }
+        }
+
+        private class Event2 : BaseEvent
+        {
+            public Event2(string name)
+            {
+                Name = name;
+            }
+
+            public string Name { get; set; }
+        }
+
+        private class Event1Codec : ICodec<Event1>
+        {
+            public byte[] Encode(Event1 obj)
+            {
+                return BitConverter.GetBytes(obj.Number);
+            }
+
+            public Event1 Decode(byte[] data)
+            {
+                return new Event1(BitConverter.ToInt32(data, 0));
+            }
+        }
+
+        private class Event2Codec : ICodec<Event2>
+        {
+            public byte[] Encode(Event2 obj)
+            {
+                return Encoding.ASCII.GetBytes(obj.Name);
+            }
+
+            public Event2 Decode(byte[] data)
+            {
+                return new Event2(Encoding.ASCII.GetString(data));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/Properties/AssemblyInfo.cs b/lang/cs/Tests/WakeTests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d126f3f
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Org.Apache.Reef.Wake.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Org.Apache.Reef.Wake.Tests")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("68a2ef80-e51b-4abb-9ccc-81354e152758")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/PubSubSubjectTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/PubSubSubjectTest.cs b/lang/cs/Tests/WakeTests/PubSubSubjectTest.cs
new file mode 100644
index 0000000..be27782
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/PubSubSubjectTest.cs
@@ -0,0 +1,209 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.RX.Impl;
+
+namespace Test.Wake
+{
+    [TestClass]
+    public class PubSubSubjectTest
+    {
+        [TestMethod]
+        public void TestPubSubSubjectSingleThread()
+        {
+            int sum = 0;
+
+            // Observer that adds sum of numbers up to and including x
+            PubSubSubject<int> subject = new PubSubSubject<int>();
+            subject.Subscribe(Observer.Create<int>(
+                x =>
+                {
+                    for (int i = 0; i <= x; i++)
+                    {
+                        sum += i;
+                    }
+                }));
+
+            subject.OnNext(10);
+            subject.OnCompleted();
+            Assert.AreEqual(sum, 55);
+        }
+
+        [TestMethod]
+        public void TestPubSubSubjectMultipleThreads()
+        {
+            int sum = 0;
+
+            PubSubSubject<int> subject = new PubSubSubject<int>();
+            subject.Subscribe(Observer.Create<int>(x => sum += x));
+
+            Thread[] threads = new Thread[10];
+            for (int i = 0; i < threads.Length; i++)
+            {
+                threads[i] = new Thread(() =>
+                {
+                    for (int j = 0; j < 10000; j++)
+                    {
+                        subject.OnNext(1);
+                    }
+                });
+
+                threads[i].Start();
+            }
+
+            foreach (Thread thread in threads)
+            {
+                thread.Join();
+            }
+
+            Assert.AreEqual(sum, 100000);
+        }
+
+        [TestMethod]
+        public void TestMultipleTypes()
+        {
+            int sum1 = 0;
+            int sum2 = 0;
+
+            PubSubSubject<SuperEvent> subject = new PubSubSubject<SuperEvent>();
+            subject.Subscribe(Observer.Create<SubEvent1>(x => sum1 += 100));
+            subject.Subscribe(Observer.Create<SubEvent2>(x => sum2 += 500));
+
+            subject.OnNext(new SubEvent1());
+            subject.OnNext(new SubEvent2());
+            subject.OnNext(new SubEvent2());
+
+            Assert.AreEqual(sum1, 100);
+            Assert.AreEqual(sum2, 1000);
+        }
+
+        [TestMethod]
+        public void TestOnCompleted()
+        {
+            int sum = 0;
+
+            PubSubSubject<int> subject = new PubSubSubject<int>();
+            subject.Subscribe(Observer.Create<int>(x => sum += x));
+
+            subject.OnNext(10);
+            Assert.AreEqual(10, sum);
+
+            subject.OnNext(10);
+            Assert.AreEqual(20, sum);
+
+            // Check that after calling OnCompleted, OnNext will do nothing
+            subject.OnCompleted();
+            subject.OnNext(10);
+            Assert.AreEqual(20, sum);
+        }
+
+        [TestMethod]
+        public void TestOnError()
+        {
+            int sum = 0;
+
+            PubSubSubject<int> subject = new PubSubSubject<int>();
+            subject.Subscribe(Observer.Create<int>(x => sum += x));
+
+            subject.OnNext(10);
+            Assert.AreEqual(10, sum);
+
+            subject.OnNext(10);
+            Assert.AreEqual(20, sum);
+
+            // Check that after calling OnError, OnNext will do nothing
+            subject.OnError(new Exception("error"));
+            subject.OnNext(10);
+            Assert.AreEqual(20, sum);
+        }
+
+        [TestMethod]
+        public void TestDisposeSingleSubject()
+        {
+            int sum = 0;
+
+            PubSubSubject<int> subject = new PubSubSubject<int>();
+            var disposable = subject.Subscribe(Observer.Create<int>(x => sum += x));
+            
+            subject.OnNext(10);
+            subject.OnNext(10);
+            subject.OnNext(10);
+            Assert.AreEqual(30, sum);
+
+            // Unregister the subject and check that calling OnNext does nothing
+            disposable.Dispose();
+            subject.OnNext(10);
+            Assert.AreEqual(30, sum);
+        }
+
+        [TestMethod]
+        public void TestDisposeMultipleSubjects()
+        {
+            int sum1 = 0;
+            int sum2 = 0;
+
+            SubEvent1 event1 = new SubEvent1();
+            SubEvent2 event2 = new SubEvent2();
+
+            PubSubSubject<SuperEvent> subject = new PubSubSubject<SuperEvent>();
+            var disposable1 = subject.Subscribe(Observer.Create<SubEvent1>(x => sum1 += 100));
+            var disposable2 = subject.Subscribe(Observer.Create<SubEvent2>(x => sum2 += 500));
+
+            subject.OnNext(event1);
+            subject.OnNext(event2);
+            subject.OnNext(event2);
+            Assert.AreEqual(sum1, 100);
+            Assert.AreEqual(sum2, 1000);
+
+            // Check that unsubscribing from SubEvent1 does not affect other subscriptions
+            disposable1.Dispose();
+            subject.OnNext(event1);
+            subject.OnNext(event2);
+            Assert.AreEqual(sum1, 100);
+            Assert.AreEqual(sum2, 1500);
+
+            // Unsubscribe from the remaining event types
+            disposable2.Dispose();
+            subject.OnNext(event1);
+            subject.OnNext(event2);
+            Assert.AreEqual(sum1, 100);
+            Assert.AreEqual(sum2, 1500);
+        }
+
+        class SuperEvent
+        {
+        }
+
+        class SubEvent1 : SuperEvent
+        {
+        }
+
+        class SubEvent2 : SuperEvent
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/RemoteManagerTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/RemoteManagerTest.cs b/lang/cs/Tests/WakeTests/RemoteManagerTest.cs
new file mode 100644
index 0000000..3c4150a
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/RemoteManagerTest.cs
@@ -0,0 +1,344 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.RX;
+using Org.Apache.Reef.Wake.Util;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Reactive;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Test
+{
+    [TestClass]
+    public class RemoteManagerTest
+    {
+        [TestMethod]
+        public void TestOneWayCommunication()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                var observer = Observer.Create<string>(queue.Add);
+                IPEndPoint endpoint1 = new IPEndPoint(listeningAddress, 0);
+                remoteManager2.RegisterObserver(endpoint1, observer);
+
+                var remoteObserver = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                remoteObserver.OnNext("abc");
+                remoteObserver.OnNext("def");
+                remoteObserver.OnNext("ghi");
+
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+            }
+
+            Assert.AreEqual(3, events.Count);
+        }
+
+        [TestMethod]
+        public void TestOneWayCommunicationClientOnly()
+        {
+            int listeningPort = NetworkUtils.GenerateRandomPort(6000, 7000);
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, listeningPort, new StringCodec()))
+            {
+                IPEndPoint remoteEndpoint = new IPEndPoint(listeningAddress, 0);
+                var observer = Observer.Create<string>(queue.Add);
+                remoteManager2.RegisterObserver(remoteEndpoint, observer);
+
+                var remoteObserver = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                remoteObserver.OnNext("abc");
+                remoteObserver.OnNext("def");
+                remoteObserver.OnNext("ghi");
+
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+            }
+
+            Assert.AreEqual(3, events.Count);
+        }
+
+        [TestMethod]
+        public void TestTwoWayCommunication()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue1 = new BlockingCollection<string>();
+            BlockingCollection<string> queue2 = new BlockingCollection<string>();
+            List<string> events1 = new List<string>();
+            List<string> events2 = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                // Register observers for remote manager 1 and remote manager 2
+                var remoteEndpoint = new IPEndPoint(listeningAddress, 0);
+                var observer1 = Observer.Create<string>(queue1.Add);
+                var observer2 = Observer.Create<string>(queue2.Add);
+                remoteManager1.RegisterObserver(remoteEndpoint, observer1);
+                remoteManager2.RegisterObserver(remoteEndpoint, observer2);
+
+                // Remote manager 1 sends 3 events to remote manager 2
+                var remoteObserver1 = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                remoteObserver1.OnNext("abc");
+                remoteObserver1.OnNext("def");
+                remoteObserver1.OnNext("ghi");
+
+                // Remote manager 2 sends 4 events to remote manager 1
+                var remoteObserver2 = remoteManager2.GetRemoteObserver(remoteManager1.LocalEndpoint);
+                remoteObserver2.OnNext("jkl");
+                remoteObserver2.OnNext("mno");
+                remoteObserver2.OnNext("pqr");
+                remoteObserver2.OnNext("stu");
+
+                events1.Add(queue1.Take());
+                events1.Add(queue1.Take());
+                events1.Add(queue1.Take());
+                events1.Add(queue1.Take());
+
+                events2.Add(queue2.Take());
+                events2.Add(queue2.Take());
+                events2.Add(queue2.Take());
+            }
+
+            Assert.AreEqual(4, events1.Count);
+            Assert.AreEqual(3, events2.Count);
+        }
+
+        [TestMethod]
+        public void TestCommunicationThreeNodesOneWay()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager3 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                var remoteEndpoint = new IPEndPoint(listeningAddress, 0);
+                var observer = Observer.Create<string>(queue.Add);
+                remoteManager3.RegisterObserver(remoteEndpoint, observer);
+
+                var remoteObserver1 = remoteManager1.GetRemoteObserver(remoteManager3.LocalEndpoint);
+                var remoteObserver2 = remoteManager2.GetRemoteObserver(remoteManager3.LocalEndpoint);
+
+                remoteObserver2.OnNext("abc");
+                remoteObserver1.OnNext("def");
+                remoteObserver2.OnNext("ghi");
+                remoteObserver1.OnNext("jkl");
+                remoteObserver2.OnNext("mno");
+
+                for (int i = 0; i < 5; i++)
+                {
+                    events.Add(queue.Take());
+                }
+            }
+
+            Assert.AreEqual(5, events.Count);
+        }
+
+        [TestMethod]
+        public void TestCommunicationThreeNodesBothWays()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue1 = new BlockingCollection<string>();
+            BlockingCollection<string> queue2 = new BlockingCollection<string>();
+            BlockingCollection<string> queue3 = new BlockingCollection<string>();
+            List<string> events1 = new List<string>();
+            List<string> events2 = new List<string>();
+            List<string> events3 = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager3 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                var remoteEndpoint = new IPEndPoint(listeningAddress, 0);
+
+                var observer = Observer.Create<string>(queue1.Add);
+                remoteManager1.RegisterObserver(remoteEndpoint, observer);
+                var observer2 = Observer.Create<string>(queue2.Add);
+                remoteManager2.RegisterObserver(remoteEndpoint, observer2);
+                var observer3 = Observer.Create<string>(queue3.Add);
+                remoteManager3.RegisterObserver(remoteEndpoint, observer3);
+
+                var remoteObserver1 = remoteManager1.GetRemoteObserver(remoteManager3.LocalEndpoint);
+                var remoteObserver2 = remoteManager2.GetRemoteObserver(remoteManager3.LocalEndpoint);
+
+                // Observer 1 and 2 send messages to observer 3
+                remoteObserver1.OnNext("abc");
+                remoteObserver1.OnNext("abc");
+                remoteObserver1.OnNext("abc");
+                remoteObserver2.OnNext("def");
+                remoteObserver2.OnNext("def");
+
+                // Observer 3 sends messages back to observers 1 and 2
+                var remoteObserver3a = remoteManager3.GetRemoteObserver(remoteManager1.LocalEndpoint);
+                var remoteObserver3b = remoteManager3.GetRemoteObserver(remoteManager2.LocalEndpoint);
+
+                remoteObserver3a.OnNext("ghi");
+                remoteObserver3a.OnNext("ghi");
+                remoteObserver3b.OnNext("jkl");
+                remoteObserver3b.OnNext("jkl");
+                remoteObserver3b.OnNext("jkl");
+
+                events1.Add(queue1.Take());
+                events1.Add(queue1.Take());
+
+                events2.Add(queue2.Take());
+                events2.Add(queue2.Take());
+                events2.Add(queue2.Take());
+
+                events3.Add(queue3.Take());
+                events3.Add(queue3.Take());
+                events3.Add(queue3.Take());
+                events3.Add(queue3.Take());
+                events3.Add(queue3.Take());
+            }
+
+            Assert.AreEqual(2, events1.Count);
+            Assert.AreEqual(3, events2.Count);
+            Assert.AreEqual(5, events3.Count);
+        }
+
+        [TestMethod]
+        public void TestRemoteSenderCallback()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                // Register handler for when remote manager 2 receives events; respond
+                // with an ack
+                var remoteEndpoint = new IPEndPoint(listeningAddress, 0);
+                var remoteObserver2 = remoteManager2.GetRemoteObserver(remoteManager1.LocalEndpoint);
+
+                var receiverObserver = Observer.Create<string>(
+                    message => remoteObserver2.OnNext("received message: " + message));
+                remoteManager2.RegisterObserver(remoteEndpoint, receiverObserver);
+
+                // Register handler for remote manager 1 to record the ack
+                var senderObserver = Observer.Create<string>(queue.Add);
+                remoteManager1.RegisterObserver(remoteEndpoint, senderObserver);
+
+                // Begin to send messages
+                var remoteObserver1 = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                remoteObserver1.OnNext("hello");
+                remoteObserver1.OnNext("there");
+                remoteObserver1.OnNext("buddy");
+
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+            }
+
+            Assert.AreEqual(3, events.Count);
+            Assert.AreEqual("received message: hello", events[0]);
+            Assert.AreEqual("received message: there", events[1]);
+            Assert.AreEqual("received message: buddy", events[2]);
+        }
+        
+        [TestMethod]
+        public void TestRegisterObserverByType()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                // RemoteManager2 listens and records events of type IRemoteEvent<string>
+                var observer = Observer.Create<IRemoteMessage<string>>(message => queue.Add(message.Message));
+                remoteManager2.RegisterObserver(observer);
+
+                // Remote manager 1 sends 3 events to remote manager 2
+                var remoteObserver = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                remoteObserver.OnNext("abc");
+                remoteObserver.OnNext("def");
+                remoteObserver.OnNext("ghi");
+
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+            }
+
+            Assert.AreEqual(3, events.Count);
+        }
+
+        [TestMethod]
+        public void TestCachedConnection()
+        {
+            IPAddress listeningAddress = IPAddress.Parse("127.0.0.1");
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            using (var remoteManager1 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            using (var remoteManager2 = new DefaultRemoteManager<string>(listeningAddress, 0, new StringCodec()))
+            {
+                var observer = Observer.Create<string>(queue.Add);
+                IPEndPoint endpoint1 = new IPEndPoint(listeningAddress, 0);
+                remoteManager2.RegisterObserver(endpoint1, observer);
+
+                var remoteObserver = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                remoteObserver.OnNext("abc");
+                remoteObserver.OnNext("def");
+
+                var cachedObserver = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
+                cachedObserver.OnNext("ghi");
+                cachedObserver.OnNext("jkl");
+
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+                events.Add(queue.Take());
+            }
+
+            Assert.AreEqual(4, events.Count);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/TransportTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/TransportTest.cs b/lang/cs/Tests/WakeTests/TransportTest.cs
new file mode 100644
index 0000000..07671a5
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/TransportTest.cs
@@ -0,0 +1,205 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Reactive;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.Wake.Test
+{
+    [TestClass]
+    public class TransportTest
+    {
+        [TestMethod]
+        public void TestTransportServer()
+        {
+            ICodec<string> codec = new StringCodec();
+            int port = NetworkUtils.GenerateRandomPort(6000, 7000);
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+
+            IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port);
+            var remoteHandler = Observer.Create<TransportEvent<string>>(tEvent => queue.Add(tEvent.Data));
+
+            using (var server = new TransportServer<string>(endpoint, remoteHandler, codec))
+            {
+                server.Run();
+
+                IPEndPoint remoteEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
+                using (var client = new TransportClient<string>(remoteEndpoint, codec))
+                {
+                    client.Send("Hello");
+                    client.Send(", ");
+                    client.Send("World!");
+
+                    events.Add(queue.Take());
+                    events.Add(queue.Take());
+                    events.Add(queue.Take());
+                } 
+            }
+
+            Assert.AreEqual(3, events.Count);
+        }
+
+        [TestMethod]
+        public void TestTransportServerEvent()
+        {
+            ICodec<TestEvent> codec = new TestEventCodec();
+            int port = NetworkUtils.GenerateRandomPort(6000, 7000);
+
+            BlockingCollection<TestEvent> queue = new BlockingCollection<TestEvent>();
+            List<TestEvent> events = new List<TestEvent>();
+
+            IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port);
+            var remoteHandler = Observer.Create<TransportEvent<TestEvent>>(tEvent => queue.Add(tEvent.Data));
+
+            using (var server = new TransportServer<TestEvent>(endpoint, remoteHandler, codec))
+            {
+                server.Run();
+
+                IPEndPoint remoteEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
+                using (var client = new TransportClient<TestEvent>(remoteEndpoint, codec))
+                {
+                    client.Send(new TestEvent("Hello"));
+                    client.Send(new TestEvent(", "));
+                    client.Send(new TestEvent("World!"));
+
+                    events.Add(queue.Take());
+                    events.Add(queue.Take());
+                    events.Add(queue.Take());
+                } 
+            }
+
+            Assert.AreEqual(3, events.Count);
+        }
+
+        [TestMethod]
+        public void TestTransportSenderStage()
+        {
+            ICodec<string> codec = new StringCodec();
+            int port = NetworkUtils.GenerateRandomPort(6000, 7000);
+            IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port);
+
+            List<string> events = new List<string>();
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+
+            // Server echoes the message back to the client
+            var remoteHandler = Observer.Create<TransportEvent<string>>(tEvent => tEvent.Link.Write(tEvent.Data));
+
+            using (TransportServer<string> server = new TransportServer<string>(endpoint, remoteHandler, codec))
+            {
+                server.Run();
+
+                var clientHandler = Observer.Create<TransportEvent<string>>(tEvent => queue.Add(tEvent.Data));
+                IPEndPoint remoteEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
+                using (var client = new TransportClient<string>(remoteEndpoint, codec, clientHandler))
+                {
+                    client.Send("Hello");
+                    client.Send(", ");
+                    client.Send(" World");
+
+                    events.Add(queue.Take());
+                    events.Add(queue.Take());
+                    events.Add(queue.Take());
+                } 
+            }
+
+            Assert.AreEqual(3, events.Count);
+        }
+
+        [TestMethod]
+        public void TestRaceCondition()
+        {
+            ICodec<string> codec = new StringCodec();
+            int port = NetworkUtils.GenerateRandomPort(6000, 7000);
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+            List<string> events = new List<string>();
+            int numEventsExpected = 150;
+
+            IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port);
+            var remoteHandler = Observer.Create<TransportEvent<string>>(tEvent => queue.Add(tEvent.Data));
+
+            using (var server = new TransportServer<string>(endpoint, remoteHandler, codec))
+            {
+                server.Run();
+
+                for (int i = 0; i < numEventsExpected / 3; i++)
+                {
+                    Task.Run(() =>
+                    {
+                        IPEndPoint remoteEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
+                        using (var client = new TransportClient<string>(remoteEndpoint, codec))
+                        {
+                            client.Send("Hello");
+                            client.Send(", ");
+                            client.Send("World!");
+                        }
+                    });
+                }
+
+                for (int i = 0; i < numEventsExpected; i++)
+                {
+                    events.Add(queue.Take());
+                }
+            }
+
+            Assert.AreEqual(numEventsExpected, events.Count);
+        }
+
+        private class TestEvent
+        {
+            public TestEvent(string message)
+            {
+                Message = message;
+            }
+
+            public string Message { get; set; }
+
+            public override string ToString()
+            {
+                return "TestEvent: " + Message;
+            }
+        }
+
+        private class TestEventCodec : ICodec<TestEvent>
+        {
+            public byte[] Encode(TestEvent obj)
+            {
+                return new StringCodec().Encode(obj.Message);
+            }
+
+            public TestEvent Decode(byte[] data)
+            {
+                return new TestEvent(new StringCodec().Decode(data));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/WakeTests.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/WakeTests.csproj b/lang/cs/Tests/WakeTests/WakeTests.csproj
new file mode 100644
index 0000000..0f90252
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/WakeTests.csproj
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{214C64C6-04E5-4867-B69A-E3502EA50871}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Wake.Test</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Wake.Test</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\bin\Debug\Org.Apache.Reef.Wake.Test\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\bin\Release\Microsoft.Wake.Tests\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Reactive.Core">
+      <HintPath>..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Reactive.Interfaces">
+      <HintPath>..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ClockTest.cs" />
+    <Compile Include="MultiCodecTest.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="PubSubSubjectTest.cs" />
+    <Compile Include="RemoteManagerTest.cs" />
+    <Compile Include="TransportTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Source\TANG\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/WakeTests/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/WakeTests/packages.config b/lang/cs/Tests/WakeTests/packages.config
new file mode 100644
index 0000000..75e5b34
--- /dev/null
+++ b/lang/cs/Tests/WakeTests/packages.config
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Rx-Core" version="2.2.5" targetFramework="net45" />
+  <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/java/reef-bridge-project/reef-bridge-clr/src/main/CSharp/CSharp/ClrHandler/externals/Org.Apache.Reef.Driver.dll
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/CSharp/CSharp/ClrHandler/externals/Org.Apache.Reef.Driver.dll b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/CSharp/CSharp/ClrHandler/externals/Org.Apache.Reef.Driver.dll
index 63582c0..c9a581b 100644
Binary files a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/CSharp/CSharp/ClrHandler/externals/Org.Apache.Reef.Driver.dll and b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/CSharp/CSharp/ClrHandler/externals/Org.Apache.Reef.Driver.dll differ

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 26ae273..f90872e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -235,11 +235,26 @@ under the License.
                             <exclude>.gitattributes</exclude>
                             <exclude>.gitignore</exclude>
                             <exclude>.git/**</exclude>
-                            <exclude>.idea/**</exclude>
-                            <exclude>target/**</exclude>
+                            <exclude>lang/java/.idea/**</exclude>
+                            <exclude>**/target/**</exclude>
                             <exclude>README.*</exclude>
                             <!-- The below are sometimes created during tests -->
                             <exclude>REEF_LOCAL_RUNTIME/**</exclude>
+                            <!-- The Visual Studio build files -->
+                            <exclude>lang/cs/ReefDotNet.sln</exclude>
+                            <exclude>**/*.csproj.user</exclude>
+                            <!-- The below are auto generated during the .Net build -->                            
+                            <exclude>lang/cs/bin/**</exclude>
+                            <exclude>**/obj/**</exclude>
+                            <!-- NuGet dependencies downloaded as part of the build -->
+                            <exclude>lang/cs/packages/**</exclude>
+                            <!-- The below are auto generated files for serialization -->
+                            <exclude>lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/*</exclude>
+                            <exclude>lang/cs/Source/REEF/reef-common/ReefCommon/avro/*</exclude>
+                            <!-- The below are binary data files used in tests -->
+                            <exclude>lang/cs/Tests/ReefTests/ConfigFiles/evaluator.conf</exclude>
+                            <exclude>lang/cs/Tests/TangTests/evaluator.conf</exclude>
+                            <exclude>lang/cs/Tests/TangTests/simpleConstructorJavaProto.bin</exclude>
                         </excludes>
                     </configuration>
                 </plugin>


[09/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/Link.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/Link.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/Link.cs
new file mode 100644
index 0000000..d5b987a
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/Link.cs
@@ -0,0 +1,256 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Represents an open connection between remote hosts
+    /// </summary>
+    public class Link<T> : ILink<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(Link<T>));
+
+        private IPEndPoint _localEndpoint;
+        private ICodec<T> _codec;
+        private Channel _channel;
+        private bool _disposed;
+
+        /// <summary>
+        /// Constructs a Link object.
+        /// Connects to the specified remote endpoint.
+        /// </summary>
+        /// <param name="remoteEndpoint">The remote endpoint to connect to</param>
+        /// <param name="codec">The codec for serializing messages</param>
+        public Link(IPEndPoint remoteEndpoint, ICodec<T> codec)
+        {
+            if (remoteEndpoint == null)
+            {
+                throw new ArgumentNullException("remoteEndpoint");
+            }
+            if (codec == null)
+            {
+                throw new ArgumentNullException("codec");
+            }
+
+            Client = new TcpClient();
+            Client.Connect(remoteEndpoint);
+
+            _codec = codec;
+            _channel = new Channel(Client.GetStream());
+            _localEndpoint = GetLocalEndpoint();
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Constructs a Link object.
+        /// Uses the already connected TcpClient.
+        /// </summary>
+        /// <param name="client">The already connected client</param>
+        /// <param name="codec">The encoder and decoder</param>
+        public Link(TcpClient client, ICodec<T> codec)
+        {
+            if (client == null)
+            {
+                throw new ArgumentNullException("client");
+            }
+            if (codec == null)
+            {
+                throw new ArgumentNullException("codec");
+            }
+
+            Client = client;
+            _codec = codec;
+            _channel = new Channel(Client.GetStream());
+            _localEndpoint = GetLocalEndpoint();
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Returns the local socket address
+        /// </summary>
+        public IPEndPoint LocalEndpoint
+        {
+            get { return _localEndpoint; }
+        }
+
+        /// <summary>
+        /// Returns the remote socket address
+        /// </summary>
+        public IPEndPoint RemoteEndpoint
+        {
+            get { return (IPEndPoint) Client.Client.RemoteEndPoint; }
+        }
+
+        /// <summary>
+        /// Gets the underlying TcpClient
+        /// </summary>
+        public TcpClient Client { get; private set; }
+
+        /// <summary>
+        /// Writes the message to the remote host
+        /// </summary>
+        /// <param name="value">The data to write</param>
+        public void Write(T value)
+        {
+            if (value == null)
+            {
+                throw new ArgumentNullException("value");    
+            }
+            if (_disposed)
+            {
+                Exceptions.Throw(new IllegalStateException("Link has been closed."), LOGGER);
+            }
+
+            byte[] message = _codec.Encode(value);
+            _channel.Write(message);
+        }
+
+        /// <summary>
+        /// Writes the value to this link asynchronously
+        /// </summary>
+        /// <param name="value">The data to write</param>
+        /// <param name="token">The cancellation token</param>
+        public async Task WriteAsync(T value, CancellationToken token)
+        {
+            if (_disposed)
+            {
+                Exceptions.Throw(new IllegalStateException("Link has been closed."), LOGGER); 
+            }
+
+            byte[] message = _codec.Encode(value);
+            await _channel.WriteAsync(message, token);
+        }
+
+        /// <summary>
+        /// Reads the value from the link synchronously
+        /// </summary>
+        public T Read()
+        {
+            if (_disposed)
+            {
+                Exceptions.Throw(new IllegalStateException("Link has been disposed."), LOGGER);
+            }
+
+            byte[] message = _channel.Read();
+            return (message == null) ? default(T) : _codec.Decode(message);
+        }
+
+        /// <summary>
+        /// Reads the value from the link asynchronously
+        /// </summary>
+        /// <param name="token">The cancellation token</param>
+        public async Task<T> ReadAsync(CancellationToken token)
+        {
+            if (_disposed)
+            {
+                Exceptions.Throw(new IllegalStateException("Link has been disposed."), LOGGER);
+            }
+
+            byte[] message = await _channel.ReadAsync(token);
+            return (message == null) ? default(T) : _codec.Decode(message);
+        }
+
+        /// <summary>
+        /// Close the client connection
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Subclasses of Links should overwrite this to handle disposing
+        /// of the link
+        /// </summary>
+        /// <param name="disposing">To dispose or not</param>
+        public virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+            {
+                return;
+            }
+
+            if (disposing)
+            {
+                try
+                {
+                    Client.GetStream().Close();
+                }
+                catch (InvalidOperationException)
+                {
+                    LOGGER.Log(Level.Warning, "failed to close stream on a non-connected socket.");
+                }
+
+                Client.Close();
+            }
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Overrides Equals. Two Link objects are equal if they are connected
+        /// to the same remote endpoint.
+        /// </summary>
+        /// <param name="obj">The object to compare</param>
+        /// <returns>True if the object is equal to this Link, otherwise false</returns>
+        public override bool Equals(object obj)
+        {
+            Link<T> other = obj as Link<T>;
+            if (other == null)
+            {
+                return false;
+            }
+
+            return other.RemoteEndpoint.Equals(RemoteEndpoint);
+        }
+
+        /// <summary>
+        /// Gets the hash code for the Link object.
+        /// </summary>
+        /// <returns>The object's hash code</returns>
+        public override int GetHashCode()
+        {
+            return RemoteEndpoint.GetHashCode();
+        }
+
+        /// <summary>
+        /// Discovers the IPEndpoint for the current machine.
+        /// </summary>
+        /// <returns>The local IPEndpoint</returns>
+        private IPEndPoint GetLocalEndpoint()
+        {
+            IPAddress address = NetworkUtils.LocalIPAddress;
+            int port = ((IPEndPoint) Client.Client.LocalEndPoint).Port;
+            return new IPEndPoint(address, port);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiCodec.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiCodec.cs
new file mode 100644
index 0000000..2791eb3
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiCodec.cs
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+ 
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Codec that can encode and decode a class depending on the class type.
+    /// </summary>
+    public class MultiCodec<T> : ICodec<T>
+    {
+        private readonly MultiEncoder<T> _encoder;
+
+        private readonly MultiDecoder<T> _decoder;
+
+        /// <summary>
+        /// Constructs a new MultiCodec object.
+        /// </summary>
+        public MultiCodec()
+        {
+            _encoder = new MultiEncoder<T>();
+            _decoder = new MultiDecoder<T>();
+        }
+
+        /// <summary>
+        /// Register a codec to be used when encoding/decoding objects of this type.
+        /// </summary>
+        /// <typeparam name="U">The type of codec</typeparam>
+        /// <param name="codec">The codec to use when encoding/decoding
+        /// objects of this type</param>
+        public void Register<U>(ICodec<U> codec) where U : T
+        {
+            _encoder.Register(codec);
+            _decoder.Register(codec);
+        }
+
+        /// <summary>
+        /// Register a codec to be used when encoding/decoding objects of this type.
+        /// </summary>
+        /// <typeparam name="U">The type of codec</typeparam>
+        /// <param name="codec">The codec to use when encoding/decoding
+        /// objects of this type</param>
+        /// <param name="name">The name of the class to encode/decode</param>
+        public void Register<U>(ICodec<U> codec, string name) where U : T
+        {
+            _encoder.Register(codec, name);
+            _decoder.Register(codec, name);
+        }
+
+        /// <summary>
+        /// Encodes an object with the appropriate encoding or null if it cannot
+        /// be encoded.
+        /// </summary>
+        /// <param name="obj">Data to encode</param>
+        public byte[] Encode(T obj)
+        {
+            return _encoder.Encode(obj);
+        }
+
+        /// <summary>
+        /// Decodes byte array into the appripriate object type.
+        /// </summary>
+        /// <param name="data">Data to be decoded</param>
+        public T Decode(byte[] data)
+        {
+            return _decoder.Decode(data);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiDecoder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiDecoder.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiDecoder.cs
new file mode 100644
index 0000000..789e226
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiDecoder.cs
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Proto.WakeRemoteProtos;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Decoder using the WakeTuple protocol buffer
+    /// (class name and bytes)
+    /// </summary>
+    public class MultiDecoder<T> : IDecoder<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MultiDecoder<T>));
+        private Dictionary<Type, object> _decoderMap;
+        private Dictionary<string, Type> _nameMap;
+
+        /// <summary>
+        /// Constructs a decoder that decodes bytes based on the class type
+        /// </summary>
+        public MultiDecoder()
+        {
+            _decoderMap = new Dictionary<Type, object>();
+            _nameMap = new Dictionary<string, Type>();
+        }
+
+        /// <summary>
+        /// Register the decoder for objects of type U
+        /// </summary>
+        /// <typeparam name="U">The type of decoder to use when decoding
+        /// objects of this type</typeparam>
+        /// <param name="decoder">The decoder to use when decoding
+        /// objects of this type</param>
+        public void Register<U>(IDecoder<U> decoder) where U : T
+        {
+            Type type = typeof(U);
+            _decoderMap[type] = decoder;
+            _nameMap[type.ToString()] = type;
+        }
+
+        /// <summary>
+        /// Register the decoder for objects of type U
+        /// </summary>
+        /// <typeparam name="U">The type of decoder to use when decoding
+        /// objects of this type</typeparam>
+        /// <param name="decoder">The decoder to use when decoding
+        /// objects of this type</param>
+        /// <param name="name">The name of the class to decode</param>
+        public void Register<U>(IDecoder<U> decoder, string name) where U : T
+        {
+            Type type = typeof(U);
+            _decoderMap[type] = decoder;
+            _nameMap[name] = type;
+        }
+
+        /// <summary>
+        /// Decodes byte array according to the underlying object type.
+        /// </summary>
+        /// <param name="data">The data to decode</param>
+        public T Decode(byte[] data)
+        {
+            WakeTuplePBuf pbuf = WakeTuplePBuf.Deserialize(data);
+            if (pbuf == null)
+            {
+                return default(T);
+            }
+
+            // Get object's class Type
+            Type type;
+            if (!_nameMap.TryGetValue(pbuf.className, out type))
+            {
+                return default(T);
+            }
+
+            // Get decoder for that type
+            object decoder;
+            if (!_decoderMap.TryGetValue(type, out decoder))
+            {
+                Exceptions.Throw(new RemoteRuntimeException("Decoder for " + type + " not known."), LOGGER);
+            }
+
+            // Invoke the decoder to decode the byte array
+            Type handlerType = typeof(IDecoder<>).MakeGenericType(new[] { type });
+            MethodInfo info = handlerType.GetMethod("Decode");
+            return (T) info.Invoke(decoder, new[] { (object) pbuf.data });
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiEncoder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiEncoder.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiEncoder.cs
new file mode 100644
index 0000000..cccf52f
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/MultiEncoder.cs
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Remote.Proto.WakeRemoteProtos;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Encoder using the WakeTuple protocol buffer
+    /// (class name and bytes)
+    /// </summary>
+    public class MultiEncoder<T> : IEncoder<T>
+    {
+        private static Logger _logger = Logger.GetLogger(typeof(MultiEncoder<>));
+        private Dictionary<Type, object> _encoderMap;
+        private Dictionary<Type, string> _nameMap;
+
+        /// <summary>
+        /// Constructs an encoder that encodes an object to bytes based on the class name
+        /// </summary>
+        public MultiEncoder()
+        {
+            _encoderMap = new Dictionary<Type, object>();
+            _nameMap = new Dictionary<Type, string>();
+        }
+
+        public void Register<U>(IEncoder<U> encoder) where U : T
+        {
+            _encoderMap[typeof(U)] = encoder;
+            _nameMap[typeof(U)] = typeof(U).ToString();
+        }
+
+        public void Register<U>(IEncoder<U> encoder, string name) where U : T
+        {
+            _encoderMap[typeof(U)] = encoder;
+            _nameMap[typeof(U)] = name;
+            _logger.Log(Level.Verbose, "Registering name for " + name);
+        }
+
+        /// <summary>Encodes an object to a byte array</summary>
+        /// <param name="obj"></param>
+        public byte[] Encode(T obj)
+        {
+            // Find encoder for object type
+            object encoder;
+            if (!_encoderMap.TryGetValue(obj.GetType(), out encoder))
+            {
+                return null;
+            }
+
+            // Invoke encoder for this type
+            Type handlerType = typeof(IEncoder<>).MakeGenericType(new[] { obj.GetType() });
+            MethodInfo info = handlerType.GetMethod("Encode");
+            byte[] data = (byte[]) info.Invoke(encoder, new[] { (object) obj });
+
+            // Serialize object type and object data into well known tuple
+            // To decode, deserialize the tuple, get object type, and look up the
+            // decoder for that type
+            string name = _nameMap[obj.GetType()];
+            _logger.Log(Level.Verbose, "Encoding name for " + name);
+            WakeTuplePBuf pbuf = new WakeTuplePBuf { className = name, data = data };
+            pbuf.className = name;
+            pbuf.data = data; 
+            return pbuf.Serialize();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/ObserverContainer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/ObserverContainer.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/ObserverContainer.cs
new file mode 100644
index 0000000..577cd95
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/ObserverContainer.cs
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.RX.Impl;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Stores registered IObservers for DefaultRemoteManager.
+    /// Can register and look up IObservers by remote IPEndPoint.
+    /// </summary>
+    internal class ObserverContainer<T> : IObserver<TransportEvent<IRemoteEvent<T>>>
+    {
+        private ConcurrentDictionary<IPEndPoint, IObserver<T>> _endpointMap;
+        private ConcurrentDictionary<Type, IObserver<IRemoteMessage<T>>> _typeMap;
+        private IObserver<T> _universalObserver;
+
+        /// <summary>
+        /// Constructs a new ObserverContainer used to manage remote IObservers.
+        /// </summary>
+        public ObserverContainer()
+        {
+            _endpointMap = new ConcurrentDictionary<IPEndPoint, IObserver<T>>(new IPEndPointComparer());
+            _typeMap = new ConcurrentDictionary<Type, IObserver<IRemoteMessage<T>>>();
+        }
+
+        /// <summary>
+        /// Registers an IObserver used to handle incoming messages from the remote host
+        /// at the specified IPEndPoint.
+        /// </summary>
+        /// <param name="remoteEndpoint">The IPEndPoint of the remote host</param>
+        /// <param name="observer">The IObserver to handle incoming messages</param>
+        /// <returns>An IDisposable used to unregister the observer with</returns>
+        public IDisposable RegisterObserver(IPEndPoint remoteEndpoint, IObserver<T> observer) 
+        {
+            if (remoteEndpoint.Address.Equals(IPAddress.Any))
+            {
+                _universalObserver = observer;
+                return Disposable.Create(() => { _universalObserver = null; });
+            }
+
+            _endpointMap[remoteEndpoint] = observer;
+            return Disposable.Create(() => _endpointMap.TryRemove(remoteEndpoint, out observer));
+        }
+
+        /// <summary>
+        /// Registers an IObserver to handle incoming messages from a remote host
+        /// </summary>
+        /// <param name="observer">The IObserver to handle incoming messages</param>
+        /// <returns>An IDisposable used to unregister the observer with</returns>
+        public IDisposable RegisterObserver(IObserver<IRemoteMessage<T>> observer)
+        {
+            _typeMap[typeof(T)] = observer;
+            return Disposable.Create(() => _typeMap.TryRemove(typeof(T), out observer));
+        }
+
+        /// <summary>
+        /// Look up the IObserver for the registered IPEndPoint or event type 
+        /// and execute the IObserver.
+        /// </summary>
+        /// <param name="transportEvent">The incoming remote event</param>
+        public void OnNext(TransportEvent<IRemoteEvent<T>> transportEvent)
+        {
+            IRemoteEvent<T> remoteEvent = transportEvent.Data;
+            remoteEvent.LocalEndPoint = transportEvent.Link.LocalEndpoint;
+            remoteEvent.RemoteEndPoint = transportEvent.Link.RemoteEndpoint;
+            T value = remoteEvent.Value;
+            bool handled = false;
+
+            IObserver<T> observer1;
+            IObserver<IRemoteMessage<T>> observer2;
+            if (_universalObserver != null)
+            {
+                _universalObserver.OnNext(value);
+                handled = true;
+            }
+            if (_endpointMap.TryGetValue(remoteEvent.RemoteEndPoint, out observer1))
+            {
+                // IObserver was registered by IPEndpoint
+                observer1.OnNext(value);
+                handled = true;
+            } 
+            else if (_typeMap.TryGetValue(value.GetType(), out observer2))
+            {
+                // IObserver was registered by event type
+                IRemoteIdentifier id = new SocketRemoteIdentifier(remoteEvent.RemoteEndPoint);
+                IRemoteMessage<T> remoteMessage = new DefaultRemoteMessage<T>(id, value);
+                observer2.OnNext(remoteMessage);
+                handled = true;
+            }
+
+            if (!handled)
+            {
+                throw new WakeRuntimeException("Unrecognized Wake RemoteEvent message");
+            }
+        }
+
+        public void OnError(Exception error)
+        {
+        }
+
+        public void OnCompleted()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEvent.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEvent.cs
new file mode 100644
index 0000000..9e2fe2a
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEvent.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Net;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class RemoteEvent<T> : IRemoteEvent<T>
+    {
+        public RemoteEvent(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, string source, string sink, long seq, T value)
+        {
+            LocalEndPoint = localEndPoint;
+            RemoteEndPoint = remoteEndPoint;
+            Source = source;
+            Sink = sink;
+            Value = value;
+            Sequence = seq;
+        }
+
+        public RemoteEvent(IPEndPoint localEndpoint, IPEndPoint remoteEndpoint, T value)
+        {
+            LocalEndPoint = localEndpoint;
+            RemoteEndPoint = remoteEndpoint;
+            Value = value;
+        }
+
+        public RemoteEvent()
+        {
+        }
+
+        public IPEndPoint LocalEndPoint { get; set; }
+
+        public IPEndPoint RemoteEndPoint { get; set; }
+
+        public string Source { get; set; }
+
+        public string Sink { get; set; }
+
+        public T Value { get; set; }
+
+        public long Sequence { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventCodec.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventCodec.cs
new file mode 100644
index 0000000..2c5b16d
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventCodec.cs
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote.Impl
+{
+    internal class RemoteEventCodec<T> : ICodec<IRemoteEvent<T>>
+    {
+        private readonly RemoteEventEncoder<T> _encoder;
+        private readonly RemoteEventDecoder<T> _decoder;
+
+        public RemoteEventCodec(ICodec<T> codec) 
+        {
+            _encoder = new RemoteEventEncoder<T>(codec);
+            _decoder = new RemoteEventDecoder<T>(codec);
+        }
+
+        public byte[] Encode(IRemoteEvent<T> obj)
+        {
+            return _encoder.Encode(obj);
+        }
+
+        public IRemoteEvent<T> Decode(byte[] data)
+        {
+            return _decoder.Decode(data);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventDecoder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventDecoder.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventDecoder.cs
new file mode 100644
index 0000000..f9cfbc1
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventDecoder.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Wake.Remote.Proto.WakeRemoteProtos;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class RemoteEventDecoder<T> : IDecoder<IRemoteEvent<T>>
+    {
+        private IDecoder<T> _decoder;
+
+        public RemoteEventDecoder(IDecoder<T> decoder)
+        {
+            _decoder = decoder;
+        }
+
+        public IRemoteEvent<T> Decode(byte[] data)
+        {
+            WakeMessagePBuf pbuf = WakeMessagePBuf.Deserialize(data);
+            return new RemoteEvent<T>(null, null, pbuf.source, pbuf.sink, pbuf.seq, _decoder.Decode(pbuf.data));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEncoder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEncoder.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEncoder.cs
new file mode 100644
index 0000000..432e688
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEncoder.cs
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Wake.Remote.Proto.WakeRemoteProtos;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class RemoteEventEncoder<T> : IEncoder<IRemoteEvent<T>>
+    {
+        private readonly IEncoder<T> _encoder;
+
+        public RemoteEventEncoder(IEncoder<T> encoder)
+        {
+            _encoder = encoder;
+        }
+
+        public byte[] Encode(IRemoteEvent<T> obj)
+        {
+            WakeMessagePBuf pbuf = new WakeMessagePBuf();
+            pbuf.sink = obj.Sink;
+            pbuf.source = obj.Source;
+            pbuf.data = _encoder.Encode(obj.Value);
+            pbuf.seq = obj.Sequence;
+            return pbuf.Serialize();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEndpoint.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEndpoint.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEndpoint.cs
new file mode 100644
index 0000000..10a048e
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/RemoteEventEndpoint.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class RemoteEventEndPoint<T>
+    {
+        private IRemoteIdentifier _id;
+
+        public RemoteEventEndPoint(IRemoteIdentifier id)
+        {
+            _id = id;
+        }
+
+        public IRemoteIdentifier Id
+        {
+            get { return _id; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/SocketRemoteIdentifier.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/SocketRemoteIdentifier.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/SocketRemoteIdentifier.cs
new file mode 100644
index 0000000..2f402a8
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/SocketRemoteIdentifier.cs
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System.Globalization;
+using System.Net;
+using System.Text;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Remote identifier based on a socket address
+    /// </summary>
+    public class SocketRemoteIdentifier : IRemoteIdentifier
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(SocketRemoteIdentifier));
+        private IPEndPoint _addr;
+
+        public SocketRemoteIdentifier(IPEndPoint addr)
+        {
+            _addr = addr;
+        }
+
+        public SocketRemoteIdentifier(string str)
+        {
+            int index = str.IndexOf(":", System.StringComparison.Ordinal);
+            if (index <= 0)
+            {
+                Exceptions.Throw(new RemoteRuntimeException("Invalid name " + str), LOGGER); 
+            }
+            string host = str.Substring(0, index);
+            int port = int.Parse(str.Substring(index + 1), CultureInfo.InvariantCulture);
+            _addr = new IPEndPoint(IPAddress.Parse(host), port);
+        }
+
+        public IPEndPoint Addr
+        {
+            get { return _addr;  }
+        }
+
+        public override int GetHashCode()
+        {
+            return _addr.GetHashCode();
+        }
+
+        public override bool Equals(object obj)
+        {
+            return _addr.Equals(((SocketRemoteIdentifier)obj).Addr);
+        }
+
+        public override string ToString()
+        {
+            StringBuilder builder = new StringBuilder();
+            builder.Append("socket://");
+            builder.Append(_addr);
+            return builder.ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/StringCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/StringCodec.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/StringCodec.cs
new file mode 100644
index 0000000..4e25b18
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/StringCodec.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class StringCodec : ICodec<string>
+    {
+        [Inject]
+        public StringCodec()
+        {
+        }
+
+        public byte[] Encode(string obj)
+        {
+            return Encoding.ASCII.GetBytes(obj);
+        }
+
+        public string Decode(byte[] data)
+        {
+            return Encoding.ASCII.GetString(data);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifier.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifier.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifier.cs
new file mode 100644
index 0000000..31829cd
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifier.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class StringIdentifier : IIdentifier
+    {
+        private readonly string _str;
+
+        public StringIdentifier(string s)
+        {
+            _str = s;
+        }
+
+        public override int GetHashCode()
+        {
+            return _str.GetHashCode();
+        }
+
+        public override bool Equals(object o)
+        {
+            StringIdentifier other = o as StringIdentifier;
+            return other != null && _str.Equals(other._str);
+        }
+
+        public override string ToString()
+        {
+            return _str;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifierFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifierFactory.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifierFactory.cs
new file mode 100644
index 0000000..b9bcb50
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/StringIdentifierFactory.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class StringIdentifierFactory : IIdentifierFactory
+    {
+        [Inject]
+        public StringIdentifierFactory()
+        {
+        }
+
+        public IIdentifier Create(string s)
+        {
+            return new StringIdentifier(s);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportClient.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportClient.cs
new file mode 100644
index 0000000..848a915
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportClient.cs
@@ -0,0 +1,133 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Net;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Establish connections to TransportServer for remote message passing
+    /// </summary>
+    public class TransportClient<T> : IDisposable
+    {
+        private ILink<T> _link;
+        private IObserver<TransportEvent<T>> _observer;
+        private CancellationTokenSource _cancellationSource;
+        private bool _disposed;
+
+        /// <summary>
+        /// Construct a TransportClient.
+        /// Used to send messages to the specified remote endpoint.
+        /// </summary>
+        /// <param name="remoteEndpoint">The endpoint of the remote server to connect to</param>
+        /// <param name="codec">Codec to decode/encodec</param>
+        public TransportClient(IPEndPoint remoteEndpoint, ICodec<T> codec) 
+        {
+            if (remoteEndpoint == null)
+            {
+                throw new ArgumentNullException("remoteEndpoint");
+            }
+            if (codec == null)
+            {
+                throw new ArgumentNullException("codec");
+            }
+
+            _link = new Link<T>(remoteEndpoint, codec);
+            _cancellationSource = new CancellationTokenSource();
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Construct a TransportClient.
+        /// Used to send messages to the specified remote endpoint.
+        /// </summary>
+        /// <param name="remoteEndpoint">The endpoint of the remote server to connect to</param>
+        /// <param name="codec">Codec to decode/encodec</param>
+        /// <param name="observer">Callback used when receiving responses from remote host</param>
+        public TransportClient(IPEndPoint remoteEndpoint, 
+                               ICodec<T> codec, 
+                               IObserver<TransportEvent<T>> observer) 
+                                   : this(remoteEndpoint, codec)
+        {
+            _observer = observer;
+            Task.Run(() => ResponseLoop());
+        }
+
+        /// <summary>
+        /// Gets the underlying transport link.
+        /// </summary>
+        public ILink<T> Link
+        {
+            get { return _link; }
+        }
+
+        /// <summary>
+        /// Send the remote message.
+        /// </summary>
+        /// <param name="message">The message to send</param>
+        public void Send(T message)
+        {
+            if (message == null)
+            {
+                throw new ArgumentNullException("message");    
+            }
+
+            _link.Write(message);
+        }
+
+        /// <summary>
+        /// Close all opened connections
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected void Dispose(bool disposing)
+        {
+            if (!_disposed && disposing)
+            {
+                _link.Dispose();
+                _disposed = true;
+            }
+        }
+
+        /// <summary>
+        /// Continually read responses from remote host
+        /// </summary>
+        private async Task ResponseLoop()
+        {
+            while (!_cancellationSource.IsCancellationRequested)
+            {
+                T message = await _link.ReadAsync(_cancellationSource.Token);
+                if (message == null)
+                {
+                    break;
+                }
+
+                TransportEvent<T> transportEvent = new TransportEvent<T>(message, _link);
+                _observer.OnNext(transportEvent);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportEvent.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportEvent.cs
new file mode 100644
index 0000000..6c4644c
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportEvent.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class TransportEvent<T>
+    {
+        public TransportEvent(T data, ILink<T> link)
+        {
+            Data = data;
+            Link = link;
+        }
+
+        public T Data { get; private set; }
+
+        public ILink<T> Link { get; private set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportServer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportServer.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportServer.cs
new file mode 100644
index 0000000..20cdc8a
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/TransportServer.cs
@@ -0,0 +1,195 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Globalization;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Server to handle incoming remote messages.
+    /// </summary>
+    public class TransportServer<T> : IDisposable
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TransportServer<>));
+
+        private TcpListener _listener;
+        private CancellationTokenSource _cancellationSource;
+        private IObserver<TransportEvent<T>> _remoteObserver;
+        private ICodec<T> _codec; 
+        private bool _disposed;
+        private Task _serverTask;
+
+        /// <summary>
+        /// Constructs a TransportServer to listen for remote events.  
+        /// Listens on the specified remote endpoint.  When it recieves a remote
+        /// event, it will envoke the specified remote handler.
+        /// </summary>
+        /// <param name="port">Port to listen on</param>
+        /// <param name="remoteHandler">The handler to invoke when receiving incoming
+        /// remote messages</param>
+        /// <param name="codec">The codec to encode/decode"</param>
+        public TransportServer(int port, IObserver<TransportEvent<T>> remoteHandler, ICodec<T> codec)
+            : this(new IPEndPoint(NetworkUtils.LocalIPAddress, port), remoteHandler, codec)
+        {
+        }
+
+        /// <summary>
+        /// Constructs a TransportServer to listen for remote events.  
+        /// Listens on the specified remote endpoint.  When it recieves a remote
+        /// event, it will envoke the specified remote handler.
+        /// </summary>
+        /// <param name="localEndpoint">Endpoint to listen on</param>
+        /// <param name="remoteHandler">The handler to invoke when receiving incoming
+        /// remote messages</param>
+        /// <param name="codec">The codec to encode/decode"</param>
+        public TransportServer(IPEndPoint localEndpoint, 
+                               IObserver<TransportEvent<T>> remoteHandler, 
+                               ICodec<T> codec)
+        {
+            _listener = new TcpListener(localEndpoint.Address, localEndpoint.Port);
+            _remoteObserver = remoteHandler;
+            _cancellationSource = new CancellationTokenSource();
+            _cancellationSource.Token.ThrowIfCancellationRequested();
+            _codec = codec;
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Returns the listening endpoint for the TransportServer 
+        /// </summary>
+        public IPEndPoint LocalEndpoint
+        {
+            get { return _listener.LocalEndpoint as IPEndPoint; }
+        }
+
+        /// <summary>
+        /// Starts listening for incoming remote messages.
+        /// </summary>
+        public void Run()
+        {
+            _listener.Start();
+            _serverTask = Task.Run(() => StartServer());
+        }
+
+        /// <summary>
+        /// Close the TransportServer and all open connections
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        public void Dispose(bool disposing)
+        {
+            if (!_disposed && disposing)
+            {
+                _cancellationSource.Cancel();
+                try
+                {
+                    _listener.Stop();
+                }
+                catch (SocketException)
+                {
+                    LOGGER.Log(Level.Info, "Disposing of transport server before listener is created.");
+                }
+
+                if (_serverTask != null)
+                {
+                    _serverTask.Wait();
+
+                    // Give the TransportServer Task 500ms to shut down, ignore any timeout errors
+                    try
+                    {
+                        CancellationTokenSource serverDisposeTimeout = new CancellationTokenSource(500);
+                        _serverTask.Wait(serverDisposeTimeout.Token);
+                    }
+                    catch (Exception e)
+                    {
+                        Console.Error.WriteLine(e); 
+                    }
+                    finally
+                    {
+                        _serverTask.Dispose();
+                    }
+                }
+            }
+
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Helper method to start TransportServer.  This will
+        /// be run in an asynchronous Task.
+        /// </summary>
+        /// <returns>An asynchronous Task for the running server.</returns>
+        private async Task StartServer()
+        {
+            try
+            {
+                while (!_cancellationSource.Token.IsCancellationRequested)
+                {
+                    TcpClient client = await _listener.AcceptTcpClientAsync().ConfigureAwait(false);
+                    ProcessClient(client).Forget();
+                }
+            }
+            catch (InvalidOperationException)
+            {
+                LOGGER.Log(Level.Info, "TransportServer has been closed.");
+            }
+            catch (OperationCanceledException)
+            {
+                LOGGER.Log(Level.Info, "TransportServer has been closed.");
+            }
+        }
+
+        /// <summary>
+        /// Recieves event from connected TcpClient and invokes handler on the event.
+        /// </summary>
+        /// <param name="client">The connected client</param>
+        private async Task ProcessClient(TcpClient client)
+        {
+            // Keep reading messages from client until they disconnect or timeout
+            CancellationToken token = _cancellationSource.Token;
+            using (ILink<T> link = new Link<T>(client, _codec))
+            {
+                while (!token.IsCancellationRequested)
+                {
+                    T message = await link.ReadAsync(token);
+                    TransportEvent<T> transportEvent = new TransportEvent<T>(message, link);
+
+                    _remoteObserver.OnNext(transportEvent);
+
+                    if (message == null)
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Proto/WakeRemoteProtos.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Proto/WakeRemoteProtos.cs b/lang/cs/Source/WAKE/Wake/Remote/Proto/WakeRemoteProtos.cs
new file mode 100644
index 0000000..247fff9
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Proto/WakeRemoteProtos.cs
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using ProtoBuf;
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Wake.Remote.Proto.WakeRemoteProtos
+{
+    /// <summary>
+    /// Message p buff
+    /// </summary>
+    public partial class WakeMessagePBuf
+    {
+        public static WakeMessagePBuf Deserialize(byte[] bytes)
+        {
+            WakeMessagePBuf pbuf = null;
+            using (var s = new MemoryStream(bytes))
+            {
+                pbuf = Serializer.Deserialize<WakeMessagePBuf>(s);
+            }
+            return pbuf;
+        }
+
+        public byte[] Serialize()
+        {
+            using (var s = new MemoryStream())
+            {
+                Serializer.Serialize(s, this);
+                return s.ToArray();
+            }
+        }
+    }
+
+    /// <summary>
+    /// Wake tuple buf
+    /// </summary>
+    public partial class WakeTuplePBuf
+    {
+        public static WakeTuplePBuf Deserialize(byte[] bytes)
+        {
+            WakeTuplePBuf pbuf = null;
+            using (var s = new MemoryStream(bytes))
+            {
+                pbuf = Serializer.Deserialize<WakeTuplePBuf>(s);
+            }
+            return pbuf;
+        }
+
+        public byte[] Serialize()
+        {
+            using (var s = new MemoryStream())
+            {
+                Serializer.Serialize(s, this);
+                return s.ToArray();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/RemoteConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/RemoteConfiguration.cs b/lang/cs/Source/WAKE/Wake/Remote/RemoteConfiguration.cs
new file mode 100644
index 0000000..633cc79
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/RemoteConfiguration.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Wake.Remote
+{
+    public class RemoteConfiguration
+    {
+        [NamedParameter(shortName: "rm_name", documentation: "The name of the remote manager.")]
+        public class ManagerName : Name<string>
+        {
+        }
+
+        [NamedParameter(shortName: "rm_host", documentation: "The host address to be used for messages.")]
+        public class HostAddress : Name<string>
+        {
+        }
+
+        [NamedParameter(shortName: "rm_port", documentation: "The port to be used for messages.")]
+        public class Port : Name<int>
+        {
+        }
+
+        [NamedParameter(documentation: "The codec to be used for messages.")]
+        public class MessageCodec : Name<ICodec<Type>>
+        {
+        }
+
+        [NamedParameter(documentation: "The event handler to be used for exception")]
+        public class ErrorHandler : Name<IObserver<Exception>>
+        {
+        }
+
+        [NamedParameter(shortName: "rm_order", documentation: "Whether or not to use the message ordering guarantee", defaultValue: "true")]
+        public class OrderingGuarantee : Name<bool>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/RemoteRuntimeException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/RemoteRuntimeException.cs b/lang/cs/Source/WAKE/Wake/Remote/RemoteRuntimeException.cs
new file mode 100644
index 0000000..061e532
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/RemoteRuntimeException.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.Remote
+{
+    /// <summary>Wake remote runtime exception</summary>
+    [System.Serializable]
+    public class RemoteRuntimeException : Exception
+    {
+        private const long serialVersionUID = 1L;
+
+        /// <summary>Constructs a new runtime remote exception with the specified detail message and cause
+        ///     </summary>
+        /// <param name="s">the detailed message</param>
+        /// <param name="e">the cause</param>
+        public RemoteRuntimeException(string s, Exception e)
+            : base(s, e)
+        {
+        }
+
+        /// <summary>Constructs a new runtime remote exception with the specified detail message
+        ///     </summary>
+        /// <param name="s">the detailed message</param>
+        public RemoteRuntimeException(string s)
+            : base(s)
+        {
+        }
+
+        /// <summary>Constructs a new runtime remote exception with the specified cause</summary>
+        /// <param name="e">the cause</param>
+        public RemoteRuntimeException(Exception e)
+            : base("Runtime Exception", e)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Event/Alarm.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Event/Alarm.cs b/lang/cs/Source/WAKE/Wake/Time/Event/Alarm.cs
new file mode 100644
index 0000000..611b5a1
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Event/Alarm.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.Time
+{
+    /// <summary>
+    ///  Represents a timer event.
+    /// </summary>
+    public abstract class Alarm : Time
+    {
+        private IObserver<Alarm> _handler;
+
+        public Alarm(long timestamp, IObserver<Alarm> handler) : base(timestamp)
+        {
+            _handler = handler;
+        }
+
+        public void Handle()
+        {
+            _handler.OnNext(this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Event/StartTime.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Event/StartTime.cs b/lang/cs/Source/WAKE/Wake/Time/Event/StartTime.cs
new file mode 100644
index 0000000..4cea1bc
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Event/StartTime.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Time
+{
+    /// <summary>
+    /// Represents the Time at which a component started.
+    /// </summary>
+    public class StartTime : Time
+    {
+        public StartTime(long timeStamp) : base(timeStamp)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Event/StopTime.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Event/StopTime.cs b/lang/cs/Source/WAKE/Wake/Time/Event/StopTime.cs
new file mode 100644
index 0000000..8e3bf65
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Event/StopTime.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Time
+{
+    /// <summary>
+    /// Represents the Time at which a component stops.
+    /// </summary>
+    public class StopTime : Time
+    {
+        public StopTime(long timeStamp) : base(timeStamp)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/IClock.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/IClock.cs b/lang/cs/Source/WAKE/Wake/Time/IClock.cs
new file mode 100644
index 0000000..6d906b8
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/IClock.cs
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Impl;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+
+namespace Org.Apache.Reef.Wake.Time
+{
+    public abstract class IClock : IDisposable
+    {
+        /// <summary>
+        /// Schedule a TimerEvent at the given future offset
+        /// </summary>
+        /// <param name="offset">The offset in the future to schedule the alarm</param>
+        /// <param name="handler">The IObserver to to be called</param>
+        public abstract void ScheduleAlarm(long offset, IObserver<Alarm> handler);
+
+        /// <summary>
+        /// Clock is idle if it has no future alarms set
+        /// </summary>
+        /// <returns>True if no future alarms are set, otherwise false</returns>
+        public abstract bool IsIdle();
+
+        /// <summary>
+        /// Dispose of the clock and all scheduled alarms
+        /// </summary>
+        public abstract void Dispose();
+
+        /// <summary>
+        /// Bind this to an event handler to statically subscribe to the StartTime Event
+        /// </summary>
+        [NamedParameter(documentation: "Will be called upon the start even", defaultClass: typeof(MissingStartHandlerHandler))]
+        public class StartHandler : Name<ISet<IObserver<StartTime>>>
+        {
+        }
+
+        /// <summary>
+        /// Bind this to an event handler to statically subscribe to the StopTime Event
+        /// </summary>
+        [NamedParameter(documentation: "Will be called upon the stop event", defaultClass: typeof(LoggingEventHandler<StopTime>))]
+        public class StopHandler : Name<ISet<IObserver<StopTime>>>
+        {
+        }
+
+        /// <summary>
+        /// Bind this to an event handler to statically subscribe to the RuntimeStart Event
+        /// </summary>
+        [NamedParameter(documentation: "Will be called upon the runtime start event", defaultClass: typeof(LoggingEventHandler<RuntimeStart>))]
+        public class RuntimeStartHandler : Name<ISet<IObserver<RuntimeStart>>>
+        {
+        }
+
+        /// <summary>
+        /// Bind this to an event handler to statically subscribe to the RuntimeStop Event
+        /// </summary>
+        [NamedParameter(documentation: "Will be called upon the runtime stop event", defaultClass: typeof(LoggingEventHandler<RuntimeStop>))]
+        public class RuntimeStopHandler : Name<ISet<IObserver<RuntimeStop>>>
+        {
+        }
+
+        /// <summary>
+        /// Bind this to an event handler to statically subscribe to the IdleClock Event
+        /// </summary>
+        [NamedParameter(documentation: "Will be called upon the Idle event", defaultClass: typeof(LoggingEventHandler<IdleClock>))]
+        public class IdleHandler : Name<ISet<IObserver<IdleClock>>>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/ClientAlarm.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/ClientAlarm.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/ClientAlarm.cs
new file mode 100644
index 0000000..ac95896
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/ClientAlarm.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime.Event
+{
+    public class ClientAlarm : Alarm
+    {
+        public ClientAlarm(long timestamp, IObserver<Alarm> handler) : base(timestamp, handler)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/IdleClock.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/IdleClock.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/IdleClock.cs
new file mode 100644
index 0000000..3ca1fd8
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/IdleClock.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Time.Runtime.Event
+{
+    public class IdleClock : Time
+    {
+        public IdleClock(long timestamp) : base(timestamp)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeAlarm.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeAlarm.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeAlarm.cs
new file mode 100644
index 0000000..701bf88
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeAlarm.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime.Event
+{
+    public class RuntimeAlarm : Alarm
+    {
+        public RuntimeAlarm(long timestamp, IObserver<Alarm> handler) : base(timestamp, handler)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStart.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStart.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStart.cs
new file mode 100644
index 0000000..d08cccc
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStart.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Time.Runtime.Event
+{
+    public class RuntimeStart : Time
+    {
+        public RuntimeStart(long timeStamp) : base(timeStamp)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStop.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStop.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStop.cs
new file mode 100644
index 0000000..6324e20
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/Event/RuntimeStop.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime.Event
+{
+    public class RuntimeStop : Time
+    {
+        public RuntimeStop(long timestamp) : this(timestamp, null)
+        {
+        }
+
+        public RuntimeStop(long timestamp, Exception e) : base(timestamp)
+        {
+            Exception = e;
+        }
+
+        public Exception Exception { get; private set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/ITimer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/ITimer.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/ITimer.cs
new file mode 100644
index 0000000..c932aa4
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/ITimer.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime
+{
+    [DefaultImplementation(typeof(RealTimer))]
+    public interface ITimer
+    {
+        /// <summary>
+        /// Gets the current time
+        /// </summary>
+        long CurrentTime { get; }
+
+        /// <summary>
+        /// Gets the difference between the given time and the current time
+        /// </summary>
+        /// <param name="time">The time to compare against the current time</param>
+        long GetDuration(long time);
+
+        /// <summary>
+        /// Checks if the given time has already passed.
+        /// </summary>
+        /// <param name="time">The time to check if it has passed or not</param>
+        bool IsReady(long time);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/LogicalTimer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/LogicalTimer.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/LogicalTimer.cs
new file mode 100644
index 0000000..f4b6c75
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/LogicalTimer.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime
+{
+    /// <summary>
+    /// LogicalTimer class used for testing purposes.
+    /// </summary>
+    public class LogicalTimer : ITimer
+    {
+        [Inject]
+        public LogicalTimer()
+        {
+        }
+
+        public long CurrentTime
+        {
+            get { return 0; }
+        }
+
+        public long GetDuration(long time)
+        {
+            return 0;
+        }
+
+        public bool IsReady(long time)
+        {
+            return true;
+        }
+    }
+}


[29/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IResourceCatalog.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IResourceCatalog.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IResourceCatalog.cs
new file mode 100644
index 0000000..0c77b95
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IResourceCatalog.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Common.Catalog
+{
+    public interface IResourceCatalog
+    {
+        string Name { get; set; }
+
+        ICollection<ICapability> Capabilities { get; set; }
+
+        ICollection<INodeDescriptor> Nodes { get; set; }
+
+        ICollection<IRackDescriptor> Racks { get; set; }
+
+        INodeDescriptor GetNode(string nodeId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/NodeDescriptorImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/NodeDescriptorImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/NodeDescriptorImpl.cs
new file mode 100644
index 0000000..6e0fa67
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/NodeDescriptorImpl.cs
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using System.Collections.Generic;
+using System.Net;
+
+namespace Org.Apache.Reef.Common.Catalog
+{
+    public class NodeDescriptorImpl : INodeDescriptor
+    {
+        private RackDescriptorImpl _rack;
+
+        private string _id;
+
+        private IPEndPoint _address;
+
+        private RAM _ram;
+
+        private IList<ICapability> _capabilities;
+
+        public NodeDescriptorImpl()
+        {
+        }
+
+        public NodeDescriptorImpl(string id, IPEndPoint addresss, RackDescriptorImpl rack, RAM ram)
+        {
+            _id = id;
+            _address = addresss;
+            _rack = rack;
+            _ram = ram;
+            _capabilities = new List<ICapability>();
+            _rack.AddNodeDescriptor(this);
+        }
+
+        public RackDescriptorImpl Rack 
+        {
+            get
+            {
+                return _rack;
+            }
+        }
+
+        public string Id
+        {
+            get
+            {
+                return _id;
+            }
+        }
+
+        public string HostName { get; set; }
+
+        public CPU Cpu
+        {
+            get
+            {
+                return new CPU(1);
+            }
+
+            set
+            {
+            }
+        }
+
+        public RAM Ram
+        {
+            get
+            {
+                return _ram;
+            }
+
+            set
+            {
+                _ram = value;
+            }
+        }
+
+        public IList<ICapability> Capabilities
+        {
+            get
+            {
+                return _capabilities;
+            }
+        }
+
+        public IPEndPoint InetSocketAddress
+        {
+            get
+            {
+                return _address;
+            }
+
+            set
+            {
+                _address = value;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/RackDescriptorImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/RackDescriptorImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/RackDescriptorImpl.cs
new file mode 100644
index 0000000..3b28c98
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/RackDescriptorImpl.cs
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Org.Apache.Reef.Common.Catalog
+{
+    public class RackDescriptorImpl : IRackDescriptor
+    {
+        public RackDescriptorImpl(string name)
+        {
+            Name = name;
+            Capabilities = new List<ICapability>();
+            Nodes = new List<INodeDescriptor>();
+        }
+
+        public string Name { get; set; }
+
+        public ICollection<ICapability> Capabilities { get; set; }
+
+        public ICollection<INodeDescriptor> Nodes { get; set; }
+
+        public ICollection<IRackDescriptor> Racks { get; set; }
+
+        public INodeDescriptor GetNode(string nodeId)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void AddNodeDescriptor(NodeDescriptorImpl node)
+        {
+            Nodes.Add(node);
+        }
+
+        public override string ToString()
+        {
+            StringBuilder stringBuilder = new StringBuilder();
+            stringBuilder.Append("Rack " + Name);
+            foreach (INodeDescriptor nodeDescriptor in Nodes)
+            {
+                stringBuilder.Append(Environment.NewLine + nodeDescriptor);
+            }
+            return stringBuilder.ToString();
+        }
+
+        public override int GetHashCode()
+        {
+            return Name.GetHashCode();
+        }
+
+        public override bool Equals(object obj)
+        {
+            return base.Equals(obj);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/ResourceCatalogImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/ResourceCatalogImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/ResourceCatalogImpl.cs
new file mode 100644
index 0000000..9348b67
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/ResourceCatalogImpl.cs
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Net;
+using System.Text;
+
+namespace Org.Apache.Reef.Common.Catalog
+{
+    public class ResourceCatalogImpl : IResourceCatalog
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ResourceCatalogImpl));
+        
+        private static string defaultRackName = "default-rack";
+
+        private Dictionary<string, RackDescriptorImpl> _racks = new Dictionary<string, RackDescriptorImpl>();
+ 
+        private Dictionary<string, NodeDescriptorImpl> _nodes = new Dictionary<string, NodeDescriptorImpl>();
+
+        public string Name { get; set; }
+
+        public ICollection<ICapability> Capabilities { get; set; }
+
+        public ICollection<INodeDescriptor> Nodes { get; set; }
+
+        public ICollection<IRackDescriptor> Racks { get; set; }
+
+        public INodeDescriptor GetNode(string nodeId)
+        {
+            return _nodes[nodeId];
+        }
+
+        public void Handle(NodeDescriptorProto node)
+        {
+            string rackName = node.rack_name == null ? node.rack_name : defaultRackName;
+            string message = string.Format(
+                CultureInfo.InvariantCulture,
+                "Catalog new node: id[{0}], rack[{1}], host[{2}], port[{3}], memory[{4}]",
+                node.identifier,
+                rackName,
+                node.host_name,
+                node.port,
+                node.memory_size);
+            LOGGER.Log(Level.Info, message);
+            if (!string.IsNullOrWhiteSpace(rackName) && !_racks.ContainsKey(rackName))
+            {
+                RackDescriptorImpl newRack = new RackDescriptorImpl(rackName);
+                _racks.Add(rackName, newRack);
+            }
+            RackDescriptorImpl rack = _racks[rackName];
+            IPAddress ipAddress = null;
+            IPAddress.TryParse(node.host_name, out ipAddress);
+            if (ipAddress == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("cannot parse host ipaddress: " + node.host_name), LOGGER);
+            }
+            IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, node.port);
+            RAM ram = new RAM(node.memory_size);
+            NodeDescriptorImpl nodeDescriptor = new NodeDescriptorImpl(node.identifier, ipEndPoint, rack, ram);
+            _nodes.Add(nodeDescriptor.Id, nodeDescriptor);
+        }
+
+        public override string ToString()
+        {
+            StringBuilder stringBuilder = new StringBuilder();
+            stringBuilder.Append("=== Resource Catalog ===");
+            foreach (IRackDescriptor rackDescriptor in Racks)
+            {
+                stringBuilder.Append(Environment.NewLine + rackDescriptor);
+            }
+            return stringBuilder.ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/CPU.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/CPU.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/CPU.cs
new file mode 100644
index 0000000..0acda2d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/CPU.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Common.Capabilities
+{
+    public class CPU : ICapability
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(CPU));
+
+        private int _cores;
+
+        public CPU(int cores)
+        {
+            if (cores <= 0)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("cores cannot be non-positive"), LOGGER);
+            }
+            _cores = cores;
+        }
+
+        public int Cores
+        {
+            get
+            {
+                return _cores;
+            }
+        }
+
+        public override string ToString()
+        {
+            return string.Format(CultureInfo.InvariantCulture, "CPU Cores = [{0}]", Cores);
+        }
+
+        public override int GetHashCode()
+        {
+            return Cores.GetHashCode();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/ICapability.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/ICapability.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/ICapability.cs
new file mode 100644
index 0000000..8761426
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/ICapability.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Capabilities
+{
+    public interface ICapability
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/RAM.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/RAM.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/RAM.cs
new file mode 100644
index 0000000..ed6e078
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/capabilities/RAM.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common.Capabilities
+{
+    public class RAM : ICapability
+    {
+        private int _megaBytes;
+
+        public RAM(int megaBytes)
+        {
+            _megaBytes = megaBytes;
+        }
+
+        public int MegaBytes
+        {
+            get
+            {
+                return _megaBytes;
+            }
+        }
+
+        public override string ToString()
+        {
+            return string.Format(CultureInfo.InvariantCulture, "RAM(in mega bytes) = [{0}]", MegaBytes);
+        }
+
+        public override int GetHashCode()
+        {
+            return MegaBytes.GetHashCode();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/context/ContextMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/context/ContextMessage.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/context/ContextMessage.cs
new file mode 100644
index 0000000..9c4737c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/context/ContextMessage.cs
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public class ContextMessage
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ContextMessage));
+        private readonly string _messageSourcId;
+        private readonly byte[] _bytes;
+
+        private ContextMessage(string messageSourceId, byte[] bytes)
+        {
+            _messageSourcId = messageSourceId;
+            _bytes = bytes;
+        }
+
+        public string MessageSourceId
+        {
+            get { return _messageSourcId; }
+        }
+
+        public byte[] Bytes
+        {
+            get { return _bytes; }
+        }
+
+        /// <summary>
+        /// construt a new new ContextMessage with the given content.
+        /// </summary>
+        /// <param name="messageSourceId">The message's sourceID. This will be accessible in the Driver for routing.</param>
+        /// <param name="bytes">The actual content of the message, serialized into a byte[]</param>
+        /// <returns>new ContextMessage with the given content.</returns>
+        public static ContextMessage From(string messageSourceId, byte[] bytes)
+        {
+            if (string.IsNullOrEmpty(messageSourceId))
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("messageSourceId"), LOGGER);
+            }
+            if (bytes == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("bytes"), LOGGER);
+            }
+            return new ContextMessage(messageSourceId, bytes);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessage.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessage.cs
new file mode 100644
index 0000000..183dafa
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessage.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public interface IContextMessage : IMessage, IIdentifiable
+    {
+        string MessageSourceId { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageHandler.cs
new file mode 100644
index 0000000..7eeb367
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageHandler.cs
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public interface IContextMessageHandler : IObserver<byte[]>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageSource.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageSource.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageSource.cs
new file mode 100644
index 0000000..6025771
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/context/IContextMessageSource.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public interface IContextMessageSource
+    {
+        Optional<ContextMessage> Message { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultLocalHttpDriverConnection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultLocalHttpDriverConnection.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultLocalHttpDriverConnection.cs
new file mode 100644
index 0000000..2e6cdc0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultLocalHttpDriverConnection.cs
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Common.Evaluator
+{
+    public class DefaultLocalHttpDriverConnection : IDriverConnection
+    {
+        private readonly Uri _queryUri;
+
+        [Inject]
+        public DefaultLocalHttpDriverConnection()
+        {
+            _queryUri = new Uri(
+                    string.Concat(
+                    Constants.LocalHttpEndpointBaseUri,
+                    Constants.HttpReefUriSpecification,
+                    Constants.HttpDriverUriTarget));
+        }
+
+        public DriverInformation GetDriverInformation(string applicationId)
+        {
+            // application id not needed for local runtime
+            return DriverInformation.GetDriverInformationFromHttp(_queryUri);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnClusterHttpDriverConnection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnClusterHttpDriverConnection.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnClusterHttpDriverConnection.cs
new file mode 100644
index 0000000..c09647d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnClusterHttpDriverConnection.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Common.Evaluator
+{
+    public class DefaultYarnClusterHttpDriverConnection : IDriverConnection
+    {
+        [Inject]
+        public DefaultYarnClusterHttpDriverConnection()
+        {
+        }
+
+        public DriverInformation GetDriverInformation(string applicationId)
+        {
+            // e.g., http://headnodehost:9014/proxy/application_1407519727821_0012/reef/v1/driver
+            Uri queryUri = new Uri(
+                string.Concat(
+                Constants.HDInsightClusterHttpEndpointBaseUri,
+                applicationId,
+                Constants.HttpReefUriSpecification,
+                Constants.HttpDriverUriTarget));
+            return DriverInformation.GetDriverInformationFromHttp(queryUri);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnOneBoxHttpDriverConnection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnOneBoxHttpDriverConnection.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnOneBoxHttpDriverConnection.cs
new file mode 100644
index 0000000..c12984e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DefaultYarnOneBoxHttpDriverConnection.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common.Evaluator
+{
+    public class DefaultYarnOneBoxHttpDriverConnection : IDriverConnection
+    {
+        [Inject]
+        public DefaultYarnOneBoxHttpDriverConnection()
+        {
+        }
+
+        public DriverInformation GetDriverInformation(string applicationId)
+        {
+            // e.g., http://yingdac1:8088/proxy/application_1407519727821_0012/reef/v1/driver
+            string oneBoxHost = string.Format(CultureInfo.InvariantCulture, "http://{0}:8088/proxy/", Environment.MachineName);
+            Uri queryUri = new Uri(
+                string.Concat(
+                oneBoxHost,
+                applicationId,
+                Constants.HttpReefUriSpecification,
+                Constants.HttpDriverUriTarget));
+            return DriverInformation.GetDriverInformationFromHttp(queryUri);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DriverInformation.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DriverInformation.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DriverInformation.cs
new file mode 100644
index 0000000..653627f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/DriverInformation.cs
@@ -0,0 +1,136 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Avro;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+
+namespace Org.Apache.Reef.Common.Evaluator
+{
+    public class DriverInformation
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DriverInformation));
+        
+        private string _rid;
+
+        private string _startTime;
+
+        private string _nameServerId;
+
+        private IList<AvroReefServiceInfo> _services;
+
+        public DriverInformation(string rid, string startTime, IList<AvroReefServiceInfo> services)
+        {
+            _rid = rid;
+            _startTime = startTime;
+            _services = services;
+
+            if (_services == null)
+            {
+                LOGGER.Log(Level.Warning, "no services information from driver.");
+            }
+            else
+            {
+                AvroReefServiceInfo nameServerInfo =
+                  _services.FirstOrDefault(
+                      s => s.serviceName.Equals(Constants.NameServerServiceName, StringComparison.OrdinalIgnoreCase));
+                if (nameServerInfo != null)
+                {
+                    _nameServerId = nameServerInfo.serviceInfo;
+                }
+            }  
+        }
+
+        public string DriverRemoteIdentifier
+        {
+            get
+            {
+                return _rid;
+            }
+        }
+
+        public string DriverStartTime
+        {
+            get
+            {
+                return _startTime;
+            }
+        }
+
+        public string NameServerId
+        {
+            get
+            {
+                return _nameServerId;
+            }
+        }
+
+        public static DriverInformation GetDriverInformationFromHttp(Uri queryUri)
+        {
+            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(queryUri);
+            request.AllowAutoRedirect = false;
+            request.KeepAlive = false;
+            request.ContentType = "text/html";
+
+            string driverInfomation;
+            AvroDriverInfo info = null;
+            try
+            {
+                using (HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse())
+                {
+                    Stream stream = webResponse.GetResponseStream();
+                    if (stream == null)
+                    {
+                        return null;
+                    }
+                    using (StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
+                    {
+                        driverInfomation = streamReader.ReadToEnd();
+                        LOGGER.Log(Level.Verbose, "Http response line: " + driverInfomation);
+                        info = AvroJsonSerializer<AvroDriverInfo>.FromString(driverInfomation);
+                    }
+                }
+            }
+            catch (WebException)
+            {
+                LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "In RECOVERY mode, cannot connect to [{0}] for driver information, will try again later.", queryUri));
+                return null;
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "Cannot read content from {0}.", queryUri), LOGGER);
+            }
+
+            if (info != null)
+            {
+                LOGGER.Log(
+                    Level.Verbose, 
+                    string.Format(CultureInfo.InvariantCulture, "Driver information extracted with remote identier [{0}], start time [{1}], and servics [{2}]", info.remoteId, info.startTime, info.services));
+                return new DriverInformation(info.remoteId, info.startTime, info.services);
+            }
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorOperationState.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorOperationState.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorOperationState.cs
new file mode 100644
index 0000000..77c1e63
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorOperationState.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Evaluator
+{
+    public enum EvaluatorOperationState
+    {
+        /// <summary>
+        /// default state
+        /// </summary>
+        UNINITIATED = 0,
+
+        /// <summary>
+        /// normal operational state
+        /// </summary>
+        OPERATIONAL = 1,
+
+        /// <summary>
+        /// in the process of recovering 
+        /// </summary>
+        RECOVERY = 2
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorRuntimeState.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorRuntimeState.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorRuntimeState.cs
new file mode 100644
index 0000000..d405c25
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorRuntimeState.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.evaluator
+{
+    public enum EvaluatorRuntimeState
+    {
+        /// <summary>
+        /// default state
+        /// </summary>
+        UNINITIATED = 0,
+
+        /// <summary>
+        /// normal operational state
+        /// </summary>
+        RUNNING = 1,
+
+        /// <summary>
+        /// in the process of recovering 
+        /// </summary>
+        RECOVERY = 2
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorType.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorType.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorType.cs
new file mode 100644
index 0000000..4de31c8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/EvaluatorType.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Evaluator
+{
+    public enum EvaluatorType
+    {
+        /// <summary>
+        /// default  type
+        /// </summary>
+        UNDECIDED = 0,
+
+        /// <summary>
+        /// Indicates an Evaluator that runs on the JVM
+        /// </summary>
+        JVM = 1,
+
+        /// <summary>
+        /// Indicates an Evaluator that runs on the CLR
+        /// </summary>
+        CLR = 2
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/IDriverConnection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/IDriverConnection.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/IDriverConnection.cs
new file mode 100644
index 0000000..7113246
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/evaluator/IDriverConnection.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Evaluator
+{
+    public interface IDriverConnection
+    {
+        DriverInformation GetDriverInformation(string applicationId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStart.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStart.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStart.cs
new file mode 100644
index 0000000..bdd236d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStart.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Events
+{
+    public interface IContextStart
+    {
+        string Id { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStop.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStop.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStop.cs
new file mode 100644
index 0000000..90031fb
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/events/IContextStop.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Events
+{
+    public interface IContextStop
+    {
+        string Id { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/EvaluatorException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/EvaluatorException.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/EvaluatorException.cs
new file mode 100644
index 0000000..4b62f29
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/EvaluatorException.cs
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Common.Exceptions
+{
+    public class EvaluatorException : System.Exception, IIdentifiable
+    {
+        private readonly string _evaluatorId;
+
+        public EvaluatorException(string evaluatorId)
+        {
+            _evaluatorId = evaluatorId;
+            RunningTask = null;
+        }
+
+        public EvaluatorException(string evaluatorId, string message, System.Exception cause)
+            : base(message, cause)
+        {
+            _evaluatorId = evaluatorId;
+            RunningTask = null;
+        }
+
+        public EvaluatorException(string evaluatorId, string message)
+            : this(evaluatorId, message, (IRunningTask)null)
+        {
+        }
+
+        public EvaluatorException(string evaluatorId, string message, IRunningTask runningTask)
+            : base(message)
+        {
+            _evaluatorId = evaluatorId;
+            RunningTask = runningTask;
+        }
+
+        public EvaluatorException(string evaluatorId, System.Exception cause)
+            : this(evaluatorId, cause, null)
+        {
+        }
+
+        public EvaluatorException(string evaluatorId, Exception cause, IRunningTask runningTask)
+            : base(string.Empty, cause)
+        {
+            _evaluatorId = evaluatorId;
+            RunningTask = runningTask;
+        }
+
+        public IRunningTask RunningTask { get; set; }
+
+        public string Id
+        {
+            get { return _evaluatorId; }
+            set { }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/JobException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/JobException.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/JobException.cs
new file mode 100644
index 0000000..3f98f5e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/exceptions/JobException.cs
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Common
+{
+    public class JobException : Exception, IIdentifiable
+    {
+        private string _jobId;
+
+        public JobException(string jobId)
+        {
+            _jobId = jobId;
+        }
+
+        public JobException(string jobId, string message, Exception cause) 
+            : base(message, cause)
+        {
+            _jobId = jobId;
+        }
+
+        public JobException(string jobId, string message)
+            : base(message)
+        {
+            _jobId = jobId;
+        }
+
+        public JobException(string jobId, Exception cause)
+            : base(string.Empty, cause)
+        {
+            _jobId = jobId;
+        }
+
+        public string Id
+        {
+            get { return _jobId; }
+            set { }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/io/INameClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/io/INameClient.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/io/INameClient.cs
new file mode 100644
index 0000000..047b048
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/io/INameClient.cs
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+
+namespace Org.Apache.Reef.Common.io
+{
+    /// <summary>
+    /// Client for the Reef name service. 
+    /// Used to register, unregister, and lookup IP Addresses of known hosts.
+    /// </summary>
+    public interface INameClient : IDisposable
+    {
+        /// <summary>
+        /// Registers the identifier with the NameService.  
+        /// Overwrites the previous mapping if the identifier has already 
+        /// been registered.
+        /// </summary>
+        /// <param name="id">The key used to map the remote endpoint</param>
+        /// <param name="endpoint">The endpoint to map</param>
+        void Register(string id, IPEndPoint endpoint);
+
+        /// <summary>
+        /// Unregisters the remote identifier with the NameService
+        /// </summary>
+        /// <param name="id">The identifier to unregister</param>
+        void Unregister(string id);
+
+        /// <summary>
+        /// Looks up the IPEndpoint for the registered identifier.
+        /// </summary>
+        /// <param name="id">The identifier to look up</param>
+        /// <returns>The mapped IPEndpoint for the identifier, or null if
+        /// the identifier has not been registered with the NameService</returns>
+        IPEndPoint Lookup(string id);
+
+        /// <summary>
+        /// Looks up the IPEndpoint for each of the registered identifiers in the list.
+        /// </summary>
+        /// <param name="ids">The list of identifiers to look up</param>
+        /// <returns>The list of NameAssignments representing a pair of identifer
+        /// and mapped IPEndpoint for that identifier.  If any of the requested identifiers
+        /// are not registered with the NameService, their corresponding NameAssignment
+        /// IPEndpoint value will be null.</returns>
+        List<NameAssignment> Lookup(List<string> ids);
+
+        /// <summary>
+        /// Restart the name client in case of failure.
+        /// </summary>
+        /// <param name="serverEndpoint">The new server endpoint to connect to</param>
+        void Restart(IPEndPoint serverEndpoint);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/io/NameAssignment.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/io/NameAssignment.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/io/NameAssignment.cs
new file mode 100644
index 0000000..4fbbfb0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/io/NameAssignment.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Net;
+using System.Net.Sockets;
+
+namespace Org.Apache.Reef.Common.io
+{
+    /// <summary>
+    /// Tuple containing the string identifier and IPEndpoint.
+    /// Used by NameServer and NameClient
+    /// </summary>
+    public class NameAssignment
+    {
+        public NameAssignment(string id, IPEndPoint endpoint)
+        {
+            Identifier = id;
+            Endpoint = endpoint;
+        }
+
+        public NameAssignment(string id, string address, int port)
+        {
+            Identifier = id;
+            IPAddress ipAddress;
+            if (!IPAddress.TryParse(address, out ipAddress))
+            {
+                IPHostEntry hostEntry = Dns.GetHostEntry(address);
+                foreach (var ip in hostEntry.AddressList)
+                {
+                    if (ip.AddressFamily == AddressFamily.InterNetwork)
+                    {
+                        ipAddress = ip;
+                        break;
+                    }
+                }
+            }
+            Endpoint = new IPEndPoint(ipAddress, port);
+        }
+
+        public string Identifier { get; set; }
+
+        public IPEndPoint Endpoint { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfiguration.cs
new file mode 100644
index 0000000..192c98c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfiguration.cs
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Common.io
+{
+    public class NamingConfiguration : ConfigurationModuleBuilder
+    {
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredParameter<string> NameServerAddress = new RequiredParameter<string>();
+
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredParameter<int> NameServerPort = new RequiredParameter<int>();
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new NamingConfiguration()
+                    .BindNamedParameter(GenericType<NamingConfigurationOptions.NameServerAddress>.Class, NameServerAddress)
+                    .BindNamedParameter(GenericType<NamingConfigurationOptions.NameServerPort>.Class, NameServerPort)
+                    .Build();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfigurationOptions.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfigurationOptions.cs
new file mode 100644
index 0000000..0d222d6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/io/NamingConfigurationOptions.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Common.io
+{
+    public class NamingConfigurationOptions
+    {
+        [NamedParameter("IP address of NameServer")]
+        public class NameServerAddress : Name<string>
+        {
+        }
+
+        [NamedParameter("Port of NameServer")]
+        public class NameServerPort : Name<int>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/packages.config b/lang/cs/Source/REEF/reef-common/ReefCommon/packages.config
new file mode 100644
index 0000000..88cf17b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/packages.config
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+  <package id="Rx-Core" version="2.2.5" targetFramework="net45" />
+  <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ClientRuntime.pb.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ClientRuntime.pb.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ClientRuntime.pb.cs
new file mode 100644
index 0000000..8dddaee
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ClientRuntime.pb.cs
@@ -0,0 +1,147 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: client_runtime.proto
+// Note: requires additional types generated from: reef_service_protos.proto
+
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+
+namespace Org.Apache.Reef.Common.ProtoBuf.ClienRuntimeProto{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"JobSubmissionProto")]
+  public partial class JobSubmissionProto : global::ProtoBuf.IExtensible
+  {
+    public JobSubmissionProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private string _remote_id;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"remote_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string remote_id
+    {
+      get { return _remote_id; }
+      set { _remote_id = value; }
+    }
+    private string _configuration;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"configuration", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string configuration
+    {
+      get { return _configuration; }
+      set { _configuration = value; }
+    }
+    private string _user_name;
+    [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"user_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string user_name
+    {
+      get { return _user_name; }
+      set { _user_name = value; }
+    }
+    private SIZE _driver_size = SIZE.SMALL;
+    [global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"driver_size", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(SIZE.SMALL)]
+    public SIZE driver_size
+    {
+      get { return _driver_size; }
+      set { _driver_size = value; }
+    }
+    private int _driver_memory = default(int);
+    [global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"driver_memory", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int driver_memory
+    {
+      get { return _driver_memory; }
+      set { _driver_memory = value; }
+    }
+    private int _priority = default(int);
+    [global::ProtoBuf.ProtoMember(9, IsRequired = false, Name=@"priority", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int priority
+    {
+      get { return _priority; }
+      set { _priority = value; }
+    }
+    private string _queue = "";
+    [global::ProtoBuf.ProtoMember(10, IsRequired = false, Name=@"queue", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string queue
+    {
+      get { return _queue; }
+      set { _queue = value; }
+    }
+    private readonly global::System.Collections.Generic.List<FileResourceProto> _global_file = new global::System.Collections.Generic.List<FileResourceProto>();
+    [global::ProtoBuf.ProtoMember(11, Name=@"global_file", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<FileResourceProto> global_file
+    {
+      get { return _global_file; }
+    }
+  
+    private readonly global::System.Collections.Generic.List<FileResourceProto> _local_File = new global::System.Collections.Generic.List<FileResourceProto>();
+    [global::ProtoBuf.ProtoMember(12, Name=@"local_File", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<FileResourceProto> local_File
+    {
+      get { return _local_File; }
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"JobControlProto")]
+  public partial class JobControlProto : global::ProtoBuf.IExtensible
+  {
+    public JobControlProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private Signal _signal = Signal.SIG_TERMINATE;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"signal", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(Signal.SIG_TERMINATE)]
+    public Signal signal
+    {
+      get { return _signal; }
+      set { _signal = value; }
+    }
+    private byte[] _message = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] message
+    {
+      get { return _message; }
+      set { _message = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+    [global::ProtoBuf.ProtoContract(Name=@"Signal")]
+    public enum Signal
+    {
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"SIG_TERMINATE", Value=1)]
+      SIG_TERMINATE = 1,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"SIG_SUSPEND", Value=2)]
+      SIG_SUSPEND = 2,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"SIG_RESUME", Value=3)]
+      SIG_RESUME = 3
+    }
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/DriverRuntime.pb.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/DriverRuntime.pb.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/DriverRuntime.pb.cs
new file mode 100644
index 0000000..00dffe7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/DriverRuntime.pb.cs
@@ -0,0 +1,339 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: driver_runtime.proto
+// Note: requires additional types generated from: reef_service_protos.proto
+
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+
+namespace Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto
+{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"DriverProcessRegistrationProto")]
+  public partial class DriverProcessRegistrationProto : global::ProtoBuf.IExtensible
+  {
+    public DriverProcessRegistrationProto() {}
+    
+    private string _remote_identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"remote_identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string remote_identifier
+    {
+      get { return _remote_identifier; }
+      set { _remote_identifier = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NodeDescriptorProto")]
+  public partial class NodeDescriptorProto : global::ProtoBuf.IExtensible
+  {
+    public NodeDescriptorProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private string _host_name;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"host_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string host_name
+    {
+      get { return _host_name; }
+      set { _host_name = value; }
+    }
+    private int _port;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"port", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public int port
+    {
+      get { return _port; }
+      set { _port = value; }
+    }
+    private int _memory_size;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"memory_size", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public int memory_size
+    {
+      get { return _memory_size; }
+      set { _memory_size = value; }
+    }
+    private string _rack_name = "";
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"rack_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string rack_name
+    {
+      get { return _rack_name; }
+      set { _rack_name = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResourceAllocationProto")]
+  public partial class ResourceAllocationProto : global::ProtoBuf.IExtensible
+  {
+    public ResourceAllocationProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private int _resource_memory;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"resource_memory", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public int resource_memory
+    {
+      get { return _resource_memory; }
+      set { _resource_memory = value; }
+    }
+    private string _node_id;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"node_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string node_id
+    {
+      get { return _node_id; }
+      set { _node_id = value; }
+    }
+    private int _virtual_cores = default(int);
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"virtual_cores", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int virtual_cores
+    {
+      get { return _virtual_cores; }
+      set { _virtual_cores = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResourceStatusProto")]
+  public partial class ResourceStatusProto : global::ProtoBuf.IExtensible
+  {
+    public ResourceStatusProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private State _state;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"state", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public State state
+    {
+      get { return _state; }
+      set { _state = value; }
+    }
+    private string _diagnostics = "";
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"diagnostics", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string diagnostics
+    {
+      get { return _diagnostics; }
+      set { _diagnostics = value; }
+    }
+    private int _exit_code = default(int);
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"exit_code", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int exit_code
+    {
+      get { return _exit_code; }
+      set { _exit_code = value; }
+    }
+    private bool _is_from_previous_driver = default(bool);
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"is_from_previous_driver", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(default(bool))]
+    public bool is_from_previous_driver
+    {
+      get { return _is_from_previous_driver; }
+      set { _is_from_previous_driver = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RuntimeStatusProto")]
+  public partial class RuntimeStatusProto : global::ProtoBuf.IExtensible
+  {
+    public RuntimeStatusProto() {}
+    
+    private string _name;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string name
+    {
+      get { return _name; }
+      set { _name = value; }
+    }
+    private State _state;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"state", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public State state
+    {
+      get { return _state; }
+      set { _state = value; }
+    }
+    private RuntimeErrorProto _error = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public RuntimeErrorProto error
+    {
+      get { return _error; }
+      set { _error = value; }
+    }
+    private int _outstanding_container_requests = default(int);
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"outstanding_container_requests", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int outstanding_container_requests
+    {
+      get { return _outstanding_container_requests; }
+      set { _outstanding_container_requests = value; }
+    }
+    private readonly global::System.Collections.Generic.List<string> _container_allocation = new global::System.Collections.Generic.List<string>();
+    [global::ProtoBuf.ProtoMember(6, Name=@"container_allocation", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<string> container_allocation
+    {
+      get { return _container_allocation; }
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResourceRequestProto")]
+  public partial class ResourceRequestProto : global::ProtoBuf.IExtensible
+  {
+    public ResourceRequestProto() {}
+    
+    private int _memory_size = default(int);
+    [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"memory_size", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int memory_size
+    {
+      get { return _memory_size; }
+      set { _memory_size = value; }
+    }
+    private int _priority = default(int);
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"priority", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int priority
+    {
+      get { return _priority; }
+      set { _priority = value; }
+    }
+    private int _virtual_cores = default(int);
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"virtual_cores", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    [global::System.ComponentModel.DefaultValue(default(int))]
+    public int virtual_cores
+    {
+      get { return _virtual_cores; }
+      set { _virtual_cores = value; }
+    }
+    private int _resource_count;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"resource_count", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public int resource_count
+    {
+      get { return _resource_count; }
+      set { _resource_count = value; }
+    }
+    private readonly global::System.Collections.Generic.List<string> _node_name = new global::System.Collections.Generic.List<string>();
+    [global::ProtoBuf.ProtoMember(6, Name=@"node_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<string> node_name
+    {
+      get { return _node_name; }
+    }
+  
+    private readonly global::System.Collections.Generic.List<string> _rack_name = new global::System.Collections.Generic.List<string>();
+    [global::ProtoBuf.ProtoMember(7, Name=@"rack_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<string> rack_name
+    {
+      get { return _rack_name; }
+    }
+  
+    private bool _relax_locality = default(bool);
+    [global::ProtoBuf.ProtoMember(10, IsRequired = false, Name=@"relax_locality", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(default(bool))]
+    public bool relax_locality
+    {
+      get { return _relax_locality; }
+      set { _relax_locality = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResourceReleaseProto")]
+  public partial class ResourceReleaseProto : global::ProtoBuf.IExtensible
+  {
+    public ResourceReleaseProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResourceLaunchProto")]
+  public partial class ResourceLaunchProto : global::ProtoBuf.IExtensible
+  {
+    public ResourceLaunchProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private string _remote_id;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"remote_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string remote_id
+    {
+      get { return _remote_id; }
+      set { _remote_id = value; }
+    }
+    private string _evaluator_conf;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"evaluator_conf", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string evaluator_conf
+    {
+      get { return _evaluator_conf; }
+      set { _evaluator_conf = value; }
+    }
+    private ProcessType _type;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"type", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public ProcessType type
+    {
+      get { return _type; }
+      set { _type = value; }
+    }
+    private readonly global::System.Collections.Generic.List<FileResourceProto> _file = new global::System.Collections.Generic.List<FileResourceProto>();
+    [global::ProtoBuf.ProtoMember(10, Name=@"file", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<FileResourceProto> file
+    {
+      get { return _file; }
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+}
\ No newline at end of file


[31/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
[REEF-97] Add the REEF.NET code base

The REEF.Net REEF code is now found in the lang/cs/ folder.

JIRA: [REEF-97] https://issues.apache.org/jira/browse/REEF-97

Pull Request: This closes #56


Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/2ae282de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/2ae282de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/2ae282de

Branch: refs/heads/master
Commit: 2ae282de19a1a6dec2f8563936a3fac19232c76f
Parents: 5cc6071
Author: Julia Wang <ju...@microsoft.com>
Authored: Fri Jan 23 13:34:36 2015 -0800
Committer: Markus Weimer <we...@apache.org>
Committed: Thu Jan 29 12:39:17 2015 -0800

----------------------------------------------------------------------
 lang/cs/.gitignore                              |   10 +
 lang/cs/.nuget/NuGet.Config                     |   24 +
 lang/cs/.nuget/NuGet.targets                    |  162 +++
 lang/cs/ReefDotNet.sln                          |  161 +++
 .../CLRBridgeClient/CLRBridgeClient.cs          |  148 +++
 .../CLRBridgeClient/CLRBridgeClient.csproj      |  114 ++
 .../CLRBridgeClient/Properties/AssemblyInfo.cs  |   55 +
 .../reef-applications/CLRBridgeClient/run.cmd   |   45 +
 .../reef-applications/Evaluator/Evaluator.cs    |  260 ++++
 .../Evaluator/Evaluator.csproj                  |  105 ++
 .../Evaluator/Properties/AssemblyInfo.cs        |   55 +
 .../reef-applications/Evaluator/packages.config |   22 +
 .../ReefCommon/ClientJobStatusHandler.cs        |  142 +++
 .../REEF/reef-common/ReefCommon/Constants.cs    |   38 +
 .../EvaluatorHeartBeatSanityChecker.cs          |   55 +
 .../reef-common/ReefCommon/FailedRuntime.cs     |   49 +
 .../ReefCommon/IContextAndTaskSubmittable.cs    |   55 +
 .../ReefCommon/IContextSubmittable.cs           |   42 +
 .../ReefCommon/IJobMessageObserver.cs           |   30 +
 .../reef-common/ReefCommon/ITaskSubmittable.cs  |   35 +
 .../ReefCommon/Properties/AssemblyInfo.cs       |   55 +
 .../reef-common/ReefCommon/ReefCommon.csproj    |  215 ++++
 .../ReefCommon/api/AbstractFailure.cs           |  142 +++
 .../ReefCommon/api/IAbstractFailure.cs          |   25 +
 .../REEF/reef-common/ReefCommon/api/IFailure.cs |   57 +
 .../ReefCommon/api/IResourceLaunchHandler.cs    |   28 +
 .../ReefCommon/api/IResourceReleaseHandler.cs   |   28 +
 .../ReefCommon/api/IResourceRequestHandler.cs   |   28 +
 .../ReefCommon/avro/AvroDriverInfo.cs           |   65 +
 .../ReefCommon/avro/AvroHttpRequest.cs          |   79 ++
 .../ReefCommon/avro/AvroHttpSerializer.cs       |   36 +
 .../ReefCommon/avro/AvroJsonSerializer.cs       |   52 +
 .../ReefCommon/avro/AvroReefServiceInfo.cs      |   55 +
 .../ReefCommon/catalog/INodeDescriptor.cs       |   36 +
 .../ReefCommon/catalog/IRackDescriptor.cs       |   25 +
 .../ReefCommon/catalog/IResourceCatalog.cs      |   37 +
 .../ReefCommon/catalog/NodeDescriptorImpl.cs    |  116 ++
 .../ReefCommon/catalog/RackDescriptorImpl.cs    |   75 ++
 .../ReefCommon/catalog/ResourceCatalogImpl.cs   |   95 ++
 .../ReefCommon/catalog/capabilities/CPU.cs      |   60 +
 .../catalog/capabilities/ICapability.cs         |   25 +
 .../ReefCommon/catalog/capabilities/RAM.cs      |   51 +
 .../ReefCommon/context/ContextMessage.cs        |   66 +
 .../ReefCommon/context/IContextMessage.cs       |   28 +
 .../context/IContextMessageHandler.cs           |   27 +
 .../ReefCommon/context/IContextMessageSource.cs |   28 +
 .../DefaultLocalHttpDriverConnection.cs         |   45 +
 .../DefaultYarnClusterHttpDriverConnection.cs   |   44 +
 .../DefaultYarnOneBoxHttpDriverConnection.cs    |   46 +
 .../ReefCommon/evaluator/DriverInformation.cs   |  136 ++
 .../evaluator/EvaluatorOperationState.cs        |   39 +
 .../evaluator/EvaluatorRuntimeState.cs          |   39 +
 .../ReefCommon/evaluator/EvaluatorType.cs       |   39 +
 .../ReefCommon/evaluator/IDriverConnection.cs   |   26 +
 .../ReefCommon/events/IContextStart.cs          |   26 +
 .../ReefCommon/events/IContextStop.cs           |   26 +
 .../ReefCommon/exceptions/EvaluatorException.cs |   75 ++
 .../ReefCommon/exceptions/JobException.cs       |   58 +
 .../reef-common/ReefCommon/io/INameClient.cs    |   71 ++
 .../reef-common/ReefCommon/io/NameAssignment.cs |   60 +
 .../ReefCommon/io/NamingConfiguration.cs        |   45 +
 .../ReefCommon/io/NamingConfigurationOptions.cs |   36 +
 .../REEF/reef-common/ReefCommon/packages.config |   26 +
 .../ReefCommon/protobuf/cs/ClientRuntime.pb.cs  |  147 +++
 .../ReefCommon/protobuf/cs/DriverRuntime.pb.cs  |  339 +++++
 .../protobuf/cs/EvaluatorRunTime.pb.cs          |  305 +++++
 .../ReefCommon/protobuf/cs/ReefProtocol.pb.cs   |   78 ++
 .../ReefCommon/protobuf/cs/ReefService.pb.cs    |  393 ++++++
 .../ReefCommon/protobuf/cs/Serializer.cs        |  130 ++
 .../cs/codec/EvaluatorHeartbeatProtoCodec.cs    |   41 +
 .../protobuf/cs/codec/REEFMessageCodec.cs       |   37 +
 .../protobuf/proto/client_runtime.proto         |   56 +
 .../protobuf/proto/driver_runtime.proto         |   90 ++
 .../protobuf/proto/evaluator_runtime.proto      |   91 ++
 .../protobuf/proto/reef_protocol.proto          |   44 +
 .../protobuf/proto/reef_service_protos.proto    |  117 ++
 .../ReefCommon/runtime/MachineStatus.cs         |  137 +++
 .../ReefCommon/runtime/evaluator/Constants.cs   |   40 +
 .../runtime/evaluator/EvaluatorRuntime.cs       |  255 ++++
 .../runtime/evaluator/EvaluatorSettings.cs      |  185 +++
 .../runtime/evaluator/HeartBeatManager.cs       |  390 ++++++
 .../evaluator/ReefMessageProtoObserver.cs       |  140 +++
 .../context/ContextClientCodeException.cs       |   70 ++
 .../evaluator/context/ContextConfiguration.cs   |  140 +++
 .../evaluator/context/ContextLifeCycle.cs       |  105 ++
 .../runtime/evaluator/context/ContextManager.cs |  362 ++++++
 .../runtime/evaluator/context/ContextRuntime.cs |  478 ++++++++
 .../evaluator/context/ContextStartImpl.cs       |   33 +
 .../evaluator/context/ContextStopImpl.cs        |   33 +
 .../evaluator/context/RootContextLauncher.cs    |  125 ++
 .../runtime/evaluator/task/CloseEventImpl.cs    |   48 +
 .../runtime/evaluator/task/DriverMessageImpl.cs |   52 +
 .../runtime/evaluator/task/SuspendEventImpl.cs  |   48 +
 .../evaluator/task/TaskClientCodeException.cs   |   65 +
 .../runtime/evaluator/task/TaskLifeCycle.cs     |   69 ++
 .../runtime/evaluator/task/TaskRuntime.cs       |  328 +++++
 .../runtime/evaluator/task/TaskStartImpl.cs     |   34 +
 .../runtime/evaluator/task/TaskState.cs         |   40 +
 .../runtime/evaluator/task/TaskStatus.cs        |  330 +++++
 .../runtime/evaluator/task/TaskStopImpl.cs      |   35 +
 .../evaluator/utils/EvaluatorConfigurations.cs  |  121 ++
 .../runtime/evaluator/utils/RemoteManager.cs    |   25 +
 .../reef-common/ReefCommon/services/IService.cs |   25 +
 .../ReefCommon/services/ServiceConfiguration.cs |   83 ++
 .../services/ServicesConfigurationOptions.cs    |   31 +
 .../ReefCommon/tasks/IDriverMessageHandler.cs   |   31 +
 .../ReefCommon/tasks/IRunningTask.cs            |   53 +
 .../REEF/reef-common/ReefCommon/tasks/ITask.cs  |   28 +
 .../ReefCommon/tasks/ITaskMessageSource.cs      |   31 +
 .../ReefCommon/tasks/TaskConfiguration.cs       |  148 +++
 .../tasks/TaskConfigurationOptions.cs           |   69 ++
 .../reef-common/ReefCommon/tasks/TaskMessage.cs |   68 +
 .../defaults/DefaultDriverMessageHandler.cs     |   42 +
 .../tasks/defaults/DefaultTaskMessageSource.cs  |   49 +
 .../ReefCommon/tasks/events/ICloseEvent.cs      |   28 +
 .../ReefCommon/tasks/events/IDriverMessage.cs   |   28 +
 .../ReefCommon/tasks/events/ISuspendEvent.cs    |   25 +
 .../ReefCommon/tasks/events/ITaskStart.cs       |   26 +
 .../ReefCommon/tasks/events/ITaskStop.cs        |   26 +
 .../reef-common/ReefDriver/ClientManager.cs     |   43 +
 .../REEF/reef-common/ReefDriver/Constants.cs    |  114 ++
 .../ReefDriver/DriverConfigGenerator.cs         |  151 +++
 .../ReefDriver/DriverConfigurationSettings.cs   |  135 ++
 .../reef-common/ReefDriver/DriverManager.cs     |  540 ++++++++
 .../ReefDriver/DriverRuntimeConfiguration.cs    |   64 +
 .../DriverRuntimeConfigurationOptions.cs        |   42 +
 .../ReefDriver/DriverSubmissionSettings.cs      |  185 +++
 .../reef-common/ReefDriver/EvaluatorManager.cs  |  655 ++++++++++
 .../REEF/reef-common/ReefDriver/FailedJob.cs    |   51 +
 .../REEF/reef-common/ReefDriver/IDriver.cs      |   28 +
 .../reef-common/ReefDriver/IStartHandler.cs     |   26 +
 .../ReefDriver/Properties/AssemblyInfo.cs       |   55 +
 .../reef-common/ReefDriver/ReefDriver.csproj    |  208 ++++
 .../ReefDriver/bridge/BridgeLogger.cs           |   65 +
 .../ReefDriver/bridge/ClrClientHelper.cs        |  175 +++
 .../ReefDriver/bridge/ClrHandlerHelper.cs       |  177 +++
 .../ReefDriver/bridge/ClrSystemHandler.cs       |   53 +
 .../bridge/ClrSystemHandlerWrapper.cs           |  273 +++++
 .../ReefDriver/bridge/DriverBridge.cs           |  321 +++++
 .../bridge/DriverBridgeConfiguration.cs         |  273 +++++
 .../bridge/DriverBridgeConfigurationOptions.cs  |  154 +++
 .../ReefDriver/bridge/HttpMessage.cs            |   60 +
 .../ReefDriver/bridge/HttpServerHandler.cs      |  165 +++
 .../ReefDriver/bridge/HttpServerPort.cs         |   33 +
 .../ReefDriver/bridge/IHttpHandler.cs           |   39 +
 .../ReefDriver/bridge/IHttpMessage.cs           |   33 +
 .../ReefDriver/bridge/ReefHttpRequest.cs        |   49 +
 .../ReefDriver/bridge/ReefHttpResponse.cs       |   30 +
 .../bridge/clr2java/IActiveContextClr2Java.cs   |   36 +
 .../clr2java/IAllocatedEvaluaotrClr2Java.cs     |   42 +
 .../bridge/clr2java/IClosedContextClr2Java.cs   |   34 +
 .../ReefDriver/bridge/clr2java/IClr2Java.cs     |   26 +
 .../clr2java/ICompletedEvaluatorClr2Java.cs     |   30 +
 .../bridge/clr2java/ICompletedTaskClr2Java.cs   |   28 +
 .../bridge/clr2java/IContextMessageClr2Java.cs  |   30 +
 .../clr2java/IEvaluatorRequestorClr2Java.cs     |   28 +
 .../bridge/clr2java/IFailedContextClr2Java.cs   |   36 +
 .../bridge/clr2java/IFailedEvaluatorClr2Java.cs |   30 +
 .../bridge/clr2java/IFailedTaskClr2Java.cs      |   28 +
 .../clr2java/IHttpServerBridgeClr2Java.cs       |   34 +
 .../bridge/clr2java/IRunningTaskClr2Java.cs     |   30 +
 .../bridge/clr2java/ISuspendedTaskClr2Java.cs   |   42 +
 .../bridge/clr2java/ITaskMessageClr2Java.cs     |   26 +
 .../ReefDriver/bridge/events/ActiveContext.cs   |  117 ++
 .../bridge/events/AllocatedEvaluator.cs         |  175 +++
 .../ReefDriver/bridge/events/ClosedContext.cs   |   98 ++
 .../bridge/events/CompletedEvaluator.cs         |   60 +
 .../ReefDriver/bridge/events/CompletedTask.cs   |   75 ++
 .../ReefDriver/bridge/events/ContextMessage.cs  |   53 +
 .../bridge/events/EvaluatorRequstor.cs          |   95 ++
 .../ReefDriver/bridge/events/FailedContext.cs   |  110 ++
 .../ReefDriver/bridge/events/FailedEvaluator.cs |   72 ++
 .../ReefDriver/bridge/events/FailedTask.cs      |  140 +++
 .../ReefDriver/bridge/events/RunningTask.cs     |   97 ++
 .../ReefDriver/bridge/events/SuspendedTask.cs   |   81 ++
 .../ReefDriver/bridge/events/TaskMessage.cs     |   64 +
 .../ReefDriver/context/ContextConfiguration.cs  |   93 ++
 .../context/ContextConfigurationOptions.cs      |   60 +
 .../ReefDriver/context/EvaluatorContext.cs      |  148 +++
 .../ReefDriver/context/IActiveContext.cs        |   29 +
 .../ReefDriver/context/IClosedContext.cs        |   26 +
 .../reef-common/ReefDriver/context/IContext.cs  |   45 +
 .../ReefDriver/context/IFailedContext.cs        |   28 +
 .../defaults/DefaultContextMessageSource.cs     |   42 +
 .../defaults/DefaultContextStartHandler.cs      |   48 +
 .../defaults/DefaultContextStopHandler.cs       |   48 +
 .../ReefDriver/contract/IBridgeContract.cs      |   26 +
 .../defaults/DefaultClientCloseHandler.cs       |   53 +
 .../DefaultClientCloseWithMessageHandler.cs     |   54 +
 .../defaults/DefaultClientMessageHandler.cs     |   54 +
 .../defaults/DefaultContextActiveHandler.cs     |   56 +
 .../defaults/DefaultContextClosureHandler.cs    |   55 +
 .../defaults/DefaultContextFailureHandler.cs    |   51 +
 .../defaults/DefaultContextMessageHandler.cs    |   55 +
 .../defaults/DefaultCustomTraceListener.cs      |   45 +
 .../DefaultDriverRestartContextActiveHandler.cs |   56 +
 .../defaults/DefaultDriverRestartHandler.cs     |   54 +
 .../DefaultDriverRestartTaskRunningHandler.cs   |   54 +
 .../DefaultEvaluatorAllocationHandler.cs        |   57 +
 .../DefaultEvaluatorCompletionHandler.cs        |   54 +
 .../defaults/DefaultEvaluatorFailureHandler.cs  |   55 +
 .../DefaultEvaluatorRequestorHandler.cs         |   61 +
 .../ReefDriver/defaults/DefaultHttpHandler.cs   |   49 +
 .../defaults/DefaultTaskCompletionHandler.cs    |   60 +
 .../defaults/DefaultTaskFailureHandler.cs       |   53 +
 .../defaults/DefaultTaskMessageHandler.cs       |   55 +
 .../defaults/DefaultTaskRunningHandler.cs       |   54 +
 .../defaults/DefaultTaskSuspensionHandler.cs    |   53 +
 .../evaluator/EvaluatorDescriptorImpl.cs        |  218 ++++
 .../ReefDriver/evaluator/EvaluatorRequest.cs    |  108 ++
 .../evaluator/EvaluatorRequestBuilder.cs        |   60 +
 .../ReefDriver/evaluator/IAllocatedEvaluator.cs |   55 +
 .../ReefDriver/evaluator/ICompletedEvaluator.cs |   30 +
 .../evaluator/IEvaluatorDescriptor.cs           |   57 +
 .../ReefDriver/evaluator/IEvaluatorRequest .cs  |   42 +
 .../ReefDriver/evaluator/IEvaluatorRequestor.cs |   47 +
 .../ReefDriver/evaluator/IFailedEvaluator.cs    |   41 +
 .../REEF/reef-common/ReefDriver/packages.config |   24 +
 .../ReefDriver/task/ICompletedTask.cs           |   29 +
 .../reef-common/ReefDriver/task/IFailedTask.cs  |   30 +
 .../reef-common/ReefDriver/task/IRunningTask.cs |   65 +
 .../ReefDriver/task/ISuspendedTask.cs           |   29 +
 .../reef-common/ReefDriver/task/ITaskMessage.cs |   28 +
 .../ReefDriver/task/RunningTaskImpl.cs          |  127 ++
 .../HelloCLRBridge/HelloCLRBridge.csproj        |  118 ++
 .../HelloCLRBridge/HelloTraceListener.cs        |   48 +
 .../HelloCLRBridge/Properties/AssemblyInfo.cs   |   55 +
 .../AnotherHelloAllocatedEvaluatorHandler.cs    |   48 +
 .../handlers/HelloActiveContextHandler.cs       |   82 ++
 .../handlers/HelloAllocatedEvaluatorHandler.cs  |  131 ++
 .../handlers/HelloCompletedEvaluatorHandler.cs  |   59 +
 .../HelloDriverRestartActiveContextHandler.cs   |   69 ++
 .../HelloDriverRestartRunningTaskHandler.cs     |   67 +
 .../handlers/HelloEvaluatorRequestorHandler.cs  |   65 +
 .../handlers/HelloFailedEvaluatorHandler.cs     |   68 +
 .../handlers/HelloFailedTaskHandler.cs          |   67 +
 .../HelloCLRBridge/handlers/HelloHttpHandler.cs |   51 +
 .../handlers/HelloRestartHandler.cs             |   48 +
 .../handlers/HelloRunningTaskHandler.cs         |   65 +
 .../handlers/HelloSimpleEventHandlers.cs        |  421 +++++++
 .../handlers/HelloStartHandler.cs               |   64 +
 .../handlers/HelloTaskMessageHandler.cs         |   54 +
 .../Properties/AssemblyInfo.cs                  |   55 +
 .../RetainedEvalCLRBridge.csproj                |   98 ++
 .../handler/RetainedEvalActiveContextHandler.cs |   56 +
 .../RetainedEvalAllocatedEvaluatorHandler.cs    |   48 +
 .../RetainedEvalEvaluatorRequestorHandler.cs    |   48 +
 .../handler/RetainedEvalStartHandler.cs         |   90 ++
 .../Naming/Codec/NamingLookupRequestCodec.cs    |   41 +
 .../Naming/Codec/NamingLookupResponseCodec.cs   |   55 +
 .../Naming/Codec/NamingRegisterRequestCodec.cs  |   47 +
 .../Naming/Codec/NamingRegisterResponseCodec.cs |   44 +
 .../Codec/NamingUnregisterRequestCodec.cs       |   41 +
 .../Naming/Contracts/AvroNamingAssignment.cs    |   62 +
 .../Naming/Contracts/AvroNamingLookupRequest.cs |   51 +
 .../Contracts/AvroNamingLookupResponse.cs       |   51 +
 .../Contracts/AvroNamingRegisterRequest.cs      |   62 +
 .../Contracts/AvroNamingUnRegisterRequest.cs    |   50 +
 .../Network/Naming/Events/NamingEvent.cs        |   35 +
 .../Naming/Events/NamingGetAllRequest.cs        |   29 +
 .../Naming/Events/NamingGetAllResponse.cs       |   38 +
 .../Naming/Events/NamingLookupRequest.cs        |   36 +
 .../Naming/Events/NamingLookupResponse.cs       |   39 +
 .../Naming/Events/NamingRegisterRequest.cs      |   36 +
 .../Naming/Events/NamingRegisterResponse.cs     |   34 +
 .../Naming/Events/NamingUnregisterRequest.cs    |   34 +
 .../Naming/Events/NamingUnregisterResponse.cs   |   34 +
 .../REEF/reef-io/Network/Naming/INameServer.cs  |   69 ++
 .../REEF/reef-io/Network/Naming/NameClient.cs   |  279 +++++
 .../reef-io/Network/Naming/NameLookupClient.cs  |   97 ++
 .../Network/Naming/NameRegisterClient.cs        |   67 +
 .../REEF/reef-io/Network/Naming/NameServer.cs   |  196 +++
 .../Network/Naming/NamingConfiguration.cs       |   50 +
 .../Naming/NamingConfigurationOptions.cs        |   41 +
 .../Observers/NamingGetAllRequestObserver.cs    |   47 +
 .../Observers/NamingLookupRequestObserver.cs    |   50 +
 .../Observers/NamingRegisterRequestObserver.cs  |   51 +
 .../NamingUnregisterRequestObserver.cs          |   47 +
 .../Source/REEF/reef-io/Network/Network.csproj  |  159 +++
 .../NetworkService/Codec/ControlMessageCodec.cs |   43 +
 .../NetworkService/Codec/NsMessageCodec.cs      |   85 ++
 .../NetworkService/Codec/NsMessageProto.cs      |   63 +
 .../Network/NetworkService/ControlMessage.cs    |   39 +
 .../Network/NetworkService/IConnection.cs       |   40 +
 .../Network/NetworkService/INetworkService.cs   |   58 +
 .../Network/NetworkService/NetworkService.cs    |  156 +++
 .../NetworkServiceConfiguration.cs              |   57 +
 .../NetworkService/NetworkServiceOptions.cs     |   33 +
 .../Network/NetworkService/NsConnection.cs      |  139 +++
 .../reef-io/Network/NetworkService/NsMessage.cs |   71 ++
 .../reef-io/Network/Properties/AssemblyInfo.cs  |   55 +
 .../Utilities/BlockingCollectionExtensions.cs   |   78 ++
 .../REEF/reef-io/Network/Utilities/Utils.cs     |   76 ++
 .../Source/REEF/reef-io/Network/packages.config |   26 +
 .../reef-tasks/Tasks/FailedTask/FailedTask.cs   |   44 +
 .../reef-tasks/Tasks/HelloTask/HelloService.cs  |   58 +
 .../reef-tasks/Tasks/HelloTask/HelloTask.cs     |  123 ++
 .../Tasks/HelloTask/HelloTaskMessage.cs         |   49 +
 .../reef-tasks/Tasks/Properties/AssemblyInfo.cs |   55 +
 .../reef-tasks/Tasks/ShellTask/ShellTask.cs     |   90 ++
 .../Tasks/StreamingTasks/StreamTask1.cs         |   66 +
 .../Tasks/StreamingTasks/StreamTask2.cs         |   50 +
 .../Source/REEF/reef-tasks/Tasks/Tasks.csproj   |   93 ++
 lang/cs/Source/TANG/Examples/AnonymousType.cs   |   57 +
 lang/cs/Source/TANG/Examples/CheckChild.cs      |   37 +
 .../Examples/DocumentedLocalNamedParameter.cs   |   43 +
 lang/cs/Source/TANG/Examples/Examples.csproj    |   95 ++
 lang/cs/Source/TANG/Examples/FileNames.cs       |   39 +
 .../TANG/Examples/ForksInjectorInConstructor.cs |   59 +
 lang/cs/Source/TANG/Examples/GenericArgument.cs |   48 +
 .../Source/TANG/Examples/GenericAsArgument.cs   |   44 +
 .../TANG/Examples/NamedParameterConstructors.cs |   40 +
 .../TANG/Examples/Properties/AssemblyInfo.cs    |   55 +
 lang/cs/Source/TANG/Examples/ShortNameFooAB.cs  |   38 +
 .../Source/TANG/Examples/SimpleConstructors.cs  |   42 +
 lang/cs/Source/TANG/Examples/TestClasses.cs     |   57 +
 lang/cs/Source/TANG/Examples/Timer.cs           |   46 +
 lang/cs/Source/TANG/Examples/TweetExample.cs    |   90 ++
 .../Tang/Annotations/DefaultImplementation.cs   |   43 +
 lang/cs/Source/TANG/Tang/Annotations/Inject.cs  |   28 +
 lang/cs/Source/TANG/Tang/Annotations/Name.cs    |   28 +
 .../TANG/Tang/Annotations/NamedParameter.cs     |   44 +
 .../Source/TANG/Tang/Annotations/Parameter.cs   |   39 +
 lang/cs/Source/TANG/Tang/Annotations/Unit.cs    |   29 +
 .../TANG/Tang/Exceptions/BindException.cs       |   36 +
 .../Tang/Exceptions/ClassHierarchyException.cs  |   34 +
 .../Tang/Exceptions/IllegalStateException.cs    |   40 +
 .../TANG/Tang/Exceptions/InjectionException.cs  |   35 +
 .../Tang/Exceptions/NameResolutionException.cs  |   37 +
 .../TANG/Tang/Exceptions/ParseException.cs      |   36 +
 .../AvroConfiguration.cs                        |   47 +
 .../ConfigurationEntry.cs                       |   44 +
 .../Tang/Formats/AvroConfigurationSerializer.cs |  324 +++++
 .../TANG/Tang/Formats/ConfigurationFile.cs      |  371 ++++++
 .../TANG/Tang/Formats/ConfigurationModule.cs    |  302 +++++
 .../Tang/Formats/ConfigurationModuleBuilder.cs  |  519 ++++++++
 .../Tang/Formats/IConfigurationSerializer.cs    |   49 +
 lang/cs/Source/TANG/Tang/Formats/IImpl.cs       |   31 +
 lang/cs/Source/TANG/Tang/Formats/IParam.cs      |   31 +
 .../cs/Source/TANG/Tang/Formats/OptionalImpl.cs |   31 +
 .../TANG/Tang/Formats/OptionalParameter.cs      |   31 +
 lang/cs/Source/TANG/Tang/Formats/Provides.cs    |   31 +
 .../cs/Source/TANG/Tang/Formats/RequiredImpl.cs |   31 +
 .../TANG/Tang/Formats/RequiredParameter.cs      |   31 +
 .../ClassHierarchy/AbstractNode.cs              |  131 ++
 .../ClassHierarchy/ClassHierarchyImpl.cs        |  526 ++++++++
 .../ClassHierarchy/ClassNodeImpl.cs             |  157 +++
 .../ClassHierarchy/ConstructorArgImpl.cs        |   97 ++
 .../ClassHierarchy/ConstructorDefImpl.cs        |  203 +++
 .../ClassHierarchy/NamedParameterNodeImpl.cs    |   88 ++
 .../ClassHierarchy/NodeFactory.cs               |  315 +++++
 .../ClassHierarchy/PackageNodeImpl.cs           |   49 +
 .../ClassHierarchy/ParameterParser.cs           |  199 +++
 .../Configuration/ConfigurationBuilderImpl.cs   |  364 ++++++
 .../Configuration/ConfigurationImpl.cs          |  122 ++
 .../Configuration/Configurations.cs             |   55 +
 .../Configuration/CsConfigurationBuilderImpl.cs |  489 ++++++++
 .../Configuration/CsConfigurationImpl.cs        |   34 +
 .../InjectionPlan/Constructor.cs                |  217 ++++
 .../Implementations/InjectionPlan/CsInstance.cs |   90 ++
 .../InjectionPlan/InjectionFuture.cs            |  100 ++
 .../InjectionPlan/InjectionFuturePlan.cs        |   73 ++
 .../InjectionPlan/InjectionPlan.cs              |  222 ++++
 .../InjectionPlan/InjectorImpl.cs               | 1091 +++++++++++++++++
 .../InjectionPlan/ListInjectionPlan.cs          |  117 ++
 .../InjectionPlan/SetInjectionPlan.cs           |  122 ++
 .../Implementations/InjectionPlan/Subplan.cs    |  235 ++++
 .../Tang/Implementations/Tang/TangFactory.cs    |   30 +
 .../TANG/Tang/Implementations/Tang/TangImpl.cs  |  201 +++
 lang/cs/Source/TANG/Tang/Interface/IAspect.cs   |   31 +
 .../TANG/Tang/Interface/IClassHierarchy.cs      |   30 +
 .../TANG/Tang/Interface/IConfiguration.cs       |   49 +
 .../Tang/Interface/IConfigurationBuilder.cs     |   54 +
 .../TANG/Tang/Interface/ICsClassHierarchy.cs    |   33 +
 .../Tang/Interface/ICsConfigurationBuilder.cs   |  121 ++
 .../ICsInternalConfigurationBuilder.cs          |   70 ++
 .../TANG/Tang/Interface/IExternalConstructor.cs |   26 +
 lang/cs/Source/TANG/Tang/Interface/IInjector.cs |  180 +++
 lang/cs/Source/TANG/Tang/Interface/ITang.cs     |   46 +
 .../Source/TANG/Tang/Properties/AssemblyInfo.cs |   55 +
 .../Protobuf/ProtocolBufferClassHierarchy.cs    |  473 +++++++
 .../Protobuf/ProtocolBufferInjectionPlan.cs     |  204 +++
 .../TANG/Tang/Protobuf/class_hierarchy.cs       |  274 +++++
 .../Source/TANG/Tang/Protobuf/injection_plan.cs |  132 ++
 lang/cs/Source/TANG/Tang/Tang.csproj            |  179 +++
 lang/cs/Source/TANG/Tang/Types/IClassNode.cs    |   37 +
 .../Source/TANG/Tang/Types/IConstructorArg.cs   |   32 +
 .../Source/TANG/Tang/Types/IConstructorDef.cs   |   34 +
 .../TANG/Tang/Types/INamedParameterNode.cs      |   38 +
 lang/cs/Source/TANG/Tang/Types/INode.cs         |   37 +
 lang/cs/Source/TANG/Tang/Types/IPackageNode.cs  |   24 +
 lang/cs/Source/TANG/Tang/Types/ITraversable.cs  |   27 +
 .../TANG/Tang/Util/AbstractMonotonicMultiMap.cs |  263 ++++
 lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs |   70 ++
 lang/cs/Source/TANG/Tang/Util/GenericType.cs    |   49 +
 .../Source/TANG/Tang/Util/MonotonicHashMap.cs   |   83 ++
 .../Source/TANG/Tang/Util/MonotonicHashSet.cs   |  131 ++
 .../TANG/Tang/Util/MonotonicMultiHashMap.cs     |   30 +
 .../Source/TANG/Tang/Util/MonotonicMultiMap.cs  |   30 +
 lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs   |  106 ++
 .../Source/TANG/Tang/Util/MonotonicTreeMap.cs   |   68 +
 .../TANG/Tang/Util/ReflectionUtilities.cs       |  594 +++++++++
 lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs   |   62 +
 lang/cs/Source/TANG/Tang/packages.config        |   24 +
 .../ClassHierarchyBuilder.csproj                |   90 ++
 .../Tools/ClassHierarchyBuilder/Program.cs      |   97 ++
 .../Properties/AssemblyInfo.cs                  |   55 +
 .../Tools/ReefAll/Properties/AssemblyInfo.cs    |   55 +
 lang/cs/Source/Tools/ReefAll/ReefAll.csproj     |  102 ++
 lang/cs/Source/Utilities/AvroUtils.cs           |   61 +
 lang/cs/Source/Utilities/ByteUtilities.cs       |   45 +
 .../Diagnostics/DiagnosticsMessages.cs          |   42 +
 .../Source/Utilities/Diagnostics/Exceptions.cs  |  282 +++++
 lang/cs/Source/Utilities/IIdentifiable.cs       |   26 +
 lang/cs/Source/Utilities/IMessage.cs            |   33 +
 .../Utilities/Logging/JavaLoggingSetting.cs     |   39 +
 lang/cs/Source/Utilities/Logging/Level.cs       |   59 +
 lang/cs/Source/Utilities/Logging/Logger.cs      |  227 ++++
 lang/cs/Source/Utilities/NetUtilities.cs        |   51 +
 lang/cs/Source/Utilities/Optional.cs            |  116 ++
 .../Source/Utilities/Properties/AssemblyInfo.cs |   55 +
 lang/cs/Source/Utilities/Utilities.csproj       |   97 ++
 lang/cs/Source/Utilities/ValidationUtilities.cs |   42 +
 lang/cs/Source/Utilities/packages.config        |   23 +
 lang/cs/Source/WAKE/Wake/AbstractEStage.cs      |   42 +
 lang/cs/Source/WAKE/Wake/IEStage.cs             |   26 +
 lang/cs/Source/WAKE/Wake/IEventHandler.cs       |   34 +
 lang/cs/Source/WAKE/Wake/IIdentifier.cs         |   57 +
 lang/cs/Source/WAKE/Wake/IIdentifierFactory.cs  |   35 +
 lang/cs/Source/WAKE/Wake/IObserverFactory.cs    |   32 +
 lang/cs/Source/WAKE/Wake/IStage.cs              |   29 +
 .../WAKE/Wake/Impl/LoggingEventHandler.cs       |   53 +
 .../Wake/Impl/MissingStartHandlerHandler.cs     |   49 +
 .../Source/WAKE/Wake/Impl/MultiEventHandler.cs  |   65 +
 lang/cs/Source/WAKE/Wake/Impl/PeriodicEvent.cs  |   26 +
 .../Source/WAKE/Wake/Impl/PubSubEventHandler.cs |   94 ++
 .../Source/WAKE/Wake/Impl/SingleThreadStage.cs  |  100 ++
 lang/cs/Source/WAKE/Wake/Impl/SyncStage.cs      |   48 +
 .../cs/Source/WAKE/Wake/Impl/ThreadPoolStage.cs |  100 ++
 lang/cs/Source/WAKE/Wake/Impl/TimerStage.cs     |   66 +
 .../Source/WAKE/Wake/Properties/AssemblyInfo.cs |   55 +
 .../WAKE/Wake/Protobuf/RemoteProtocol.proto     |   36 +
 .../WAKE/Wake/Protobuf/WakeRemoteProtosGen.cs   |   96 ++
 lang/cs/Source/WAKE/Wake/RX/AbstractObserver.cs |   45 +
 lang/cs/Source/WAKE/Wake/RX/AbstractRxStage.cs  |   54 +
 lang/cs/Source/WAKE/Wake/RX/IRxStage.cs         |   28 +
 .../cs/Source/WAKE/Wake/RX/IStaticObservable.cs |   31 +
 lang/cs/Source/WAKE/Wake/RX/ISubject.cs         |   31 +
 .../Source/WAKE/Wake/RX/Impl/PubSubSubject.cs   |  180 +++
 lang/cs/Source/WAKE/Wake/RX/Impl/RxSyncStage.cs |   70 ++
 .../WAKE/Wake/RX/Impl/RxThreadPoolStage.cs      |  134 ++
 .../cs/Source/WAKE/Wake/RX/Impl/RxTimerStage.cs |   67 +
 .../Source/WAKE/Wake/RX/Impl/SimpleSubject.cs   |   59 +
 .../WAKE/Wake/RX/ObserverCompletedException.cs  |   46 +
 lang/cs/Source/WAKE/Wake/Remote/ICodec.cs       |   34 +
 .../cs/Source/WAKE/Wake/Remote/ICodecFactory.cs |   35 +
 lang/cs/Source/WAKE/Wake/Remote/IDecoder.cs     |   38 +
 lang/cs/Source/WAKE/Wake/Remote/IEncoder.cs     |   38 +
 lang/cs/Source/WAKE/Wake/Remote/ILink.cs        |   73 ++
 lang/cs/Source/WAKE/Wake/Remote/IRemoteEvent.cs |   42 +
 .../WAKE/Wake/Remote/IRemoteIdentifier.cs       |   28 +
 .../Wake/Remote/IRemoteIdentifierFactory.cs     |   26 +
 .../Source/WAKE/Wake/Remote/IRemoteManager.cs   |   42 +
 .../Source/WAKE/Wake/Remote/IRemoteMessage.cs   |   39 +
 .../WAKE/Wake/Remote/ISubscriptionManager.cs    |   26 +
 .../Source/WAKE/Wake/Remote/Impl/ByteCodec.cs   |   41 +
 .../WAKE/Wake/Remote/Impl/ByteCodecFactory.cs   |   41 +
 lang/cs/Source/WAKE/Wake/Remote/Impl/Channel.cs |  258 ++++
 .../Wake/Remote/Impl/DefaultRemoteManager.cs    |  338 +++++
 .../Wake/Remote/Impl/DefaultRemoteMessage.cs    |   34 +
 .../WAKE/Wake/Remote/Impl/IPEndpointComparer.cs |   59 +
 .../cs/Source/WAKE/Wake/Remote/Impl/IntCodec.cs |   42 +
 lang/cs/Source/WAKE/Wake/Remote/Impl/Link.cs    |  256 ++++
 .../Source/WAKE/Wake/Remote/Impl/MultiCodec.cs  |   89 ++
 .../WAKE/Wake/Remote/Impl/MultiDecoder.cs       |  110 ++
 .../WAKE/Wake/Remote/Impl/MultiEncoder.cs       |   87 ++
 .../WAKE/Wake/Remote/Impl/ObserverContainer.cs  |  132 ++
 .../Source/WAKE/Wake/Remote/Impl/RemoteEvent.cs |   59 +
 .../WAKE/Wake/Remote/Impl/RemoteEventCodec.cs   |   43 +
 .../WAKE/Wake/Remote/Impl/RemoteEventDecoder.cs |   39 +
 .../WAKE/Wake/Remote/Impl/RemoteEventEncoder.cs |   43 +
 .../Wake/Remote/Impl/RemoteEventEndpoint.cs     |   42 +
 .../Wake/Remote/Impl/SocketRemoteIdentifier.cs  |   76 ++
 .../Source/WAKE/Wake/Remote/Impl/StringCodec.cs |   46 +
 .../WAKE/Wake/Remote/Impl/StringIdentifier.cs   |   53 +
 .../Wake/Remote/Impl/StringIdentifierFactory.cs |   41 +
 .../WAKE/Wake/Remote/Impl/TransportClient.cs    |  133 ++
 .../WAKE/Wake/Remote/Impl/TransportEvent.cs     |   42 +
 .../WAKE/Wake/Remote/Impl/TransportServer.cs    |  195 +++
 .../WAKE/Wake/Remote/Proto/WakeRemoteProtos.cs  |   76 ++
 .../WAKE/Wake/Remote/RemoteConfiguration.cs     |   57 +
 .../WAKE/Wake/Remote/RemoteRuntimeException.cs  |   54 +
 lang/cs/Source/WAKE/Wake/Time/Event/Alarm.cs    |   41 +
 .../cs/Source/WAKE/Wake/Time/Event/StartTime.cs |   31 +
 lang/cs/Source/WAKE/Wake/Time/Event/StopTime.cs |   31 +
 lang/cs/Source/WAKE/Wake/Time/IClock.cs         |   89 ++
 .../WAKE/Wake/Time/Runtime/Event/ClientAlarm.cs |   34 +
 .../WAKE/Wake/Time/Runtime/Event/IdleClock.cs   |   28 +
 .../Wake/Time/Runtime/Event/RuntimeAlarm.cs     |   34 +
 .../Wake/Time/Runtime/Event/RuntimeStart.cs     |   28 +
 .../WAKE/Wake/Time/Runtime/Event/RuntimeStop.cs |   37 +
 lang/cs/Source/WAKE/Wake/Time/Runtime/ITimer.cs |   49 +
 .../WAKE/Wake/Time/Runtime/LogicalTimer.cs      |   55 +
 .../Source/WAKE/Wake/Time/Runtime/RealTimer.cs  |   64 +
 .../WAKE/Wake/Time/Runtime/RuntimeClock.cs      |  257 ++++
 lang/cs/Source/WAKE/Wake/Time/Time.cs           |   82 ++
 lang/cs/Source/WAKE/Wake/Util/Actionable.cs     |   42 +
 lang/cs/Source/WAKE/Wake/Util/Disposable.cs     |   63 +
 .../Wake/Util/FixedThreadPoolTaskService.cs     |  105 ++
 lang/cs/Source/WAKE/Wake/Util/IStartable.cs     |   32 +
 lang/cs/Source/WAKE/Wake/Util/ITaskService.cs   |   34 +
 .../LimitedConcurrencyLevelTaskScheduler.cs     |  187 +++
 lang/cs/Source/WAKE/Wake/Util/NetworkUtils.cs   |   66 +
 .../WAKE/Wake/Util/SerializationHelper.cs       |   46 +
 lang/cs/Source/WAKE/Wake/Util/TaskExtensions.cs |   34 +
 lang/cs/Source/WAKE/Wake/Util/TimeHelper.cs     |   49 +
 lang/cs/Source/WAKE/Wake/Wake.csproj            |  214 ++++
 .../cs/Source/WAKE/Wake/WakeRuntimeException.cs |   54 +
 lang/cs/Source/WAKE/Wake/packages.config        |   24 +
 .../src/main/cs/Examples/P2p/IEventSource.cs    |   35 +
 .../Wake/src/main/cs/Examples/P2p/Pull2Push.cs  |  103 ++
 .../WAKE/Wake/src/main/cs/PeriodicEvent.cs      |   23 +
 lang/cs/Source/WAKE/Wake/testkey.snk            |  Bin 0 -> 596 bytes
 .../Tests/ReefTests/ConfigFiles/evaluator.conf  |  Bin 0 -> 2837 bytes
 .../EvaluatorConfigurationsTests.cs             |   42 +
 .../ReefTests/Evaluator.Tests/EvaluatorTests.cs |   94 ++
 .../Functional.Tests/Bridge/TestBridgeClient.cs |   99 ++
 .../Bridge/TestHelloBridgeHandlers.cs           |  101 ++
 .../Bridge/TestSimpleEventHandlers.cs           |  110 ++
 .../Driver/DriverTestStartHandler.cs            |   46 +
 .../Functional.Tests/Driver/TestDriver.cs       |   68 +
 .../Functional.Tests/Messaging/MessageDriver.cs |  122 ++
 .../Functional.Tests/Messaging/MessageTask.cs   |  106 ++
 .../Messaging/TestTaskMessage.cs                |   75 ++
 .../Functional.Tests/ReefFunctionalTest.cs      |  200 +++
 .../BlockingCollectionExtensionTests.cs         |   78 ++
 .../Tests/ReefTests/IO.Tests/NameServerTests.cs |  274 +++++
 .../ReefTests/IO.Tests/NetworkServiceTests.cs   |  202 +++
 .../Tests/ReefTests/Properties/AssemblyInfo.cs  |   55 +
 lang/cs/Tests/ReefTests/ReefTests.csproj        |  192 +++
 .../Utility.Test/TestDriverConfigGenerator.cs   |  101 ++
 .../ReefTests/Utility.Test/TestExceptions.cs    |   49 +
 ...bridge-0.11.0-incubating-SNAPSHOT-shaded.jar |  Bin 0 -> 13555831 bytes
 lang/cs/Tests/ReefTests/bin/run.cmd             |   45 +
 lang/cs/Tests/ReefTests/packages.config         |   32 +
 .../ClassHierarchy/TestAnonymousType.cs         |   63 +
 .../ClassHierarchy/TestClassHierarchy.cs        |  717 +++++++++++
 .../TestClassHierarchyRoundTrip.cs              |   69 ++
 .../TangTests/ClassHierarchy/TestGeneric.cs     |   46 +
 .../ClassHierarchy/TestMultipleInterface.cs     |  103 ++
 .../ClassHierarchy/TestParameterParser.cs       |  323 +++++
 .../ClassHierarchy/TestSerilization.cs          |  234 ++++
 .../Configuration/TestAvroConfiguration.cs      |   68 +
 .../TestAvroSerializerRoundTrip.cs              |   71 ++
 .../Configuration/TestConfiguration.cs          |  566 +++++++++
 .../TestCsConfigurationBuilderExtension.cs      |  178 +++
 .../TangTests/Format/TestConfigurationModule.cs |  522 ++++++++
 .../Format/TestConfigurationModuleForList.cs    |  145 +++
 .../TangTests/Format/TestTaskConfiguration.cs   |  389 ++++++
 .../Injection/TestAmbigousConstructors.cs       |   80 ++
 .../TangTests/Injection/TestForkInjection.cs    |   79 ++
 .../Tests/TangTests/Injection/TestInjection.cs  |  386 ++++++
 .../TangTests/Injection/TestInjectionFuture.cs  |  240 ++++
 .../TangTests/Injection/TestListInjection.cs    |  565 +++++++++
 .../Injection/TestMissingParameters.cs          |  151 +++
 .../Injection/TestMissingParamtersInNested.cs   |  142 +++
 .../Injection/TestMultipleConstructors.cs       |  360 ++++++
 .../TangTests/Injection/TestNamedParameter.cs   |  357 ++++++
 .../TangTests/Injection/TestSetInjection.cs     |  739 +++++++++++
 .../Tests/TangTests/Properties/AssemblyInfo.cs  |   55 +
 .../ScenarioTest/HttpHandlerConfiguration.cs    |   35 +
 .../ScenarioTest/HttpRuntimeConfiguration.cs    |   36 +
 .../ScenarioTest/HttpRuntimeStartHandler.cs     |   50 +
 .../ScenarioTest/HttpRuntimeStopHandler.cs      |   50 +
 .../Tests/TangTests/ScenarioTest/HttpServer.cs  |   49 +
 .../TangTests/ScenarioTest/IHttpHandler.cs      |   27 +
 .../TangTests/ScenarioTest/JettyHandler.cs      |   44 +
 .../ScenarioTest/TestDefaultConstructor.cs      |   79 ++
 .../TangTests/ScenarioTest/TestHttpService.cs   |  194 +++
 .../TangTests/ScenarioTest/TestRuntimeClock.cs  |  253 ++++
 .../ScenarioTest/TestTrackingURIProvider.cs     |   59 +
 .../ScenarioTest/TrackingURIProvider.cs         |   63 +
 .../ScenarioTest/TrackingYRIProvider.cs         |   25 +
 .../cs/Tests/TangTests/SmokeTest/AnInterface.cs |   29 +
 .../SmokeTest/AnInterfaceImplementation.cs      |   65 +
 .../TangTests/SmokeTest/CyclicDependency.cs     |   70 ++
 .../SmokeTest/CyclicDependencyClassOne.cs       |   61 +
 .../SmokeTest/CyclicDependencyClassTwo.cs       |   55 +
 lang/cs/Tests/TangTests/SmokeTest/Handler.cs    |   26 +
 .../TangTests/SmokeTest/InjectableClass.cs      |   60 +
 .../TangTests/SmokeTest/ListOfBaseTypes.cs      |  108 ++
 .../Tests/TangTests/SmokeTest/ObjectTreeTest.cs |   54 +
 .../TangTests/SmokeTest/RootImplementation.cs   |  178 +++
 .../Tests/TangTests/SmokeTest/RootInterface.cs  |   26 +
 .../Tests/TangTests/SmokeTest/RoundTripTest.cs  |   40 +
 .../Tests/TangTests/SmokeTest/SetInterface.cs   |   31 +
 .../TangTests/SmokeTest/SetInterfaceImplOne.cs  |   82 ++
 .../TangTests/SmokeTest/SetInterfaceImplTwo.cs  |   82 ++
 .../Tests/TangTests/SmokeTest/SetOfBaseTypes.cs |  105 ++
 .../TangTests/SmokeTest/SetOfImplementations.cs |   72 ++
 .../SmokeTest/TestConfigurationModuleBuilder.cs |  107 ++
 .../TangTests/Tang/TestDefaultImpementaion.cs   |  196 +++
 .../TangTests/Tang/TestExternalConstructors.cs  |  148 +++
 .../TangTests/Tang/TestLegacyConstructors.cs    |   73 ++
 lang/cs/Tests/TangTests/Tang/TestTang.cs        | 1158 ++++++++++++++++++
 lang/cs/Tests/TangTests/TangTests.csproj        |  180 +++
 .../Tests/TangTests/Utilities/TestUtilities.cs  |  294 +++++
 lang/cs/Tests/TangTests/Utilities/Utilities.cs  |   62 +
 lang/cs/Tests/TangTests/evaluator.conf          |  Bin 0 -> 2837 bytes
 lang/cs/Tests/TangTests/packages.config         |   24 +
 .../TangTests/simpleConstructorJavaProto.bin    |  Bin 0 -> 1994 bytes
 lang/cs/Tests/WakeTests/ClockTest.cs            |  183 +++
 lang/cs/Tests/WakeTests/MultiCodecTest.cs       |  102 ++
 .../Tests/WakeTests/Properties/AssemblyInfo.cs  |   55 +
 lang/cs/Tests/WakeTests/PubSubSubjectTest.cs    |  209 ++++
 lang/cs/Tests/WakeTests/RemoteManagerTest.cs    |  344 ++++++
 lang/cs/Tests/WakeTests/TransportTest.cs        |  205 ++++
 lang/cs/Tests/WakeTests/WakeTests.csproj        |  103 ++
 lang/cs/Tests/WakeTests/packages.config         |   23 +
 .../externals/Org.Apache.Reef.Driver.dll        |  Bin 121344 -> 121344 bytes
 pom.xml                                         |   19 +-
 621 files changed, 59262 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/.gitignore
----------------------------------------------------------------------
diff --git a/lang/cs/.gitignore b/lang/cs/.gitignore
new file mode 100644
index 0000000..aeaff29
--- /dev/null
+++ b/lang/cs/.gitignore
@@ -0,0 +1,10 @@
+bin
+!Tests/ReefTests/bin/
+packages
+TestResults
+**/*.exe
+**/*.suo
+**/*.csproj.user
+**/obj
+
+

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/.nuget/NuGet.Config
----------------------------------------------------------------------
diff --git a/lang/cs/.nuget/NuGet.Config b/lang/cs/.nuget/NuGet.Config
new file mode 100644
index 0000000..0ebb37e
--- /dev/null
+++ b/lang/cs/.nuget/NuGet.Config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<configuration>
+  <solution>
+    <add key="disableSourceControlIntegration" value="true" />
+  </solution>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/.nuget/NuGet.targets
----------------------------------------------------------------------
diff --git a/lang/cs/.nuget/NuGet.targets b/lang/cs/.nuget/NuGet.targets
new file mode 100644
index 0000000..401dcdd
--- /dev/null
+++ b/lang/cs/.nuget/NuGet.targets
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+
+        <!-- Enable the restore command to run before builds -->
+        <RestorePackages Condition="  '$(RestorePackages)' == '' ">false</RestorePackages>
+
+        <!-- Property that enables building a package from a project -->
+        <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
+
+        <!-- Determines if package restore consent is required to restore packages -->
+        <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
+
+        <!-- Download NuGet.exe if it does not already exist -->
+        <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>
+    </PropertyGroup>
+
+    <ItemGroup Condition=" '$(PackageSources)' == '' ">
+        <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
+        <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
+        <!--
+            <PackageSource Include="https://www.nuget.org/api/v2/" />
+            <PackageSource Include="https://my-nuget-source/nuget/" />
+        -->
+    </ItemGroup>
+
+    <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
+        <!-- Windows specific commands -->
+        <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+    </PropertyGroup>
+
+    <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
+        <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
+        <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
+    </PropertyGroup>
+
+    <PropertyGroup>
+        <PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
+        <PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
+    </PropertyGroup>
+
+    <PropertyGroup>
+      <PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
+      <PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
+    </PropertyGroup>
+    
+    <PropertyGroup>
+        <!-- NuGet command -->
+        <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
+        <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
+
+        <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
+        <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
+
+        <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
+
+        <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
+        <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
+
+        <PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
+        <PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
+
+        <!-- Commands -->
+        <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)"  $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
+        <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
+
+        <!-- We need to ensure packages are restored prior to assembly resolve -->
+        <BuildDependsOn Condition="$(RestorePackages) == 'true'">
+            RestorePackages;
+            $(BuildDependsOn);
+        </BuildDependsOn>
+
+        <!-- Make the build depend on restore packages -->
+        <BuildDependsOn Condition="$(BuildPackage) == 'true'">
+            $(BuildDependsOn);
+            BuildPackage;
+        </BuildDependsOn>
+    </PropertyGroup>
+
+    <Target Name="CheckPrerequisites">
+        <!-- Raise an error if we're unable to locate nuget.exe  -->
+        <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
+        <!--
+        Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
+        This effectively acts as a lock that makes sure that the download operation will only happen once and all
+        parallel builds will have to wait for it to complete.
+        -->
+        <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
+    </Target>
+
+    <Target Name="_DownloadNuGet">
+        <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
+    </Target>
+
+    <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">        
+        <Exec Command="$(RestoreCommand)"
+              Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
+
+        <Exec Command="$(RestoreCommand)"
+              LogStandardErrorAsError="true"
+              Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
+    </Target>
+
+    <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+        <Exec Command="$(BuildCommand)"
+              Condition=" '$(OS)' != 'Windows_NT' " />
+
+        <Exec Command="$(BuildCommand)"
+              LogStandardErrorAsError="true"
+              Condition=" '$(OS)' == 'Windows_NT' " />
+    </Target>
+
+    <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+        <ParameterGroup>
+            <OutputFilename ParameterType="System.String" Required="true" />
+        </ParameterGroup>
+        <Task>
+            <Reference Include="System.Core" />
+            <Using Namespace="System" />
+            <Using Namespace="System.IO" />
+            <Using Namespace="System.Net" />
+            <Using Namespace="Microsoft.Build.Framework" />
+            <Using Namespace="Microsoft.Build.Utilities" />
+            <Code Type="Fragment" Language="cs">
+                <![CDATA[
+                try {
+                    OutputFilename = Path.GetFullPath(OutputFilename);
+
+                    Log.LogMessage("Downloading latest version of NuGet.exe...");
+                    WebClient webClient = new WebClient();
+                    webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
+
+                    return true;
+                }
+                catch (Exception ex) {
+                    Log.LogErrorFromException(ex);
+                    return false;
+                }
+            ]]>
+            </Code>
+        </Task>
+    </UsingTask>
+</Project>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/ReefDotNet.sln
----------------------------------------------------------------------
diff --git a/lang/cs/ReefDotNet.sln b/lang/cs/ReefDotNet.sln
new file mode 100644
index 0000000..bbd2250
--- /dev/null
+++ b/lang/cs/ReefDotNet.sln
@@ -0,0 +1,161 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{2B7EE9D5-CA54-4204-B89D-B48A7FC6E3CD}"
+	ProjectSection(SolutionItems) = preProject
+		.nuget\NuGet.Config = .nuget\NuGet.Config
+		.nuget\NuGet.exe = .nuget\NuGet.exe
+		.nuget\NuGet.targets = .nuget\NuGet.targets
+	EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utilities", "Source\Utilities\Utilities.csproj", "{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wake", "Source\WAKE\Wake\Wake.csproj", "{CDFB3464-4041-42B1-9271-83AF24CD5008}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tang", "Source\TANG\Tang\Tang.csproj", "{97DBB573-3994-417A-9F69-FFA25F00D2A6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Source\TANG\Examples\Examples.csproj", "{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReefCommon", "Source\REEF\reef-common\ReefCommon\ReefCommon.csproj", "{545A0582-4105-44CE-B99C-B1379514A630}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReefDriver", "Source\REEF\reef-common\ReefDriver\ReefDriver.csproj", "{A6BAA2A7-F52F-4329-884E-1BCF711D6805}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Network", "Source\REEF\reef-io\Network\Network.csproj", "{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasks", "Source\REEF\reef-tasks\Tasks\Tasks.csproj", "{75503F90-7B82-4762-9997-94B5C68F15DB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CLRBridgeClient", "Source\REEF\reef-applications\CLRBridgeClient\CLRBridgeClient.csproj", "{5094C35B-4FDB-4322-AC05-45D684501CBF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evaluator", "Source\REEF\reef-applications\Evaluator\Evaluator.csproj", "{1B983182-9C30-464C-948D-F87EB93A8240}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloCLRBridge", "Source\REEF\reef-examples\HelloCLRBridge\HelloCLRBridge.csproj", "{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RetainedEvalCLRBridge", "Source\REEF\reef-examples\RetainedEvalCLRBridge\RetainedEvalCLRBridge.csproj", "{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassHierarchyBuilder", "Source\Tools\ClassHierarchyBuilder\ClassHierarchyBuilder.csproj", "{34A9CD98-0D15-4CA0-AEA5-E53593A31047}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReefAll", "Source\Tools\ReefAll\ReefAll.csproj", "{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TangTests", "Tests\TangTests\TangTests.csproj", "{D5EB94D0-3ABA-4853-9050-E36B196E17D2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WakeTests", "Tests\WakeTests\WakeTests.csproj", "{214C64C6-04E5-4867-B69A-E3502EA50871}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReefTests", "Tests\ReefTests\ReefTests.csproj", "{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|x64 = Debug|x64
+		Release|Any CPU = Release|Any CPU
+		Release|x64 = Release|x64
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}.Release|Any CPU.Build.0 = Release|Any CPU
+		{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}.Release|x64.ActiveCfg = Release|Any CPU
+		{CDFB3464-4041-42B1-9271-83AF24CD5008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CDFB3464-4041-42B1-9271-83AF24CD5008}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CDFB3464-4041-42B1-9271-83AF24CD5008}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{CDFB3464-4041-42B1-9271-83AF24CD5008}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CDFB3464-4041-42B1-9271-83AF24CD5008}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CDFB3464-4041-42B1-9271-83AF24CD5008}.Release|x64.ActiveCfg = Release|Any CPU
+		{97DBB573-3994-417A-9F69-FFA25F00D2A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{97DBB573-3994-417A-9F69-FFA25F00D2A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{97DBB573-3994-417A-9F69-FFA25F00D2A6}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{97DBB573-3994-417A-9F69-FFA25F00D2A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{97DBB573-3994-417A-9F69-FFA25F00D2A6}.Release|Any CPU.Build.0 = Release|Any CPU
+		{97DBB573-3994-417A-9F69-FFA25F00D2A6}.Release|x64.ActiveCfg = Release|Any CPU
+		{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}.Release|Any CPU.Build.0 = Release|Any CPU
+		{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}.Release|x64.ActiveCfg = Release|Any CPU
+		{545A0582-4105-44CE-B99C-B1379514A630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{545A0582-4105-44CE-B99C-B1379514A630}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{545A0582-4105-44CE-B99C-B1379514A630}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{545A0582-4105-44CE-B99C-B1379514A630}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{545A0582-4105-44CE-B99C-B1379514A630}.Release|Any CPU.Build.0 = Release|Any CPU
+		{545A0582-4105-44CE-B99C-B1379514A630}.Release|x64.ActiveCfg = Release|Any CPU
+		{A6BAA2A7-F52F-4329-884E-1BCF711D6805}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{A6BAA2A7-F52F-4329-884E-1BCF711D6805}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{A6BAA2A7-F52F-4329-884E-1BCF711D6805}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{A6BAA2A7-F52F-4329-884E-1BCF711D6805}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{A6BAA2A7-F52F-4329-884E-1BCF711D6805}.Release|Any CPU.Build.0 = Release|Any CPU
+		{A6BAA2A7-F52F-4329-884E-1BCF711D6805}.Release|x64.ActiveCfg = Release|Any CPU
+		{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}.Release|x64.ActiveCfg = Release|Any CPU
+		{75503F90-7B82-4762-9997-94B5C68F15DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{75503F90-7B82-4762-9997-94B5C68F15DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{75503F90-7B82-4762-9997-94B5C68F15DB}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{75503F90-7B82-4762-9997-94B5C68F15DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{75503F90-7B82-4762-9997-94B5C68F15DB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{75503F90-7B82-4762-9997-94B5C68F15DB}.Release|x64.ActiveCfg = Release|Any CPU
+		{5094C35B-4FDB-4322-AC05-45D684501CBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5094C35B-4FDB-4322-AC05-45D684501CBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5094C35B-4FDB-4322-AC05-45D684501CBF}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{5094C35B-4FDB-4322-AC05-45D684501CBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5094C35B-4FDB-4322-AC05-45D684501CBF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5094C35B-4FDB-4322-AC05-45D684501CBF}.Release|x64.ActiveCfg = Release|Any CPU
+		{1B983182-9C30-464C-948D-F87EB93A8240}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1B983182-9C30-464C-948D-F87EB93A8240}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1B983182-9C30-464C-948D-F87EB93A8240}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{1B983182-9C30-464C-948D-F87EB93A8240}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1B983182-9C30-464C-948D-F87EB93A8240}.Release|Any CPU.Build.0 = Release|Any CPU
+		{1B983182-9C30-464C-948D-F87EB93A8240}.Release|x64.ActiveCfg = Release|Any CPU
+		{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}.Release|x64.ActiveCfg = Release|Any CPU
+		{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}.Release|Any CPU.Build.0 = Release|Any CPU
+		{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}.Release|x64.ActiveCfg = Release|Any CPU
+		{34A9CD98-0D15-4CA0-AEA5-E53593A31047}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{34A9CD98-0D15-4CA0-AEA5-E53593A31047}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{34A9CD98-0D15-4CA0-AEA5-E53593A31047}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{34A9CD98-0D15-4CA0-AEA5-E53593A31047}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{34A9CD98-0D15-4CA0-AEA5-E53593A31047}.Release|Any CPU.Build.0 = Release|Any CPU
+		{34A9CD98-0D15-4CA0-AEA5-E53593A31047}.Release|x64.ActiveCfg = Release|Any CPU
+		{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}.Release|x64.ActiveCfg = Release|Any CPU
+		{D5EB94D0-3ABA-4853-9050-E36B196E17D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D5EB94D0-3ABA-4853-9050-E36B196E17D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D5EB94D0-3ABA-4853-9050-E36B196E17D2}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{D5EB94D0-3ABA-4853-9050-E36B196E17D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D5EB94D0-3ABA-4853-9050-E36B196E17D2}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D5EB94D0-3ABA-4853-9050-E36B196E17D2}.Release|x64.ActiveCfg = Release|Any CPU
+		{214C64C6-04E5-4867-B69A-E3502EA50871}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{214C64C6-04E5-4867-B69A-E3502EA50871}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{214C64C6-04E5-4867-B69A-E3502EA50871}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{214C64C6-04E5-4867-B69A-E3502EA50871}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{214C64C6-04E5-4867-B69A-E3502EA50871}.Release|Any CPU.Build.0 = Release|Any CPU
+		{214C64C6-04E5-4867-B69A-E3502EA50871}.Release|x64.ActiveCfg = Release|Any CPU
+		{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}.Release|x64.ActiveCfg = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.cs b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.cs
new file mode 100644
index 0000000..51023e7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.cs
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Examples.HelloCLRBridge;
+using Org.Apache.Reef.Examples.HelloCLRBridge.Handlers;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace Org.Apache.Reef.CLRBridgeClient
+{
+    public class CLRBridgeClient
+    {
+        public const string ReefHome = "REEF_HOME";
+        public const string DefaultClrFolder = @"lang\java\reef-bridge-project\reef-bridge\dotnetHello";
+        public const string DefaultReefJar = @"lang\java\reef-bridge-project\reef-bridge\target\" + Constants.BridgeJarFileName;
+        public const string DefaultRunCommand = "run.cmd";
+
+        private static string _clrFolder = null;
+        private static string _reefJar = null;
+        private static string _className = Constants.BridgeLaunchClass;
+        private static string _runCommand = DefaultRunCommand;
+        private static string _submitControlForAllocatedEvaluator = "submitContextAndTask"; // submitContext, submitContextAndTask, submitContextAndServiceAndTask
+
+        public static HashSet<string> AppDll
+        {
+            get
+            {
+                HashSet<string> appDlls = new HashSet<string>();
+                appDlls.Add(typeof(HelloStartHandler).Assembly.GetName().Name);
+                appDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+                appDlls.Add(typeof(INameServer).Assembly.GetName().Name);
+                return appDlls;
+            }
+        }
+
+        public static IConfiguration ClrConfigurations
+        {
+            get
+            {
+                return DriverBridgeConfiguration.ConfigurationModule
+                .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<HelloStartHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<HelloAllocatedEvaluatorHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<AnotherHelloAllocatedEvaluatorHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnContextActive, GenericType<HelloActiveContextHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskMessage, GenericType<HelloTaskMessageHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorFailed, GenericType<HelloFailedEvaluatorHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskFailed, GenericType<HelloFailedTaskHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskRunning, GenericType<HelloRunningTaskHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorRequested, GenericType<HelloEvaluatorRequestorHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnHttpEvent, GenericType<HelloHttpHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorCompleted, GenericType<HelloCompletedEvaluatorHandler>.Class)
+                .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class)
+                .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString())
+                .Set(DriverBridgeConfiguration.CommandLineArguments, _submitControlForAllocatedEvaluator) // this is for testing purpose only
+                .Set(DriverBridgeConfiguration.OnDriverRestarted, GenericType<HelloRestartHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnDriverReconnect, GenericType<DefaultLocalHttpDriverConnection>.Class)
+                .Set(DriverBridgeConfiguration.OnDirverRestartContextActive, GenericType<HelloDriverRestartActiveContextHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnDriverRestartTaskRunning, GenericType<HelloDriverRestartRunningTaskHandler>.Class)
+                .Build();
+            }
+        }
+
+        public static void Main(string[] args)
+        {
+            Console.WriteLine("start running client: " + DateTime.Now);
+            bool runOnYarn = false;
+            if (args != null)
+            {
+                if (args.Length > 0)
+                {
+                    runOnYarn = bool.Parse(args[0]);
+                }
+
+                if (args.Length > 1)
+                {
+                    _className = args[1];
+                }
+                if (args.Length > 2)
+                {
+                    _clrFolder = args[2];
+                }
+                if (args.Length > 3)
+                {
+                    _reefJar = args[3];
+                }
+                if (args.Length > 4)
+                {
+                    _runCommand = args[4];
+                }
+            }
+
+            if (string.IsNullOrWhiteSpace(_reefJar))
+            {
+                _reefJar = Path.Combine(Environment.GetEnvironmentVariable(ReefHome), DefaultReefJar);
+            }
+
+            if (string.IsNullOrWhiteSpace(_clrFolder))
+            {
+                _clrFolder = Path.Combine(Environment.GetEnvironmentVariable(ReefHome), DefaultClrFolder);
+            }
+
+            // Configurable driver submission settings:
+            // DriverMemory, default to 512
+            // DriverIdentifer, default to "ReefClrBridge" 
+            // Submit, default to True. Setting it to false and Java client will construct the driver.config and write to to FS without submitting the job
+            // ClientWaitTime, default to -1 which means client will wait till Driver is done
+            // SubmissionDirectory, default to a tmp folder on (H)DFS according to the YARN assigned application id, if user sets it, it must be guaranteed to be unique across multiple jobs
+            // RunOnYarn, default to false to run on local runtime.
+            // UpdateJarBeforeSubmission, default to true. Setting it to false can reduce startup time, but only if the jar file already contains all application dlls.
+            // JavaLogLevel, default to INFO. 
+            DriverSubmissionSettings driverSubmissionSettings = new DriverSubmissionSettings()
+                                                                    {
+                                                                        RunOnYarn = runOnYarn,
+                                                                        SubmissionDirectory = "reefClrBridgeTmp/job_" + Guid.NewGuid().ToString("N").Substring(0, 8)
+                                                                    };
+
+            Console.WriteLine("start calling Run: " + DateTime.Now);
+            ClrClientHelper.Run(AppDll, ClrConfigurations, driverSubmissionSettings, _reefJar, _runCommand, _clrFolder, _className);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.csproj b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.csproj
new file mode 100644
index 0000000..0f333d3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/CLRBridgeClient.csproj
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{5094C35B-4FDB-4322-AC05-45D684501CBF}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.CLRBridgeClient</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.CLRBridgeClient</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.CLRBridgeClient\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.CLRBridgeClient\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CLRBridgeClient.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="run.cmd" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-examples\HelloCLRBridge\HelloCLRBridge.csproj">
+      <Project>{a78dd8e8-31d0-4506-8738-daa9da86d55b}</Project>
+      <Name>HelloCLRBridge</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-examples\RetainedEvalCLRBridge\RetainedEvalCLRBridge.csproj">
+      <Project>{a33c20fb-a76e-494c-80c5-bce4bad876d3}</Project>
+      <Name>RetainedEvalCLRBridge</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-io\NetWork\NetWork.csproj">
+      <Project>{883ce800-6a6a-4e0a-b7fe-c054f4f2c1dc}</Project>
+      <Name>NetWork</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-tasks\Tasks\Tasks.csproj">
+      <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+      <Name>Tasks</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0cfd271
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CLRBridgeClient")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CLRBridgeClient")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8717944c-5e99-4f95-a916-5ca3c3f8e697")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/run.cmd
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/run.cmd b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/run.cmd
new file mode 100644
index 0000000..3dca837
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/CLRBridgeClient/run.cmd
@@ -0,0 +1,45 @@
+@REM
+@REM Copyright (C) 2013 Microsoft Corporation
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM         http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+::
+:: Copyright (C) 2013 Microsoft Corporation
+::
+:: 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.
+::
+
+
+:: RUNTIME
+set SHADED_JAR=%REEF_HOME%\lang\java\reef-bridge-project\reef-bridge\target\reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar
+
+set LOGGING_CONFIG=-Djava.util.logging.config.class=org.apache.reef.util.logging.CLRLoggingConfig
+
+set CLASSPATH=%HADOOP_HOME%\share\hadoop\hdfs\lib\*;%HADOOP_HOME%\share\hadoop\hdfs\*;%HADOOP_HOME%\share\hadoop\common\*;%HADOOP_HOME%\share\hadoop\common\lib\*;%HADOOP_HOME%\share\hadoop\mapreduce\lib\*;%HADOOP_HOME%\share\hadoop\mapreduce\*;%HADOOP_HOME%\share\hadoop\yarn\*;%HADOOP_HOME%\share\hadoop\yarn\lib\*
+
+set CMD=%JAVA_HOME%\bin\java.exe -cp %HADOOP_HOME%\etc\hadoop;%SHADED_JAR%;%CLASSPATH% %LOGGING_CONFIG% %*
+::%LOGGING_CONFIG%
+echo %CMD%
+%CMD%


[23/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfigurationOptions.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfigurationOptions.cs
new file mode 100644
index 0000000..73b1475
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfigurationOptions.cs
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "allow name parameter class to be embedded")]
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    /// <summary>
+    /// Hosts all named parameters for Drivers, including bridge handlers.
+    /// </summary>
+    public class DriverBridgeConfigurationOptions
+    {
+        // Level.Verbose (since enum is not suppoted for TANG, we use a string here)
+        private const string _verboseLevel = "Verbose";
+
+        [NamedParameter(documentation: "Called when driver is restarted, after CLR bridge is set up.", defaultClasses: new[] { typeof(DefaultDriverRestartHandler) })]
+        public class DriverRestartHandler : Name<IObserver<StartTime>>
+        {
+        }
+
+        [NamedParameter(documentation: "Called when evaluator is requested.", defaultClasses: new[] { typeof(DefaultEvaluatorRequestorHandler) })] 
+        public class EvaluatorRequestHandlers : Name<ISet<IObserver<IEvaluatorRequestor>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Called when an exception occurs on a running evaluator.", defaultClasses: new[] { typeof(DefaultEvaluatorFailureHandler) })]
+        public class FailedEvaluatorHandlers : Name<ISet<IObserver<IFailedEvaluator>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Called when an evaluator completes.", defaultClasses: new[] { typeof(DefaultEvaluatorCompletionHandler) })]
+        public class CompletedEvaluatorHandlers : Name<ISet<IObserver<ICompletedEvaluator>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Called when an allocated evaluator is given to the client.", defaultClasses: new[] { typeof(DefaultEvaluatorAllocationHandler) })]
+        public class AllocatedEvaluatorHandlers : Name<ISet<IObserver<IAllocatedEvaluator>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Running task handler.", defaultClasses: new[] { typeof(DefaultTaskRunningHandler) })]
+        public class RunningTaskHandlers : Name<ISet<IObserver<IRunningTask>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Running task during driver restart handler.", defaultClasses: new[] { typeof(DefaultDriverRestartTaskRunningHandler) })]
+        public class DriverRestartRunningTaskHandlers : Name<ISet<IObserver<IRunningTask>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Task exception handler.", defaultClasses: new[] { typeof(DefaultTaskFailureHandler) })]
+        public class FailedTaskHandlers : Name<ISet<IObserver<IFailedTask>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Task message handler.", defaultClasses: new[] { typeof(DefaultTaskMessageHandler) })]
+        public class TaskMessageHandlers : Name<ISet<IObserver<ITaskMessage>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Http Event Handlers.", defaultClasses: new[] { typeof(DefaultHttpHandler) })]
+        public class HttpEventHandlers : Name<ISet<IHttpHandler>>
+        {
+        }
+
+        [NamedParameter(documentation: "Completed task handler.", defaultClasses: new[] { typeof(DefaultTaskCompletionHandler) })]
+        public class CompletedTaskHandlers : Name<ISet<IObserver<ICompletedTask>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Suspended task handler.", defaultClasses: new[] { typeof(DefaultTaskSuspensionHandler) })]
+        public class SuspendedTaskHandlers : Name<ISet<IObserver<ISuspendedTask>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Handler for IActiveContext.", defaultClasses: new[] { typeof(DefaultContextActiveHandler) })]
+        public class ActiveContextHandlers : Name<ISet<IObserver<IActiveContext>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Handler for IActiveContext received during driver restart.", defaultClasses: new[] { typeof(DefaultDriverRestartContextActiveHandler) })]
+        public class DriverRestartActiveContextHandlers : Name<ISet<IObserver<IActiveContext>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Handler for ClosedContext.", defaultClasses: new[] { typeof(DefaultContextClosureHandler) })]
+        public class ClosedContextHandlers : Name<ISet<IObserver<IClosedContext>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Handler for FailedContext.", defaultClasses: new[] { typeof(DefaultContextFailureHandler) })]
+        public class FailedContextHandlers : Name<ISet<IObserver<IFailedContext>>>
+        {
+        }
+
+        [NamedParameter(documentation: "Handler for ContextMessage.", defaultClasses: new[] { typeof(DefaultContextMessageHandler) })]
+        public class ContextMessageHandlers : Name<ISet<IObserver<IContextMessage>>>
+        {
+        }
+
+        [NamedParameter("Command Line Arguments supplied by client", "CommandLineArguments", null)]
+        public class ArgumentSets : Name<ISet<string>>
+        {
+        }
+
+        [NamedParameter("Additional trace listners supplied by client", "TraceListeners", null, defaultClasses: new[] { typeof(DefaultCustomTraceListener) })]
+        public class TraceListenersSet : Name<ISet<TraceListener>>
+        {
+        }
+
+        [NamedParameter("Custom Trace Level", "TraceLevel", defaultValue: _verboseLevel)]
+        public class TraceLevel : Name<string>
+        {
+        }
+
+        //[NamedParameter(documentation: "Job message handler.", defaultClasses: new[] { typeof(DefaultClientMessageHandler) })]
+        //public class ClientMessageHandlers : Name<ISet<IObserver<byte[]>>>
+        //{
+        //}
+
+        //[NamedParameter(documentation: "Client close handler.", defaultClasses: new[] { typeof(DefaultClientCloseHandler) })]
+        //public class ClientCloseHandlers : Name<ISet<IObserver<byte[]>>>
+        //{
+        //}
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpMessage.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpMessage.cs
new file mode 100644
index 0000000..bf10b5f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpMessage.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    public class HttpMessage : IHttpMessage
+    {
+        public HttpMessage(IHttpServerBridgeClr2Java httpServerBridgeClr2Java)
+        {
+            HttpServerBridgeClr2Java = httpServerBridgeClr2Java;
+        }
+
+        [DataMember]
+        private IHttpServerBridgeClr2Java HttpServerBridgeClr2Java { get; set; }
+
+        public string GetRequestString()
+        {
+            return HttpServerBridgeClr2Java.GetQueryString();
+        }
+
+        public void SetQueryResult(string responseString)
+        {
+            HttpServerBridgeClr2Java.SetQueryResult(responseString);
+        }
+
+        public byte[] GetQueryReuestData()
+        {
+            return HttpServerBridgeClr2Java.GetQueryRequestData();            
+        }
+
+        public void SetQueryResponseData(byte[] responseData)
+        {
+            HttpServerBridgeClr2Java.SetQueryResponseData(responseData);
+        }
+
+        public void SetUriSpecification(string uriSpecification)
+        {
+            HttpServerBridgeClr2Java.SetUriSpecification(uriSpecification);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerHandler.cs
new file mode 100644
index 0000000..0609fb6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerHandler.cs
@@ -0,0 +1,165 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Avro;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    /// <summary>
+    ///  HttpServerHandler, the handler for all CLR http events
+    /// </summary>
+    public class HttpServerHandler : IObserver<IHttpMessage>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(HttpServerHandler));
+
+        private static readonly string SPEC = "SPEC";
+
+        private IDictionary<string, IHttpHandler> eventHandlers = new Dictionary<string, IHttpHandler>();
+
+        private HttpServerPort httpServerPort;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="HttpServerHandler" /> class.
+        /// </summary>
+        /// <param name="httpEventHandlers">The HTTP event handlers.</param>
+        /// <param name="httpServerPort">The HTTP server port.</param>
+        [Inject]
+        public HttpServerHandler([Parameter(Value = typeof(DriverBridgeConfigurationOptions.HttpEventHandlers))] ISet<IHttpHandler> httpEventHandlers,
+                                 HttpServerPort httpServerPort)
+        {
+            LOGGER.Log(Level.Info, "Constructing HttpServerHandler");       
+            foreach (var h in httpEventHandlers)
+            {
+                string spec = h.GetSpecification();
+                if (spec.Contains(":"))
+                {
+                    Exceptions.Throw(new ArgumentException("spec cannot contain :"), "The http spec given is " + spec, LOGGER);
+                }
+                LOGGER.Log(Level.Info, "HttpHandler spec:" + spec);   
+                eventHandlers.Add(spec.ToLower(CultureInfo.CurrentCulture), h);
+            }
+            this.httpServerPort = httpServerPort;
+        }
+
+        /// <summary>
+        /// Called when receving an http request from Java side
+        /// </summary>
+        /// <param name="httpMessage">The HTTP message.</param>
+        public void OnNext(IHttpMessage httpMessage)
+        {
+            LOGGER.Log(Level.Info, "HttpHandler OnNext is called");
+            string requestString = httpMessage.GetRequestString();
+
+            if (requestString != null && requestString.Equals(SPEC))
+            {
+                LOGGER.Log(Level.Info, "HttpHandler OnNext, requestString:" + requestString);
+                LOGGER.Log(Level.Info, "HttpHandler OnNext, port number:" + httpServerPort.PortNumber);
+
+                httpMessage.SetUriSpecification(GetAllSpecifications());
+            }
+            else
+            {
+                LOGGER.Log(Level.Info, "HttpHandler OnNext, handling http request.");
+                byte[] byteData = httpMessage.GetQueryReuestData();                    
+                AvroHttpRequest avroHttpRequest = AvroHttpSerializer.FromBytes(byteData);
+                LOGGER.Log(Level.Info, "HttpHandler OnNext, requestData:" + avroHttpRequest);
+
+                string spec = GetSpecification(avroHttpRequest.PathInfo);
+                if (spec != null)
+                {
+                    LOGGER.Log(Level.Info, "HttpHandler OnNext, target:" + spec);
+                    ReefHttpRequest request = ToHttpRequest(avroHttpRequest);
+                    ReefHttpResponse response = new ReefHttpResponse();
+
+                    IHttpHandler handler;
+                    eventHandlers.TryGetValue(spec.ToLower(CultureInfo.CurrentCulture), out handler);
+
+                    byte[] responseData;
+                    if (handler != null)
+                    {
+                        LOGGER.Log(Level.Info, "HttpHandler OnNext, get eventHandler:" + handler.GetSpecification());
+                        handler.OnHttpRequest(request, response);
+                        responseData = response.OutputStream;
+                    }
+                    else
+                    {
+                        responseData =
+                            ByteUtilities.StringToByteArrays(string.Format(CultureInfo.CurrentCulture,
+                                                                           "No event handler found at CLR side for {0}.",
+                                                                           spec));
+                    }
+                    httpMessage.SetQueryResponseData(responseData);
+                }
+            }
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        private string GetAllSpecifications()
+        {
+            return string.Join(":", eventHandlers.Keys.ToArray());
+        }
+
+        private string GetSpecification(string requestUri)
+        {
+            if (requestUri != null)
+            {
+                string[] parts = requestUri.Split('/');
+
+                if (parts.Length > 1)
+                {
+                    return parts[1];
+                }
+            }
+            return null;            
+        }
+
+        private ReefHttpRequest ToHttpRequest(AvroHttpRequest avroRequest)
+        {
+            ReefHttpRequest httpRequest = new ReefHttpRequest();
+            httpRequest.PathInfo = avroRequest.PathInfo;
+            httpRequest.InputStream = avroRequest.InputStream;
+            httpRequest.Url = avroRequest.RequestUrl;
+            httpRequest.Querystring = avroRequest.QueryString;
+
+            HttpMethod m;
+            HttpMethod.TryParse(avroRequest.HttpMethod, true, out m);
+            httpRequest.Method = m;
+            return httpRequest;
+        }    
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerPort.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerPort.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerPort.cs
new file mode 100644
index 0000000..af001e2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/HttpServerPort.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Driver.bridge
+{
+    public class HttpServerPort
+    {
+        [Inject]
+        public HttpServerPort()
+        {            
+        }
+
+        public int PortNumber { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpHandler.cs
new file mode 100644
index 0000000..4bd5895
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpHandler.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public interface IHttpHandler
+    {
+        /// <summary>
+        /// Define the specification of the handler. ":" is not allowed in the specification.
+        /// </summary>
+        /// <returns>string specification</returns>
+        string GetSpecification();
+
+        /// <summary>
+        /// Called when Http request is sent
+        /// </summary>
+        /// <param name="requet">The requet.</param>
+        /// <param name="resonse">The resonse.</param>
+        void OnHttpRequest(ReefHttpRequest requet, ReefHttpResponse resonse);  
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpMessage.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpMessage.cs
new file mode 100644
index 0000000..59e66a6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/IHttpMessage.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface IHttpMessage
+    {
+        string GetRequestString();
+        
+        void SetQueryResult(string responseString);
+
+        byte[] GetQueryReuestData();
+
+        void SetQueryResponseData(byte[] responseData);
+        
+        void SetUriSpecification(string uriSpecification);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpRequest.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpRequest.cs
new file mode 100644
index 0000000..ccc9571
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpRequest.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public enum HttpMethod
+    {
+        Post,
+        Put,
+        Get,
+        Delete
+    }
+
+    public class ReefHttpRequest
+    {
+        public HttpMethod Method { get; set; }
+
+        public string Url { get; set; }
+
+        public string Querystring { get; set; }
+
+        public byte[] InputStream { get; set; }
+
+        public string PathInfo { get; set; }
+
+        public string Tostring()
+        {
+            return string.Format(CultureInfo.InvariantCulture, "Url: {0}, query string {1}", Url, Querystring);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpResponse.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpResponse.cs
new file mode 100644
index 0000000..4eb3e6f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ReefHttpResponse.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Net;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class ReefHttpResponse
+    {
+        public byte[] OutputStream { get; set; }
+
+        public HttpStatusCode Status { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IActiveContextClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IActiveContextClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IActiveContextClr2Java.cs
new file mode 100644
index 0000000..a61d639
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IActiveContextClr2Java.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public interface IActiveContextClr2Java : IClr2Java
+    {
+        void SubmitTask(string taskConfigStr);
+        
+        void Close();
+
+        string GetId();
+
+        string GetEvaluatorId();
+
+        IEvaluatorDescriptor GetEvaluatorDescriptor();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IAllocatedEvaluaotrClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IAllocatedEvaluaotrClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IAllocatedEvaluaotrClr2Java.cs
new file mode 100644
index 0000000..01f14e1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IAllocatedEvaluaotrClr2Java.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public interface IAllocatedEvaluaotrClr2Java : IClr2Java
+    {
+        void SubmitContextAndTask(string contextConfigStr, string taskConfigStr);
+
+        void SubmitContext(string contextConfigStr);
+
+        void SubmitContextAndService(string contextConfigStr, string serviceConfigStr);
+
+        void SubmitContextAndServiceAndTask(string contextConfigStr, string serviceConfigStr, string taskConfigStr);
+
+        void Close();
+
+        string GetId();
+
+        string GetNameServerInfo();
+
+        IEvaluatorDescriptor GetEvaluatorDescriptor();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClosedContextClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClosedContextClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClosedContextClr2Java.cs
new file mode 100644
index 0000000..ed45211
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClosedContextClr2Java.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public interface IClosedContextClr2Java : IClr2Java
+    {        
+        string GetId();
+
+        string GetEvaluatorId();
+
+        IEvaluatorDescriptor GetEvaluatorDescriptor();
+
+        IActiveContextClr2Java GetParentContext();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClr2Java.cs
new file mode 100644
index 0000000..3f6c5c5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IClr2Java.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface IClr2Java
+    {
+        void OnError(string message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedEvaluatorClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedEvaluatorClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedEvaluatorClr2Java.cs
new file mode 100644
index 0000000..3a27723
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedEvaluatorClr2Java.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface ICompletedEvaluatorClr2Java : IClr2Java
+    {
+        /// <summary>
+        /// evaluator id
+        /// </summary>
+        /// <returns>id of the completed evaluator</returns>
+        string GetId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedTaskClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedTaskClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedTaskClr2Java.cs
new file mode 100644
index 0000000..a69789b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ICompletedTaskClr2Java.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface ICompletedTaskClr2Java : IClr2Java
+    {
+        IActiveContextClr2Java GetActiveContext();
+        
+        string GetId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IContextMessageClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IContextMessageClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IContextMessageClr2Java.cs
new file mode 100644
index 0000000..f50dca3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IContextMessageClr2Java.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface IContextMessageClr2Java : IClr2Java
+    {
+        byte[] Get();
+
+        string GetId();
+
+        string GetMessageSourceId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IEvaluatorRequestorClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IEvaluatorRequestorClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IEvaluatorRequestorClr2Java.cs
new file mode 100644
index 0000000..b1ee4d1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IEvaluatorRequestorClr2Java.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public interface IEvaluatorRequestorClr2Java : IClr2Java
+    {
+        void Submit(IEvaluatorRequest evaluatorRequest);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedContextClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedContextClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedContextClr2Java.cs
new file mode 100644
index 0000000..cd9a157
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedContextClr2Java.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public interface IFailedContextClr2Java : IClr2Java
+    {        
+        string GetId();
+
+        string GetEvaluatorId();
+
+        string GetParentId();
+
+        IEvaluatorDescriptor GetEvaluatorDescriptor();
+
+        IActiveContextClr2Java GetParentContext();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedEvaluatorClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedEvaluatorClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedEvaluatorClr2Java.cs
new file mode 100644
index 0000000..33bb4a4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedEvaluatorClr2Java.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+
+namespace Org.Apache.Reef.Driver
+{
+    public interface IFailedEvaluatorClr2Java
+    {
+        IEvaluatorRequestorClr2Java GetEvaluatorRequestor();
+
+        string GetId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedTaskClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedTaskClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedTaskClr2Java.cs
new file mode 100644
index 0000000..70dc34e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IFailedTaskClr2Java.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface IFailedTaskClr2Java : IClr2Java
+    {
+        IActiveContextClr2Java GetActiveContext();
+
+        string GetString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IHttpServerBridgeClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IHttpServerBridgeClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IHttpServerBridgeClr2Java.cs
new file mode 100644
index 0000000..c30e3b4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IHttpServerBridgeClr2Java.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface IHttpServerBridgeClr2Java : IClr2Java
+    {
+        string GetQueryString();
+
+        void SetQueryResult(string queryResult);
+
+        byte[] GetQueryRequestData();
+
+        void SetQueryResponseData(byte[] responseData);
+
+        void SetUriSpecification(string uriSpecification);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IRunningTaskClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IRunningTaskClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IRunningTaskClr2Java.cs
new file mode 100644
index 0000000..eb95c31
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/IRunningTaskClr2Java.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface IRunningTaskClr2Java : IClr2Java
+    {
+        IActiveContextClr2Java GetActiveContext();
+
+        string GetId();
+
+        void Send(byte[] message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ISuspendedTaskClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ISuspendedTaskClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ISuspendedTaskClr2Java.cs
new file mode 100644
index 0000000..be04fd3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ISuspendedTaskClr2Java.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface ISuspendedTaskClr2Java : IClr2Java
+    {
+        /// <summary>
+        /// get active context the task is running in
+        /// </summary>
+        /// <returns>active context</returns>
+        IActiveContextClr2Java GetActiveContext();
+
+        /// <summary>
+        /// get suspsended task id
+        /// </summary>
+        /// <returns>suspsended task id</returns>
+        string GetId();
+
+        /// <summary>
+        /// get the message
+        /// </summary>
+        /// <returns>suspended task message</returns>
+        byte[] Get();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ITaskMessageClr2Java.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ITaskMessageClr2Java.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ITaskMessageClr2Java.cs
new file mode 100644
index 0000000..c364587
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/clr2java/ITaskMessageClr2Java.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Bridge
+{
+    public interface ITaskMessageClr2Java : IClr2Java
+    {
+        string GetId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ActiveContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ActiveContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ActiveContext.cs
new file mode 100644
index 0000000..fd7f826
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ActiveContext.cs
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class ActiveContext : IActiveContext
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ActiveContext));
+
+        private readonly AvroConfigurationSerializer _serializer;
+
+        public ActiveContext(IActiveContextClr2Java clr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            Clr2Java = clr2Java;
+            _serializer = new AvroConfigurationSerializer();
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public string Id
+        {
+            get
+            {
+                return Clr2Java.GetId();
+            }
+
+            set
+            {
+            }
+        }
+
+        public string EvaluatorId
+        {
+            get
+            {
+                return Clr2Java.GetEvaluatorId();
+            }
+
+            set
+            {
+            }
+        }
+
+        public Optional<string> ParentId { get; set; }
+
+        public IEvaluatorDescriptor EvaluatorDescriptor
+        {
+            get
+            {
+                return Clr2Java.GetEvaluatorDescriptor();
+            }
+
+            set
+            {
+            }
+        }
+
+        private IActiveContextClr2Java Clr2Java { get; set; }
+
+        public void SubmitTask(IConfiguration taskConfiguration)
+        {
+            LOGGER.Log(Level.Info, "ActiveContext::SubmitTask");
+            string task = _serializer.ToString(taskConfiguration);
+            LOGGER.Log(Level.Info, "serialized taskConfiguration: " + task);
+            Clr2Java.SubmitTask(task);
+        }
+
+        public void Dispose()
+        {
+            LOGGER.Log(Level.Info, "ActiveContext::Dispose");
+            Clr2Java.Close();
+        }
+
+        public void SubmitContext(IConfiguration contextConfiguration)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void SubmitContextAndService(IConfiguration contextConfiguration, IConfiguration serviceConfiguration)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void SendMessage(byte[] message)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/AllocatedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/AllocatedEvaluator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/AllocatedEvaluator.cs
new file mode 100644
index 0000000..8ef9928
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/AllocatedEvaluator.cs
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Net;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class AllocatedEvaluator : IAllocatedEvaluator
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(AllocatedEvaluator));
+        
+        private readonly AvroConfigurationSerializer _serializer;
+
+        private IEvaluatorDescriptor _evaluatorDescriptor;
+
+        public AllocatedEvaluator(IAllocatedEvaluaotrClr2Java clr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            _serializer = new AvroConfigurationSerializer();
+            Clr2Java = clr2Java;
+            Id = Clr2Java.GetId();
+            ProcessNewEvaluator();
+
+            NameServerInfo = Clr2Java.GetNameServerInfo();
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public string Id { get; set; }
+
+        public string EvaluatorBatchId { get; set; }
+
+        public EvaluatorType Type { get; set; }
+
+        public string NameServerInfo { get; set; }
+
+        [DataMember]
+        private IAllocatedEvaluaotrClr2Java Clr2Java { get; set; }
+
+        public void SubmitContext(IConfiguration contextConfiguration)
+        {
+            LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContext");
+            string context = _serializer.ToString(contextConfiguration);
+            LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context);
+            Clr2Java.SubmitContext(context);
+        }
+
+        public void SubmitContextAndTask(IConfiguration contextConfiguration, IConfiguration taskConfiguration)
+        {
+            LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContextAndTask");
+
+            string context = _serializer.ToString(contextConfiguration);
+            string task = _serializer.ToString(taskConfiguration);
+
+            LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context);
+            LOGGER.Log(Level.Info, "serialized taskConfiguration: " + task);
+
+            Clr2Java.SubmitContextAndTask(context, task);
+        }
+
+        public void SubmitContextAndService(IConfiguration contextConfiguration, IConfiguration serviceConfiguration)
+        {
+            LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContextAndService");
+
+            string context = _serializer.ToString(contextConfiguration);
+            string service = _serializer.ToString(serviceConfiguration);
+
+            LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context);
+            LOGGER.Log(Level.Info, "serialized serviceConfiguration: " + service);
+
+            Clr2Java.SubmitContextAndService(context, service);
+        }
+
+        public void SubmitContextAndServiceAndTask(IConfiguration contextConfiguration, IConfiguration serviceConfiguration, IConfiguration taskConfiguration)
+        {
+            LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContextAndServiceAndTask");
+
+            string context = _serializer.ToString(contextConfiguration);
+            string service = _serializer.ToString(serviceConfiguration);
+            string task = _serializer.ToString(taskConfiguration);
+
+            LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context);
+            LOGGER.Log(Level.Info, "serialized serviceConfiguration: " + service);
+            LOGGER.Log(Level.Info, "serialized taskConfiguration: " + task);
+
+            Clr2Java.SubmitContextAndServiceAndTask(context, service, task);
+        }
+
+        public IEvaluatorDescriptor GetEvaluatorDescriptor()
+        {
+            return _evaluatorDescriptor;
+        }
+
+        public void Dispose()
+        {
+            Clr2Java.Close();
+        }
+
+        public INodeDescriptor GetNodeDescriptor()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void AddFile(string file)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void AddLibrary(string file)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void AddFileResource(string file)
+        {
+            throw new NotImplementedException();
+        }
+
+        private void ProcessNewEvaluator()
+        {
+            _evaluatorDescriptor = Clr2Java.GetEvaluatorDescriptor();
+            lock (EvaluatorRequestor.Evaluators)
+            {
+                foreach (KeyValuePair<string, IEvaluatorDescriptor> pair in EvaluatorRequestor.Evaluators)
+                {
+                    if (pair.Value.Equals(_evaluatorDescriptor))
+                    {
+                        string key = pair.Key;
+                        EvaluatorRequestor.Evaluators.Remove(key);
+                        string assignedId = key.Substring(0, key.LastIndexOf('_'));
+                        string message = string.Format(
+                            CultureInfo.InvariantCulture,
+                            "Received evalautor [{0}] of memory {1}MB that matches request of {2}MB with batch id [{3}].",
+                            Id,
+                            _evaluatorDescriptor.Memory,
+                            pair.Value.Memory,
+                            assignedId);
+
+                        LOGGER.Log(Level.Verbose, message);
+                        EvaluatorBatchId = assignedId;
+                        break;
+                    }
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ClosedContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ClosedContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ClosedContext.cs
new file mode 100644
index 0000000..a643578
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ClosedContext.cs
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities;
+using System;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class ClosedContext : IClosedContext
+    {
+        private string _id;
+
+        private string _evaluatorId;
+
+        public ClosedContext(IClosedContextClr2Java clr2java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            _id = clr2java.GetId();
+            _evaluatorId = clr2java.GetEvaluatorId();
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public string Id
+        {
+            get
+            {
+                return _id;
+            }
+
+            set
+            {
+            }
+        }
+
+        public string EvaluatorId
+        {
+            get
+            {
+                return _evaluatorId;
+            }
+
+            set
+            {
+            }
+        }
+
+        public Optional<string> ParentId { get; set; }
+
+        public IEvaluatorDescriptor EvaluatorDescriptor
+        {
+            get
+            {
+                return ClosedContextClr2JavaClr2Java.GetEvaluatorDescriptor();
+            }
+
+            set
+            {
+            }
+        }
+
+        public IActiveContext ParentContext
+        {
+            get
+            {
+                return new ActiveContext(ParentContextClr2Java);
+            }
+
+            set
+            {
+            }
+        }
+
+        private IActiveContextClr2Java ParentContextClr2Java { get; set; }
+
+        private IClosedContextClr2Java ClosedContextClr2JavaClr2Java { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedEvaluator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedEvaluator.cs
new file mode 100644
index 0000000..0815ee1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedEvaluator.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+using System;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class CompletedEvaluator : ICompletedEvaluator
+    {
+        private string _instanceId;
+
+        public CompletedEvaluator(ICompletedEvaluatorClr2Java clr2Java)
+        {
+            _instanceId = Guid.NewGuid().ToString("N");
+            CompletedEvaluatorClr2Java = clr2Java;
+        }
+
+        [DataMember]
+        public string InstanceId
+        {
+            get { return _instanceId; }
+            set { _instanceId = value; }
+        }
+
+        [DataMember]
+        public string Id
+        {
+            get
+            {
+                return CompletedEvaluatorClr2Java.GetId();
+            }
+
+            set
+            {
+            }
+        }
+
+        [DataMember]
+        public ICompletedEvaluatorClr2Java CompletedEvaluatorClr2Java { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedTask.cs
new file mode 100644
index 0000000..30799db
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/CompletedTask.cs
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class CompletedTask : ICompletedTask
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(CompletedTask));
+
+        internal CompletedTask(ICompletedTaskClr2Java completedTaskClr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            CompletedTaskClr2Java = completedTaskClr2Java;
+            ActiveContextClr2Java = completedTaskClr2Java.GetActiveContext();
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public byte[] Message { get; set; }
+
+        public string Id
+        {
+            get
+            {
+                return CompletedTaskClr2Java.GetId();
+            }
+
+            set
+            {
+            }
+        }
+
+        public IActiveContext ActiveContext
+        {
+            get
+            {
+                return new ActiveContext(ActiveContextClr2Java);
+            }
+
+            set
+            {
+            }
+        }
+
+        [DataMember]
+        private ICompletedTaskClr2Java CompletedTaskClr2Java { get; set; }
+
+        [DataMember]
+        private IActiveContextClr2Java ActiveContextClr2Java { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ContextMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ContextMessage.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ContextMessage.cs
new file mode 100644
index 0000000..890cc77
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/ContextMessage.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class ContextMessage : IContextMessage
+    {
+        private readonly string _messageSourcId;
+        private readonly byte[] _bytes;
+        private readonly string _id;
+
+        public ContextMessage(IContextMessageClr2Java clr2Java)
+        {
+            _messageSourcId = clr2Java.GetMessageSourceId();
+            _bytes = clr2Java.Get();
+            _id = clr2Java.GetId();
+        }
+
+        public string Id
+        {
+            get { return _id; }
+            set { }
+        }
+
+        public string MessageSourceId
+        {
+            get { return _messageSourcId; }
+        }
+
+        public byte[] Message
+        {
+            get { return _bytes; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/EvaluatorRequstor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/EvaluatorRequstor.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/EvaluatorRequstor.cs
new file mode 100644
index 0000000..3f7da32
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/EvaluatorRequstor.cs
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class EvaluatorRequestor : IEvaluatorRequestor
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorRequestor));
+
+        private static Dictionary<string, IEvaluatorDescriptor> _evaluators;
+        
+        public EvaluatorRequestor(IEvaluatorRequestorClr2Java clr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            Clr2Java = clr2Java;
+        }
+
+        public static Dictionary<string, IEvaluatorDescriptor> Evaluators
+        {
+            get
+            {
+                if (_evaluators == null)
+                {
+                    _evaluators = new Dictionary<string, IEvaluatorDescriptor>();
+                }
+                return _evaluators;
+            }
+        }
+
+        public IResourceCatalog ResourceCatalog { get; set; }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        [DataMember]
+        private IEvaluatorRequestorClr2Java Clr2Java { get; set; }
+
+        public void Submit(IEvaluatorRequest request)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submitting request for {0} evaluators and {1} MB memory and  {2} core to rack {3}.", request.Number, request.MemoryMegaBytes, request.VirtualCore, request.Rack));
+
+            lock (Evaluators)
+            {
+                for (int i = 0; i < request.Number; i++)
+                {
+                    EvaluatorDescriptorImpl descriptor = new EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes, request.VirtualCore);
+                    descriptor.Rack = request.Rack;
+                    string key = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", request.EvaluatorBatchId, i);
+                    try
+                    {
+                        _evaluators.Add(key, descriptor);
+                    }
+                    catch (ArgumentException e)
+                    {
+                        Exceptions.Caught(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "EvaluatorBatchId [{0}] already exists.", key), LOGGER);
+                        Exceptions.Throw(new InvalidOperationException("Cannot use evaluator id " + key, e), LOGGER);
+                    }
+                }
+            }
+            
+            Clr2Java.Submit(request);
+        }
+
+        public void Dispose()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedContext.cs
new file mode 100644
index 0000000..8f0a8e3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedContext.cs
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class FailedContext : IFailedContext
+    {
+        private string _id;
+
+        private string _evaluatorId;
+
+        private string _parentId;
+
+        public FailedContext(IFailedContextClr2Java clr2Java)
+        {
+            _id = clr2Java.GetId();
+            _evaluatorId = clr2Java.GetEvaluatorId();
+            _parentId = clr2Java.GetParentId();
+            FailedContextClr2Java = clr2Java;
+        }
+
+        public string Id
+        {
+            get
+            {
+                return _id;
+            }
+
+            set
+            {
+            }
+        }
+
+        public string EvaluatorId
+        {
+            get
+            {
+                return _evaluatorId;
+            }
+
+            set
+            {
+            }
+        }
+
+        public Optional<string> ParentId
+        {
+            get
+            {
+                return string.IsNullOrEmpty(_parentId) ? 
+                    Optional<string>.Empty() : 
+                    Optional<string>.Of(_parentId);
+            }
+
+            set
+            {
+            }
+        }
+
+        public IEvaluatorDescriptor EvaluatorDescriptor
+        {
+            get
+            {
+                return FailedContextClr2Java.GetEvaluatorDescriptor();
+            }
+
+            set
+            {
+            }
+        }
+
+        public Optional<IActiveContext> ParentContext
+        {
+            get
+            {
+                IActiveContextClr2Java context = FailedContextClr2Java.GetParentContext();
+                if (context != null)
+                {
+                    return Optional<IActiveContext>.Of(new ActiveContext(context));
+                }
+                else
+                {
+                    return Optional<IActiveContext>.Empty();
+                }
+            }
+        }
+
+        private IFailedContextClr2Java FailedContextClr2Java { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedEvaluator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedEvaluator.cs
new file mode 100644
index 0000000..8c12dee
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedEvaluator.cs
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Exceptions;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class FailedEvaluator : IFailedEvaluator
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(FailedEvaluator));
+
+        public FailedEvaluator(IFailedEvaluatorClr2Java clr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            FailedEvaluatorClr2Java = clr2Java;
+            EvaluatorRequestorClr2Java = FailedEvaluatorClr2Java.GetEvaluatorRequestor();
+            Id = FailedEvaluatorClr2Java.GetId();
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public string Id { get; set; }
+
+        public EvaluatorException EvaluatorException { get; set; }
+
+        public List<FailedContext> FailedContexts { get; set; }
+
+        public Optional<IFailedTask> FailedTask { get; set; }
+
+        [DataMember]
+        private IFailedEvaluatorClr2Java FailedEvaluatorClr2Java { get; set; }
+
+        [DataMember]
+        private IEvaluatorRequestorClr2Java EvaluatorRequestorClr2Java { get; set; }
+
+        public IEvaluatorRequestor GetEvaluatorRequetor()
+        {
+            if (EvaluatorRequestorClr2Java == null)
+            {
+                Exceptions.Throw(new InvalidOperationException("EvaluatorRequestorClr2Java not initialized."), LOGGER);
+            }
+            return new EvaluatorRequestor(EvaluatorRequestorClr2Java);
+        }
+    }
+}


[04/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestListInjection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestListInjection.cs b/lang/cs/Tests/TangTests/Injection/TestListInjection.cs
new file mode 100644
index 0000000..1c05516
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestListInjection.cs
@@ -0,0 +1,565 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ClassHierarchyProto;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    /// <summary>
+    /// Test injection with a List
+    /// </summary>
+    [TestClass]
+    public class TestListInjection
+    {
+        /// <summary>
+        /// Tests the string inject default.
+        /// </summary>
+        [TestMethod]
+        public void TestStringInjectDefault()
+        {
+            StringClass b = TangFactory.GetTang().NewInjector().GetInstance<StringClass>();
+
+            IList<string> actual = b.StringList;
+
+            Assert.IsTrue(actual.Contains("one"));
+            Assert.IsTrue(actual.Contains("two"));
+            Assert.IsTrue(actual.Contains("three"));
+        }
+
+        /// <summary>
+        /// Tests the int inject default.
+        /// </summary>
+        [TestMethod]
+        public void TestIntInjectDefault()
+        {
+            IntClass b = TangFactory.GetTang().NewInjector().GetInstance<IntClass>();
+
+            IList<int> actual = b.IntList;
+
+            Assert.IsTrue(actual.Contains(1));
+            Assert.IsTrue(actual.Contains(2));
+            Assert.IsTrue(actual.Contains(3));
+        }
+
+        /// <summary>
+        /// Tests the string inject configuration builder.
+        /// </summary>
+        [TestMethod]
+        public void TestStringInjectConfigurationBuilder()
+        {
+            ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+            INamedParameterNode np = (INamedParameterNode)classH.GetNode(typeof(StringList));
+            IList<string> injected = new List<string>();
+            injected.Add("hi");
+            injected.Add("hello");
+            injected.Add("bye");
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(np, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IList<string> actual = ((StringClass)i.GetInstance(typeof(StringClass))).StringList;
+
+            Assert.IsTrue(actual.Contains("hi"));
+            Assert.IsTrue(actual.Contains("hello"));
+            Assert.IsTrue(actual.Contains("bye"));
+            Assert.AreEqual(actual.Count, 3);
+        }
+
+        /// <summary>
+        /// Tests the bool list with named parameter.
+        /// </summary>
+        [TestMethod]
+        public void TestBoolListWithNamedParameter()
+        {
+            ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+            INamedParameterNode np = (INamedParameterNode)classH.GetNode(typeof(BoolListClass.NamedBoolList));
+            IList<string> injected = new List<string>();
+            injected.Add("true");
+            injected.Add("false");
+            injected.Add("true");
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(np, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            BoolListClass o = i.GetInstance<BoolListClass>();
+
+            IList<bool> expected = new List<bool>();
+            expected.Add(true);
+            expected.Add(false);
+            expected.Add(true);
+            o.Verify(expected);
+        }
+
+        /// <summary>
+        /// Tests the type of the bool list with generic.
+        /// </summary>
+        [TestMethod]
+        public void TestBoolListWithGenericType()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add("true");
+            injected.Add("false");
+            injected.Add("true");
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList<BoolListClass.NamedBoolList, bool>(GenericType<BoolListClass.NamedBoolList>.Class, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            BoolListClass o = i.GetInstance<BoolListClass>();
+
+            IList<bool> expected = new List<bool>();
+            expected.Add(true);
+            expected.Add(false);
+            expected.Add(true);
+            o.Verify(expected);
+        }
+
+        /// <summary>
+        /// Tests the int list with named parameter.
+        /// </summary>
+        [TestMethod]
+        public void TestIntListWithNamedParameter()
+        {
+            ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+            INamedParameterNode np = (INamedParameterNode)classH.GetNode(typeof(IntListClass.NamedIntList));
+            IList<string> injected = new List<string>();
+            injected.Add("1");
+            injected.Add("2");
+            injected.Add("3");
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(np, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IntListClass o = i.GetInstance<IntListClass>();
+
+            IList<int> expected = new List<int>();
+            expected.Add(1);
+            expected.Add(2);
+            expected.Add(3);
+            o.Verify(expected);
+        }
+
+        /// <summary>
+        /// Tests the type of the int list with generic.
+        /// </summary>
+        [TestMethod]
+        public void TestIntListWithGenericType()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add("1");
+            injected.Add("2");
+            injected.Add("3");
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList<IntListClass.NamedIntList, int>(GenericType<IntListClass.NamedIntList>.Class, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IntListClass o = i.GetInstance<IntListClass>();
+
+            IList<int> expected = new List<int>();
+            expected.Add(1);
+            expected.Add(2);
+            expected.Add(3);
+            o.Verify(expected);
+        }
+
+        /// <summary>
+        /// Tests the string inject.
+        /// </summary>
+        [TestMethod]
+        public void TestStringInject()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add("hi");
+            injected.Add("hello");
+            injected.Add("bye");
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList<StringList, string>(GenericType<StringList>.Class, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IList<string> actual = ((StringClass)i.GetInstance(typeof(StringClass))).StringList;
+
+            Assert.IsTrue(actual.Contains("hi"));
+            Assert.IsTrue(actual.Contains("hello"));
+            Assert.IsTrue(actual.Contains("bye"));
+            Assert.AreEqual(actual.Count, 3);
+        }
+
+        /// <summary>
+        /// Tests the node inject and bind volatile instance.
+        /// </summary>
+        [TestMethod]
+        public void TestNodeInjectAndBindVolatileInstance()
+        {
+            ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+            INamedParameterNode np = (INamedParameterNode)classH.GetNode(typeof(ListOfClasses));
+            IList<INode> injected = new List<INode>();
+            injected.Add(classH.GetNode(typeof(TestSetInjection.Integer)));
+            injected.Add(classH.GetNode(typeof(TestSetInjection.Float)));
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(np, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<TestSetInjection.Integer>.Class, new TestSetInjection.Integer(42));
+            i.BindVolatileInstance(GenericType<TestSetInjection.Float>.Class, new TestSetInjection.Float(42.0001f));
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer(42)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float(42.0001f)));
+        }
+
+        /// <summary>
+        /// Tests the class name inject with named parameter node.
+        /// </summary>
+        [TestMethod]
+        public void TestClassNameInjectWithNamedParameterNode()
+        {
+            ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+            INamedParameterNode np = (INamedParameterNode)classH.GetNode(typeof(ListOfClasses));
+
+            IList<string> injected = new List<string>();
+            injected.Add(typeof(TestSetInjection.Integer).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Float).AssemblyQualifiedName);
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(np, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<TestSetInjection.Integer>.Class, new TestSetInjection.Integer(42));
+            i.BindVolatileInstance(GenericType<TestSetInjection.Float>.Class, new TestSetInjection.Float(42.0001f));
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer(42)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float(42.0001f)));
+        }
+
+        /// <summary>
+        /// Tests the name of the class name inject with named parameter.
+        /// </summary>
+        [TestMethod]
+        public void TestClassNameInjectWithNamedParameterName()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add(typeof(TestSetInjection.Integer).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Float).AssemblyQualifiedName);
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(typeof(ListOfClasses).AssemblyQualifiedName, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<TestSetInjection.Integer>.Class, new TestSetInjection.Integer(42));
+            i.BindVolatileInstance(GenericType<TestSetInjection.Float>.Class, new TestSetInjection.Float(42.0001f));
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer(42)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float(42.0001f)));
+        }
+
+        /// <summary>
+        /// Tests the object inject with injectable subclasses.
+        /// </summary>
+        [TestMethod]
+        public void TestObjectInjectWithInjectableSubclasses()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Integer2).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Integer3).AssemblyQualifiedName);
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(typeof(ListOfClasses).AssemblyQualifiedName, injected);
+            cb.BindNamedParameter<TestSetInjection.Integer1.NamedInt, int>(GenericType<TestSetInjection.Integer1.NamedInt>.Class, "5");
+            cb.BindNamedParameter<TestSetInjection.Integer3.NamedInt, int>(GenericType<TestSetInjection.Integer3.NamedInt>.Class, "10");
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Count == 3);
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer2()));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer3(10)));
+        }
+
+        /// <summary>
+        /// Tests the object inject with injectable subclasses multiple instances.
+        /// </summary>
+        [TestMethod]
+        public void TestObjectInjectWithInjectableSubclassesMultipleInstances()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Float1).AssemblyQualifiedName);
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<TestSetInjection.Integer1.NamedInt, int>(GenericType<TestSetInjection.Integer1.NamedInt>.Class, "5");
+            cb.BindNamedParameter<TestSetInjection.Float1.NamedFloat, float>(GenericType<TestSetInjection.Float1.NamedFloat>.Class, "12.5");
+            cb.BindList<ListOfClasses, INumber>(GenericType<ListOfClasses>.Class, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Count == 3);
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float1(12.5f)));
+        }
+
+        /// <summary>
+        /// Tests the object inject with injectable subclasses and typeof named parameter.
+        /// </summary>
+        [TestMethod]
+        public void TestObjectInjectWithInjectableSubclassesAndTypeofNamedParameter()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Integer2).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Integer3).AssemblyQualifiedName);
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<TestSetInjection.Integer1.NamedInt, int>(GenericType<TestSetInjection.Integer1.NamedInt>.Class, "5");
+            cb.BindNamedParameter<TestSetInjection.Integer3.NamedInt, int>(GenericType<TestSetInjection.Integer3.NamedInt>.Class, "10");
+            cb.BindList<ListOfClasses, INumber>(GenericType<ListOfClasses>.Class, injected);
+          
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Count == 3);
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer2()));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer3(10)));
+        }
+
+        /// <summary>
+        /// Tests the object inject with names configuration builder.
+        /// </summary>
+        [TestMethod]
+        public void TestObjectInjectWithNames()
+        {
+            ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+            IList<INode> injected = new List<INode>();
+            injected.Add(classH.GetNode(typeof(TestSetInjection.Integer)));
+            injected.Add(classH.GetNode(typeof(TestSetInjection.Float)));
+
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(typeof(ListOfClasses).AssemblyQualifiedName, injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<TestSetInjection.Integer>.Class, new TestSetInjection.Integer(42));
+            i.BindVolatileInstance(GenericType<TestSetInjection.Float>.Class, new TestSetInjection.Float(42.0001f));
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer(42)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float(42.0001f)));
+        }
+
+        /// <summary>
+        /// Tests the object inject with type type cs configuration builder.
+        /// </summary>
+        [TestMethod]
+        public void TestObjectInjectWithTypeType()
+        {
+            IList<Type> injected = new List<Type>();
+            injected.Add(typeof(TestSetInjection.Integer));
+            injected.Add(typeof(TestSetInjection.Float));
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList(typeof(ListOfClasses), injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<TestSetInjection.Integer>.Class, new TestSetInjection.Integer(42));
+            i.BindVolatileInstance(GenericType<TestSetInjection.Float>.Class, new TestSetInjection.Float(42.0001f));
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer(42)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float(42.0001f)));
+        }
+
+        ///// <summary>
+        ///// Tests the subclass inject with multiple instances.
+        ///// </summary>
+        //[TestMethod] 
+        //public void TestSubclassInjectWithMultipleInstances()
+        //{
+        //    ICsConfigurationBuilder cb1 = TangFactory.GetTang().NewConfigurationBuilder()
+        //        .BindNamedParameter<TestSetInjection.Integer3.NamedInt, int>(GenericType<TestSetInjection.Integer3.NamedInt>.Class, "10");
+        //    TestSetInjection.Integer3 integer3 = TangFactory.GetTang().NewInjector(cb1.Build()).GetInstance<TestSetInjection.Integer3>();
+
+        //    ICsClassHierarchy classH = TangFactory.GetTang().GetDefaultClassHierarchy();
+        //    INamedParameterNode np = (INamedParameterNode)classH.GetNode(typeof(ListOfClasses));
+        //    IList<object> injected = new List<object>();
+        //    injected.Add(new TestSetInjection.Integer1(42)); //instance from the same class
+        //    injected.Add(new TestSetInjection.Integer1(30)); //instance from the same class
+        //    injected.Add(new TestSetInjection.Float1(42.0001f)); //instance from another subclass of the same interface
+        //    injected.Add(typeof(TestSetInjection.Float1).AssemblyQualifiedName); //inject from another subclass of the same interface
+        //    injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName); //inject using configuration
+        //    injected.Add(typeof(TestSetInjection.Integer2).AssemblyQualifiedName); //inject using default
+        //    injected.Add(integer3); //add pre injected instance
+
+        //    ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+        //    cb.BindNamedParameter<TestSetInjection.Integer1.NamedInt, int>(GenericType<TestSetInjection.Integer1.NamedInt>.Class, "5");
+        //    cb.BindNamedParameter<TestSetInjection.Float1.NamedFloat, float>(GenericType<TestSetInjection.Float1.NamedFloat>.Class, "12.5");
+        //    cb.BindList(np, injected);
+
+        //    IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+        //    IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+        //    Assert.IsTrue(actual.Count == 7);
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(42)));
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(30)));
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Float1(42.0001f)));
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Float1(12.5f)));
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Integer2()));
+        //    Assert.IsTrue(actual.Contains(new TestSetInjection.Integer3(10)));
+        //}
+    }
+
+    [NamedParameter(DefaultValues = new string[] { "one", "two", "three" })]
+    internal class StringList : Name<IList<string>>
+    {
+    }
+
+    [NamedParameter(DefaultValues = new string[] { "1", "2", "3" })]
+    internal class IntList : Name<IList<int>>
+    {
+    }
+
+    [NamedParameter(DefaultValues = new string[] { "1", "2", "3" })]
+    internal class IntegerList : Name<IList<TestSetInjection.Integer>>
+    {
+    }
+
+    internal class StringClass
+    {
+        [Inject]
+        private StringClass([Parameter(typeof(StringList))] IList<string> stringList)
+        {
+            this.StringList = stringList;
+        }
+
+        public IList<string> StringList { get; set; }
+    }
+
+    internal class IntClass
+    {
+        [Inject]
+        private IntClass([Parameter(typeof(IntList))] IList<int> integerList)
+        {
+            this.IntList = integerList;
+        }
+    
+        public IList<int> IntList { get; set; }
+    }
+
+    internal class IntegerListClass
+    {
+        [Inject]
+        private IntegerListClass([Parameter(typeof(IntegerList))] IList<TestSetInjection.Integer> integerList)
+        {
+            this.IntegerList = integerList;
+        }
+
+        public IList<TestSetInjection.Integer> IntegerList { get; set; }
+    }
+
+    [NamedParameter(DefaultClasses = new Type[] { typeof(TestSetInjection.Integer), typeof(TestSetInjection.Float) })]
+    internal class ListOfClasses : Name<IList<INumber>>
+    {
+    }
+
+    internal class PoolListClass
+    {
+        [Inject]
+        private PoolListClass([Parameter(typeof(ListOfClasses))] IList<INumber> numbers)
+        {
+            this.Numbers = numbers;
+        }
+
+        public IList<INumber> Numbers { get; set; }
+    }
+
+    internal class BoolListClass
+    {
+        private readonly IList<bool> b;
+
+        [Inject]
+        public BoolListClass([Parameter(typeof(NamedBoolList))] IList<bool> b)
+        {
+            this.b = b;
+        }
+
+        public void Verify(IList<bool> v)
+        {
+            Assert.AreEqual(v.Count, b.Count);
+            foreach (bool bv in v)
+            {
+                Assert.IsTrue(b.Contains(bv));
+            }
+        }
+
+        [NamedParameter]
+        public class NamedBoolList : Name<IList<bool>>
+        {
+        }
+    }
+
+    internal class IntListClass
+    {
+        private readonly IList<int> l;
+
+        [Inject]
+        public IntListClass([Parameter(typeof(NamedIntList))] IList<int> b)
+        {
+            this.l = b;
+        }
+
+        public void Verify(IList<int> v)
+        {
+            Assert.AreEqual(v.Count, l.Count);
+            foreach (int iv in v)
+            {
+                Assert.IsTrue(l.Contains(iv));
+            }
+        }
+
+        [NamedParameter]
+        public class NamedIntList : Name<IList<int>>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestMissingParameters.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestMissingParameters.cs b/lang/cs/Tests/TangTests/Injection/TestMissingParameters.cs
new file mode 100644
index 0000000..09fdd78
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestMissingParameters.cs
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    [TestClass]
+    public class TestMissingParameters
+    {
+        [TestMethod]
+        public void MultipleParameterTest()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<MultiParameterConstructor.NamedString, string>(GenericType<MultiParameterConstructor.NamedString>.Class, "foo");
+            cb.BindNamedParameter<MultiParameterConstructor.NamedInt, int>(GenericType<MultiParameterConstructor.NamedInt>.Class, "8");
+            cb.BindNamedParameter<MultiParameterConstructor.NamedBool, bool>(GenericType<MultiParameterConstructor.NamedBool>.Class, "true");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<MultiParameterConstructor>();
+            o.Verify("foo", 8, true);
+        }
+
+        [TestMethod]
+        public void MissingAllParameterTest()
+        {
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //missing arguments: [ 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor+NamedBool, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor+NamedString, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor+NamedInt, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //]
+            MultiParameterConstructor obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiParameterConstructor>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void MissingTwoParameterTest()
+        {
+            //Cannot inject Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //missing arguments: [ 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor+NamedString, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor+NamedInt, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //]
+            MultiParameterConstructor obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<MultiParameterConstructor.NamedBool, bool>(GenericType<MultiParameterConstructor.NamedBool>.Class, "true");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiParameterConstructor>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void MissingOneParameterTest()
+        {
+            //Cannot inject Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 
+            //Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //missing argument Org.Apache.Reef.Tang.Test.Injection.MultiParameterConstructor+NamedInt, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+            MultiParameterConstructor obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<MultiParameterConstructor.NamedBool, bool>(GenericType<MultiParameterConstructor.NamedBool>.Class, "true");
+                cb.BindNamedParameter<MultiParameterConstructor.NamedString, string>(GenericType<MultiParameterConstructor.NamedString>.Class, "foo");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiParameterConstructor>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+    }
+
+    public class MultiParameterConstructor
+    {
+        private readonly string str;
+        private readonly int iVal;
+        private readonly bool bVal;
+
+        [Inject]
+        public MultiParameterConstructor([Parameter(typeof(NamedBool))] bool b, [Parameter(typeof(NamedString))] string s, [Parameter(typeof(NamedInt))] int i)
+        {
+            this.str = s;
+            this.iVal = i;
+            this.bVal = b;
+        }
+
+        public void Verify(string s, int i, bool b)
+        {
+            Assert.AreEqual(str, s);
+            Assert.AreEqual(iVal, i);
+            Assert.AreEqual(bVal, b);
+        }
+
+        [NamedParameter]
+        public class NamedString : Name<string>
+        {
+        }
+
+        [NamedParameter]
+        public class NamedInt : Name<int>
+        {
+        }
+
+        [NamedParameter]
+        public class NamedBool : Name<bool>
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestMissingParamtersInNested.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestMissingParamtersInNested.cs b/lang/cs/Tests/TangTests/Injection/TestMissingParamtersInNested.cs
new file mode 100644
index 0000000..25ddb0c
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestMissingParamtersInNested.cs
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    [TestClass]
+    public class TestMissingParamtersInNested
+    {
+        [TestMethod]
+        public void InnerParameterTest()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<ReferencedClass.NamedInt, int>(GenericType<ReferencedClass.NamedInt>.Class, "8");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<ReferencedClass>();
+            Assert.IsNotNull(o);
+        }
+
+        [TestMethod]
+        public void NestedParameterTest()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<OuterClass.NamedString, string>(GenericType<OuterClass.NamedString>.Class, "foo");
+            cb.BindNamedParameter<ReferencedClass.NamedInt, int>(GenericType<ReferencedClass.NamedInt>.Class, "8");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<OuterClass>();
+            Assert.IsNotNull(o);
+        }
+
+        [TestMethod]
+        public void MissingAllParameterTest()
+        {
+            //Cannot inject Org.Apache.Reef.Tang.Test.Injection.OuterClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 
+            //Org.Apache.Reef.Tang.Test.Injection.ReferencedClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //missing argument Org.Apache.Reef.Tang.Test.Injection.ReferencedClass+NamedInt, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+            OuterClass obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<OuterClass>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+    
+        [TestMethod]
+        public void MissingInnerParameterTest()
+        {
+            //Cannot inject Org.Apache.Reef.Tang.Test.Injection.OuterClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 
+            //Org.Apache.Reef.Tang.Test.Injection.ReferencedClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //missing argument Org.Apache.Reef.Tang.Test.Injection.ReferencedClass+NamedInt, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+            OuterClass obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<OuterClass.NamedString, string>(GenericType<OuterClass.NamedString>.Class, "foo");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<OuterClass>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void MissingOuterParameterTest()
+        {
+            //Cannot inject Org.Apache.Reef.Tang.Test.Injection.OuterClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 
+            //Org.Apache.Reef.Tang.Test.Injection.OuterClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //missing argument Org.Apache.Reef.Tang.Test.Injection.OuterClass+NamedString, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+            OuterClass obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<ReferencedClass.NamedInt, int>(GenericType<ReferencedClass.NamedInt>.Class, "8");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<OuterClass>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+    }
+
+    class OuterClass
+    {
+        [Inject]
+        public OuterClass([Parameter(typeof(NamedString))] string s, ReferencedClass refCls)
+        {
+        }
+
+        [NamedParameter]
+        public class NamedString : Name<string>
+        {
+        }
+    }
+
+    class ReferencedClass
+    {
+        [Inject]
+        public ReferencedClass([Parameter(typeof(NamedInt))] int i)
+        {           
+        }
+
+        [NamedParameter]
+        public class NamedInt : Name<int>
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestMultipleConstructors.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestMultipleConstructors.cs b/lang/cs/Tests/TangTests/Injection/TestMultipleConstructors.cs
new file mode 100644
index 0000000..bc3d25a
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestMultipleConstructors.cs
@@ -0,0 +1,360 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    public interface IH
+    {
+    }
+
+    [TestClass]
+    public class TestMultipleConstructors
+    {
+        [TestMethod]
+        public void TestMissingAllParameters()
+        {
+            //Multiple infeasible plans: Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //, Org.Apache.Reef.Tang.Test
+            //, Version=1.0.0.0
+            //, Culture=neutral
+            //, PublicKeyToken=null:
+
+            //  [ Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest = new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = 
+            //    , System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    )
+            //  ]
+            MultiConstructorTest obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiConstructorTest>();
+            }
+            catch (InjectionException)
+            {               
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void TestMissingIntParameter()
+        {
+            //Multiple infeasible plans: Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //, Org.Apache.Reef.Tang.Test
+            //, Version=1.0.0.0
+            //, Culture=neutral
+            //, PublicKeyToken=null:
+            //  [ Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest = new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = False
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = foo
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = False
+            //    , System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = foo
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    )
+            //  ]
+            MultiConstructorTest obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<MultiConstructorTest.NamedString, string>(GenericType<MultiConstructorTest.NamedString>.Class, "foo");
+                cb.BindNamedParameter<MultiConstructorTest.NamedBool, bool>(GenericType<MultiConstructorTest.NamedBool>.Class, "true");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiConstructorTest>();
+            }
+            catch (InjectionException)
+            {
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void TestOnlyBoolParameter()
+        {
+            //Multiple infeasible plans: Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //, Org.Apache.Reef.Tang.Test
+            //, Version=1.0.0.0
+            //, Culture=neutral
+            //, PublicKeyToken=null:
+            //  [ Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest = new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = False
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = False
+            //    , System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 
+            //    )
+            //  ]
+            MultiConstructorTest obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<MultiConstructorTest.NamedBool, bool>(GenericType<MultiConstructorTest.NamedBool>.Class, "true");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiConstructorTest>();
+            }
+            catch (InjectionException)
+            {
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void TestOnlyIntParameter()
+        {
+            //Multiple infeasible plans: Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //, Org.Apache.Reef.Tang.Test
+            //, Version=1.0.0.0
+            //, Culture=neutral
+            //, PublicKeyToken=null:
+            //  [ Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest = new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 8
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 8
+            //    ) 
+            //    | new Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest
+            //    ( System.Boolean Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedBool = 
+            //    , System.String Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedString = 
+            //    , System.Int32 Org.Apache.Reef.Tang.Test.Injection.MultiConstructorTest+NamedInt = 8
+            //    )
+            //  ]
+            MultiConstructorTest obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<MultiConstructorTest.NamedInt, int>(GenericType<MultiConstructorTest.NamedInt>.Class, "8");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<MultiConstructorTest>();
+            }
+            catch (InjectionException)
+            {
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void TestMultipleConstructor()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<MultiConstructorTest.NamedString, string>(GenericType<MultiConstructorTest.NamedString>.Class, "foo");
+            cb.BindNamedParameter<MultiConstructorTest.NamedInt, int>(GenericType<MultiConstructorTest.NamedInt>.Class, "8");
+            cb.BindNamedParameter<MultiConstructorTest.NamedBool, bool>(GenericType<MultiConstructorTest.NamedBool>.Class, "true");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<MultiConstructorTest>();
+            o.Verify("foo", 8, true);
+        }
+
+        [TestMethod]
+        public void TestMultiLayersWithMiddleLayerFirst()
+        {
+            TangImpl.Reset();
+            ICsConfigurationBuilder cb2 = TangFactory.GetTang().NewConfigurationBuilder();
+            cb2.BindImplementation(typeof(IH), typeof(M));
+            IInjector i2 = TangFactory.GetTang().NewInjector(cb2.Build());
+            var o2 = i2.GetInstance<IH>();
+            Assert.IsTrue(o2 is M);
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(typeof(IH), typeof(L));
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<IH>();
+            Assert.IsTrue(o is L);           
+        }
+
+        [TestMethod]
+        public void TestMultiLayersWithLowerLayerFirst()
+        {
+            TangImpl.Reset(); 
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(typeof(IH), typeof(L));
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<IH>();
+            Assert.IsTrue(o is L);
+
+            ICsConfigurationBuilder cb2 = TangFactory.GetTang().NewConfigurationBuilder();
+            cb2.BindImplementation(typeof(IH), typeof(M));                              
+            IInjector i2 = TangFactory.GetTang().NewInjector(cb2.Build());
+            var o2 = i2.GetInstance<IH>();
+            Assert.IsTrue(o2 is M);
+        }
+
+        [TestMethod]
+        public void TestMultiLayersWithBindImpl()
+        {
+            TangImpl.Reset(); 
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(typeof(IH), typeof(L));
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<IH>();
+            Assert.IsTrue(o is L);
+
+            ICsConfigurationBuilder cb2 = TangFactory.GetTang().NewConfigurationBuilder();
+            cb2.BindImplementation(typeof(IH), typeof(M));
+            cb2.BindImplementation(typeof(M), typeof(L)); //construcotr of L is explicitly bound
+            IInjector i2 = TangFactory.GetTang().NewInjector(cb2.Build());
+            var o2 = i2.GetInstance<IH>();
+            Assert.IsTrue(o2 is L);
+        }
+
+        [TestMethod]
+        public void TestMultiLayersWithNoInjectableDefaultConstructor()
+        {
+            TangImpl.Reset(); 
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(typeof(IH), typeof(L1));
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<IH>();
+            Assert.IsNotNull(o);
+
+            ICsConfigurationBuilder cb2 = TangFactory.GetTang().NewConfigurationBuilder();
+            cb2.BindImplementation(typeof(IH), typeof(M1));  //M1 doesn't have injectable default constructor, no implementation L1 is bound to M1
+            IInjector i2 = TangFactory.GetTang().NewInjector(cb2.Build());
+            string msg = null;
+            try
+            {
+                var o2 = i2.GetInstance<IH>();
+                Assert.IsTrue(o2 is L1);
+            }
+            catch (Exception e)
+            {
+                //Cannot inject Org.Apache.Reef.Tang.Test.Injection.IH, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 
+                //No known implementations / injectable constructors for Org.Apache.Reef.Tang.Test.Injection.M1, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+                msg = e.Message;
+            }
+            Assert.IsNotNull(msg);
+        }
+    }
+
+    public class MultiConstructorTest
+    {
+        private readonly string str;
+        private readonly int iVal;
+        private readonly bool bVal;
+
+        [Inject]
+        public MultiConstructorTest([Parameter(typeof(NamedBool))] bool b, [Parameter(typeof(NamedInt))] int i)
+        {
+            this.bVal = b;
+            this.iVal = i;
+            this.bVal = false;
+        }
+
+        [Inject]
+        public MultiConstructorTest([Parameter(typeof(NamedString))] string s, [Parameter(typeof(NamedInt))] int i)
+        {
+            this.str = s;
+            this.iVal = i;
+            this.bVal = false;
+        }
+
+        [Inject]
+        public MultiConstructorTest([Parameter(typeof(NamedBool))] bool b, [Parameter(typeof(NamedString))] string s, [Parameter(typeof(NamedInt))] int i)
+        {
+            this.str = s;
+            this.iVal = i;
+            this.bVal = b;
+        }
+
+        public void Verify(string s, int i, bool b)
+        {
+            Assert.AreEqual(str, s);
+            Assert.AreEqual(iVal, i);
+            Assert.AreEqual(bVal, b);
+        }
+
+        [NamedParameter]
+        public class NamedString : Name<string>
+        {
+        }
+
+        [NamedParameter]
+        public class NamedInt : Name<int>
+        {
+        }
+
+        [NamedParameter]
+        public class NamedBool : Name<bool>
+        {
+        }
+    }
+
+    class M : IH
+    {
+        [Inject]
+        public M()
+        {            
+        }
+    }
+
+    class L : M
+    {
+        [Inject]
+        public L()
+        {            
+        }
+    }
+
+    class M1 : IH
+    {
+        public M1()
+        {            
+        }
+    }
+
+    class L1 : M1
+    {
+        [Inject]
+        public L1()
+        {            
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestNamedParameter.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestNamedParameter.cs b/lang/cs/Tests/TangTests/Injection/TestNamedParameter.cs
new file mode 100644
index 0000000..9bcfd40
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestNamedParameter.cs
@@ -0,0 +1,357 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    [TestClass]
+    public class TestNamedParameter
+    {
+        [TestMethod]
+        public void TestOptionalParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<StringTest.NamedString, string>(GenericType<StringTest.NamedString>.Class, "foo");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<StringTest>();
+            o.Verify("foo");
+        }
+
+        [TestMethod]
+        public void TestOptionalParameterWithDefault()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<StringTest>();
+            o.Verify(" ");
+        }
+
+        [TestMethod]
+        public void TestBoolParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<BooleanTest.NamedBool, bool>(GenericType<BooleanTest.NamedBool>.Class, "true");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<BooleanTest>();
+            o.Verify(true);
+        }
+
+        [TestMethod]
+        public void TestBoolUpperCaseParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<BooleanTest.NamedBool, bool>(GenericType<BooleanTest.NamedBool>.Class, "True");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<BooleanTest>();
+            o.Verify(true);
+        }
+
+        [TestMethod]
+        public void TestBoolParameterWithDefault()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<BooleanTest>();
+            o.Verify(false);
+        }
+
+        [TestMethod]
+        public void TestByteParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<ByteTest.NamedByte, byte>(GenericType<ByteTest.NamedByte>.Class, "6");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<ByteTest>();
+            o.Verify(6);
+        }
+
+        [TestMethod]
+        public void TestByteArrayParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            string input = "abcde";
+            cb.BindNamedParameter<ByteArrayTest.NamedByteArray, byte[]>(GenericType<ByteArrayTest.NamedByteArray>.Class, input);
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<ByteArrayTest>();
+
+            byte[] bytes = new byte[input.Length * sizeof(char)];
+            System.Buffer.BlockCopy(input.ToCharArray(), 0, bytes, 0, bytes.Length);
+            Assert.IsTrue(o.Verify(bytes));
+        }
+
+        [TestMethod]
+        public void TestCharParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<CharTest.NamedChar, char>(GenericType<CharTest.NamedChar>.Class, "C");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<CharTest>();
+            o.Verify('C');
+        }
+
+        [TestMethod]
+        public void TestShortParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<Int16Test.NamedShort, short>(GenericType<Int16Test.NamedShort>.Class, "8");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<Int16Test>();
+            o.Verify(8);
+        }
+
+        [TestMethod]
+        public void TestIntParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<Int32Test.NamedInt, int>(GenericType<Int32Test.NamedInt>.Class, "8");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<Int32Test>();
+            o.Verify(8);
+        }
+
+        [TestMethod]
+        public void TestLongParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<Int64Test.NamedLong, long>(GenericType<Int64Test.NamedLong>.Class, "8777");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<Int64Test>();
+            o.Verify(8777);
+        }
+
+        [TestMethod]
+        public void TestFloatParameter()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<FloatTest.NamedSingle, float>(GenericType<FloatTest.NamedSingle>.Class, "3.5");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<FloatTest>();
+            float x = 3.5F;
+            o.Verify(x);
+        }
+    }
+
+    public class StringTest
+    {
+        private readonly string str;
+
+        [Inject]
+        public StringTest([Parameter(typeof(NamedString))] string s)
+        {
+            this.str = s;
+        }
+
+        public void Verify(string s)
+        {
+            Assert.AreEqual(s, str);
+        }
+
+        [NamedParameter(DefaultValue = " ")]
+        public class NamedString : Name<string>
+        {
+        }
+    }
+
+    public class CharTest
+    {
+        private readonly char c;
+
+        [Inject]
+        public CharTest([Parameter(typeof(NamedChar))] char c)
+        {
+            this.c = c;
+        }
+
+        public void Verify(char s)
+        {
+            Assert.AreEqual(s, c);
+        }
+
+        [NamedParameter(DefaultValue = " ")]
+        public class NamedChar : Name<char>
+        {            
+        }
+    }
+
+    public class ByteTest
+    {
+        private readonly byte b;
+
+        [Inject]
+        public ByteTest([Parameter(typeof(NamedByte))] byte b)
+        {
+            this.b = b;
+        }
+
+        public void Verify(byte v)
+        {
+            Assert.AreEqual(v, b);
+        }
+
+        [NamedParameter(DefaultValue = "7")]
+        public class NamedByte : Name<byte>
+        {
+        }
+    }
+
+    public class BooleanTest
+    {
+        private readonly bool b;
+
+        [Inject]
+        public BooleanTest([Parameter(typeof(NamedBool))] bool b)
+        {
+            this.b = b;
+        }
+
+        public void Verify(bool v)
+        {
+            Assert.AreEqual(v, b);
+        }
+
+        [NamedParameter(DefaultValue = "false")]
+        public class NamedBool : Name<bool>
+        {
+        }
+    }
+
+    public class ByteArrayTest
+    {
+        private readonly byte[] b;
+
+        [Inject]
+        public ByteArrayTest([Parameter(typeof(NamedByteArray))] byte[] b)
+        {
+            this.b = b;
+        }
+
+        public bool Verify(byte[] v)
+        {
+            if (v.Length != b.Length)
+            {
+                return false;
+            }
+
+            for (int i = 0; i < v.Length; i++)
+            {   
+                if (v[i] != b[i])
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        [NamedParameter]
+        public class NamedByteArray : Name<byte[]>
+        {
+        }
+    }
+
+    public class Int16Test
+    {
+        private readonly short s;
+
+        [Inject]
+        public Int16Test([Parameter(typeof(NamedShort))] short s)
+        {
+            this.s = s;
+        }
+
+        public void Verify(short v)
+        {
+            Assert.AreEqual(v, s);
+        }
+
+        [NamedParameter(DefaultValue = "3")]
+        public class NamedShort : Name<short>
+        {
+        }
+    }
+
+    public class Int32Test
+    {
+        private readonly int i;
+
+        [Inject]
+        public Int32Test([Parameter(typeof(NamedInt))] int i)
+        {
+            this.i = i;
+        }
+
+        public void Verify(int v)
+        {
+            Assert.AreEqual(v, i);
+        }
+
+        [NamedParameter(DefaultValue = "3")]
+        public class NamedInt : Name<int>
+        {
+        }
+    }
+
+    public class Int64Test
+    {
+        private readonly long l;
+
+        [Inject]
+        public Int64Test([Parameter(typeof(NamedLong))] long l)
+        {
+            this.l = l;
+        }
+
+        public void Verify(int v)
+        {
+            Assert.AreEqual(v, l);
+        }
+
+        [NamedParameter(DefaultValue = "34567")]
+        public class NamedLong : Name<long>
+        {
+        }
+    }
+
+    public class FloatTest
+    {
+        private readonly float f;
+
+        [Inject]
+        public FloatTest([Parameter(typeof(NamedSingle))] float f)
+        {
+            this.f = f;
+        }
+
+        public void Verify(float v)
+        {
+            Assert.AreEqual(v, f);
+        }
+
+        [NamedParameter(DefaultValue = "12.5")]
+        public class NamedSingle : Name<float>
+        {
+        }
+    }
+}
\ No newline at end of file


[28/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/EvaluatorRunTime.pb.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/EvaluatorRunTime.pb.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/EvaluatorRunTime.pb.cs
new file mode 100644
index 0000000..5e6007f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/EvaluatorRunTime.pb.cs
@@ -0,0 +1,305 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+// Generated from: evaluator_runtime.proto
+// Note: requires additional types generated from: reef_service_protos.proto
+namespace Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto
+{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"StopEvaluatorProto")]
+  public partial class StopEvaluatorProto : global::ProtoBuf.IExtensible
+  {
+    public StopEvaluatorProto() {}
+    
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"KillEvaluatorProto")]
+  public partial class KillEvaluatorProto : global::ProtoBuf.IExtensible
+  {
+    public KillEvaluatorProto() {}
+    
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"StartTaskProto")]
+  public partial class StartTaskProto : global::ProtoBuf.IExtensible
+  {
+    public StartTaskProto() {}
+    
+    private string _context_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"context_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string context_id
+    {
+      get { return _context_id; }
+      set { _context_id = value; }
+    }
+    private string _configuration;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"configuration", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string configuration
+    {
+      get { return _configuration; }
+      set { _configuration = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"AddContextProto")]
+  public partial class AddContextProto : global::ProtoBuf.IExtensible
+  {
+    public AddContextProto() {}
+    
+    private string _parent_context_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"parent_context_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string parent_context_id
+    {
+      get { return _parent_context_id; }
+      set { _parent_context_id = value; }
+    }
+    private string _context_configuration;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"context_configuration", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string context_configuration
+    {
+      get { return _context_configuration; }
+      set { _context_configuration = value; }
+    }
+    private string _service_configuration = "";
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"service_configuration", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string service_configuration
+    {
+      get { return _service_configuration; }
+      set { _service_configuration = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RemoveContextProto")]
+  public partial class RemoveContextProto : global::ProtoBuf.IExtensible
+  {
+    public RemoveContextProto() {}
+    
+    private string _context_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"context_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string context_id
+    {
+      get { return _context_id; }
+      set { _context_id = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"StopTaskProto")]
+  public partial class StopTaskProto : global::ProtoBuf.IExtensible
+  {
+    public StopTaskProto() {}
+    
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"SuspendTaskProto")]
+  public partial class SuspendTaskProto : global::ProtoBuf.IExtensible
+  {
+    public SuspendTaskProto() {}
+    
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ContextMessageProto")]
+  public partial class ContextMessageProto : global::ProtoBuf.IExtensible
+  {
+    public ContextMessageProto() {}
+    
+    private string _context_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"context_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string context_id
+    {
+      get { return _context_id; }
+      set { _context_id = value; }
+    }
+    private byte[] _message;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public byte[] message
+    {
+      get { return _message; }
+      set { _message = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ContextControlProto")]
+  public partial class ContextControlProto : global::ProtoBuf.IExtensible
+  {
+    public ContextControlProto() {}
+    
+    private byte[] _task_message = null;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"task_message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] task_message
+    {
+      get { return _task_message; }
+      set { _task_message = value; }
+    }
+    private ContextMessageProto _context_message = null;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"context_message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public ContextMessageProto context_message
+    {
+      get { return _context_message; }
+      set { _context_message = value; }
+    }
+    private AddContextProto _add_context = null;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"add_context", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public AddContextProto add_context
+    {
+      get { return _add_context; }
+      set { _add_context = value; }
+    }
+    private RemoveContextProto _remove_context = null;
+    [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"remove_context", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public RemoveContextProto remove_context
+    {
+      get { return _remove_context; }
+      set { _remove_context = value; }
+    }
+    private StartTaskProto _start_task = null;
+    [global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"start_task", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public StartTaskProto start_task
+    {
+      get { return _start_task; }
+      set { _start_task = value; }
+    }
+    private StopTaskProto _stop_task = null;
+    [global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"stop_task", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public StopTaskProto stop_task
+    {
+      get { return _stop_task; }
+      set { _stop_task = value; }
+    }
+    private SuspendTaskProto _suspend_task = null;
+    [global::ProtoBuf.ProtoMember(9, IsRequired = false, Name=@"suspend_task", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public SuspendTaskProto suspend_task
+    {
+      get { return _suspend_task; }
+      set { _suspend_task = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"EvaluatorHeartbeatProto")]
+  public partial class EvaluatorHeartbeatProto : global::ProtoBuf.IExtensible
+  {
+    public EvaluatorHeartbeatProto() {}
+    
+    private long _timestamp;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"timestamp", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public long timestamp
+    {
+      get { return _timestamp; }
+      set { _timestamp = value; }
+    }
+    private EvaluatorStatusProto _evaluator_status;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"evaluator_status", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public EvaluatorStatusProto evaluator_status
+    {
+      get { return _evaluator_status; }
+      set { _evaluator_status = value; }
+    }
+    private readonly global::System.Collections.Generic.List<ContextStatusProto> _context_status = new global::System.Collections.Generic.List<ContextStatusProto>();
+    [global::ProtoBuf.ProtoMember(3, Name=@"context_status", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<ContextStatusProto> context_status
+    {
+      get { return _context_status; }
+    }
+  
+    private TaskStatusProto _task_status = null;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"task_status", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public TaskStatusProto task_status
+    {
+      get { return _task_status; }
+      set { _task_status = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+
+    private bool _recovery;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name = @"recovery", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool recovery
+    {
+        get { return _recovery; }
+        set { _recovery = value; }
+    }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"EvaluatorControlProto")]
+  public partial class EvaluatorControlProto : global::ProtoBuf.IExtensible
+  {
+    public EvaluatorControlProto() {}
+    
+    private long _timestamp;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"timestamp", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public long timestamp
+    {
+      get { return _timestamp; }
+      set { _timestamp = value; }
+    }
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private ContextControlProto _context_control = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"context_control", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public ContextControlProto context_control
+    {
+      get { return _context_control; }
+      set { _context_control = value; }
+    }
+    private KillEvaluatorProto _kill_evaluator = null;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"kill_evaluator", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public KillEvaluatorProto kill_evaluator
+    {
+      get { return _kill_evaluator; }
+      set { _kill_evaluator = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefProtocol.pb.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefProtocol.pb.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefProtocol.pb.cs
new file mode 100644
index 0000000..b5a9daa
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefProtocol.pb.cs
@@ -0,0 +1,78 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: reef_protocol.proto
+// Note: requires additional types generated from: client_runtime.proto
+// Note: requires additional types generated from: evaluator_runtime.proto
+// Note: requires additional types generated from: reef_service_protos.proto
+using Org.Apache.Reef.Common.ProtoBuf.ClienRuntimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+
+namespace Org.Apache.Reef.Common.ProtoBuf.ReefProtocol
+{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"REEFMessage")]
+  public partial class REEFMessage : global::ProtoBuf.IExtensible
+  {
+    public REEFMessage() {}
+    
+    private JobSubmissionProto _jobSubmission = null;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"jobSubmission", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public JobSubmissionProto jobSubmission
+    {
+      get { return _jobSubmission; }
+      set { _jobSubmission = value; }
+    }
+    private JobControlProto _jobControl = null;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"jobControl", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public JobControlProto jobControl
+    {
+      get { return _jobControl; }
+      set { _jobControl = value; }
+    }
+    private RuntimeErrorProto _runtimeError = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"runtimeError", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public RuntimeErrorProto runtimeError
+    {
+      get { return _runtimeError; }
+      set { _runtimeError = value; }
+    }
+    private JobStatusProto _jobStatus = null;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"jobStatus", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public JobStatusProto jobStatus
+    {
+      get { return _jobStatus; }
+      set { _jobStatus = value; }
+    }
+    private EvaluatorControlProto _evaluatorControl = null;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"evaluatorControl", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public EvaluatorControlProto evaluatorControl
+    {
+      get { return _evaluatorControl; }
+      set { _evaluatorControl = value; }
+    }
+    private EvaluatorHeartbeatProto _evaluatorHeartBeat = null;
+    [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"evaluatorHeartBeat", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public EvaluatorHeartbeatProto evaluatorHeartBeat
+    {
+      get { return _evaluatorHeartBeat; }
+      set { _evaluatorHeartBeat = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefService.pb.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefService.pb.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefService.pb.cs
new file mode 100644
index 0000000..d0dd8df
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/ReefService.pb.cs
@@ -0,0 +1,393 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: reef_service_protos.proto
+namespace Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto
+
+{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"FileResourceProto")]
+  public partial class FileResourceProto : global::ProtoBuf.IExtensible
+  {
+    public FileResourceProto() {}
+    
+    private FileType _type;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"type", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public FileType type
+    {
+      get { return _type; }
+      set { _type = value; }
+    }
+    private string _name;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string name
+    {
+      get { return _name; }
+      set { _name = value; }
+    }
+    private string _path;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"path", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string path
+    {
+      get { return _path; }
+      set { _path = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RuntimeErrorProto")]
+  public partial class RuntimeErrorProto : global::ProtoBuf.IExtensible
+  {
+    public RuntimeErrorProto() {}
+    
+    private string _name;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string name
+    {
+      get { return _name; }
+      set { _name = value; }
+    }
+    private string _message;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string message
+    {
+      get { return _message; }
+      set { _message = value; }
+    }
+    private byte[] _exception = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"exception", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] exception
+    {
+      get { return _exception; }
+      set { _exception = value; }
+    }
+    private string _identifier = "";
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"JobStatusProto")]
+  public partial class JobStatusProto : global::ProtoBuf.IExtensible
+  {
+    public JobStatusProto() {}
+    
+    private string _identifier;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"identifier", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string identifier
+    {
+      get { return _identifier; }
+      set { _identifier = value; }
+    }
+    private State _state;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"state", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public State state
+    {
+      get { return _state; }
+      set { _state = value; }
+    }
+    private byte[] _message = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] message
+    {
+      get { return _message; }
+      set { _message = value; }
+    }
+    private byte[] _exception = null;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"exception", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] exception
+    {
+      get { return _exception; }
+      set { _exception = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ContextStatusProto")]
+  public partial class ContextStatusProto : global::ProtoBuf.IExtensible
+  {
+    public ContextStatusProto() {}
+    
+    private ContextStatusProto.State _context_state;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"context_state", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public ContextStatusProto.State context_state
+    {
+      get { return _context_state; }
+      set { _context_state = value; }
+    }
+    private string _context_id;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"context_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string context_id
+    {
+      get { return _context_id; }
+      set { _context_id = value; }
+    }
+    private string _parent_id = "";
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"parent_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string parent_id
+    {
+      get { return _parent_id; }
+      set { _parent_id = value; }
+    }
+    private byte[] _error = null;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] error
+    {
+      get { return _error; }
+      set { _error = value; }
+    }
+    private bool _recovery = false;
+    [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name = @"recovery", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(false)]
+    public bool recovery
+    {
+        get { return _recovery; }
+        set { _recovery = value; }
+    }
+    private readonly global::System.Collections.Generic.List<ContextStatusProto.ContextMessageProto> _context_message = new global::System.Collections.Generic.List<ContextStatusProto.ContextMessageProto>();
+    [global::ProtoBuf.ProtoMember(7, Name=@"context_message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<ContextStatusProto.ContextMessageProto> context_message
+    {
+      get { return _context_message; }
+    }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ContextMessageProto")]
+  public partial class ContextMessageProto : global::ProtoBuf.IExtensible
+  {
+    public ContextMessageProto() {}
+    
+    private string _source_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"source_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string source_id
+    {
+      get { return _source_id; }
+      set { _source_id = value; }
+    }
+    private byte[] _message;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public byte[] message
+    {
+      get { return _message; }
+      set { _message = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+    [global::ProtoBuf.ProtoContract(Name=@"State")]
+    public enum State
+    {
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"READY", Value=0)]
+      READY = 0,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"DONE", Value=1)]
+      DONE = 1,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"FAIL", Value=2)]
+      FAIL = 2
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TaskStatusProto")]
+  public partial class TaskStatusProto : global::ProtoBuf.IExtensible
+  {
+    public TaskStatusProto() {}
+    
+    private string _task_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"task_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string task_id
+    {
+      get { return _task_id; }
+      set { _task_id = value; }
+    }
+    private string _context_id;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"context_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string context_id
+    {
+      get { return _context_id; }
+      set { _context_id = value; }
+    }
+    private State _state;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"state", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public State state
+    {
+      get { return _state; }
+      set { _state = value; }
+    }
+    private byte[] _result = null;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"result", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] result
+    {
+      get { return _result; }
+      set { _result = value; }
+    }
+    private bool _recovery = false;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name = @"recovery", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(false)]
+    public bool recovery
+    {
+        get { return _recovery; }
+        set { _recovery = value; }
+    }
+    private readonly global::System.Collections.Generic.List<TaskStatusProto.TaskMessageProto> _task_message = new global::System.Collections.Generic.List<TaskStatusProto.TaskMessageProto>();
+    [global::ProtoBuf.ProtoMember(6, Name=@"task_message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<TaskStatusProto.TaskMessageProto> task_message
+    {
+      get { return _task_message; }
+    }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TaskMessageProto")]
+  public partial class TaskMessageProto : global::ProtoBuf.IExtensible
+  {
+    public TaskMessageProto() {}
+    
+    private string _source_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"source_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string source_id
+    {
+      get { return _source_id; }
+      set { _source_id = value; }
+    }
+    private byte[] _message;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"message", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public byte[] message
+    {
+      get { return _message; }
+      set { _message = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"EvaluatorStatusProto")]
+  public partial class EvaluatorStatusProto : global::ProtoBuf.IExtensible
+  {
+    public EvaluatorStatusProto() {}
+    
+    private string _evaluator_id;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"evaluator_id", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string evaluator_id
+    {
+      get { return _evaluator_id; }
+      set { _evaluator_id = value; }
+    }
+    private State _state;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"state", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public State state
+    {
+      get { return _state; }
+      set { _state = value; }
+    }
+    private byte[] _error = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public byte[] error
+    {
+      get { return _error; }
+      set { _error = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+    [global::ProtoBuf.ProtoContract(Name=@"State")]
+    public enum State
+    {
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"INIT", Value=0)]
+      INIT = 0,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"RUNNING", Value=1)]
+      RUNNING = 1,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"DONE", Value=2)]
+      DONE = 2,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"SUSPEND", Value=3)]
+      SUSPEND = 3,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"FAILED", Value=4)]
+      FAILED = 4,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"KILLED", Value=5)]
+      KILLED = 5
+    }
+  
+    [global::ProtoBuf.ProtoContract(Name=@"FileType")]
+    public enum FileType
+    {
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"PLAIN", Value=0)]
+      PLAIN = 0,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"LIB", Value=1)]
+      LIB = 1,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"ARCHIVE", Value=2)]
+      ARCHIVE = 2
+    }
+  
+    [global::ProtoBuf.ProtoContract(Name=@"SIZE")]
+    public enum SIZE
+    {
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"SMALL", Value=0)]
+      SMALL = 0,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"MEDIUM", Value=1)]
+      MEDIUM = 1,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"LARGE", Value=2)]
+      LARGE = 2,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"XLARGE", Value=3)]
+      XLARGE = 3
+    }
+  
+    [global::ProtoBuf.ProtoContract(Name=@"ProcessType")]
+    public enum ProcessType
+    {
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"JVM", Value=0)]
+      JVM = 0,
+            
+      [global::ProtoBuf.ProtoEnum(Name=@"CLR", Value=1)]
+      CLR = 1
+    }
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/Serializer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/Serializer.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/Serializer.cs
new file mode 100644
index 0000000..1af9a62
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/Serializer.cs
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Utilities;
+
+using ProtoBuf;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.IO;
+using System.Text;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1403:FileMayOnlyContainASingleNamespace", Justification = "Serializers for all protobuf types")]
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Serializers for all protobuf types")]
+
+namespace Org.Apache.Reef.Common.ProtoBuf.ReefProtocol
+{
+    /// <summary>
+    /// Add serializer/deserializer to REEFMessage
+    /// </summary>
+    public partial class REEFMessage
+    {
+        public REEFMessage(EvaluatorHeartbeatProto evaluatorHeartbeatProto)
+        {
+            _evaluatorHeartBeat = evaluatorHeartbeatProto;
+        }
+
+        public static REEFMessage Deserialize(byte[] bytes)
+        {
+            REEFMessage pbuf = null;
+            using (var s = new MemoryStream(bytes))
+            {
+                pbuf = Serializer.Deserialize<REEFMessage>(s);
+            }
+            return pbuf;
+        }
+
+        public byte[] Serialize()
+        {
+            byte[] b = null;
+            using (var s = new MemoryStream())
+            {
+                Serializer.Serialize<REEFMessage>(s, this);
+                b = new byte[s.Position];
+                var fullBuffer = s.GetBuffer();
+                Array.Copy(fullBuffer, b, b.Length);
+            }
+            return b;
+        }
+    }
+}
+
+namespace Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto
+{
+    /// <summary>
+    /// Add serializer/deserializer to EvaluatorHeartbeatProto
+    /// </summary>
+    public partial class EvaluatorHeartbeatProto
+    {
+        public static EvaluatorHeartbeatProto Deserialize(byte[] bytes)
+        {
+            EvaluatorHeartbeatProto pbuf = null;
+            using (var s = new MemoryStream(bytes))
+            {
+                pbuf = Serializer.Deserialize<EvaluatorHeartbeatProto>(s);
+            }
+            return pbuf;
+        }
+
+        public byte[] Serialize()
+        {
+            byte[] b = null;
+            using (var s = new MemoryStream())
+            {
+                Serializer.Serialize<EvaluatorHeartbeatProto>(s, this);
+                b = new byte[s.Position];
+                var fullBuffer = s.GetBuffer();
+                Array.Copy(fullBuffer, b, b.Length);
+            }
+            return b;
+        }
+
+        public override string ToString()
+        {
+            string contextStatus = string.Empty;
+            string taskStatusMessage = string.Empty;
+            foreach (ContextStatusProto contextStatusProto in context_status)
+            {
+                contextStatus += string.Format(CultureInfo.InvariantCulture, "evaluator {0} has context {1} in state {2} with recovery flag {3}",
+                                               evaluator_status.evaluator_id,
+                                               contextStatusProto.context_id,
+                                               contextStatusProto.context_state,
+                                               contextStatusProto.recovery);
+            }
+            if (task_status != null && task_status.task_message != null && task_status.task_message.Count > 0)
+            {
+                foreach (TaskStatusProto.TaskMessageProto taskMessageProto in task_status.task_message)
+                {
+                    taskStatusMessage += ByteUtilities.ByteArrarysToString(taskMessageProto.message);
+                }
+            }
+            return string.Format(CultureInfo.InvariantCulture, "EvaluatorHeartbeatProto: task_id=[{0}], task_status=[{1}], task_message=[{2}], evaluator_status=[{3}], context_status=[{4}], timestamp=[{5}], recoveryFlag =[{6}]",
+                task_status == null ? string.Empty : task_status.task_id,
+                task_status == null ? string.Empty : task_status.state.ToString(),
+                taskStatusMessage,
+                evaluator_status.state.ToString(),
+                contextStatus,
+                timestamp,
+                recovery);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/EvaluatorHeartbeatProtoCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/EvaluatorHeartbeatProtoCodec.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/EvaluatorHeartbeatProtoCodec.cs
new file mode 100644
index 0000000..9dfe708
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/EvaluatorHeartbeatProtoCodec.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.Common.ProtoBuf.ReefProtocol
+{
+    public class EvaluatorHeartbeatProtoCodec : ICodec<EvaluatorHeartbeatProto>
+    {
+        public byte[] Encode(EvaluatorHeartbeatProto obj)
+        {
+            EvaluatorHeartbeatProto pbuf = new EvaluatorHeartbeatProto();
+
+            pbuf.evaluator_status = obj.evaluator_status;
+            return pbuf.Serialize();
+        }
+
+        public EvaluatorHeartbeatProto Decode(byte[] data)
+        {
+            EvaluatorHeartbeatProto pbuf = EvaluatorHeartbeatProto.Deserialize(data);
+            return pbuf;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/REEFMessageCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/REEFMessageCodec.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/REEFMessageCodec.cs
new file mode 100644
index 0000000..84d6d05
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/cs/codec/REEFMessageCodec.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.Common.ProtoBuf.ReefProtocol
+{
+    public class REEFMessageCodec : ICodec<REEFMessage>
+    {
+        public byte[] Encode(REEFMessage obj)
+        {
+            return obj.Serialize();
+        }
+
+        public REEFMessage Decode(byte[] data)
+        {
+            REEFMessage pbuf = REEFMessage.Deserialize(data);
+            return pbuf;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/client_runtime.proto
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/client_runtime.proto b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/client_runtime.proto
new file mode 100644
index 0000000..3d1f927
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/client_runtime.proto
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+option java_package = "org.apache.reef.proto";
+option java_outer_classname = "ClientRuntimeProtocol";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+import "reef_service_protos.proto";
+
+// Messages from REEF Client -> Driver Runtime
+
+message JobSubmissionProto {
+	required string identifier     = 1; // the job identifier
+	required string remote_id      = 2; // the remote identifier
+	required string configuration  = 5; // the runtime configuration
+	required string user_name      = 6; // the user name
+
+  optional SIZE   driver_size    = 7;
+  optional int32  driver_memory  = 8;
+  optional int32  priority       = 9;
+  optional string queue          = 10;
+
+	repeated FileResourceProto global_file = 11; // files that should be placed on the driver and all subsequent evaluators
+	repeated FileResourceProto local_File  = 12; // files that should be placed on the driver only
+
+}
+
+enum Signal {
+	SIG_TERMINATE = 1;
+	SIG_SUSPEND   = 2;
+	SIG_RESUME    = 3;
+}
+
+message JobControlProto {
+	required string identifier = 1;
+	optional Signal signal     = 2;
+	optional bytes message     = 3;
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/driver_runtime.proto
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/driver_runtime.proto b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/driver_runtime.proto
new file mode 100644
index 0000000..2b21ac7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/driver_runtime.proto
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+option java_package = "org.apache.reef.proto";
+option java_outer_classname = "DriverRuntimeProtocol";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+
+import "reef_service_protos.proto";
+
+// Messages from Driver Runtime -> Driver Process
+
+message DriverProcessRegistrationProto {
+	required string remote_identifier = 1;
+}
+
+
+message NodeDescriptorProto {
+	required string identifier = 1;
+	required string host_name  = 2; // e.g., IP address
+	required int32 port        = 3; // e.g., IP port
+	required int32 memory_size = 4;
+	optional string rack_name  = 5; // e.g., /default-rack
+}
+
+message ResourceAllocationProto {
+	required string identifier     = 1; // e.g., the container id, or the thread id
+	required int32 resource_memory = 2; // megabytes
+	required string node_id        = 3;
+}
+
+message ResourceStatusProto {
+	required string identifier   = 1;
+	required State  state        = 2;
+	optional string diagnostics  = 3;
+	optional int32  exit_code    = 4;
+	optional bool is_from_previous_driver = 5;
+}
+
+message RuntimeStatusProto {
+   required string name  = 1;   // e.g., local, yarn21
+   required State  state = 2;
+   optional RuntimeErrorProto error = 3; // runtime (e.g., YARN) error
+
+   optional int32 outstanding_container_requests = 5;
+   repeated string container_allocation = 6;
+}
+
+//////////////////////////////////////////////////////
+// Messages from Driver Process -> Driver Runtime
+
+message ResourceRequestProto {
+	// optional SIZE resource_size   = 1; // Removed in REEF 0.3 in favor of memory_size.
+    optional int32 memory_size = 2; // Memory size of the evaluator in MB
+    optional int32 priority       = 3;
+
+    required int32 resource_count = 5;
+	repeated string node_name     = 6; // a list of specific nodes
+	repeated string rack_name     = 7; // a list of specific racks
+
+    optional bool relax_locality = 10;
+}
+
+message ResourceReleaseProto {
+	required string identifier = 1;
+}
+
+message ResourceLaunchProto {
+	required string identifier      = 1;
+	required string remote_id       = 2;
+	required string evaluator_conf  = 3;
+    required ProcessType type       = 4;
+	repeated FileResourceProto file = 10;
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/evaluator_runtime.proto
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/evaluator_runtime.proto b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/evaluator_runtime.proto
new file mode 100644
index 0000000..1415e5c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/evaluator_runtime.proto
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+option java_package = "org.apache.reef.proto";
+option java_outer_classname = "EvaluatorRuntimeProtocol";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+import "reef_service_protos.proto";
+
+// Stop the evaluator
+message StopEvaluatorProto {
+}
+
+// Kill the evaluator
+message KillEvaluatorProto {
+}
+
+// Start a task
+message StartTaskProto {
+    required string context_id = 1;
+    required string configuration = 2;
+}
+
+message AddContextProto {
+    required string parent_context_id = 1;
+    required string context_configuration = 2;
+    optional string service_configuration = 3;
+}
+
+message RemoveContextProto {
+    required string context_id = 1;
+}
+
+// Stop the task
+message StopTaskProto {
+}
+
+// Suspend the task
+message SuspendTaskProto {
+}
+
+/////////////////////////////////////////
+// Message aggregators
+
+message ContextMessageProto {
+    required string context_id = 1;
+    required bytes message = 2;
+}
+
+message ContextControlProto {
+    optional bytes task_message = 1;
+    optional ContextMessageProto context_message = 2;
+
+    optional AddContextProto    add_context    = 5;
+    optional RemoveContextProto remove_context = 6;
+    optional StartTaskProto     start_task     = 7;
+    optional StopTaskProto      stop_task      = 8;
+    optional SuspendTaskProto   suspend_task   = 9;
+}
+
+message EvaluatorHeartbeatProto {
+    required int64 timestamp = 1;
+    required EvaluatorStatusProto evaluator_status = 2;
+    repeated ContextStatusProto   context_status   = 3;
+    optional TaskStatusProto      task_status      = 4;
+    optional bool                 recovery         = 5;  
+}
+
+message EvaluatorControlProto {
+    required int64 timestamp = 1;
+    required string identifier = 2;
+
+    optional ContextControlProto context_control = 3;
+    optional KillEvaluatorProto kill_evaluator = 4;
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_protocol.proto
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_protocol.proto b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_protocol.proto
new file mode 100644
index 0000000..a442445
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_protocol.proto
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+import "client_runtime.proto";
+
+import "evaluator_runtime.proto";
+
+import "reef_service_protos.proto";
+
+
+option java_package = "com.Org.Apache.Reef.proto";
+
+option java_generic_services = true;
+
+option java_generate_equals_and_hash = true;
+
+option java_outer_classname = "REEFProtocol";
+
+message REEFMessage {
+    // Messages defined in client_runtime.proto
+    optional JobSubmissionProto jobSubmission = 1;
+    optional JobControlProto jobControl = 2;
+    // Messages defined in reef_service_protos.proto
+    optional RuntimeErrorProto runtimeError = 3;
+    optional JobStatusProto jobStatus = 4;
+    // Messages from evaluator_runtime.proto
+    optional EvaluatorControlProto evaluatorControl = 5;
+    optional EvaluatorHeartbeatProto evaluatorHeartBeat = 6;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_service_protos.proto
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_service_protos.proto b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_service_protos.proto
new file mode 100644
index 0000000..a553ca9
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/protobuf/proto/reef_service_protos.proto
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+option java_package = "org.apache.reef.reef.proto";
+
+option java_outer_classname = "ReefServiceProtos";
+
+option java_generic_services = true;
+
+option java_generate_equals_and_hash = true;
+
+enum State {
+    INIT = 0;
+    RUNNING = 1;
+    DONE = 2;
+    SUSPEND = 3;
+    FAILED = 4;
+    KILLED = 5;
+}
+
+enum FileType {
+    PLAIN = 0;
+    LIB = 1;
+    ARCHIVE = 2;
+}
+
+// Removed in REEF 0.3 in favor of explicit memory sizes.
+// enum SIZE {
+//    SMALL = 0;
+//    MEDIUM = 1;
+//    LARGE = 2;
+//    XLARGE = 3;
+//}
+
+enum ProcessType {
+    JVM = 0;
+    CLR = 1;
+}
+
+message FileResourceProto {
+    required FileType type = 1;
+    required string name = 2;
+    required string path = 3;
+}
+
+message RuntimeErrorProto {
+    required string name = 1; // e.g., local, yarn21
+    required string message = 2;
+    optional bytes exception = 3;
+
+    optional string identifier = 5; // e.g., evaluator id
+}
+
+message JobStatusProto {
+    required string identifier = 1;
+    required State state = 2;
+    optional bytes message = 3;
+    optional bytes exception = 4;
+}
+
+message ContextStatusProto {
+    enum State {
+        READY = 0;
+        DONE = 1;
+        FAIL = 2;
+    }
+    required State context_state = 1;
+
+    required string context_id = 2;
+    optional string parent_id = 3;
+
+    optional bytes error = 5; // when creating the context
+
+    optional bool recovery = 6;
+    // Context messages
+    message ContextMessageProto {
+        required string source_id = 1;
+        required bytes message = 2;
+    }
+    repeated ContextMessageProto context_message = 7;
+}
+
+message TaskStatusProto {
+    required string task_id = 1;
+    required string context_id = 2;
+    required State state = 3;
+    optional bytes result = 4; // e.g., return value from Task.call()
+    optional bool  recovery = 5;
+
+    // TaskMessageSource messages
+    message TaskMessageProto {
+        required string source_id = 1;
+        required bytes message = 2;
+    }
+    repeated TaskMessageProto task_message = 6;
+}
+
+message EvaluatorStatusProto {
+    required string evaluator_id = 1;
+    required State state = 2;
+    optional bytes error = 3;
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/MachineStatus.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/MachineStatus.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/MachineStatus.cs
new file mode 100644
index 0000000..548888c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/MachineStatus.cs
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Globalization;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Common.Runtime
+{
+    public class MachineStatus
+    {
+        private static PerformanceCounter _cpuCounter;
+
+        private static PerformanceCounter _ramCounter;
+
+        private static PerformanceCounter _processCpuCounter;
+
+        private static Process _process;
+
+        private static bool _checkStatus;
+
+        static MachineStatus()
+        {
+            _checkStatus = true;
+            _process = Process.GetCurrentProcess();
+            string processName = _process.ProcessName;
+
+            _cpuCounter = _cpuCounter ?? new PerformanceCounter()
+            {
+                CategoryName = "Processor",
+                CounterName = "% Processor Time",
+                InstanceName = "_Total",
+            };
+
+            _ramCounter = _ramCounter ?? new PerformanceCounter()
+            {
+                CategoryName = "Memory",
+                CounterName = "Available MBytes"
+            };
+
+            _processCpuCounter = _processCpuCounter ?? new PerformanceCounter()
+            {
+                CategoryName = "Process",
+                CounterName = "% Processor Time",
+                InstanceName = processName
+            };
+        }
+
+        public static string CurrentNodeCpuUsage
+        {
+            get
+            {
+                return _cpuCounter.NextValue() + "%";
+            }
+        }
+
+        public static string AvailableMemory
+        {
+            get
+            {
+                return _ramCounter.NextValue() + "MB";
+            }
+        }
+
+        public static string CurrentProcessMemoryUsage
+        {
+            get
+            {
+                return ((float)_process.WorkingSet64 / 1000000.0).ToString(CultureInfo.InvariantCulture) + "MB";
+            }
+        }
+
+        public static string PeakProcessMemoryUsage
+        {
+            get
+            {
+                return ((float)_process.PeakWorkingSet64 / 1000000.0).ToString(CultureInfo.InvariantCulture) + "MB";
+            }
+        }
+
+        // this may not be accurate if there are multiple evaluator processes running on a single machine
+        public static string CurrentProcessCpuUsage
+        {
+            get
+            {
+                return ((float)_processCpuCounter.RawValue / 1000000.0) + "%";
+            }
+        }
+
+        public override string ToString()
+        {
+            string info = "No machine status information retrieved. Could be due to lack of admin right to get the info.";
+            if (_checkStatus)
+            {
+                try
+                {
+                    _process.Refresh();
+                    info = string.Format(
+                    CultureInfo.InvariantCulture,
+                    "current node is running at [{0}] CPU usage and with [{1}] memory available.{2}             current evaluator process is using [{3}] of CPU and [{4}] of memory, with a peak memory usage of [{5}]",
+                    CurrentNodeCpuUsage,
+                    AvailableMemory,
+                    Environment.NewLine,
+                    CurrentProcessCpuUsage,
+                    CurrentProcessMemoryUsage,
+                    PeakProcessMemoryUsage);
+                }
+                catch (Exception e)
+                {
+                    _checkStatus = false; // It only takes one exception to switch the cheking off for good.
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, "Cannot obtain machine status due to error", Logger.GetLogger(typeof(MachineStatus)));
+                    // we do not want to crash the evealuator just because we cannot get the information.
+                    info = "Cannot obtain machine status due to error " + e.Message;
+                }
+            }
+            
+            return info;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/Constants.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/Constants.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/Constants.cs
new file mode 100644
index 0000000..dc4ee0a
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/Constants.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Evaluator
+{
+    public class Constants
+    {
+        public const string RootContextConfiguration = "RootContextConfiguration";
+
+        public const string EvaluatorIdentifier = "EvaluatorIdentifier";
+
+        public const string RootServiceConfiguration = "RootServiceConfiguration";
+
+        public const string TaskConfiguration = "TaskConfiguration";
+
+        public const string ContextIdentifier = "ContextIdentifier";
+
+        public const string ApplicationIdentifier = "ApplicationIdentifier";
+
+        public const int DefaultEvaluatorHeartbeatPeriodInMs = 4000;
+
+        public const int DefaultEvaluatorHeartbeatMaxRetry = 3;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorRuntime.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorRuntime.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorRuntime.cs
new file mode 100644
index 0000000..052764d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorRuntime.cs
@@ -0,0 +1,255 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Evaluator;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Time;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common
+{
+    public class EvaluatorRuntime : IObserver<RuntimeStart>, IObserver<RuntimeStop>, IObserver<REEFMessage>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorRuntime));
+        
+        private readonly string _evaluatorId;
+
+        private readonly ContextManager _contextManager;
+
+        private readonly HeartBeatManager _heartBeatManager;
+
+        private readonly IRemoteManager<REEFMessage> _remoteManager;
+
+        private readonly IClock _clock;
+
+        private State _state = State.INIT;
+
+        private IDisposable _evaluatorControlChannel; 
+
+        [Inject]
+        public EvaluatorRuntime(
+            ContextManager contextManager,
+            HeartBeatManager heartBeatManager)
+        {
+            using (LOGGER.LogFunction("EvaluatorRuntime::EvaluatorRuntime"))
+            {
+                _clock = heartBeatManager.EvaluatorSettings.RuntimeClock;
+                _heartBeatManager = heartBeatManager;
+                _contextManager = contextManager;
+                _evaluatorId = heartBeatManager.EvaluatorSettings.EvalutorId;
+                _remoteManager = heartBeatManager.EvaluatorSettings.RemoteManager;
+
+                ReefMessageProtoObserver driverObserver = new ReefMessageProtoObserver();
+
+                // subscribe to driver proto message
+                driverObserver.Subscribe(o => OnNext(o.Message));
+
+                // register the driver observer
+                _evaluatorControlChannel = _remoteManager.RegisterObserver(driverObserver);
+
+                // start the hearbeat
+                _clock.ScheduleAlarm(0, heartBeatManager);
+            }
+        }
+
+        public State State
+        {
+            get
+            {
+                return _state;
+            }
+        }
+
+        public void Handle(EvaluatorControlProto message)
+        {
+            lock (_heartBeatManager)
+            {
+                LOGGER.Log(Level.Info, "Handle Evaluator control message");
+                if (!message.identifier.Equals(_evaluatorId, StringComparison.OrdinalIgnoreCase))
+                {
+                    Handle(new InvalidOperationException(
+                        string.Format(CultureInfo.InvariantCulture, "Identifier mismatch: message for evaluator id[{0}] sent to evaluator id[{1}]", message.identifier, _evaluatorId)));
+                }
+                else if (_state != State.RUNNING)
+                {
+                    Handle(new InvalidOperationException(
+                        string.Format(CultureInfo.InvariantCulture, "Evaluator received a control message but its state is not {0} but rather {1}", State.RUNNING, _state)));
+                }
+                else
+                {
+                    if (message.context_control != null)
+                    {
+                        LOGGER.Log(Level.Info, "Send task control message to ContextManager");
+                        try
+                        {
+                            _contextManager.HandleTaskControl(message.context_control);
+                            if (_contextManager.ContextStackIsEmpty() && _state == State.RUNNING)
+                            {
+                                LOGGER.Log(Level.Info, "Context stack is empty, done");
+                                _state = State.DONE;
+                                _heartBeatManager.OnNext(GetEvaluatorStatus());
+                                _clock.Dispose();
+                            }
+                        }
+                        catch (Exception e)
+                        {
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                            Handle(e);
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException(e.ToString(), e), LOGGER);
+                        }
+                    }
+                    if (message.kill_evaluator != null)
+                    {
+                        LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} has been killed by the driver.", _evaluatorId));
+                        _state = State.KILLED;
+                        _clock.Dispose();
+                    }
+                }
+            }
+        }
+
+        public EvaluatorStatusProto GetEvaluatorStatus()
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator state : {0}", _state));
+            EvaluatorStatusProto evaluatorStatusProto = new EvaluatorStatusProto()
+            {
+                evaluator_id = _evaluatorId,
+                state = _state
+            };
+            return evaluatorStatusProto;
+        }
+
+        public void OnNext(RuntimeStart runtimeStart)
+        {
+            lock (_evaluatorId)
+            {
+                try
+                {
+                    LOGGER.Log(Level.Info, "Runtime start");
+                    if (_state != State.INIT)
+                    {
+                        var e = new InvalidOperationException("State should be init.");
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                    _state = State.RUNNING;
+                    _contextManager.Start();
+                    _heartBeatManager.OnNext();
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    Handle(e);
+                }
+            }
+        }
+
+        void IObserver<RuntimeStart>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<REEFMessage>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<REEFMessage>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStop>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStop>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStart>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(RuntimeStop runtimeStop)
+        {
+            LOGGER.Log(Level.Info, "Runtime stop");
+            _contextManager.Dispose();
+
+            if (_state == State.RUNNING)
+            {
+                _state = State.DONE;
+                _heartBeatManager.OnNext();
+            }
+            try
+            {
+                _evaluatorControlChannel.Dispose();
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(new InvalidOperationException("Cannot stop evaluator properly", e), Level.Error, "Exception during shut down.", LOGGER);
+            }
+            LOGGER.Log(Level.Info, "EvaluatorRuntime shutdown complete");        
+        }
+
+        public void OnNext(REEFMessage value)
+        {
+            if (value != null && value.evaluatorControl != null)
+            {
+                LOGGER.Log(Level.Info, "Received a REEFMessage with EvaluatorControl");
+                Handle(value.evaluatorControl);
+            }
+        }
+
+        private void Handle(Exception e)
+        {
+            lock (_heartBeatManager)
+            {
+                LOGGER.Log(Level.Error, string.Format(CultureInfo.InvariantCulture, "evaluator {0} failed with exception", _evaluatorId), e);
+                _state = State.FAILED;
+                string errorMessage = string.Format(
+                        CultureInfo.InvariantCulture,
+                        "failed with error [{0}] with mesage [{1}] and stack trace [{2}]",
+                        e,
+                        e.Message,
+                        e.StackTrace);
+                EvaluatorStatusProto evaluatorStatusProto = new EvaluatorStatusProto()
+                {
+                    evaluator_id = _evaluatorId,
+                    error = ByteUtilities.StringToByteArrays(errorMessage),
+                    state = _state
+                };
+                _heartBeatManager.OnNext(evaluatorStatusProto);
+                _contextManager.Dispose();
+            }       
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorSettings.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorSettings.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorSettings.cs
new file mode 100644
index 0000000..067a0a0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/EvaluatorSettings.cs
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Common.Evaluator.Context;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Time;
+using System;
+
+namespace Org.Apache.Reef.Evaluator
+{
+    // TODO: merge with EvaluatorConfigurations class
+    public class EvaluatorSettings
+    {
+        private string _applicationId;
+
+        private string _evaluatorId;
+
+        private int _heartBeatPeriodInMs;
+
+        private int _maxHeartbeatRetries;
+
+        private ContextConfiguration _rootContextConfig;
+
+        private IClock _clock;
+
+        private IRemoteManager<REEFMessage> _remoteManager;
+
+        private IInjector _injector;
+
+        private EvaluatorOperationState _operationState;
+
+        private INameClient _nameClient;
+
+        public EvaluatorSettings(
+            string applicationId,
+            string evaluatorId,
+            int heartbeatPeriodInMs,
+            int maxHeartbeatRetries,
+            ContextConfiguration rootContextConfig,
+            IClock clock,
+            IRemoteManager<REEFMessage> remoteManager,
+            IInjector injecor)
+        {
+            if (string.IsNullOrWhiteSpace(evaluatorId))
+            {
+                throw new ArgumentNullException("evaluatorId");
+            }
+            if (rootContextConfig == null)
+            {
+                throw new ArgumentNullException("rootContextConfig");
+            }
+            if (clock == null)
+            {
+                throw new ArgumentNullException("clock");
+            }
+            if (remoteManager == null)
+            {
+                throw new ArgumentNullException("remoteManager");
+            }
+            if (injecor == null)
+            {
+                throw new ArgumentNullException("injecor");
+            }
+            _applicationId = applicationId;
+            _evaluatorId = evaluatorId;
+            _heartBeatPeriodInMs = heartbeatPeriodInMs;
+            _maxHeartbeatRetries = maxHeartbeatRetries;
+            _rootContextConfig = rootContextConfig;
+            _clock = clock;
+            _remoteManager = remoteManager;
+            _injector = injecor;
+            _operationState = EvaluatorOperationState.OPERATIONAL;
+        }
+
+        public EvaluatorOperationState OperationState
+        {
+            get
+            {
+                return _operationState;
+            }
+
+            set
+            {
+                _operationState = value;
+            }
+        }
+
+        public string EvalutorId
+        {
+            get
+            {
+                return _evaluatorId;
+            }
+        }
+
+        public int HeartBeatPeriodInMs
+        {
+            get
+            {
+                return _heartBeatPeriodInMs;
+            }
+        }
+
+        public string ApplicationId
+        {
+            get
+            {
+                return _applicationId;
+            }
+        }
+
+        public int MaxHeartbeatFailures
+        {
+            get
+            {
+                return _maxHeartbeatRetries;
+            }
+        }
+
+        public ContextConfiguration RootContextConfig
+        {
+            get
+            {
+                return _rootContextConfig;
+            }
+        }
+
+        public IClock RuntimeClock
+        {
+            get
+            {
+                return _clock;
+            }
+        }
+
+        public INameClient NameClient
+        {
+            get
+            {
+                return _nameClient;
+            }
+
+            set
+            {
+                _nameClient = value;
+            }
+        }
+
+        public IRemoteManager<REEFMessage> RemoteManager
+        {
+            get
+            {
+                return _remoteManager;
+            }
+        }
+
+        public IInjector Injector
+        {
+            get
+            {
+                return _injector;
+            }
+        }
+    }
+}


[20/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs
new file mode 100644
index 0000000..6a06831
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Globalization;
+using System.Net;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.Handlers
+{
+    public class HelloHttpHandler : IHttpHandler
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(HttpServerHandler));
+
+        [Inject]
+        public HelloHttpHandler()
+        {           
+        }
+
+        public string GetSpecification()
+        {
+            return "NRT"; //Client Example 
+        }
+
+        public void OnHttpRequest(ReefHttpRequest requet, ReefHttpResponse response)  
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "HelloHttpHandler OnHttpRequest: URL: {0}, QueryString: {1}, inputStream: {2}.", requet.Url, requet.Querystring, ByteUtilities.ByteArrarysToString(requet.InputStream)));
+            response.Status = HttpStatusCode.OK;
+            response.OutputStream =
+                ByteUtilities.StringToByteArrays("Byte array returned from HelloHttpHandler in CLR!!!");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs
new file mode 100644
index 0000000..79e5af3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time;
+using System;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloRestartHandler : IObserver<StartTime>
+    {
+        [Inject]
+        public HelloRestartHandler()
+        {
+        }
+
+        public void OnNext(StartTime value)
+        {
+            Console.WriteLine("Hello from CLR: we are informed that Driver has restarted at " + new DateTime(value.TimeStamp));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs
new file mode 100644
index 0000000..927cb47
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.Handlers
+{
+    /// <summary>
+    /// Sample implementaion of RunningTaskHandler
+    /// </summary>
+    public class HelloRunningTaskHandler : IObserver<IRunningTask>
+    {
+        [Inject]
+        public HelloRunningTaskHandler()
+        {
+        }
+
+        public void OnNext(IRunningTask runningTask)
+        {
+            IActiveContext context = runningTask.ActiveContext;
+
+            string messageStr = string.Format(
+                CultureInfo.InvariantCulture,
+                "HelloRunningTaskHandler: Task [{0}] is running. Evaluator id: [{1}].",
+                runningTask.Id,
+                context.EvaluatorId);
+            Console.WriteLine(messageStr);
+
+            byte[] message = ByteUtilities.StringToByteArrays(messageStr);
+
+            runningTask.Send(message);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs
new file mode 100644
index 0000000..9e3e804
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs
@@ -0,0 +1,421 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.handlers
+{
+    enum DriverStatus
+    {
+        Init = 0,
+        Idle = 1,
+        RunningTasks = 2,
+        CompleteTasks = 3
+    }
+
+    internal enum TaskStatus
+    {
+        Submitting = 0,
+        Running = 1,
+        Completed = 2
+    }
+
+    /// <summary>
+    /// A demo class that contains basic handlers. It runs given tasks and is able to get request from http server and start to ren the tasks again. 
+    /// It handle various http requests. It also monitoring task status and driver status.
+    /// </summary>
+    public class HelloSimpleEventHandlers :
+        IObserver<IEvaluatorRequestor>,
+        IObserver<IAllocatedEvaluator>,
+        IObserver<IActiveContext>,
+        IObserver<ICompletedTask>,
+        IObserver<IRunningTask>,
+        IObserver<IFailedTask>,
+        IObserver<IFailedEvaluator>,
+        IObserver<ICompletedEvaluator>,
+        IStartHandler,
+        IHttpHandler
+    {
+        private const int NumberOfTasks = 5;
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(HelloSimpleEventHandlers));
+        private IAllocatedEvaluator _allocatedEvaluator;
+        private IActiveContext _activeContext;
+        private IList<IActiveContext> _activeContexts = new List<IActiveContext>();
+        private DriverStatus driveStatus;
+        private TaskContext _taskContext;
+
+        [Inject]
+        public HelloSimpleEventHandlers()
+        {
+            LOGGER.Log(Level.Info, "HelloSimpleEventHandlers constructor");
+            CreateClassHierarchy();
+            Identifier = "HelloSimpleEventHandlers";
+            _taskContext = new TaskContext();
+            _taskContext.TotalTasks = NumberOfTasks;
+            driveStatus = DriverStatus.Init;
+        }
+
+        public string Identifier { get; set; }
+
+        public static string ParsePathInfo(string pathInfo)
+        {
+            string[] p = pathInfo.Split('/');
+            foreach (string s in p)
+            {
+                LOGGER.Log(Level.Info, s);
+            }
+            if (p.Length > 3)
+            {
+                return p[3];
+            }
+            return null;
+        }
+
+        public static void BuildHttpResponse(
+            ReefHttpResponse response,
+            HttpStatusCode httpStatusCode,
+            string strResponse)
+        {
+            response.Status = httpStatusCode;
+            response.OutputStream = ByteUtilities.StringToByteArrays(strResponse);
+        }
+
+        public static void BuildHttpResponse(
+            ReefHttpResponse response,
+            HttpStatusCode httpStatusCode,
+            byte[] bytesResponse)
+        {
+            response.Status = httpStatusCode;
+            response.OutputStream = bytesResponse;
+        }
+
+        public void OnNext(IEvaluatorRequestor evalutorRequestor)
+        {
+            using (LOGGER.LogFunction("HelloSimpleEventHandlers::evalutorRequestor received"))
+            {
+                int evaluatorsNumber = 2;
+                int memory = 1024 * 3;
+                int cpuCoreCount = 1;
+                string rack = "WonderlandRack";
+                string evaluatorBatchId = "evaluatorThatRequires3GBofMemory";
+                EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, cpuCoreCount, rack, evaluatorBatchId);
+
+                evalutorRequestor.Submit(request);
+            }
+        }
+
+        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
+        {
+            string taskId = "Task_" + allocatedEvaluator.Id;
+            using (LOGGER.LogFunction("HelloSimpleEventHandlers::allocatedEvaluator received {0}.", taskId))
+            {
+                _allocatedEvaluator = allocatedEvaluator;
+
+                IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule.Set(ContextConfiguration.Identifier, "HelloSimpleEventHandlersContext_" + Guid.NewGuid().ToString("N")).Build();
+
+                allocatedEvaluator.SubmitContext(contextConfiguration);
+            }
+        }
+
+        public void OnNext(IActiveContext activeContext)
+        {
+            using (LOGGER.LogFunction("HelloSimpleEventHandlers::activeContext received"))
+            {
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received activeContext, EvaluatorId id: {0}", activeContext.EvaluatorId));
+                _activeContext = activeContext;
+                _activeContexts.Add(activeContext);
+                driveStatus = DriverStatus.RunningTasks;
+                SubmitNextTask(activeContext);
+            }
+        }
+
+        public void OnNext(ICompletedTask value)
+        {
+            using (LOGGER.LogFunction("HelloSimpleEventHandlers::CompletedTask received"))
+            {
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received CompletedTask: {0}, task id: {1}", value.Id, _taskContext.CurrentTaskId()));
+                _activeContext = value.ActiveContext;
+                _taskContext.UpdateTaskStatus(value.Id, TaskStatus.Completed);
+                _taskContext.TaskCompleted++;
+                SubmitNextTask(value.ActiveContext);
+            }
+        }
+
+        public void OnError(Exception error)
+        {
+            LOGGER.Log(Level.Error, string.Format(CultureInfo.InvariantCulture, "Exception in coral handlers Msg: {1} Stack: {2}", error.Message, error.StackTrace));
+        }
+
+        public void OnCompleted()
+        {
+        }
+
+        public void OnNext(IRunningTask value)
+        {
+           _taskContext.UpdateTaskStatus(_taskContext.CurrentTaskId(), TaskStatus.Running);
+        }
+
+        public void OnNext(IFailedTask value)
+        {           
+        }
+
+        public void OnNext(IFailedEvaluator value)
+        {            
+        }
+
+        public void OnNext(ICompletedEvaluator completedEvaluator)
+        {
+            string messageStr = string.Format(
+                CultureInfo.InvariantCulture,
+                "HelloSimpleEventHandlers: Evaluator [{0}] is done.",
+                completedEvaluator.Id);
+            Console.WriteLine(messageStr);
+        }
+
+        public string GetSpecification()
+        {
+            return "crystal";
+        }
+
+        public void OnHttpRequest(ReefHttpRequest request, ReefHttpResponse response)
+        {
+            string target = ParsePathInfo(request.PathInfo);
+            LOGGER.Log(Level.Info, "Target: " + target + ". PathInfo: " + request.PathInfo);
+            //if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("driverstatus"))
+            if (target != null && target.Equals("driverstatus"))
+                {
+                LOGGER.Log(Level.Info, "Target: " + target + ". Driver status: " + driveStatus.ToString());
+                string msg = string.Format(CultureInfo.CurrentCulture, "Current Driver status: {0} ", driveStatus.ToString());
+                BuildHttpResponse(response, HttpStatusCode.OK, msg);
+                return;
+            }
+
+            if (target != null && target.Equals("taskstatus"))
+            {
+                LOGGER.Log(Level.Info, "Target: " + target + ". TaskStatus string: " + _taskContext.TaskStatusString());
+                BuildHttpResponse(response, HttpStatusCode.OK, _taskContext.TaskStatusString());
+                return;
+            }
+
+            if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.Init)
+            {
+                BuildHttpResponse(response, HttpStatusCode.OK, "Driver is not ready, wait a few second then send request again!!!");
+                return;
+            }
+
+            if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.RunningTasks)
+            {
+                string msg = string.Format(CultureInfo.CurrentCulture,
+                                           "A job is running. Please check driver status and then submit your job again.");
+                BuildHttpResponse(response, HttpStatusCode.OK, msg);
+                return;
+            }
+
+            if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.Idle)
+            {
+                string numberOfTasks = getQueryValue(request.Querystring, "numberoftasks");
+                if (numberOfTasks == null)
+                {
+                    BuildHttpResponse(response, HttpStatusCode.OK, "Please specify number of tasks to run");
+                    return;
+                }
+
+                driveStatus = DriverStatus.RunningTasks;
+                using (LOGGER.LogFunction("HelloSimpleEventHandlers::Processing a new Job from web request"))
+                {
+                    _taskContext = new TaskContext();
+                    _taskContext.TotalTasks = int.Parse(numberOfTasks, CultureInfo.CurrentCulture);
+                    BuildHttpResponse(response, HttpStatusCode.OK, "Job from web request is submitted and is running!!!");
+                }
+
+                foreach (var c in _activeContexts)
+                {
+                    SubmitNextTask(c);
+                }
+                return;
+            }
+            BuildHttpResponse(response, HttpStatusCode.OK, "Unsupported query");
+        }
+
+        private static IDictionary<string, string> ParseQueryString(string queryString)
+        {
+            IDictionary<string, string> queryPairs = new Dictionary<string, string>();
+            if (queryString != null && queryString.Length > 0)
+            {
+                string[] queries = queryString.Split('&');
+                foreach (string query in queries)
+                {
+                    string[] pairs = query.Split('=');
+                    if (pairs.Length == 2 && !pairs[0].Equals(string.Empty) && !pairs[1].Equals(string.Empty))
+                    {
+                        queryPairs[pairs[0]] = pairs[1];
+                        LOGGER.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "query key: {0}, Query value: {1}.", pairs[0], pairs[1]));
+                    }
+                }
+            }
+            return queryPairs;
+        }
+
+        private static string getQueryValue(string queryString, string name)
+        {
+            IDictionary<string, string> pairs = ParseQueryString(queryString);
+            string v;
+            pairs.TryGetValue(name, out v);
+            return v;
+        }
+
+        private void CreateClassHierarchy()
+        {
+            HashSet<string> clrDlls = new HashSet<string>();
+            clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+            clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+            clrDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+            clrDlls.Add(typeof(INameClient).Assembly.GetName().Name);
+            clrDlls.Add(typeof(NameClient).Assembly.GetName().Name);
+
+            ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+        }
+
+        private void SubmitNextTask(IActiveContext activeContext)
+        {
+            LOGGER.Log(Level.Info, "SubmitNextTask with evaluatorid: " + activeContext.EvaluatorId);
+            IConfiguration finalConfiguration = GetNextTaskConfiguration();
+            if (null != finalConfiguration)
+            {
+                LOGGER.Log(Level.Info, "Executing task id " + _taskContext.CurrentTaskId());
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submitting Task {0}", _taskContext.CurrentTaskId()));
+
+                activeContext.SubmitTask(finalConfiguration);
+            }
+            else
+            {
+                if (_taskContext.TaskCompleted == _taskContext.TotalTasks)
+                {
+                    LOGGER.Log(Level.Info, "All tasks submitted and completed, active context remian idle");
+                    driveStatus = DriverStatus.Idle;
+                }
+            }
+        }
+
+        private IConfiguration GetNextTaskConfiguration()
+        {
+            string nextTaskId = _taskContext.NextTaskId();
+            LOGGER.Log(Level.Info, "GetNextTaskConfiguration, nextTaskId: " + nextTaskId);
+            if (nextTaskId != null)
+            {
+                IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
+                    .Set(TaskConfiguration.Identifier, nextTaskId)
+                    .Set(TaskConfiguration.Task, GenericType<HelloTask>.Class)
+                    .Set(TaskConfiguration.OnMessage, GenericType<HelloTask.HelloDriverMessageHandler>.Class)
+                    .Set(TaskConfiguration.OnSendMessage, GenericType<HelloTaskMessage>.Class)
+                    .Build();
+                return taskConfiguration;
+            }
+            return null;
+        }
+    }
+
+    class TaskContext
+    {
+        private IList<string> taskIds = new List<string>();
+
+        private IDictionary<string, TaskStatus> tasks = new Dictionary<string, TaskStatus>();
+
+        public TaskContext()
+        {
+            NextTaskIndex = 0;
+            TaskCompleted = 0;
+        }
+
+        public int TotalTasks { get; set; }
+
+        public int NextTaskIndex { get; set; }
+
+        public int TaskCompleted { get; set; }
+
+        public string NextTaskId()
+        {
+            Console.WriteLine("NextTaskId: " + NextTaskIndex);
+           if (NextTaskIndex < TotalTasks)
+           {
+               string id = "Jan7DemoTask_" + DateTime.Now.Ticks;
+               taskIds.Add(id);
+               tasks.Add(id, TaskStatus.Submitting);
+               NextTaskIndex++;
+               return id;
+           }
+           return null;
+        }
+
+        public string CurrentTaskId()
+        {
+            Console.WriteLine("CurrentTaskIndex: " + (NextTaskIndex - 1));
+            if (NextTaskIndex <= TotalTasks)
+            {
+                Console.WriteLine("CurrentTaskId: " + taskIds[NextTaskIndex - 1]);
+                return taskIds[NextTaskIndex - 1];
+            }
+            return null; //either not started or completed
+        }
+
+        public void UpdateTaskStatus(string taskId, TaskStatus status)
+        {
+            tasks[taskId] = status;
+        }
+
+        public string TaskStatusString()
+        {
+            Console.WriteLine("TaskStatusString 1, nextTaskIndex: " + NextTaskIndex);
+            StringBuilder sb = new StringBuilder();
+
+            if (tasks.Count > 0)
+            {
+                foreach (var pair in tasks)
+                {
+                    sb.AppendLine("Task id: " + pair.Key + " Task status: " + pair.Value.ToString());
+                }
+            }
+            else
+            {
+                sb.Append("No task is running yet");
+            }
+
+            return sb.ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs
new file mode 100644
index 0000000..edd1737
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloStartHandler : IStartHandler
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(HelloStartHandler));
+
+        [Inject]
+        public HelloStartHandler(HttpServerPort httpServerPort)
+        {
+            CreateClassHierarchy();
+            Identifier = "HelloStartHandler";
+            LOGGER.Log(Level.Info, "HttpPort received in HelloStartHandler: " + httpServerPort.PortNumber);
+        }
+
+        public HelloStartHandler(string id)
+        {
+            Identifier = id;
+            CreateClassHierarchy();
+        }
+
+        public string Identifier { get; set; }
+
+        private void CreateClassHierarchy()
+        {
+            HashSet<string> clrDlls = new HashSet<string>();
+            clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+            clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+            clrDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+            clrDlls.Add(typeof(INameClient).Assembly.GetName().Name);
+            clrDlls.Add(typeof(NameClient).Assembly.GetName().Name);
+
+            ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs
new file mode 100644
index 0000000..8cee6ef
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using System.Text;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloTaskMessageHandler : IObserver<ITaskMessage>
+    {
+        [Inject]
+        public HelloTaskMessageHandler()
+        {
+        }
+
+        public void OnNext(ITaskMessage taskMessage)
+        {
+            Console.WriteLine(string.Format(
+                CultureInfo.InvariantCulture,
+                "CLR HelloTaskMessageHandler received following message from Task: {0}, Message: {1}.",
+                taskMessage.TaskId,
+                Encoding.UTF8.GetString(taskMessage.Message)));           
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..726f304
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RetainedEvalCLRBridge")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RetainedEvalCLRBridge")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("636170aa-ea18-45bf-b345-83dae7fb6a03")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj
new file mode 100644
index 0000000..c463f84
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Examples.RetainedEvalCLRBridge</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Examples.RetainedEvalCLRBridge</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Examples.RetainedEvalCLRBridge\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Examples.RetainedEvalCLRBridge\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="handler\RetainedEvalActiveContextHandler.cs" />
+    <Compile Include="handler\RetainedEvalAllocatedEvaluatorHandler.cs" />
+    <Compile Include="handler\RetainedEvalEvaluatorRequestorHandler.cs" />
+    <Compile Include="handler\RetainedEvalStartHandler.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-tasks\Tasks\Tasks.csproj">
+      <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+      <Name>Tasks</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs
new file mode 100644
index 0000000..2647ff6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+
+namespace Org.Apache.Reef.Examples.RetainedEvalBridge
+{
+    public class RetainedEvalActiveContextHandler : IObserver<IActiveContext>
+    {
+        public void OnNext(IActiveContext activeContext)
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.AddConfiguration(TaskConfiguration.ConfigurationModule
+                .Set(TaskConfiguration.Identifier, "bridgeCLRShellTask_" + DateTime.Now.Ticks)
+                .Set(TaskConfiguration.Task, GenericType<ShellTask>.Class)
+                .Build());
+            cb.BindNamedParameter<ShellTask.Command, string>(GenericType<ShellTask.Command>.Class, "echo");
+
+            IConfiguration taskConfiguration = cb.Build();
+
+            activeContext.SubmitTask(taskConfiguration);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs
new file mode 100644
index 0000000..c9b63c4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+
+namespace Org.Apache.Reef.Examples.RetainedEvalBridge
+{
+    public class RetainedEvalAllocatedEvaluatorHandler : IObserver<IAllocatedEvaluator>
+    {
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
+        {
+            IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule
+                    .Set(ContextConfiguration.Identifier, "RetainedEvalCLRBridgeContextId")
+                    .Build();
+
+            allocatedEvaluator.SubmitContext(contextConfiguration);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs
new file mode 100644
index 0000000..884f304
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Evaluator;
+using System;
+
+namespace Org.Apache.Reef.Examples.RetainedEvalCLRBridge
+{
+    public class RetainedEvalEvaluatorRequestorHandler : IObserver<IEvaluatorRequestor>
+    {
+        public void OnNext(IEvaluatorRequestor requestor)
+        {
+            int evaluatorsNumber = 1;
+            int memory = 512;
+            string rack = "WonderlandRack";
+            EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, rack);
+
+            requestor.Submit(request);
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs
new file mode 100644
index 0000000..3ff3cd6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Examples.RetainedEvalBridge;
+using Org.Apache.Reef.Examples.RetainedEvalCLRBridge;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Org.Apache.Reef.Interop.Examples.RetainedEval
+{
+    public class RetainedEvalStartHandler : IStartHandler
+    {
+        private static ClrSystemHandler<IEvaluatorRequestor> _evaluatorRequestorHandler;
+        private static ClrSystemHandler<IAllocatedEvaluator> _allocatedEvaluatorHandler;
+        private static ClrSystemHandler<IActiveContext> _activeContextHandler;
+
+        [Inject]
+        public RetainedEvalStartHandler()
+        {
+            CreateClassHierarchy();
+            Identifier = "RetainedEvalStartHandler";
+        }
+
+        public RetainedEvalStartHandler(string id)
+        {
+            Identifier = id;
+            CreateClassHierarchy();
+        }
+
+        public string Identifier { get; set; }
+
+        public IList<ulong> GetHandlers()
+        {
+            ulong[] handlers = Enumerable.Repeat(Constants.NullHandler, Constants.HandlersNumber).ToArray();
+
+            // initiate Evaluator Requestor handler
+            _evaluatorRequestorHandler = new ClrSystemHandler<IEvaluatorRequestor>();
+            handlers[Constants.Handlers[Constants.EvaluatorRequestorHandler]] = ClrHandlerHelper.CreateHandler(_evaluatorRequestorHandler);
+            Console.WriteLine("_evaluatorRequestorHandler initiated");
+            _evaluatorRequestorHandler.Subscribe(new RetainedEvalEvaluatorRequestorHandler());
+
+            // initiate Allocated Evaluator handler
+            _allocatedEvaluatorHandler = new ClrSystemHandler<IAllocatedEvaluator>();
+            handlers[Constants.Handlers[Constants.AllocatedEvaluatorHandler]] = ClrHandlerHelper.CreateHandler(_allocatedEvaluatorHandler);
+            Console.WriteLine("_allocatedEvaluatorHandler initiated");
+            _allocatedEvaluatorHandler.Subscribe(new RetainedEvalAllocatedEvaluatorHandler());
+
+            // initiate Active Context handler
+            _activeContextHandler = new ClrSystemHandler<IActiveContext>();
+            handlers[Constants.Handlers[Constants.ActiveContextHandler]] = ClrHandlerHelper.CreateHandler(_activeContextHandler);
+            Console.WriteLine("_activeContextHandler initiated");
+            _activeContextHandler.Subscribe(new RetainedEvalActiveContextHandler());
+
+            return handlers;
+        }
+
+        private void CreateClassHierarchy()
+        {
+            HashSet<string> clrDlls = new HashSet<string>();
+            clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+            clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+            clrDlls.Add(typeof(ShellTask).Assembly.GetName().Name);
+
+            ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs
new file mode 100644
index 0000000..a518e2e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+    internal class NamingLookupRequestCodec : ICodec<NamingLookupRequest>
+    {
+        public byte[] Encode(NamingLookupRequest obj)
+        {
+            var request = new AvroNamingLookupRequest { ids = obj.Identifiers };
+            return AvroUtils.AvroSerialize(request);
+        }
+
+        public NamingLookupRequest Decode(byte[] data)
+        {
+            AvroNamingLookupRequest request = AvroUtils.AvroDeserialize<AvroNamingLookupRequest>(data);
+            return new NamingLookupRequest(request.ids);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs
new file mode 100644
index 0000000..e4c59df
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using System.Collections.Generic;
+using System.Linq;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+    internal class NamingLookupResponseCodec : ICodec<NamingLookupResponse>
+    {
+        public byte[] Encode(NamingLookupResponse obj)
+        {
+            List<AvroNamingAssignment> tuples = obj.NameAssignments
+                .Select(assignment => new AvroNamingAssignment()
+                {
+                    id = assignment.Identifier, 
+                    host = assignment.Endpoint.Address.ToString(),
+                    port = assignment.Endpoint.Port
+                }).ToList();
+
+            AvroNamingLookupResponse response = new AvroNamingLookupResponse { tuples = tuples };
+            return AvroUtils.AvroSerialize(response);
+        }
+
+        public NamingLookupResponse Decode(byte[] data)
+        {
+            AvroNamingLookupResponse response = AvroUtils.AvroDeserialize<AvroNamingLookupResponse>(data);
+            List<NameAssignment> assignments =
+                response.tuples.Select(x => new NameAssignment(x.id, x.host, x.port)).ToList();
+
+            return new NamingLookupResponse(assignments);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs
new file mode 100644
index 0000000..f75a8d5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+    internal class NamingRegisterRequestCodec : ICodec<NamingRegisterRequest>
+    {
+        public byte[] Encode(NamingRegisterRequest obj)
+        {
+            AvroNamingRegisterRequest request = new AvroNamingRegisterRequest
+            {
+                id = obj.NameAssignment.Identifier,
+                host = obj.NameAssignment.Endpoint.Address.ToString(),
+                port = obj.NameAssignment.Endpoint.Port
+            };
+            return AvroUtils.AvroSerialize(request);
+        }
+
+        public NamingRegisterRequest Decode(byte[] data)
+        {
+            AvroNamingRegisterRequest request = AvroUtils.AvroDeserialize<AvroNamingRegisterRequest>(data);
+            return new NamingRegisterRequest(new NameAssignment(request.id, request.host, request.port));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs
new file mode 100644
index 0000000..877abdd
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+    internal class NamingRegisterResponseCodec : ICodec<NamingRegisterResponse>
+    {
+        private NamingRegisterRequestCodec _codec;
+
+        public NamingRegisterResponseCodec(NamingRegisterRequestCodec codec)
+        {
+            _codec = codec;
+        }
+
+        public byte[] Encode(NamingRegisterResponse obj)
+        {
+            return _codec.Encode(obj.Request);
+        }
+
+        public NamingRegisterResponse Decode(byte[] data)
+        {
+            return new NamingRegisterResponse(_codec.Decode(data));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs
new file mode 100644
index 0000000..9512660
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+    internal class NamingUnregisterRequestCodec : ICodec<NamingUnregisterRequest>
+    {
+        public byte[] Encode(NamingUnregisterRequest obj)
+        {
+            AvroNamingUnRegisterRequest request = new AvroNamingUnRegisterRequest { id = obj.Identifier };
+            return AvroUtils.AvroSerialize(request);
+        }
+
+        public NamingUnregisterRequest Decode(byte[] data)
+        {
+            AvroNamingUnRegisterRequest request = AvroUtils.AvroDeserialize<AvroNamingUnRegisterRequest>(data);
+            return new NamingUnregisterRequest(request.id);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs
new file mode 100644
index 0000000..5cfd5ab
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingAssignment.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingAssignment
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingAssignment"",""fields"":[{""name"":""id"",""type"":""string""},{""name"":""host"",""type"":""string""},{""name"":""port"",""type"":""int""}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the id field.
+        /// </summary>
+        [DataMember]
+        public string id { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the host field.
+        /// </summary>
+        [DataMember]
+        public string host { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the port field.
+        /// </summary>
+        [DataMember]
+        public int port { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs
new file mode 100644
index 0000000..0698fd6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingLookupRequest.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingLookupRequest
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingLookupRequest"",""fields"":[{""name"":""ids"",""type"":{""type"":""array"",""items"":""string""}}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the ids field.
+        /// </summary>
+        [DataMember]
+        public List<string> ids { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs
new file mode 100644
index 0000000..4599faa
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingLookupResponse.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingLookupResponse
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingLookupResponse"",""fields"":[{""name"":""tuples"",""type"":{""type"":""array"",""items"":{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingAssignment"",""fields"":[{""name"":""id"",""type"":""string""},{""name"":""host"",""type"":""string""},{""name"":""port"",""type"":""int""}]}}}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the tuples field.
+        /// </summary>
+        [DataMember]
+        public List<AvroNamingAssignment> tuples { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs
new file mode 100644
index 0000000..76f14be
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingRegisterRequest.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingRegisterRequest
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingRegisterRequest"",""fields"":[{""name"":""id"",""type"":""string""},{""name"":""host"",""type"":""string""},{""name"":""port"",""type"":""int""}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the id field.
+        /// </summary>
+        [DataMember]
+        public string id { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the host field.
+        /// </summary>
+        [DataMember]
+        public string host { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the port field.
+        /// </summary>
+        [DataMember]
+        public int port { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
new file mode 100644
index 0000000..299e940
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingUnRegisterRequest.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingUnRegisterRequest
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingUnRegisterRequest"",""fields"":[{""name"":""id"",""type"":""string""}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the id field.
+        /// </summary>
+        [DataMember]
+        public string id { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs
new file mode 100644
index 0000000..5c992f2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Event representing a lookup, registering, or unregistering of 
+    /// an identifier with the Name Service.
+    /// </summary>
+    internal class NamingEvent
+    {
+        /// <summary>
+        /// The link for communication between the NameClient and NameServer
+        /// </summary>
+        public ILink<NamingEvent> Link { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs
new file mode 100644
index 0000000..d680810
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Event to request all registered identifiers and their mapped
+    /// IPEndpoints
+    /// </summary>
+    internal class NamingGetAllRequest : NamingEvent
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs
new file mode 100644
index 0000000..08e608e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Common.io;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Response event for looking up all registered identifiers and their
+    /// mapped IPEndpoints
+    /// </summary>
+    internal class NamingGetAllResponse : NamingEvent
+    {
+        public NamingGetAllResponse(List<NameAssignment> assignments)
+        {
+            Assignments = assignments;
+        }
+
+        public List<NameAssignment> Assignments { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs
new file mode 100644
index 0000000..9f9e184
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Event to request look up of IPEndpoints in the Name Service
+    /// </summary>
+    internal class NamingLookupRequest : NamingEvent
+    {
+        public NamingLookupRequest(List<string> ids)
+        {
+            Identifiers = ids;
+        }
+
+        public List<string> Identifiers { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs
new file mode 100644
index 0000000..872c8c7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Microsoft.Hadoop.Avro;
+using Org.Apache.Reef.Common.io;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Event for lookup response in Name Service.
+    /// </summary>
+    internal class NamingLookupResponse : NamingEvent
+    {
+        public NamingLookupResponse(List<NameAssignment> nameAssignments)
+        {
+            NameAssignments = nameAssignments;
+        }
+
+        [NullableSchema]
+        public List<NameAssignment> NameAssignments { get; set; } 
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs
new file mode 100644
index 0000000..3da980b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Event to request registering an identifier and endpoint with the Name Service
+    /// </summary>
+    internal class NamingRegisterRequest : NamingEvent
+    {
+        public NamingRegisterRequest(NameAssignment nameAssignment)
+        {
+            NameAssignment = nameAssignment;
+        }
+
+        public NameAssignment NameAssignment { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs
new file mode 100644
index 0000000..d879d35
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Response event for registering an IPEndpoint with the Name Service
+    /// </summary>
+    internal class NamingRegisterResponse : NamingEvent
+    {
+        public NamingRegisterResponse(NamingRegisterRequest request)
+        {
+            Request = request;
+        }
+
+        public NamingRegisterRequest Request { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs
new file mode 100644
index 0000000..966e533
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Event to request unregistering of an IPEndpoint with the Name Service
+    /// </summary>
+    internal class NamingUnregisterRequest : NamingEvent
+    {
+        public NamingUnregisterRequest(string identifier)
+        {
+            Identifier = identifier;
+        }
+
+        public string Identifier { get; set; }
+    }
+}


[16/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/AbstractNode.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/AbstractNode.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/AbstractNode.cs
new file mode 100644
index 0000000..a88e7d2
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/AbstractNode.cs
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class AbstractNode : INode
+    {
+        /// It is from Type.FullName. This name is used as Name in a Node. 
+        /// It is not unique for a generic type with different type of arguments.
+        /// It is used for toString or debug info as AssemblyQualifiedName is really long
+        private String name;
+
+        /// It is from Type.AssemblyQualifiedName. THis name is used as full name in a Node
+        /// It is unique for a generic type with different type of arguments.
+        private String fullName; //it comes from 
+
+        //parent node in the class hierarchy
+        private INode parent; 
+        
+        //children in the class hierarchy
+        protected IDictionary<String, INode> children = new MonotonicTreeMap<string, INode>();
+
+        public AbstractNode(INode parent, String name, String fullName)
+        {
+            this.parent = parent;
+            this.name = name;
+            this.fullName = fullName;
+            if (parent != null)
+            {
+                parent.Add(this);
+            }
+        }
+
+        public ICollection<INode> GetChildren()
+        {
+            return children.Values;
+        }
+
+        public bool Contains(String key) 
+        {
+            return children.ContainsKey(key);
+        }
+
+        public INode Get(String key)
+        {
+            INode val;
+            if (children.TryGetValue(key, out val))
+            {
+                return val;
+            }
+            return null;
+        }
+
+        public virtual void Add(INode n)
+        {
+            children.Add(n.GetFullName(), n);
+        }
+
+        public string GetFullName()
+        {
+            return fullName;
+        }
+
+        public string GetName()
+        {
+            return name;
+        }
+
+        public INode GetParent()
+        {
+            return parent;
+        }
+
+        public override bool Equals(Object o) 
+        {
+            if(o == null) return false;
+            if(o == this) return true;
+    
+            AbstractNode n = (AbstractNode) o;
+            bool parentsEqual;
+            if (n.parent == this.parent) {
+                parentsEqual = true;
+            } else if (n.parent == null) {
+                parentsEqual = false;
+            } else if (this.parent == null) {
+                parentsEqual = false;
+            } else {
+                parentsEqual = n.parent.Equals(this.parent);
+            }
+            if (!parentsEqual) {
+                return false;
+            }
+            return fullName.Equals(n.fullName);
+        }
+
+        public override int GetHashCode()
+        {
+            return fullName.GetHashCode();
+        }
+
+        public override String ToString()
+        {
+            return "[" + this.GetType().FullName + " '" + fullName + "']";
+        }
+
+        public int CompareTo(INode n)
+        {
+            return fullName.CompareTo(n.GetFullName());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs
new file mode 100644
index 0000000..3f9f16e
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs
@@ -0,0 +1,526 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ClassHierarchyImpl : ICsClassHierarchy
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof (ClassHierarchyImpl));
+        private INode rootNode;
+        private MonotonicTreeMap<String, INamedParameterNode> shortNames = new MonotonicTreeMap<String, INamedParameterNode>();
+        private IList<string> assemblies;
+        private AssemblyLoader loader = null;
+
+        public ParameterParser Parameterparser = new ParameterParser();
+
+        public ClassHierarchyImpl(String file) : this(new string[] { file }, new Type[0])
+        {
+        }
+
+        public ClassHierarchyImpl(string[] assemblies) : this(assemblies, new Type[0])
+        {
+        }
+
+        //parameterParsers are classes that extends from IExternalConstructor
+        public ClassHierarchyImpl(string[] assemblies, Type[] parameterParsers)  
+        {
+            this.assemblies = assemblies;
+            rootNode = NodeFactory.CreateRootPackageNode();
+            loader = new AssemblyLoader(assemblies);
+           
+            foreach (Type p in parameterParsers) //p must be extend from IExternalConstructor
+            {
+                try 
+                {
+                    Parameterparser.AddParser(p);
+                } 
+                catch (BindException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Could not register parameter parsers", e), LOGGER);
+                }
+            }
+
+            foreach (var a in loader.Assemblies)
+            {
+                foreach (var t in a.GetTypes())
+                {
+                    RegisterType(t);
+                }
+            }
+        }
+
+        public INode RegisterType(string assemblyQualifiedName)
+        {
+            Type type = this.loader.GetType(assemblyQualifiedName);
+            if (type != null)
+            {
+                return RegisterType(type);
+            }
+            return null;
+        }
+
+        public INode RegisterType(Type type)
+        {
+            if (ReflectionUtilities.IsAnnonymousType(type))
+            {
+                // DevNote: Kinda hacky way to indicate the no-op case.
+                return rootNode;
+            }
+
+            INode n = GetAlreadyBoundNode(type);
+            if (n != null)
+            {
+                return n;
+            }
+
+            if (type.BaseType != null)
+            {
+                RegisterType(type.BaseType);
+            }
+
+            foreach (Type interf in type.GetInterfaces())
+            {
+                RegisterType(ReflectionUtilities.EnsureInterfaceType(interf));
+            }
+
+            Type enclosingClass = type.DeclaringType; // this.GetEnclosingClass(type);
+            if (enclosingClass != null)
+            {
+                RegisterType(enclosingClass);
+            }
+
+            INode node = RegisterClass(type);
+
+            foreach (Type inner in type.GetNestedTypes())
+            {
+                RegisterType(inner);
+            }
+
+            IClassNode classNode = node as ClassNodeImpl;
+            if (classNode != null)
+            {
+                foreach (IConstructorDef constructorDef in classNode.GetInjectableConstructors())
+                {
+                    foreach (IConstructorArg constructorArg in constructorDef.GetArgs())
+                    {
+                        if (constructorArg.Gettype() == null)
+                        {
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("not type in arg"), LOGGER);
+                        }
+                        RegisterType(constructorArg.Gettype());  //Gettype returns param's Type.fullname
+                        if (constructorArg.GetNamedParameterName() != null)
+                        {
+                            INamedParameterNode np = (INamedParameterNode)RegisterType(constructorArg.GetNamedParameterName());
+                            try
+                            {
+                                if (np.IsSet() || np.IsList())
+                                {
+                                    //throw new NotImplementedException();
+                                }
+                                else
+                                {
+                                    if (!ReflectionUtilities.IsCoercable(ClassForName(constructorArg.Gettype()), ClassForName(np.GetFullArgName())))
+                                    {
+                                        var e = new ClassHierarchyException(
+                                            "Named parameter type mismatch in " + classNode.GetFullName() + ".  Constructor expects a "
+                                                + constructorArg.Gettype() + " but " + np.GetName() + " is a "
+                                                + np.GetFullArgName());
+                                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                                    }
+                                }
+                            }
+                            catch (TypeLoadException e)
+                            {
+                                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                                var ex = new ClassHierarchyException("Constructor refers to unknown class "
+                                    + constructorArg.GetType(), e);
+                                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                            }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                INamedParameterNode npNode = node as INamedParameterNode;
+                if (npNode != null)
+                {
+                    RegisterType(npNode.GetFullArgName());
+                }
+            }
+            
+            return node;
+        }
+
+        private INode RegisterClass(Type type)
+        {
+            INode node = GetAlreadyBoundNode(type);
+            if (node != null)
+            {
+                return node;
+            }
+
+            node = BuildPathToNode(type);
+            IClassNode classNode = node as IClassNode;
+            if (classNode != null)
+            {
+                Type baseType = type.BaseType;
+                if (baseType != null)
+                {
+                    IClassNode n = (IClassNode) GetAlreadyBoundNode(baseType);
+                    if (n != null)
+                    {
+                        n.PutImpl(classNode);
+                    }
+                    else
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Error in finding Node for BaseType"), LOGGER);
+                    }
+                }
+
+                foreach (Type interf in ReflectionUtilities.GetInterfaces(type, false))
+                {
+                    IClassNode n = (IClassNode)GetAlreadyBoundNode(ReflectionUtilities.EnsureInterfaceType(interf));
+                    if (n != null)
+                    {
+                        n.PutImpl(classNode);
+                    }
+                    else
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Error in finding Node for Interface"), LOGGER);
+                    }
+                }
+            }
+            return node;
+        }
+
+        public INode BuildPathToNode(Type type)
+        {
+            INode parent = GetParentNode(type);
+
+            Type argType = ReflectionUtilities.GetNamedParameterTargetOrNull(type);
+
+            if (argType == null)
+            {
+                return NodeFactory.CreateClassNode(parent, type);
+            }
+            INamedParameterNode np = NodeFactory.CreateNamedParameterNode(parent, type, argType);
+
+            if(Parameterparser.CanParse(ReflectionUtilities.GetAssemblyQualifiedName(argType))) {
+                if(type.GetCustomAttribute<NamedParameterAttribute>().DefaultClass != null) 
+                {
+                    var e = new ClassHierarchyException("Named parameter " + ReflectionUtilities.GetAssemblyQualifiedName(type) + " defines default implementation for parsable type " + ReflectionUtilities.GetAssemblyQualifiedName(argType));
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+            }
+
+            string shortName = np.GetShortName();
+            if (shortName != null && !shortName.Equals(""))
+            {
+                INamedParameterNode oldNode = null;
+                shortNames.TryGetValue(shortName, out oldNode);
+                if (oldNode != null)
+                {
+                    if (oldNode.GetFullName().Equals(np.GetFullName()))
+                    {
+                        var ex = new IllegalStateException("Tried to double bind "
+                            + oldNode.GetFullName() + " to short name " + shortName);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                    var e = new ClassHierarchyException("Named parameters " + oldNode.GetFullName()
+                        + " and " + np.GetFullName() + " have the same short name: "
+                        + shortName);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                shortNames.Add(shortName, np);
+
+            }
+            return np;            
+        }
+
+        //return Type T if type implements Name<T>, null otherwise
+        //e.g. [NamedParameter(typeof(System.String), "Number of seconds to sleep", "10", "sec")]
+        //class Seconds : Name<Int32> { }
+        //return Int32
+
+        //TODO add error handlings
+        public Type GetNamedParameterTargetOrNull(Type type)
+        {
+            var npAnnotation = type.GetCustomAttribute<NamedParameterAttribute>();
+            if (npAnnotation != null)
+            {
+                Type[] intfs = type.GetInterfaces();
+                if (intfs.Length == 1)
+                {
+                    if (intfs[0].Name.Equals(GetNameOfNameInterface()))
+                    {
+                        Type[] args = intfs[0].GetGenericArguments();
+                        if (args.Length == 1)
+                        {
+                            return args[0];
+                        }
+                    }
+                }
+
+            }
+            return null;   
+        }
+
+        private INode GetAlreadyBoundNode(Type t)
+        {
+            //get outclass names including itsself
+            string[] outerClassNames = ReflectionUtilities.GetEnclosingClassNames(t);
+
+            INode current = rootNode;
+            for (int i = 0; i < outerClassNames.Length; i++)            
+            {
+                current = current.Get(outerClassNames[i]);
+                if (current == null)
+                {
+                    StringBuilder sb = new StringBuilder();
+                    for (int j = 0; j <= i; j++)
+                    {
+                        sb.Append(outerClassNames[j]);
+                        if (j != i)
+                        {
+                            sb.Append(".");
+                        }
+                    }
+                    return null;
+                    //throw new NameResolutionException(t.FullName, sb.ToString());
+                }
+
+            }
+            return current; 
+        }
+
+        //starting from the root, get child for each eclosing class excluding the type itsself
+        //all enclosing classes should be already in the hierarchy
+        //Type B2 = asm.GetType(@"Org.Apache.Reef.Tang.Examples.B+B1+B2");
+        //string[] pathB2 = ClassNameParser.GetEnclosingClassShortNames(B2);
+        //Assert.AreEqual(pathB2[0], "B");
+        //Assert.AreEqual(pathB2[1], "B1");
+        //Assert.AreEqual(pathB2[2], "B2");
+        //return INode for B1
+        private INode GetParentNode(Type type)
+        {
+            INode current = rootNode;
+            string[] enclosingPath = ReflectionUtilities.GetEnclosingClassNames(type);
+            for (int i = 0; i < enclosingPath.Length - 1; i++)
+            {
+                current = current.Get(enclosingPath[i]);
+            }
+            return current;
+        }
+
+        private string GetNameOfNameInterface()
+        {
+            var tn = typeof(Name<int>);
+            return tn.Name;
+        }
+
+        public INode GetNode(string fullName)
+        {
+            Type t = loader.GetType(fullName);
+
+            if (t == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NameResolutionException(fullName, fullName), LOGGER);
+            }
+
+            return this.GetNode(t);
+        }
+
+        public INode GetNode(Type type)
+        {
+            this.RegisterType(type);
+            return GetAlreadyBoundNode(type);
+        }
+
+        public INode GetNamespace()
+        {
+            return rootNode;
+        }
+
+        public bool IsImplementation(IClassNode inter, IClassNode impl)
+        {
+            return impl.IsImplementationOf(inter);
+        }
+
+        public IClassHierarchy Merge(IClassHierarchy ch)
+        {
+            if (this == ch) { return this; }
+
+            if (!(ch is ClassHierarchyImpl)) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Can't merge java and non-java class hierarchies yet!"), LOGGER);
+            }
+
+            if(this.assemblies.Count == 0) 
+            {
+                return ch;
+            }
+    
+            ClassHierarchyImpl chi = (ClassHierarchyImpl)ch;
+            MonotonicHashSet<string> otherJars = new MonotonicHashSet<string>();
+            otherJars.AddAll(chi.assemblies);
+            MonotonicHashSet<string> myJars = new MonotonicHashSet<string>();
+            myJars.AddAll(this.assemblies);
+            if(myJars.ContainsAll(otherJars)) 
+            {
+                return this;
+            } 
+            if (otherJars.ContainsAll(myJars)) 
+            {
+                return ch;
+            } 
+            myJars.AddAll(otherJars);
+            return new ClassHierarchyImpl(myJars.ToArray());
+        }
+
+        public object Parse(INamedParameterNode np, string value)
+        {
+            IClassNode iface = null;
+            try 
+            {
+                iface = (IClassNode)GetNode(np.GetFullArgName());
+            } 
+            catch(NameResolutionException e) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                var ex = new IllegalStateException("Could not parse validated named parameter argument type.  NamedParameter is " + np.GetFullName() + " argument type is " + np.GetFullArgName(), e);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            Type clazz;
+            String fullName;
+            try 
+            {
+                clazz = (Type)ClassForName(iface.GetFullName());
+                fullName = null;
+            } 
+            catch(TypeLoadException e) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, LOGGER);
+                clazz = null;
+                fullName = iface.GetFullName();
+            }
+
+            object result = null;
+            if (clazz != null) 
+            {
+                result = Parameterparser.Parse(clazz, value);
+            }
+            else
+            {
+                result = Parameterparser.Parse(fullName, value);                
+            }
+
+            if (result == null)
+            {
+                try
+                {
+                    INode impl = GetNode(value);
+                    if (impl is IClassNode)
+                    {
+                        if (IsImplementation(iface, (IClassNode) impl))
+                        {
+                            return impl;
+                        }
+                    }
+                    var ex =
+                        new ParseException(
+                            "Name<" + iface.GetFullName() + "> " + np.GetFullName() + " cannot take non-subclass " +
+                            impl.GetFullName());
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                catch (NameResolutionException ec)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ec, Level.Error, LOGGER);
+                    var ex =
+                        new ParseException(
+                            "Name<" + iface.GetFullName() + "> " + np.GetFullName() + " cannot take non-class " + value,
+                            ec);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+            }
+            return result; 
+        }
+
+        public object ParseDefaultValue(INamedParameterNode name)
+        {
+            string[] vals = name.GetDefaultInstanceAsStrings();
+            object[] ret = new Object[vals.Length];
+            for (int i = 0; i < vals.Length; i++)
+            {
+                string val = vals[i];
+                try
+                {
+                    ret[i] = Parse(name, val);
+                }
+                catch (ParseException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    var ex = new ClassHierarchyException("Could not parse default value " + val, e);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+            }
+            if (name.IsSet())
+            {
+                return new HashSet<object>(ret.ToList<object>());
+            }
+            if (name.IsList())
+            {
+                return new List<object>(ret.ToList<object>());
+            }
+            if (ret.Length == 0)
+            {
+                return null;
+            }
+            if (ret.Length == 1)
+            {
+                return ret[0];
+            }
+            var ec = new IllegalStateException("Multiple defaults for non-set named parameter! " + name.GetFullName());
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ec, LOGGER);
+            return null; //this line would be never reached as Throw will throw an exception
+        }
+
+        public Type ClassForName(string name)
+        {
+            return this.GetType(name);
+        }
+
+        public Type GetType(string name)
+        {
+            return this.loader.GetType(name);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassNodeImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassNodeImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassNodeImpl.cs
new file mode 100644
index 0000000..27a57b9
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ClassNodeImpl.cs
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ClassNodeImpl : AbstractNode, IClassNode
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClassNodeImpl));
+
+        private readonly bool injectable;
+        private readonly bool unit;
+        private readonly bool externalConstructor;
+        private readonly IList<IConstructorDef> injectableConstructors;
+        private readonly IList<IConstructorDef> allConstructors;
+        private readonly MonotonicSet<IClassNode> knownImpls;
+        private readonly String defaultImpl;
+
+        public ClassNodeImpl(INode parent, String simpleName, String fullName,
+            bool unit, bool injectable, bool externalConstructor,
+            IList<IConstructorDef> injectableConstructors,
+            IList<IConstructorDef> allConstructors,
+            String defaultImplementation)
+            : base(parent, simpleName, fullName)
+        {
+
+            this.unit = unit;
+            this.injectable = injectable;
+            this.externalConstructor = externalConstructor;
+            this.injectableConstructors = injectableConstructors;
+            this.allConstructors = allConstructors;
+            this.knownImpls = new MonotonicSet<IClassNode>();
+            this.defaultImpl = defaultImplementation;
+        }
+
+        public IList<IConstructorDef> GetInjectableConstructors()
+        {
+            return injectableConstructors;
+        }
+
+        public IList<IConstructorDef> GetAllConstructors()
+        {
+            return allConstructors;
+        }
+
+        public bool IsInjectionCandidate()
+        {
+            return injectable;
+        }
+
+        public bool IsExternalConstructor()
+        {
+            return externalConstructor;
+        }
+
+        public override String ToString()
+        {
+            StringBuilder sb = new StringBuilder(base.ToString() + ": ");
+            if (GetInjectableConstructors() != null)
+            {
+                foreach (IConstructorDef c in GetInjectableConstructors())
+                {
+                    sb.Append(c.ToString() + ", ");
+                }
+            }
+            else
+            {
+                sb.Append("OBJECT BUILD IN PROGRESS!  BAD NEWS!");
+            }
+            return sb.ToString();
+        }
+
+        public IConstructorDef GetConstructorDef(IList<IClassNode> paramTypes)
+        {
+            if (!IsInjectionCandidate())
+            {
+                var e = new BindException("Cannot @Inject non-static member/local class: "
+                + GetFullName());
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            foreach (IConstructorDef c in GetAllConstructors())
+            {
+                if (c.TakesParameters(paramTypes))
+                {
+                    return c;
+                }
+            }
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new BindException("Could not find requested constructor for class " + GetFullName()), LOGGER);
+            return null; // this line would not be reached as Thrwo throws an exception 
+        }
+
+        public void PutImpl(IClassNode impl)
+        {
+            knownImpls.Add(impl);
+        }
+
+        public ISet<IClassNode> GetKnownImplementations()
+        {
+            return new MonotonicSet<IClassNode>(knownImpls);
+        }
+
+        public bool IsUnit()
+        {
+            return unit;
+        }
+
+        public bool IsImplementationOf(IClassNode inter)
+        {
+            List<IClassNode> worklist = new List<IClassNode>();
+            if (this.Equals(inter))
+            {
+                return true;
+            }
+            worklist.Add(inter);
+            while (worklist.Count != 0)
+            {
+                IClassNode cn = worklist[worklist.Count - 1];
+                worklist.RemoveAt(worklist.Count - 1);
+                ISet<IClassNode> impls = cn.GetKnownImplementations();
+                if (impls.Contains(this))
+                {
+                    return true;
+                }
+                worklist.AddRange(impls);
+            }
+            return false;
+        }
+
+        public String GetDefaultImplementation()
+        {
+            return defaultImpl;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorArgImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorArgImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorArgImpl.cs
new file mode 100644
index 0000000..31e4103
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorArgImpl.cs
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ConstructorArgImpl : IConstructorArg
+    {
+        private readonly String type;
+        private readonly String name;
+        private readonly bool isInjectionFuture;
+
+        public ConstructorArgImpl(String type, String namedParameterName, bool isInjectionFuture)
+        {
+            if (type == null)
+            {
+                ;
+            }
+            this.type = type;
+            this.name = namedParameterName;
+
+            //if (name != null && name.Contains(','))
+            //    throw new ApplicationException("Name contains comma : " + name);
+            this.isInjectionFuture = isInjectionFuture;
+        }
+
+        public string GetName()
+        {
+            return name == null ? type : name;
+        }
+
+        public string GetNamedParameterName()
+        {
+            return name;
+        }
+
+        public string Gettype()
+        {
+            return type;
+        }
+
+        public bool IsInjectionFuture()
+        {
+            return isInjectionFuture;
+        }
+
+        public override String ToString()
+        {
+            return name == null ? type : type + " " + name;
+        }
+
+        public override int GetHashCode()
+        {
+            return 0;
+        }
+
+        public override bool Equals(Object o)
+        {
+            ConstructorArgImpl arg = (ConstructorArgImpl)o;
+            if (!type.Equals(arg.type))
+            {
+                return false;
+            }
+            if (name == null && arg.name == null)
+            {
+                return true;
+            }
+            if (name == null && arg.name != null)
+            {
+                return false;
+            }
+            if (name != null && arg.name == null)
+            {
+                return false;
+            }
+            return name.Equals(arg.name);
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorDefImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorDefImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorDefImpl.cs
new file mode 100644
index 0000000..4e72da7
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ConstructorDefImpl.cs
@@ -0,0 +1,203 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ConstructorDefImpl : IConstructorDef
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ConstructorDefImpl));
+
+        private readonly IList<IConstructorArg> args = new List<IConstructorArg>();
+        private readonly String className;
+
+        public ConstructorDefImpl(String className, IConstructorArg[] args, bool injectable)
+        {
+            this.args = args;
+            this.className = className;
+            if (injectable)
+            {
+                var duplicateItems = from x in args
+                                     group x by x into grouped
+                                     where grouped.Count() > 1
+                                     select grouped.Key;
+
+                if (duplicateItems.Any())
+                {
+                    var e = new ClassHierarchyException(
+                        "Repeated constructor parameter detected.  "
+                        + "Cannot inject constructor " + ToString());
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        public IList<IConstructorArg> GetArgs()
+        {
+            return args;
+        }
+
+        public String GetClassName()
+        {
+            return className;
+        }
+
+        private String Join(String sep, Object[] vals)
+        {
+            if (vals.Length != 0)
+            {
+                StringBuilder sb = new StringBuilder(vals[0].ToString());
+                for (int i = 1; i < vals.Length; i++)
+                {
+                    sb.Append(sep + vals[i]);
+                }
+                return sb.ToString();
+            }
+            else
+            {
+                return "";
+            }
+        }
+
+        public override String ToString()
+        {
+            StringBuilder sb = new StringBuilder(className);
+            sb.Append("(");
+            sb.Append(Join(",", args.ToArray()));
+            sb.Append(")");
+            return sb.ToString();
+        }
+
+        // Return true if our list of args is a superset of those in def.
+        public bool IsMoreSpecificThan(IConstructorDef def)
+        {
+            // Is everything in def also in this?
+            for (int i = 0; i < def.GetArgs().Count; i++)
+            {
+                bool found = false;
+                for (int j = 0; j < this.GetArgs().Count; j++)
+                {
+                    if (GetArgs()[j].Equals(def.GetArgs()[i]))
+                    {
+                        found = true;
+                        break;
+                    }
+                }
+                // If not, then argument j from def is not in our list.  Return false.
+                if (found == false)
+                    return false;
+            }
+            // Everything in def's arg list is in ours.  Do we have at least one extra
+            // argument?
+            return GetArgs().Count > def.GetArgs().Count;
+        }
+
+        public bool TakesParameters(IList<IClassNode> paramTypes)
+        {
+            if (paramTypes.Count != args.Count)
+            {
+                return false;
+            }
+
+            int i = 0;
+            foreach (INode t in paramTypes)
+            {
+                string s;
+                if (t is INamedParameterNode)
+                {
+                    s = ((INamedParameterNode)paramTypes[i]).GetFullArgName();
+                }
+                else
+                {
+                    s = paramTypes[i].GetFullName();
+                }
+                if (!args[i].Gettype().Equals(s))
+                {
+                    return false;
+                }
+                else
+                {
+                    i++;
+                }
+
+            }
+            return true;
+        }
+
+        public override bool Equals(Object o)
+        {
+            return EqualsIgnoreOrder((IConstructorDef)o);
+        }
+
+        public override int GetHashCode()
+        {
+            return 0;
+        }
+
+        //A(int i, string j) vs. A(string i, int j) is Ambiguous in injection
+        private bool EqualsIgnoreOrder(IConstructorDef def)
+        {
+            if (GetArgs().Count != def.GetArgs().Count)
+            {
+                return false;
+            }
+            for (int i = 0; i < GetArgs().Count; i++)
+            {
+                bool found = false;
+                for (int j = 0; j < def.GetArgs().Count; j++)
+                {
+                    if (GetArgs()[i].GetName().Equals(def.GetArgs()[j].GetName()))
+                    {
+                        found = true;
+                    }
+                }
+                if (!found)
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        public int CompareTo(object obj)
+        {
+            IConstructorDef o = (IConstructorDef)obj;
+            return ToString().CompareTo(o.ToString());
+        }
+
+        public bool IsInList(IList<IConstructorDef> list )
+        {
+            foreach (IConstructorDef def in list)
+            {
+                if (CompareTo(def) == 0)
+                {
+                    return true;
+                }
+
+            }
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs
new file mode 100644
index 0000000..3bdc868
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class NamedParameterNodeImpl : AbstractNode, INamedParameterNode
+    {
+        private readonly String fullArgName;
+        private readonly String simpleArgName;
+        private readonly String documentation;
+        private readonly String shortName;
+        private readonly String[] defaultInstanceAsStrings;
+        private readonly bool isSet;
+        private readonly bool isList;
+
+        public NamedParameterNodeImpl(INode parent, String simpleName,
+            String fullName, String fullArgName, String simpleArgName, bool isSet, bool isList,
+            String documentation, String shortName, String[] defaultInstanceAsStrings)
+            : base(parent, simpleName, fullName)
+        {
+            this.fullArgName = fullArgName;
+            this.simpleArgName = simpleArgName;
+            this.isSet = isSet;
+            this.isList = isList;
+            this.documentation = documentation;
+            this.shortName = shortName;
+            this.defaultInstanceAsStrings = defaultInstanceAsStrings;
+        }
+
+        public override String ToString()
+        {
+            return GetSimpleArgName() + " " + GetName();
+        }
+
+        public String GetSimpleArgName()
+        {
+            return simpleArgName;
+        }
+
+        public String GetFullArgName()
+        {
+            return fullArgName;
+        }
+
+        public String GetDocumentation()
+        {
+            return documentation;
+        }
+
+        public String GetShortName()
+        {
+            return shortName;
+        }
+
+        public String[] GetDefaultInstanceAsStrings()
+        {
+            return defaultInstanceAsStrings;
+        }
+
+        public bool IsSet()
+        {
+            return isSet;
+        }
+
+        public bool IsList()
+        {
+            return isList;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NodeFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NodeFactory.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NodeFactory.cs
new file mode 100644
index 0000000..474f2d5
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/NodeFactory.cs
@@ -0,0 +1,315 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class NodeFactory
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(NodeFactory));
+
+        public static IPackageNode CreateRootPackageNode()
+        {
+            return new PackageNodeImpl();
+        }
+
+        public static INode CreateClassNode(INode parent, Type clazz)
+        {
+            //var namedParameter = clazz.GetCustomAttribute<NamedParameterAttribute>();
+            var unit = null != clazz.GetCustomAttribute<UnitAttribute>();
+            string simpleName = ReflectionUtilities.GetName(clazz);
+            string fullName = ReflectionUtilities.GetAssemblyQualifiedName(clazz);
+            //bool isStatic = true; // clazz.IsSealed && clazz.IsAbstract; always true in C# for Java static class
+            //bool injectable = true; // always true in C#
+
+            bool isAssignableFromExternalConstructor = ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof(IExternalConstructor<>), clazz); 
+
+            //bool parentIsUnit = false; 
+
+            //No such thing in C#, should be false
+            //bool foundNonStaticInnerClass = false;
+            //foreach (Type c in clazz.getNestedTypes()) {
+            //  if (!Modifier.isStatic(c.getModifiers())) {
+            //    foundNonStaticInnerClass = true;
+            //  }
+            //}
+
+            var injectableConstructors = new List<IConstructorDef>();
+            var allConstructors = new List<IConstructorDef>();
+
+            foreach (ConstructorInfo c in clazz.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))  
+            {
+                var constructorAnnotatedInjectable = null != c.GetCustomAttribute<InjectAttribute>();
+
+                bool constructorInjectable = constructorAnnotatedInjectable;
+
+                ConstructorDefImpl constructorDef = CreateConstructorDef(c, constructorAnnotatedInjectable);
+
+                if (constructorInjectable)
+                {
+//                    if (injectableConstructors.Contains(constructorDef))
+                    if (constructorDef.IsInList(injectableConstructors))
+                    {
+                        var e = new ClassHierarchyException(
+                            "Ambiguous boundConstructors detected in class " + clazz + ": "
+                                + constructorDef + " differs from some other" + " constructor only "
+                                + "by parameter order.");
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                    else
+                    {
+                        injectableConstructors.Add(constructorDef);
+                    }
+                }
+                allConstructors.Add(constructorDef);
+
+            }
+
+            string defaultImplementation = null;
+            DefaultImplementationAttribute defaultImpl = clazz.GetCustomAttribute<DefaultImplementationAttribute>();
+            if (null != defaultImpl)
+            {
+                Type defaultImplementationClazz = defaultImpl.Value;
+
+                if (defaultImplementationClazz == null)
+                {
+                    defaultImplementation = defaultImpl.Name;
+                }
+                else
+                {
+                    if (!ReflectionUtilities.IsAssignableFromIgnoreGeneric(clazz, defaultImplementationClazz))
+                    {
+                        var e = new ClassHierarchyException(clazz
+                                                          + " declares its default implementation to be non-subclass "
+                                                          + defaultImplementationClazz);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                    defaultImplementation = ReflectionUtilities.GetAssemblyQualifiedName(defaultImplementationClazz);
+                }
+            }
+            else
+            {
+                defaultImplementation = null;
+            }        
+
+            return new ClassNodeImpl(parent, simpleName, fullName, unit, true, isAssignableFromExternalConstructor, 
+                injectableConstructors, allConstructors, defaultImplementation);
+        }
+
+        //TODO
+        private static ConstructorDefImpl CreateConstructorDef(ConstructorInfo constructor, bool injectable)
+        {
+            var parameters = constructor.GetParameters();
+
+            IConstructorArg[] args = new ConstructorArgImpl[parameters.Length];
+
+            for (int i = 0; i < parameters.Length; i++)
+            {
+                //TODO for getInterfaceTarget() call
+                Type type = parameters[i].ParameterType;
+                type = ReflectionUtilities.EnsureInterfaceType(type);
+                //if (type.IsGenericType && type.FullName == null)
+                //{
+                //    type = type.GetGenericTypeDefinition();
+                //}
+                bool isFuture;
+
+                if(ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof(IInjectionFuture<>), type)) 
+                {
+                    type = ReflectionUtilities.GetInterfaceTarget(typeof(IInjectionFuture<>), type);
+                    isFuture = true;
+                } 
+                else 
+                {
+                    isFuture = false;
+                }
+
+                ParameterAttribute named = parameters[i].GetCustomAttribute<ParameterAttribute>();
+                if (named != null && !injectable)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException(constructor + " is not injectable, but it has an @Parameter annotation."), LOGGER);
+                }
+
+                if (type == null)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Exception"), LOGGER);
+                }
+
+                string typename = ReflectionUtilities.GetAssemblyQualifiedName(type);
+                if (typename == null)
+                {
+                    typename = type.Name;
+                }
+                args[i] = new ConstructorArgImpl(typename, named == null ? null : ReflectionUtilities.GetAssemblyQualifiedName(named.Value), isFuture);
+            }
+            return new ConstructorDefImpl(ReflectionUtilities.GetAssemblyQualifiedName(constructor.DeclaringType), args, injectable); 
+        }
+
+        public static INamedParameterNode CreateNamedParameterNode(INode parent, Type clazz, Type argClass)
+        {
+            Type setRawArgType = ReflectionUtilities.GetInterfaceTarget(typeof(ISet<>), argClass);
+            bool isSet = setRawArgType != null;
+            if(isSet) {
+                argClass = setRawArgType;
+            }
+
+            Type listRawArgType = ReflectionUtilities.GetInterfaceTargetForType(typeof (IList<>), argClass);
+            bool isList = listRawArgType != null;
+            if (isList)
+            {
+                argClass = listRawArgType;
+            }
+
+            string simpleName = ReflectionUtilities.GetName(clazz);
+            string fullName = ReflectionUtilities.GetAssemblyQualifiedName(clazz);
+            string fullArgName = ReflectionUtilities.GetAssemblyQualifiedName(argClass);
+            string simpleArgName = ReflectionUtilities.GetName(argClass);
+
+            NamedParameterAttribute namedParameter = clazz.GetCustomAttribute<NamedParameterAttribute>();
+
+            if (namedParameter == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Got name without named parameter post-validation!"), LOGGER);
+            }
+
+            bool hasStringDefault, hasClassDefault, hasStringSetDefault, hasClassSetDefault;
+            int default_count = 0;
+            //if(!namedParameter.default_value().isEmpty()) {  //QUESTION: difference from below? 
+            if (namedParameter.DefaultValue != null && namedParameter.DefaultValue.Length > 0)
+            {
+                hasStringDefault = true;
+                default_count++;
+            }
+            else
+            {
+                hasStringDefault = false;
+            }
+
+            if (namedParameter.DefaultClass != null /*Void.class*/)
+            {
+                hasClassDefault = true;
+                default_count++;
+            }
+            else
+            {
+                hasClassDefault = false;
+            }
+
+            if (namedParameter.DefaultValues != null && namedParameter.DefaultValues.Length > 0)
+            {
+                hasStringSetDefault = true;
+                default_count++;
+            }
+            else
+            {
+                hasStringSetDefault = false;
+            }
+
+            if (namedParameter.DefaultClasses != null && namedParameter.DefaultClasses.Length > 0) 
+            {
+                hasClassSetDefault = true;
+                default_count++;
+            }
+            else
+            {
+                hasClassSetDefault = false;
+            }
+
+            if (default_count > 1)
+            {
+                var e = new ClassHierarchyException("Named parameter " + fullName + " defines more than one of default_value, default_class, default_values and default_classes");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+
+            string[] defaultInstanceAsStrings = new string[]{};
+
+            if (default_count == 0)
+            {
+                defaultInstanceAsStrings = new String[] { };
+            }
+            else if (hasClassDefault)
+            {
+                Type default_class = namedParameter.DefaultClass;
+                AssertIsSubclassOf(clazz, default_class, argClass);
+                defaultInstanceAsStrings = new String[] { ReflectionUtilities.GetAssemblyQualifiedName(default_class) };
+            }
+            else if (hasStringDefault)
+            {
+                // Don't know if the string is a class or literal here, so don't bother validating.
+                defaultInstanceAsStrings = new String[] { namedParameter.DefaultValue };
+            }
+            else if (hasClassSetDefault)
+            {
+                Type[] clzs = namedParameter.DefaultClasses;
+                defaultInstanceAsStrings = new String[clzs.Length];
+                for (int i = 0; i < clzs.Length; i++)
+                {
+                    AssertIsSubclassOf(clazz, clzs[i], argClass);
+                    defaultInstanceAsStrings[i] = ReflectionUtilities.GetAssemblyQualifiedName(clzs[i]);
+                }
+            }
+            else if (hasStringSetDefault)
+            {
+                defaultInstanceAsStrings = namedParameter.DefaultValues;
+            }
+            else
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(), LOGGER);
+            }
+
+            string documentation = namedParameter.Documentation;
+            string shortName = namedParameter.ShortName;
+            if (namedParameter.ShortName != null && namedParameter.ShortName.Length == 0)
+            {
+                shortName = null;
+            }
+
+            return new NamedParameterNodeImpl(parent, simpleName, fullName,
+                fullArgName, simpleArgName, isSet, isList, documentation, shortName, defaultInstanceAsStrings);
+        }
+
+        // private static void assertIsSubclassOf(Class<?> named_parameter, Class<?> default_class, Type argClass) {
+        private static void AssertIsSubclassOf(Type namedparameter, Type defaultclass, Type argClass)
+        {
+            bool isSubclass = false;
+            string argClassName = ReflectionUtilities.GetAssemblyQualifiedName(argClass);
+            foreach (Type t in ReflectionUtilities.ClassAndAncestors(defaultclass))
+            {
+                if (argClassName.Equals(ReflectionUtilities.GetAssemblyQualifiedName(t)))
+                {
+                    isSubclass = true;
+                }
+            }
+            if (!(isSubclass))
+            {
+                var e = new ClassHierarchyException(namedparameter + " defines a default class "
+                    + ReflectionUtilities.GetName(defaultclass) + " with a type that does not extend of its target's type " + argClass);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/PackageNodeImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/PackageNodeImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/PackageNodeImpl.cs
new file mode 100644
index 0000000..7516493
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/PackageNodeImpl.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class PackageNodeImpl : AbstractNode, IPackageNode
+    {
+        public PackageNodeImpl(INode parent, String name, String fullName) : 
+            base(parent, name, fullName)
+        {
+        }
+
+        public PackageNodeImpl()
+            : base(null, "", "[root node]")
+        {
+        }
+
+        /**
+        * Unlike normal nodes, the root node needs to take the package name of its
+        * children into account.  Therefore, we use the full name as the key when
+        * we insert nodes into the root.
+        */
+        public override void Add(INode n) {
+            if (children.Count == 289)
+            {
+                Console.WriteLine("Test");
+            }
+            children.Add(n.GetFullName(), n);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ParameterParser.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ParameterParser.cs b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ParameterParser.cs
new file mode 100644
index 0000000..840e447
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/ClassHierarchy/ParameterParser.cs
@@ -0,0 +1,199 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ParameterParser
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ParameterParser));
+
+        MonotonicTreeMap<String, ConstructorInfo> parsers = new MonotonicTreeMap<String, ConstructorInfo>();
+
+        //ec: ACons, tc: A
+        public void AddParser(Type ec)
+        {
+            Type tc = (Type)ReflectionUtilities.GetInterfaceTarget(typeof(IExternalConstructor<>), ec);
+            AddParser(tc, ec);
+        }
+
+        //TODO
+        //public  <T, U extends T> void AddParser(Class<U> clazz, Class<? extends ExternalConstructor<T>> ec) throws BindException {
+        //public void AddParser<T, U, V>(GenericType<U> clazz, GenericType<V> ec) 
+        //    where U : T
+        //    where V:  IExternalConstructor<T>
+        //{
+
+        //clazz: A, ec: ACons
+        private void AddParser(Type clazz, Type ec)
+        {
+            ConstructorInfo c = ec.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string) }, null);
+            
+            if (c == null)
+            {
+                var e = new BindException("Constructor " + ReflectionUtilities.GetAssemblyQualifiedName(ec) + "(String) does not exist!");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+
+            //c.setAccessible(true); //set as public 
+            parsers.Add(ReflectionUtilities.GetAssemblyQualifiedName(clazz), c);
+        }
+
+
+        public void MergeIn(ParameterParser p)
+        {
+            foreach (string s in p.parsers.Keys)
+            {
+                if (!parsers.ContainsKey(s))
+                {
+                    ConstructorInfo ci;
+                    p.parsers.TryGetValue(s, out ci);
+                    parsers.Add(s, ci);
+                }
+                else
+                {
+                    ConstructorInfo oldC;
+                    ConstructorInfo newC;
+                    parsers.TryGetValue(s, out oldC);
+                    p.parsers.TryGetValue(s, out newC);
+                    if (!oldC.Equals(newC))
+                    {
+                        var e = new ArgumentException(
+                        "Conflict detected when merging parameter parsers! To parse " + s
+                        + " I have a: " + ReflectionUtilities.GetAssemblyQualifiedName(oldC.DeclaringType)
+                        + " the other instance has a: " + ReflectionUtilities.GetAssemblyQualifiedName(newC.DeclaringType));
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                }
+            }
+        }
+
+        //(Integer, "3") return object of new Integer(3)
+        public object Parse(Type c, String s)
+        {
+            Type d = ReflectionUtilities.BoxClass(c);
+            foreach (Type e in ReflectionUtilities.ClassAndAncestors(d)) // get all the super classes of Integer for example
+            {
+                string name = ReflectionUtilities.GetAssemblyQualifiedName(e);
+                if (parsers.ContainsKey(name))
+                {
+                    object ret = Parse(name, s);
+                    if (c.IsAssignableFrom(ret.GetType())) //check if ret can be cast as c
+                    {
+                        return ret;
+                    }
+                    else
+                    {
+                        var ex = new InvalidCastException("Cannot cast from " + ret.GetType() + " to " + c);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                }
+            }
+            return Parse(d.Name, s);
+        }
+
+        //name: "Integer", value: "12"
+        public object Parse(string name, string value)
+        {
+            if (parsers.ContainsKey(name))
+            {
+                try
+                {
+                    ConstructorInfo c = null;
+                    parsers.TryGetValue(name, out c);
+                    var o = c.Invoke(new object[] { value });
+                    var m = o.GetType().GetMethod("NewInstance", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+                    return m.Invoke(o, new object[] {});
+                }
+                catch (TargetInvocationException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Error invoking constructor for " + name, e), LOGGER);
+                }
+            }
+            else if (name.Equals(typeof(string).Name))
+            {
+                return (object)value;
+            }
+            if (name.Equals(typeof(Byte).Name))
+            {
+                return (object)(Byte)Byte.Parse(value);
+            }
+            if (name.Equals(typeof(Char).Name))
+            {
+                return (object)(Char)value[0];
+            }
+            if (name.Equals(typeof(short).Name))
+            {
+                return (System.Int16)System.Int16.Parse(value);
+            }
+            if (name.Equals(typeof(int).Name))
+            {
+                return (object)(Int32)Int32.Parse(value);
+            }
+            if (name.Equals(typeof(long).Name))
+            {
+                return (object)(Int64)Int64.Parse(value);
+            }
+            if (name.Equals(typeof(float).Name))
+            {
+                return (object)(Single)Single.Parse(value);
+            }
+            if (name.Equals(typeof(Double).Name))
+            {
+                return (object)(Double)Double.Parse(value);
+            }
+            if (name.Equals(typeof(Boolean).Name))
+            {
+                return (object)(Boolean)Boolean.Parse(value);
+            }
+            if (name.Equals(typeof(byte[]).Name))  
+            {
+                byte[] bytes = new byte[value.Length * sizeof(char)];
+                System.Buffer.BlockCopy(value.ToCharArray(), 0, bytes, 0, bytes.Length);
+                return bytes;
+            }
+            return null; 
+        }
+
+        private static readonly ISet<string> BUILTIN_NAMES = new HashSet<string>(new string[]
+            {
+                typeof(string).AssemblyQualifiedName, 
+                typeof(Byte).AssemblyQualifiedName,
+                typeof(char).AssemblyQualifiedName,
+                typeof(short).AssemblyQualifiedName,
+                typeof(Int32).AssemblyQualifiedName,
+                typeof(long).AssemblyQualifiedName,
+                typeof(float).AssemblyQualifiedName,
+                typeof(double).AssemblyQualifiedName,
+                typeof(bool).AssemblyQualifiedName
+            } ); 
+        
+        public bool CanParse(string name)
+        {
+            return parsers.ContainsKey(name) || BUILTIN_NAMES.Contains(name);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationBuilderImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationBuilderImpl.cs
new file mode 100644
index 0000000..cd2aa30
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationBuilderImpl.cs
@@ -0,0 +1,364 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ConfigurationBuilderImpl : IConfigurationBuilder
+    {
+        public IClassHierarchy ClassHierarchy;
+
+        public readonly IDictionary<IClassNode, IClassNode> BoundImpls = new MonotonicTreeMap<IClassNode, IClassNode>();
+        public readonly IDictionary<IClassNode, IClassNode> BoundConstructors = new MonotonicTreeMap<IClassNode, IClassNode>();
+        public readonly IDictionary<INamedParameterNode, String> NamedParameters = new MonotonicTreeMap<INamedParameterNode, String>();
+        public readonly IDictionary<IClassNode, IConstructorDef> LegacyConstructors = new MonotonicTreeMap<IClassNode, IConstructorDef>();
+        public readonly MonotonicMultiMap<INamedParameterNode, object> BoundSetEntries = new MonotonicMultiMap<INamedParameterNode, object>();
+        public readonly IDictionary<INamedParameterNode, IList<object>> BoundLists = new MonotonicTreeMap<INamedParameterNode, IList<object>>();
+
+        public readonly static string INIT = "<init>";
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ConfigurationBuilderImpl));
+
+        protected ConfigurationBuilderImpl() 
+        {
+            this.ClassHierarchy = TangFactory.GetTang().GetDefaultClassHierarchy();
+        }
+
+        public ConfigurationBuilderImpl(IClassHierarchy classHierarchy)
+        {
+            this.ClassHierarchy = classHierarchy;
+        }
+
+        protected ConfigurationBuilderImpl(string[] assemblies, IConfiguration[] confs, Type[] parsers)
+        {
+            this.ClassHierarchy = TangFactory.GetTang().GetDefaultClassHierarchy(assemblies, parsers);
+            foreach (IConfiguration tc in confs) 
+            {
+                AddConfiguration(((ConfigurationImpl) tc));
+            }
+        }
+
+        public ConfigurationBuilderImpl(ConfigurationBuilderImpl t) 
+        {
+            this.ClassHierarchy = t.GetClassHierarchy();
+            try {
+                AddConfiguration(t.GetClassHierarchy(), t);
+            } 
+            catch (BindException e) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Could not copy builder", e), LOGGER); 
+            }
+        }
+
+        protected ConfigurationBuilderImpl(string[] assemblies) : this(assemblies, new IConfiguration[0], new Type[0])
+        {
+        }
+
+        protected ConfigurationBuilderImpl(IConfiguration[] confs) : this(new string[0], confs, new Type[0])
+        {
+        }
+
+        public void AddConfiguration(IConfiguration conf)
+        {
+            AddConfiguration(conf.GetClassHierarchy(), ((ConfigurationImpl)conf).Builder);
+        }
+
+        private void AddConfiguration(IClassHierarchy ns, ConfigurationBuilderImpl builder)
+        {
+            this.ClassHierarchy = this.ClassHierarchy.Merge(ns);
+            
+            if((ClassHierarchy is ClassHierarchyImpl || builder.ClassHierarchy is ClassHierarchyImpl)) 
+            {
+                if((ClassHierarchy is ClassHierarchyImpl && builder.ClassHierarchy is ClassHierarchyImpl)) 
+                {
+                    ((ClassHierarchyImpl) ClassHierarchy).Parameterparser.MergeIn(((ClassHierarchyImpl) builder.ClassHierarchy).Parameterparser);
+                } 
+                else 
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Attempt to merge Java and non-Java class hierarchy!  Not supported."), LOGGER);
+                }
+            }
+
+            foreach (IClassNode cn in builder.BoundImpls.Keys) 
+            {
+                IClassNode n = null;
+                builder.BoundImpls.TryGetValue(cn, out n);
+                if (n != null)
+                {
+                    Bind(cn.GetFullName(), n.GetFullName());
+                }
+            }
+
+            foreach (IClassNode cn in builder.BoundConstructors.Keys) 
+            {
+                IClassNode n = null;
+                builder.BoundConstructors.TryGetValue(cn, out n);
+                if (n != null)
+                {
+                    Bind(cn.GetFullName(), n.GetFullName());
+                }
+            }
+
+            // The namedParameters set contains the strings that can be used to
+            // instantiate new
+            // named parameter instances. Create new ones where we can.
+            foreach (INamedParameterNode np in builder.NamedParameters.Keys) 
+            {
+                string v = null;
+                builder.NamedParameters.TryGetValue(np, out v);
+                Bind(np.GetFullName(), v);
+            }
+    
+            foreach (IClassNode cn in builder.LegacyConstructors.Keys) 
+            {
+                IConstructorDef cd = null;
+                builder.LegacyConstructors.TryGetValue(cn, out cd);
+                RegisterLegacyConstructor(cn, cd.GetArgs());  
+            }
+
+            foreach (KeyValuePair<INamedParameterNode, object> e in builder.BoundSetEntries) 
+            {
+              String name = ((INamedParameterNode)e.Key).GetFullName();
+              if(e.Value is INode) 
+              {
+                    BindSetEntry(name, (INode)e.Value);
+              } 
+              else if (e.Value is string) 
+              {
+                    BindSetEntry(name, (string)e.Value);
+              } else {
+                var ex = new IllegalStateException(string.Format(CultureInfo.CurrentCulture, "The value {0} set to the named parameter {1} is illegel.", e.Value, name));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+              }
+            }
+
+            foreach (var p in builder.BoundLists)
+            {
+                BoundLists.Add(p.Key, p.Value);
+            }
+        }
+
+        public IClassHierarchy GetClassHierarchy()
+        {
+            return this.ClassHierarchy;
+        }
+
+        public void RegisterLegacyConstructor(IClassNode cn, IList<IClassNode> args)
+        {
+            LegacyConstructors.Add(cn, cn.GetConstructorDef(args));
+        }
+
+        public void RegisterLegacyConstructor(string s, IList<string> args)
+        {
+            IClassNode cn = (IClassNode) this.ClassHierarchy.GetNode(s);
+            IList<IClassNode> cnArgs = new List<IClassNode>();
+            for (int i = 0; i < args.Count; i++)
+            {
+                cnArgs.Add((IClassNode)ClassHierarchy.GetNode(args[i]));
+            }
+            RegisterLegacyConstructor(cn, cnArgs);
+        }
+
+        public void RegisterLegacyConstructor(IClassNode c, IList<IConstructorArg> args)
+        {
+            string[] cn = new string[args.Count];
+
+            for (int i = 0; i < args.Count; i++)
+            {
+                cn[i] = args[i].Gettype();
+            }
+            RegisterLegacyConstructor(c.GetFullName(), cn);
+        }
+
+        public IConfiguration Build()
+        {
+            return new ConfigurationImpl(new ConfigurationBuilderImpl(this));
+        }
+
+        public void Bind(string key, string value)
+        {
+            INode n = this.ClassHierarchy.GetNode(key);
+            if (n is INamedParameterNode)
+            {
+                BindParameter((INamedParameterNode)n, value);
+            }
+            else if (n is IClassNode)
+            {
+                INode m = this.ClassHierarchy.GetNode(value);
+                Bind((IClassNode)n, (IClassNode)m);
+            }
+            else
+            {
+                var ex = new IllegalStateException(string.Format("getNode() returned {0} which is neither a ClassNode nor a NamedParameterNode", n));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+        }
+
+        public void Bind(Types.INode key, Types.INode value)
+        {
+            if (key is INamedParameterNode)
+            {
+                BindParameter((INamedParameterNode)key, value.GetFullName());
+            }
+            else if (key is IClassNode)
+            {
+                IClassNode k = (IClassNode)key;
+                if (value is IClassNode)
+                {
+                    IClassNode val = (IClassNode)value;
+                    if (val.IsExternalConstructor() && !k.IsExternalConstructor())
+                    {
+                        BindConstructor(k, (IClassNode) val);
+                    }
+                    else
+                    {
+                        BindImplementation(k, (IClassNode)val);
+                    }
+                }
+            }
+        }
+
+        public void BindParameter(INamedParameterNode name, String value)
+        {
+            /* Parse and discard value; this is just for type checking, skip for now*/
+            if (this.ClassHierarchy is ICsClassHierarchy) 
+            {
+                ((ICsClassHierarchy)ClassHierarchy).Parse(name, value);
+            }
+
+            if(name.IsSet()) 
+            {
+                BindSetEntry((INamedParameterNode)name, value);
+            } 
+            else 
+            {
+                NamedParameters.Add(name, value);
+            }
+        }
+
+        public void BindImplementation(IClassNode n, IClassNode m)
+        {
+            if (this.ClassHierarchy.IsImplementation(n, m))
+            {
+                BoundImpls.Add(n, m);
+            }
+            else
+            {
+                var ex = new ArgumentException(string.Format("Class {0} does not extend {1}.", m, n));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+        }
+
+        public void BindSetEntry(String iface, String impl)
+        {
+            BoundSetEntries.Add((INamedParameterNode)this.ClassHierarchy.GetNode(iface), impl);
+        }
+
+        public void BindSetEntry(String iface, INode impl)
+        {
+            BoundSetEntries.Add((INamedParameterNode)ClassHierarchy.GetNode(iface), impl);
+        }
+
+        public void BindSetEntry(INamedParameterNode iface, String impl)
+        {
+            BoundSetEntries.Add(iface, impl);
+        }
+
+        public void BindSetEntry(INamedParameterNode iface, INode impl)
+        {
+            BoundSetEntries.Add(iface, impl);
+        }
+
+        public void BindList(INamedParameterNode iface, IList<INode> impl)
+        {
+            IList<object> l = new List<object>();
+            foreach (var n in impl)
+            {
+                l.Add((object)n);
+            }
+            BoundLists.Add(iface, l);
+        }
+
+        public void BindList(INamedParameterNode iface, IList<string> impl)
+        {
+            IList<object> l = new List<object>();
+            foreach (var n in impl)
+            {
+                l.Add((object)n);
+            }
+            BoundLists.Add(iface, l);
+        }
+
+        public void BindList(string iface, IList<INode> impl)
+        {
+            BindList((INamedParameterNode)ClassHierarchy.GetNode(iface), impl);            
+        }
+
+        public void BindList(string iface, IList<string> impl)
+        {
+            BindList((INamedParameterNode)ClassHierarchy.GetNode(iface), impl);
+        }
+
+        public void BindConstructor(Types.IClassNode k, Types.IClassNode v)
+        {
+            BoundConstructors.Add(k, v);
+        }
+
+        public string ClassPrettyDefaultString(string longName)
+        {
+            INamedParameterNode param = (INamedParameterNode) this.ClassHierarchy.GetNode(longName);
+            return param.GetSimpleArgName() + "=" + Join(",", param.GetDefaultInstanceAsStrings());
+        }
+
+        private String Join(string sep, string[] s)
+        {
+            if (s.Length == 0)
+            {
+                return null;
+            }
+            else
+            {
+                StringBuilder sb = new StringBuilder(s[0]);
+                for (int i = 1; i < s.Length; i++)
+                {
+                    sb.Append(sep);
+                    sb.Append(s[i]);
+                }
+                return sb.ToString();
+            }
+        }
+
+        public string ClassPrettyDescriptionString(string fullName)
+        {
+            INamedParameterNode param = (INamedParameterNode) this.ClassHierarchy.GetNode(fullName);
+            return param.GetDocumentation() + "\n" + param.GetFullName();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationImpl.cs
new file mode 100644
index 0000000..17739e8
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Configuration/ConfigurationImpl.cs
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ConfigurationImpl : IConfiguration
+    {
+        public readonly ConfigurationBuilderImpl Builder;
+
+        public ConfigurationImpl(ConfigurationBuilderImpl builder)
+        {
+            Builder = builder;
+        }
+
+        public IClassHierarchy GetClassHierarchy()
+        {
+            return Builder.ClassHierarchy;
+        }
+
+        public IConfigurationBuilder newBuilder()
+        {
+            return ((ConfigurationImpl)Builder.Build()).Builder;
+        }
+           
+        public ICollection<IClassNode> GetBoundImplementations()
+        {
+            return Builder.BoundImpls.Keys;
+        }
+
+        public IClassNode GetBoundImplementation(IClassNode cn)
+        {
+            IClassNode v;
+
+            Builder.BoundImpls.TryGetValue(cn, out v);
+
+            return v;
+        }
+
+        public ICollection<IClassNode> GetBoundConstructors()
+        {
+            return Builder.BoundConstructors.Keys;
+        }
+
+        public IClassNode GetBoundConstructor(IClassNode cn)
+        {
+            IClassNode v;
+
+            Builder.BoundConstructors.TryGetValue(cn, out v);
+
+            return v;
+        }
+
+        public ICollection<INamedParameterNode> GetNamedParameters()
+        {
+            return Builder.NamedParameters.Keys;
+        }
+
+        public string GetNamedParameter(INamedParameterNode np)
+        {
+            string v = null;
+            Builder.NamedParameters.TryGetValue(np, out v);
+
+            return v;
+        }
+
+        public IConstructorDef GetLegacyConstructor(IClassNode cn)
+        {
+            IConstructorDef v;
+
+            Builder.LegacyConstructors.TryGetValue(cn, out v);
+
+            return v;
+        }
+
+        public ICollection<IClassNode> GetLegacyConstructors()
+        {
+            return Builder.LegacyConstructors.Keys;
+        }
+
+        public ISet<Object> GetBoundSet(INamedParameterNode np) 
+        {
+            return Builder.BoundSetEntries.GetValuesForKey(np);
+        }
+
+        public IEnumerator<KeyValuePair<INamedParameterNode, object>> GetBoundSets() 
+        {
+            return Builder.BoundSetEntries.GetEnumerator();
+        }
+
+        public IDictionary<INamedParameterNode, IList<object>> GetBoundList()
+        {
+            return Builder.BoundLists;
+        }
+
+        public IList<object> GetBoundList(INamedParameterNode np)
+        {
+            IList<object> list;
+            Builder.BoundLists.TryGetValue(np, out list);
+            return list;
+        }
+    }
+}
\ No newline at end of file


[08/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/RealTimer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/RealTimer.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/RealTimer.cs
new file mode 100644
index 0000000..2e99202
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/RealTimer.cs
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime
+{
+    public class RealTimer : ITimer
+    {
+        [Inject]
+        public RealTimer()
+        {
+        }
+
+        /// <summary>
+        /// Gets the number of milliseconds since Epoch
+        /// </summary>
+        public long CurrentTime
+        {
+            get { return DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; }
+        }
+
+        /// <summary>
+        /// Gets the difference between the given time and the current time
+        /// </summary>
+        /// <param name="time">The time to compare against the current time</param>
+        public long GetDuration(long time)
+        {
+            return time - CurrentTime;
+        }
+
+        /// <summary>
+        /// Checks if the given time has already passed.
+        /// </summary>
+        /// <param name="time">The time to check if it has passed or not</param>
+        public bool IsReady(long time)
+        {
+            return GetDuration(time) <= 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Runtime/RuntimeClock.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Runtime/RuntimeClock.cs b/lang/cs/Source/WAKE/Wake/Time/Runtime/RuntimeClock.cs
new file mode 100644
index 0000000..a8c77af
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Runtime/RuntimeClock.cs
@@ -0,0 +1,257 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive;
+using System.Reactive.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Wake.RX.Impl;
+
+namespace Org.Apache.Reef.Wake.Time.Runtime.Event
+{
+    public class RuntimeClock : IClock
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(RuntimeClock));
+
+        private ITimer _timer;
+        private PubSubSubject<Time> _handlers;
+        private ISet<Time> _schedule;
+
+        private IInjectionFuture<ISet<IObserver<StartTime>>> _startHandler;
+        private IInjectionFuture<ISet<IObserver<StopTime>>> _stopHandler;
+        private IInjectionFuture<ISet<IObserver<RuntimeStart>>> _runtimeStartHandler;
+        private IInjectionFuture<ISet<IObserver<RuntimeStop>>> _runtimeStopHandler;
+        private IInjectionFuture<ISet<IObserver<IdleClock>>> _idleHandler;
+
+        private bool _disposed;
+            
+        /// <summary>
+        /// Create a new RuntimeClock with injectable IObservers
+        /// </summary>
+        /// <param name="timer">The runtime clock timer</param>
+        /// <param name="startHandler">The start handler</param>
+        /// <param name="stopHandler">The stop handler</param>
+        /// <param name="runtimeStartHandler">The runtime start handler</param>
+        /// <param name="runtimeStopHandler">The runtime stop handler</param>
+        /// <param name="idleHandler">The idle handler</param>
+        [Inject]
+        internal RuntimeClock(
+            ITimer timer,
+            [Parameter(typeof(StartHandler))] IInjectionFuture<ISet<IObserver<StartTime>>> startHandler, 
+            [Parameter(typeof(StopHandler))] IInjectionFuture<ISet<IObserver<StopTime>>> stopHandler,
+            [Parameter(typeof(RuntimeStartHandler))] IInjectionFuture<ISet<IObserver<RuntimeStart>>> runtimeStartHandler,
+            [Parameter(typeof(RuntimeStopHandler))] IInjectionFuture<ISet<IObserver<RuntimeStop>>> runtimeStopHandler,
+            [Parameter(typeof(IdleHandler))] IInjectionFuture<ISet<IObserver<IdleClock>>> idleHandler)
+        {
+            _timer = timer;
+            _schedule = new SortedSet<Time>();
+            _handlers = new PubSubSubject<Time>();
+
+            _startHandler = startHandler;
+            _stopHandler = stopHandler;
+            _runtimeStartHandler = runtimeStartHandler;
+            _runtimeStopHandler = runtimeStopHandler;
+            _idleHandler = idleHandler;
+        }
+
+        public IInjectionFuture<ISet<IObserver<RuntimeStart>>> InjectedRuntimeStartHandler
+        {
+            get { return _runtimeStartHandler; }
+            set { _runtimeStartHandler = value; }
+        }
+
+        public IInjectionFuture<ISet<IObserver<RuntimeStop>>> InjectedRuntimeStopHandler
+        {
+            get { return _runtimeStopHandler; }
+            set { _runtimeStopHandler = value; }
+        }
+
+        /// <summary>
+        /// Schedule a TimerEvent at the given future offset
+        /// </summary>
+        /// <param name="offset">The offset in the future to schedule the alarm</param>
+        /// <param name="handler">The IObserver to to be called</param>
+        public override void ScheduleAlarm(long offset, IObserver<Alarm> handler)
+        {
+            if (_disposed)
+            {
+                return;
+            }
+            if (handler == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("handler"), LOGGER);
+            }
+
+            lock (_schedule)
+            {
+                _schedule.Add(new ClientAlarm(_timer.CurrentTime + offset, handler));
+                Monitor.PulseAll(_schedule);
+            }
+        }
+
+        /// <summary>
+        /// Clock is idle if it has no future alarms set
+        /// </summary>
+        /// <returns>True if no future alarms are set, otherwise false</returns>
+        public override bool IsIdle()
+        {
+            lock (_schedule)
+            {
+                return _schedule.Count == 0;
+            }
+        }
+
+        /// <summary>
+        /// Dispose of the clock and all scheduled alarms
+        /// </summary>
+        public override void Dispose()
+        {
+            lock (_schedule)
+            {
+                _schedule.Clear();
+                _schedule.Add(new StopTime(_timer.CurrentTime));
+                Monitor.PulseAll(_schedule);
+                _disposed = true;
+            }
+        }
+
+        /// <summary>
+        /// Register the IObserver for the particular Time event.
+        /// </summary>
+        /// <param name="observer">The handler to register</param>
+        public void RegisterObserver<U>(IObserver<U> observer) where U : Time
+        {
+            if (_disposed)
+            {
+                return;
+            }
+
+            _handlers.Subscribe(observer);
+        }
+
+        /// <summary>
+        /// Start the RuntimeClock.
+        /// Clock will continue to run and handle events until it has been disposed.
+        /// </summary>
+        public void Run()
+        {
+            SubscribeHandlers();
+            _handlers.OnNext(new RuntimeStart(_timer.CurrentTime));
+            _handlers.OnNext(new StartTime(_timer.CurrentTime));
+
+            while (true)
+            {
+                lock (_schedule)
+                {
+                    if (IsIdle())
+                    {
+                        _handlers.OnNext(new IdleClock(_timer.CurrentTime));
+                    }
+                    
+                    // Blocks and releases lock until it receives the next event
+                    Time alarm = GetNextEvent();
+                    ProcessEvent(alarm);
+
+                    if (alarm is StopTime)
+                    {
+                        break;
+                    }
+                }
+            }
+            _handlers.OnNext(new RuntimeStop(_timer.CurrentTime));
+        }
+
+        /// <summary>
+        /// Register the event handlers
+        /// </summary>
+        private void SubscribeHandlers()
+        {
+            Subscribe(_startHandler.Get());
+            Subscribe(_stopHandler.Get());
+            Subscribe(_runtimeStartHandler.Get());
+            Subscribe(_runtimeStopHandler.Get());
+            Subscribe(_idleHandler.Get());
+        }
+
+        /// <summary>
+        /// Subscribe a set of IObservers for a particular Time event
+        /// </summary>
+        /// <param name="observers">The set of observers to subscribe</param>
+        private void Subscribe<U>(ISet<IObserver<U>> observers) where U : Time
+        {
+            foreach (IObserver<U> observer in observers)
+            {
+                _handlers.Subscribe(observer);
+            }
+        }
+            
+        /// <summary>
+        /// Wait until the first scheduled alarm is ready to be handled
+        /// Assumes that we have a lock on the _schedule SortedSet
+        /// </summary>
+        private Time GetNextEvent()
+        {
+            // Wait for an alarm to be scheduled on the condition variable Count
+            while (_schedule.Count == 0)
+            {
+                Monitor.Wait(_schedule);
+            }
+
+            // Once the alarm is scheduled, wait for the prescribed amount of time.
+            // If a new alarm is scheduled with a shorter duration, Wait will preempt
+            // and duration will update to reflect the new alarm's timestamp
+            for (long duration = _timer.GetDuration(_schedule.First().TimeStamp);
+                 duration > 0;
+                 duration = _timer.GetDuration(_schedule.First().TimeStamp))
+            {
+                Monitor.Wait(_schedule, TimeSpan.FromMilliseconds(duration));
+            }
+
+            Time time = _schedule.First();
+            _schedule.Remove(time);
+            return time;
+        }
+
+        /// <summary>
+        /// Process the next Time event. 
+        /// </summary>
+        /// <param name="time">The Time event to handle</param>
+        private void ProcessEvent(Time time)
+        {
+            if (time is Alarm)
+            {
+                Alarm alarm = (Alarm) time;
+                alarm.Handle();
+            }
+            else
+            {
+                _handlers.OnNext(time);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Time/Time.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Time/Time.cs b/lang/cs/Source/WAKE/Wake/Time/Time.cs
new file mode 100644
index 0000000..0ebc1a7
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Time/Time.cs
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Wake.Time
+{
+    /// <summary>
+    /// Time object
+    /// </summary>
+    public abstract class Time : IComparable<Time>
+    {
+        public Time(long timeStamp)
+        {
+            TimeStamp = timeStamp;
+        }
+
+        public long TimeStamp { get; private set; }
+
+        public override string ToString()
+        {
+            return string.Format(CultureInfo.InvariantCulture, "{0}:[{1}]", GetType().Name, TimeStamp);
+        }
+
+        public override int GetHashCode()
+        {
+            return base.GetHashCode();
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (this == obj)
+            {
+                return true;
+            }
+            Time other = obj as Time;
+            if (other != null)
+            {
+                return CompareTo(other) == 0;
+            }
+            return false;
+        }
+
+        public int CompareTo(Time other)
+        {
+            if (TimeStamp < other.TimeStamp)
+            {
+                return -1;
+            }
+            if (TimeStamp > other.TimeStamp)
+            {
+                return 1;
+            }
+            if (GetHashCode() < other.GetHashCode())
+            {
+                return -1;
+            }
+            if (GetHashCode() > other.GetHashCode())
+            {
+                return 1;
+            }
+            return 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/Actionable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/Actionable.cs b/lang/cs/Source/WAKE/Wake/Util/Actionable.cs
new file mode 100644
index 0000000..5e5364c
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/Actionable.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Threading;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public class Actionable
+    {
+        private readonly ThreadStart _threadStart;
+
+        public Actionable()
+        {
+        }
+
+        internal Actionable(ThreadStart threadStart)
+        {
+            _threadStart = threadStart;
+        }
+
+        public void Call()
+        {
+            _threadStart();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/Disposable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/Disposable.cs b/lang/cs/Source/WAKE/Wake/Util/Disposable.cs
new file mode 100644
index 0000000..ebe30bc
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/Disposable.cs
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    /// <summary>
+    /// Generates IDisposables from a factory method
+    /// </summary>
+    internal class Disposable : IDisposable
+    {
+        private Action _disposeFunction;
+        private bool _disposed;
+
+        private Disposable(Action disposeFunction)
+        {
+            _disposeFunction = disposeFunction;
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Factory method to create an IDisposable from a function.
+        /// </summary>
+        /// <param name="disposeFunction">The function to call when disposing</param>
+        /// <returns>An IDisposable from the given dispose function</returns>
+        public static IDisposable Create(Action disposeFunction)
+        {
+            return new Disposable(disposeFunction); 
+        }
+
+        /// <summary>
+        /// Dispose of resources by calling the supplied dispose function
+        /// </summary>
+        public void Dispose()
+        {
+            if (!_disposed)
+            {
+                _disposeFunction();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/FixedThreadPoolTaskService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/FixedThreadPoolTaskService.cs b/lang/cs/Source/WAKE/Wake/Util/FixedThreadPoolTaskService.cs
new file mode 100644
index 0000000..e86820d
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/FixedThreadPoolTaskService.cs
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public class FixedThreadPoolTaskService : ITaskService
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(FixedThreadPoolTaskService));
+
+        TaskFactory factory;
+
+        List<Task> tasks = new List<Task>();        
+        bool shuttingDown;
+
+        internal FixedThreadPoolTaskService(int maxDegreeOfParallelism)
+        {
+            LimitedConcurrencyLevelTaskScheduler lcts = new LimitedConcurrencyLevelTaskScheduler(maxDegreeOfParallelism);
+            factory = new TaskFactory(lcts);
+        }
+
+        public bool AwaitTermination(long n, TimeSpan unit)
+        {
+            Task[] allTasks;
+            lock (tasks)
+            {
+                if (tasks.Count == 0)
+                {
+                    return true;
+                }
+                allTasks = tasks.ToArray();
+            }
+            return Task.WaitAll(allTasks, unit);
+        }
+
+        public void ShutdownNow()
+        {
+            Shutdown();
+        }
+
+        public void Shutdown()
+        {
+            lock (tasks)
+            {
+                shuttingDown = true;
+            }
+        }
+
+        public Task<T> Submit<T>(Func<T> c)
+        {
+            Task<T> task = null;
+            lock (tasks)
+            {                
+                if (shuttingDown)
+                {
+                    Exceptions.Throw(new InvalidOperationException("Shutting down"), LOGGER);
+                }
+
+                CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
+                CancellationToken cancellationToken = cancellationTokenSource.Token;
+                task = factory.StartNew(c, cancellationToken);                                
+                tasks.Add(task);
+            }
+            return task;
+        }
+
+        public void Execute(ThreadStart threadStart)
+        {
+            new Actionable(threadStart).Call();
+        }
+
+        internal void RemoveTask(Task task)
+        {
+            lock (tasks)
+            {
+                tasks.Remove(task);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/IStartable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/IStartable.cs b/lang/cs/Source/WAKE/Wake/Util/IStartable.cs
new file mode 100644
index 0000000..2327819
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/IStartable.cs
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public interface IStartable
+    {
+        void Start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/ITaskService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/ITaskService.cs b/lang/cs/Source/WAKE/Wake/Util/ITaskService.cs
new file mode 100644
index 0000000..2ad0e1e
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/ITaskService.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public interface ITaskService
+    {        
+        void Shutdown();     
+
+        void Execute(ThreadStart threadStart);
+
+        Task<T> Submit<T>(Func<T> ob);
+    }       
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/LimitedConcurrencyLevelTaskScheduler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/LimitedConcurrencyLevelTaskScheduler.cs b/lang/cs/Source/WAKE/Wake/Util/LimitedConcurrencyLevelTaskScheduler.cs
new file mode 100644
index 0000000..4bd3083
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/LimitedConcurrencyLevelTaskScheduler.cs
@@ -0,0 +1,187 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    internal class LimitedConcurrencyLevelTaskScheduler : TaskScheduler
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(LimitedConcurrencyLevelTaskScheduler));
+
+        /// <summary>Whether the current thread is processing work items.</summary>
+        [ThreadStatic]
+        private static bool _currentThreadIsProcessingItems;
+
+        /// <summary>The list of tasks to be executed.</summary>
+        private readonly LinkedList<Task> _tasks = new LinkedList<Task>(); // protected by lock(_tasks)
+
+        /// <summary>The maximum concurrency level allowed by this scheduler.</summary>
+        private readonly int _maxDegreeOfParallelism;
+
+        /// <summary>Whether the scheduler is currently processing work items.</summary>
+        private int _delegatesQueuedOrRunning = 0; // protected by lock(_tasks)
+
+        /// <summary>
+        /// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the
+        /// specified degree of parallelism.
+        /// </summary>
+        /// <param name="maxDegreeOfParallelism">The maximum degree of parallelism provided by this scheduler.</param>
+        public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
+        {
+            if (maxDegreeOfParallelism < 1)
+            {
+                Exceptions.Throw(new ArgumentOutOfRangeException("maxDegreeOfParallelism"), LOGGER);
+            }
+            _maxDegreeOfParallelism = maxDegreeOfParallelism;
+        }
+
+        /// <summary>Gets the maximum concurrency level supported by this scheduler.</summary>
+        public sealed override int MaximumConcurrencyLevel
+        {
+            get
+            {
+                return _maxDegreeOfParallelism;
+            }
+        }
+
+        /// <summary>Queues a task to the scheduler.</summary>
+        /// <param name="task">The task to be queued.</param>
+        protected sealed override void QueueTask(Task task)
+        {
+            // Add the task to the list of tasks to be processed.  If there aren't enough
+            // delegates currently queued or running to process tasks, schedule another.
+            lock (_tasks)
+            {
+                _tasks.AddLast(task);
+                if (_delegatesQueuedOrRunning < _maxDegreeOfParallelism)
+                {
+                    ++_delegatesQueuedOrRunning;
+                    NotifyThreadPoolOfPendingWork();
+                }
+            }
+        }
+
+        /// <summary>Attempts to execute the specified task on the current thread.</summary>
+        /// <param name="task">The task to be executed.</param>
+        /// <param name="taskWasPreviouslyQueued"></param>
+        /// <returns>Whether the task could be executed on the current thread.</returns>
+        protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
+        {
+            // If this thread isn't already processing a task, we don't support inlining
+            if (!_currentThreadIsProcessingItems)
+            {
+                return false;
+            }
+
+            // If the task was previously queued, remove it from the queue
+            if (taskWasPreviouslyQueued)
+            {
+                TryDequeue(task);
+            }
+
+            // Try to run the task.
+            return TryExecuteTask(task);
+        }
+
+        /// <summary>Attempts to remove a previously scheduled task from the scheduler.</summary>
+        /// <param name="task">The task to be removed.</param>
+        /// <returns>Whether the task could be found and removed.</returns>
+        protected sealed override bool TryDequeue(Task task)
+        {
+            lock (_tasks)
+            {
+                return _tasks.Remove(task);
+            }
+        }
+
+        /// <summary>Gets an enumerable of the tasks currently scheduled on this scheduler.</summary>
+        /// <returns>An enumerable of the tasks currently scheduled.</returns>
+        protected sealed override IEnumerable<Task> GetScheduledTasks()
+        {
+            bool lockTaken = false;
+            try
+            {
+                Monitor.TryEnter(_tasks, ref lockTaken);
+                if (lockTaken)
+                {
+                    return _tasks.ToArray();
+                }
+                else
+                {
+                    throw new NotSupportedException();
+                }
+            }
+            finally
+            {
+                if (lockTaken)
+                {
+                    Monitor.Exit(_tasks);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Informs the ThreadPool that there's work to be executed for this scheduler.
+        /// </summary>
+        private void NotifyThreadPoolOfPendingWork()
+        {
+            ThreadPool.UnsafeQueueUserWorkItem(_ =>
+            {
+                // Note that the current thread is now processing work items.
+                // This is necessary to enable inlining of tasks into this thread.
+                _currentThreadIsProcessingItems = true;
+                try
+                {
+                    // Process all available items in the queue.
+                    while (true)
+                    {
+                        Task item;
+                        lock (_tasks)
+                        {
+                            // When there are no more items to be processed,
+                            // note that we're done processing, and get out.
+                            if (_tasks.Count == 0)
+                            {
+                                --_delegatesQueuedOrRunning;
+                                break;
+                            }
+                            // Get the next item from the queue
+                            item = _tasks.First.Value;
+                            _tasks.RemoveFirst();
+                        }
+                        // Execute the task we pulled out of the queue
+                        base.TryExecuteTask(item);
+                    }
+                }
+                    // We're done processing items on the current thread
+                finally
+                {
+                    _currentThreadIsProcessingItems = false;
+                }
+            }, null);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/NetworkUtils.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/NetworkUtils.cs b/lang/cs/Source/WAKE/Wake/Util/NetworkUtils.cs
new file mode 100644
index 0000000..c598c49
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/NetworkUtils.cs
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public class NetworkUtils
+    {
+        private static IPAddress _localAddress;
+        private static Random _random = new Random();
+
+        /// <summary>
+        /// Returns the first usable IP Address for the machine.
+        /// </summary>
+        /// <returns>The machine's local IP Address</returns>
+        public static IPAddress LocalIPAddress
+        {
+            get
+            {
+                if (_localAddress == null)
+                {
+                    IPAddress[] localIps = Dns.GetHostAddresses(Dns.GetHostName());
+                    _localAddress = localIps.Where(i => i.AddressFamily.Equals(AddressFamily.InterNetwork))
+                                            .OrderBy(ip => ip.ToString())
+                                            .First();
+                }
+                
+                return _localAddress;
+            } 
+        }
+
+        /// <summary>
+        /// Generate a random port between low (inclusive) and high (exclusive)
+        /// </summary>
+        /// <param name="low">The inclusive lower bound of the of the port range</param>
+        /// <param name="high">The exclusive upper bound of the port range</param>
+        /// <returns>The randomly generated port</returns>
+        public static int GenerateRandomPort(int low, int high)
+        {
+            return _random.Next(low, high);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/SerializationHelper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/SerializationHelper.cs b/lang/cs/Source/WAKE/Wake/Util/SerializationHelper.cs
new file mode 100644
index 0000000..cd9e220
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/SerializationHelper.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using ProtoBuf;
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public class SerializationHelper
+    {
+        public static byte[] Serialize<T>(T t)
+        {
+            using (var s = new MemoryStream())
+            {
+                Serializer.Serialize(s, t);
+                return s.ToArray();
+            }
+        }
+
+        public static T Deserialize<T>(byte[] bytes)
+        {
+            using (var s = new MemoryStream(bytes))
+            {
+                return Serializer.Deserialize<T>(s);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/TaskExtensions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/TaskExtensions.cs b/lang/cs/Source/WAKE/Wake/Util/TaskExtensions.cs
new file mode 100644
index 0000000..0c1da40
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/TaskExtensions.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public static class TaskExtensions
+    {
+        public static void Forget(this Task task)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Util/TimeHelper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Util/TimeHelper.cs b/lang/cs/Source/WAKE/Wake/Util/TimeHelper.cs
new file mode 100644
index 0000000..2b437fa
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Util/TimeHelper.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Threading;
+
+namespace Org.Apache.Reef.Wake.Util
+{
+    public class TimeHelper
+    {
+        public const long TicksPerMilliSecond = 10000;
+        public const long TicksPerMicroSecond = 10;
+        public const double TicksPerNanoSecond = .01;
+
+        public static long CurrentTimeToNanoSeconds
+        {
+            get
+            {
+                return DateTime.Now.Ticks / 100;
+            }
+        }
+
+        public static long AsLongNanoSeconds(TimeSpan timeSpan)
+        {
+            return (long)(timeSpan.Ticks * TicksPerNanoSecond);
+        }
+
+        public static double AsDoubleNanoSeconds(TimeSpan timeSpan)
+        {
+            return timeSpan.Ticks * TicksPerNanoSecond;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Wake.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Wake.csproj b/lang/cs/Source/WAKE/Wake/Wake.csproj
new file mode 100644
index 0000000..689df3c
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Wake.csproj
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{CDFB3464-4041-42B1-9271-83AF24CD5008}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Wake</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Wake</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.Wake\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\bin\Release\Microsoft.Wake\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Reactive.Core">
+      <HintPath>..\..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Reactive.Interfaces">
+      <HintPath>..\..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AbstractEStage.cs" />
+    <Compile Include="IEStage.cs" />
+    <Compile Include="IEventHandler.cs" />
+    <Compile Include="IIdentifier.cs" />
+    <Compile Include="IIdentifierFactory.cs" />
+    <Compile Include="Impl\LoggingEventHandler.cs" />
+    <Compile Include="Impl\MissingStartHandlerHandler.cs" />
+    <Compile Include="Impl\MultiEventHandler.cs" />
+    <Compile Include="Impl\PeriodicEvent.cs" />
+    <Compile Include="Impl\PubSubEventHandler.cs" />
+    <Compile Include="Impl\SingleThreadStage.cs" />
+    <Compile Include="Impl\SyncStage.cs" />
+    <Compile Include="Impl\ThreadPoolStage.cs" />
+    <Compile Include="Impl\TimerStage.cs" />
+    <Compile Include="IObserverFactory.cs" />
+    <Compile Include="IStage.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Protobuf\WakeRemoteProtosGen.cs" />
+    <Compile Include="Remote\ICodec.cs" />
+    <Compile Include="Remote\ICodecFactory.cs" />
+    <Compile Include="Remote\IDecoder.cs" />
+    <Compile Include="Remote\IEncoder.cs" />
+    <Compile Include="Remote\ILink.cs" />
+    <Compile Include="Remote\Impl\ByteCodec.cs" />
+    <Compile Include="Remote\Impl\ByteCodecFactory.cs" />
+    <Compile Include="Remote\Impl\Channel.cs" />
+    <Compile Include="Remote\Impl\DefaultRemoteManager.cs" />
+    <Compile Include="Remote\Impl\DefaultRemoteMessage.cs" />
+    <Compile Include="Remote\Impl\IntCodec.cs" />
+    <Compile Include="Remote\Impl\IPEndpointComparer.cs" />
+    <Compile Include="Remote\Impl\Link.cs" />
+    <Compile Include="Remote\Impl\MultiCodec.cs" />
+    <Compile Include="Remote\Impl\MultiDecoder.cs" />
+    <Compile Include="Remote\Impl\MultiEncoder.cs" />
+    <Compile Include="Remote\Impl\ObserverContainer.cs" />
+    <Compile Include="Remote\Impl\RemoteEvent.cs" />
+    <Compile Include="Remote\Impl\RemoteEventCodec.cs" />
+    <Compile Include="Remote\Impl\RemoteEventDecoder.cs" />
+    <Compile Include="Remote\Impl\RemoteEventEncoder.cs" />
+    <Compile Include="Remote\Impl\RemoteEventEndpoint.cs" />
+    <Compile Include="Remote\Impl\SocketRemoteIdentifier.cs" />
+    <Compile Include="Remote\Impl\StringCodec.cs" />
+    <Compile Include="Remote\Impl\StringIdentifier.cs" />
+    <Compile Include="Remote\Impl\StringIdentifierFactory.cs" />
+    <Compile Include="Remote\Impl\TransportClient.cs" />
+    <Compile Include="Remote\Impl\TransportEvent.cs" />
+    <Compile Include="Remote\Impl\TransportServer.cs" />
+    <Compile Include="Remote\IRemoteEvent.cs" />
+    <Compile Include="Remote\IRemoteIdentifier.cs" />
+    <Compile Include="Remote\IRemoteIdentifierFactory.cs" />
+    <Compile Include="Remote\IRemoteManager.cs" />
+    <Compile Include="Remote\IRemoteMessage.cs" />
+    <Compile Include="Remote\ISubscriptionManager.cs" />
+    <Compile Include="Remote\Proto\WakeRemoteProtos.cs" />
+    <Compile Include="Remote\RemoteConfiguration.cs" />
+    <Compile Include="Remote\RemoteRuntimeException.cs" />
+    <Compile Include="RX\AbstractObserver.cs" />
+    <Compile Include="RX\AbstractRxStage.cs" />
+    <Compile Include="RX\Impl\PubSubSubject.cs" />
+    <Compile Include="RX\Impl\RxSyncStage.cs" />
+    <Compile Include="RX\Impl\RxThreadPoolStage.cs" />
+    <Compile Include="RX\Impl\RxTimerStage.cs" />
+    <Compile Include="RX\Impl\SimpleSubject.cs" />
+    <Compile Include="RX\IRxStage.cs" />
+    <Compile Include="RX\IStaticObservable.cs" />
+    <Compile Include="RX\ISubject.cs" />
+    <Compile Include="RX\ObserverCompletedException.cs" />
+    <Compile Include="src\main\cs\Examples\P2p\IEventSource.cs" />
+    <Compile Include="src\main\cs\Examples\P2p\Pull2Push.cs" />
+    <Compile Include="src\main\cs\PeriodicEvent.cs" />
+    <Compile Include="Time\Event\Alarm.cs" />
+    <Compile Include="Time\Event\StartTime.cs" />
+    <Compile Include="Time\Event\StopTime.cs" />
+    <Compile Include="Time\IClock.cs" />
+    <Compile Include="Time\Runtime\Event\ClientAlarm.cs" />
+    <Compile Include="Time\Runtime\Event\IdleClock.cs" />
+    <Compile Include="Time\Runtime\Event\RuntimeAlarm.cs" />
+    <Compile Include="Time\Runtime\Event\RuntimeStart.cs" />
+    <Compile Include="Time\Runtime\Event\RuntimeStop.cs" />
+    <Compile Include="Time\Runtime\ITimer.cs" />
+    <Compile Include="Time\Runtime\LogicalTimer.cs" />
+    <Compile Include="Time\Runtime\RealTimer.cs" />
+    <Compile Include="Time\Runtime\RuntimeClock.cs" />
+    <Compile Include="Time\Time.cs" />
+    <Compile Include="Util\Actionable.cs" />
+    <Compile Include="Util\Disposable.cs" />
+    <Compile Include="Util\FixedThreadPoolTaskService.cs" />
+    <Compile Include="Util\IStartable.cs" />
+    <Compile Include="Util\ITaskService.cs" />
+    <Compile Include="Util\LimitedConcurrencyLevelTaskScheduler.cs" />
+    <Compile Include="Util\NetworkUtils.cs" />
+    <Compile Include="Util\SerializationHelper.cs" />
+    <Compile Include="Util\TaskExtensions.cs" />
+    <Compile Include="Util\TimeHelper.cs" />
+    <Compile Include="WakeRuntimeException.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+    <None Include="Protobuf\RemoteProtocol.proto" />
+    <None Include="testkey.snk" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Impl\Impl\" />
+    <Folder Include="RX\RX\Impl\" />
+    <Folder Include="Time\Time\Event\" />
+    <Folder Include="Time\Time\Runtime\Event\" />
+    <Folder Include="Util\Util\" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <PropertyGroup>
+    <MainProtoBufDir>.\target\generated-sources\proto\main\cs\Wake</MainProtoBufDir>
+    <TestProtoBufDir>.\target\generated-sources\proto\test\cs\Wake</TestProtoBufDir>
+    <TestRemoteDir>..\..\wake\target\generated-sources\proto\test\cs\Wake</TestRemoteDir>
+  </PropertyGroup>
+  <Target Name="ProtoBuf">
+    <MakeDir Directories="$(MainProtoBufDir)" Condition="!Exists('$(MainProtoBufDir)')" />
+    <MakeDir Directories="$(TestProtoBufDir)" Condition="!Exists('$(TestProtoBufDir)')" />
+    <MakeDir Directories="$(TestRemoteDir)" Condition="!Exists('$(TestRemoteDir)')" />
+    <Exec Command="protogen -i:.\src\main\proto\RemoteProtocol.proto -o:$(MainProtoBufDir)\WakeRemoteProtosGen.cs -ns:Wake.Remote.Proto.WakeRemoteProtos" />
+    <!--<Exec Command="protogen -i:.\src\test\proto\TestProtocol.proto -o:$(TestProtoBufDir)\TestProtosGen.cs -ns:Wake.Test.Proto.TestProtos" />
+    <Exec Command="protogen -i:.\src\test\proto\TestEvent1.proto -o:$(TestRemoteDir)\TestEvent1.pb.cs -ns:Wake.Test.Remote.TestRemote" />-->
+  </Target>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/WakeRuntimeException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/WakeRuntimeException.cs b/lang/cs/Source/WAKE/Wake/WakeRuntimeException.cs
new file mode 100644
index 0000000..0ac2c13
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/WakeRuntimeException.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake
+{
+    /// <summary>Wake runtime exception</summary>
+    [System.Serializable]
+    public class WakeRuntimeException : Exception
+    {
+        private const long serialVersionUID = 1L;
+
+        /// <summary>Constructs a new runtime wake exception with the specified detail message and cause
+        ///     </summary>
+        /// <param name="s">the detailed message</param>
+        /// <param name="e">the cause</param>
+        public WakeRuntimeException(string s, Exception e)
+            : base(s, e)
+        {
+        }
+
+        /// <summary>Constructs a new runtime stage exception with the specified detail message
+        ///     </summary>
+        /// <param name="s">the detailed message</param>
+        public WakeRuntimeException(string s)
+            : base(s)
+        {
+        }
+
+        /// <summary>Constructs a new runtime stage exception with the specified cause</summary>
+        /// <param name="e">the cause</param>
+        public WakeRuntimeException(Exception e)
+            : base("Runtime Exception", e)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/packages.config b/lang/cs/Source/WAKE/Wake/packages.config
new file mode 100644
index 0000000..fd78097
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/packages.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+  <package id="Rx-Core" version="2.2.5" targetFramework="net45" />
+  <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
+</packages>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/IEventSource.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/IEventSource.cs b/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/IEventSource.cs
new file mode 100644
index 0000000..d761032
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/IEventSource.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Wake.Examples.P2p
+{
+    /// <summary>
+    /// The pull side of the interface: Clients implement this and register it with
+    /// the PullToPush class.
+    /// </summary>
+    /// <typeparam name="T">The event type</typeparam>
+    public interface IEventSource<T>
+    {
+        /// <summary>
+        /// Gets the next event
+        /// </summary>
+        /// <returns>The next event</returns>
+        T GetNext();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/Pull2Push.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/Pull2Push.cs b/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/Pull2Push.cs
new file mode 100644
index 0000000..3f596f2
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/src/main/cs/Examples/P2p/Pull2Push.cs
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Util;
+using System;
+using System.Collections.Generic;
+
+namespace Wake.Examples.P2p
+{
+    /// <summary>Performs a Pull-to-Push conversion in Wake.</summary>
+    /// <remarks>
+    /// Performs a Pull-to-Push conversion in Wake.
+    /// The class pulls from a set of event sources, and pushes to a single
+    /// EventHandler. If the downstream event handler blocks, this will block,
+    /// providing a simple rate limiting scheme.
+    /// The EventSources are managed in a basic Queue.
+    /// </remarks>
+    public sealed class Pull2Push<T> : IStartable, IDisposable
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(Pull2Push<T>));
+        
+        private readonly IEventHandler<T> _output;
+
+        private readonly Queue<IEventSource<T>> _sources = new Queue<IEventSource<T>>();
+
+        private bool _closed = false;
+
+        /// <summary>
+        /// Constructs a new Pull2Push object
+        /// </summary>
+        /// <param name="output">
+        /// the EventHandler that receives the messages from this
+        /// Pull2Push.
+        /// </param>
+        public Pull2Push(IEventHandler<T> output)
+        {
+            // The downstream EventHandler
+            // The upstream event sources
+            _output = output;
+        }
+
+        /// <summary>Registers an event source.</summary>
+        /// <param name="source">
+        /// The source that will be added to the queue of this
+        /// Pull2Push
+        /// </param>
+        public void Register(IEventSource<T> source)
+        {
+            _sources.Enqueue(source);
+        }
+
+        /// <summary>Executes the message loop.</summary>
+        public void Start()
+        {
+            while (!_closed)
+            {
+                // Grab the next available message source, if any
+                IEventSource<T> nextSource = _sources.Dequeue();
+                if (null != nextSource)
+                {
+                    // Grab the next message from that source, if any
+                    T message = nextSource.GetNext();
+                    if (null != message)
+                    {
+                        // Add the source to the end of the queue again.
+                        _sources.Enqueue(nextSource);
+                        // Send the message. Note that this may block depending on the underlying EventHandler.
+                        _output.OnNext(message);
+                    }
+                    else
+                    {
+                        // The message source has returned null as the next message. We drop the message source in that case.
+                        LOGGER.Log(Level.Info, "Droping message source {0} from the queue " + nextSource.ToString());
+                    }
+                }
+            }
+        }
+
+        // No source where available. We could put a wait() here. 
+        public void Dispose()
+        {
+            _closed = true;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/src/main/cs/PeriodicEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/src/main/cs/PeriodicEvent.cs b/lang/cs/Source/WAKE/Wake/src/main/cs/PeriodicEvent.cs
new file mode 100644
index 0000000..a91e298
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/src/main/cs/PeriodicEvent.cs
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2013 Microsoft.
+ *
+ * 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 Wake.Impl
+{
+	/// <summary>Periodic event for timers</summary>
+	public class PeriodicEvent
+	{
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/testkey.snk
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/testkey.snk b/lang/cs/Source/WAKE/Wake/testkey.snk
new file mode 100644
index 0000000..133423f
Binary files /dev/null and b/lang/cs/Source/WAKE/Wake/testkey.snk differ

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/ConfigFiles/evaluator.conf
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/ConfigFiles/evaluator.conf b/lang/cs/Tests/ReefTests/ConfigFiles/evaluator.conf
new file mode 100644
index 0000000..67256f5
Binary files /dev/null and b/lang/cs/Tests/ReefTests/ConfigFiles/evaluator.conf differ

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorConfigurationsTests.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorConfigurationsTests.cs b/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorConfigurationsTests.cs
new file mode 100644
index 0000000..69fc9ae
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorConfigurationsTests.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class EvaluatorConfigurationsTests
+    {
+        [TestMethod, Priority(0), TestCategory("Unit")]
+        [DeploymentItem(@"ConfigFiles")]
+        public void TestEvaluatorConfigurations()
+        {
+            EvaluatorConfigurations evaluatorConfigurations = new EvaluatorConfigurations("evaluator.conf");
+
+            Assert.IsTrue(evaluatorConfigurations.EvaluatorId.Equals("Node-1-1414443998204"));
+
+            Assert.IsTrue(evaluatorConfigurations.ApplicationId.Equals("REEF_LOCAL_RUNTIME"));
+
+            string rootContextConfigString = evaluatorConfigurations.RootContextConfiguration;
+            Assert.IsFalse(string.IsNullOrWhiteSpace(rootContextConfigString));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorTests.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorTests.cs b/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorTests.cs
new file mode 100644
index 0000000..2c3eaa2
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Evaluator.Tests/EvaluatorTests.cs
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Avro;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.IO;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class EvaluatorTests
+    {
+        [TestMethod, Priority(0), TestCategory("Functional")]
+        [Description("Parse Evaluator configuration from Java, inject and execute Shell task with DIR command based on the configuration")]
+        [DeploymentItem(@"ConfigFiles")]
+        public void CanInjectAndExecuteTask()
+        {
+            //To enforce that shell task dll be copied to output directory.
+            ShellTask tmpTask = new ShellTask("invalid");
+            Assert.IsNotNull(tmpTask);
+
+            string tmp = Directory.GetCurrentDirectory();
+            Assert.IsNotNull(tmp);
+
+            AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+            AvroConfiguration avroConfiguration = serializer.AvroDeseriaizeFromFile("evaluator.conf");
+            Assert.IsNotNull(avroConfiguration);
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.AddConfiguration(TaskConfiguration.ConfigurationModule
+                .Set(TaskConfiguration.Identifier, "Test_CLRContext_task")
+                .Set(TaskConfiguration.Task, GenericType<ShellTask>.Class)
+                .Build());
+            cb.BindNamedParameter<ShellTask.Command, string>(GenericType<ShellTask.Command>.Class, "dir");
+
+            IConfiguration taskConfiguration = cb.Build();
+
+            string taskConfig = serializer.ToString(taskConfiguration);
+
+            ITask task = null;
+            TaskConfiguration config = new TaskConfiguration(taskConfig);
+            Assert.IsNotNull(config);
+            try
+            {
+                IInjector injector = TangFactory.GetTang().NewInjector(config.TangConfig);
+                task = (ITask)injector.GetInstance(typeof(ITask));
+            }
+            catch (Exception e)
+            {
+                throw new InvalidOperationException("unable to inject task with configuration: " + taskConfig, e);
+            }
+
+            byte[] bytes = task.Call(null);
+            string result = System.Text.Encoding.Default.GetString(bytes);
+
+            //a dir command is executed in the container directory, which includes the file "evaluator.conf"
+            Assert.IsTrue(result.Contains("evaluator.conf"));
+        }
+
+        [TestMethod, Priority(0), TestCategory("Unit")]
+        [Description("Test driver information extacted from Http server")]
+        public void CanExtractDriverInformaiton()
+        {
+            const string InfoString = "{\"remoteId\":\"socket://10.121.136.231:14272\",\"startTime\":\"2014 08 28 10:50:32\",\"services\":[{\"serviceName\":\"NameServer\",\"serviceInfo\":\"10.121.136.231:16663\"}]}";
+            AvroDriverInfo info = AvroJsonSerializer<AvroDriverInfo>.FromString(InfoString);
+            Assert.IsTrue(info.remoteId.Equals("socket://10.121.136.231:14272"));
+            Assert.IsTrue(info.startTime.Equals("2014 08 28 10:50:32"));
+            Assert.IsTrue(new DriverInformation(info.remoteId, info.startTime, info.services).NameServerId.Equals("10.121.136.231:16663"));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestBridgeClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestBridgeClient.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestBridgeClient.cs
new file mode 100644
index 0000000..f0785f9
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestBridgeClient.cs
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Utilities.Logging;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class TestBridgeClient : ReefFunctionalTest
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TestBridgeClient));
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            CleanUp();
+            Init();
+        }
+
+        [TestCleanup]
+        public void TestCleanup()
+        {
+            Console.WriteLine("Post test check and clean up");
+            CleanUp();
+        }
+
+        [TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Run CLR Bridge on local runtime")]
+        [DeploymentItem(@".")]
+        [Ignore] // This is diabled by default on builds
+        public void CanRunClrBridgeOnYarn()
+        {
+            RunClrBridgeClient(runOnYarn: true);
+        }
+
+        [TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Run CLR Bridge on local runtime")]
+        [DeploymentItem(@".")]
+        [Timeout(180 * 1000)]
+        public void CanRunClrBridgeOnLocalRuntime()
+        {
+            IsOnLocalRuntiime = true;
+            RunClrBridgeClient(runOnYarn: false);
+            ValidateSuccessForLocalRuntime(2);
+        }
+
+        private void RunClrBridgeClient(bool runOnYarn)
+        {
+            const string clrBridgeClient = "Org.Apache.Reef.CLRBridgeClient.exe";
+            List<string> arguments = new List<string>();
+            arguments.Add(runOnYarn.ToString());
+            arguments.Add(Constants.BridgeLaunchClass);
+            arguments.Add(".");
+            arguments.Add(Path.Combine(_binFolder, Constants.BridgeJarFileName));
+            arguments.Add(Path.Combine(_binFolder, _cmdFile));
+
+            ProcessStartInfo startInfo = new ProcessStartInfo()
+            {
+                FileName = clrBridgeClient,
+                Arguments = string.Join(" ", arguments),
+                RedirectStandardOutput = true,
+                UseShellExecute = false,
+                CreateNoWindow = false
+            }; 
+            
+            LOGGER.Log(Level.Info, "executing\r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
+            using (Process process = Process.Start(startInfo))
+            {
+                process.WaitForExit();
+                if (process.ExitCode != 0)
+                {
+                    throw new InvalidOperationException("CLR client exited with error code " + process.ExitCode);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestHelloBridgeHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestHelloBridgeHandlers.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestHelloBridgeHandlers.cs
new file mode 100644
index 0000000..7e896ec
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestHelloBridgeHandlers.cs
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Examples.HelloCLRBridge;
+using Org.Apache.Reef.Examples.HelloCLRBridge.Handlers;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class TestHelloBridgeHandlers : ReefFunctionalTest
+    {
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            CleanUp();
+            Init();
+        }
+
+        [TestCleanup]
+        public void TestCleanup()
+        {
+            Console.WriteLine("Post test check and clean up");
+            CleanUp();
+        }
+
+        [TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Test Hello Handler on local runtime")]
+        [DeploymentItem(@".")]
+        [Timeout(180 * 1000)]
+        public void RunHelloHandlerOnLocalRuntime()
+        {
+            IsOnLocalRuntiime = true;
+            TestRun(AssembliesToCopy(), DriverConfiguration());
+            ValidateSuccessForLocalRuntime(2);
+            ValidateEvaluatorSetting();
+        }
+
+        public IConfiguration DriverConfiguration()
+        {
+            return DriverBridgeConfiguration.ConfigurationModule
+                 .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<HelloStartHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<HelloAllocatedEvaluatorHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<AnotherHelloAllocatedEvaluatorHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnContextActive, GenericType<HelloActiveContextHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnTaskMessage, GenericType<HelloTaskMessageHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnEvaluatorFailed, GenericType<HelloFailedEvaluatorHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnTaskFailed, GenericType<HelloFailedTaskHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnTaskRunning, GenericType<HelloRunningTaskHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnEvaluatorRequested, GenericType<HelloEvaluatorRequestorHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnHttpEvent, GenericType<HelloHttpHandler>.Class)
+                 .Set(DriverBridgeConfiguration.OnEvaluatorCompleted, GenericType<HelloCompletedEvaluatorHandler>.Class)
+                 .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class)
+                 .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString())
+                 .Set(DriverBridgeConfiguration.CommandLineArguments, "submitContextAndTask")
+                 .Build();
+        }
+
+        public HashSet<string> AssembliesToCopy()
+        {
+            HashSet<string> appDlls = new HashSet<string>();
+            appDlls.Add(typeof(HelloStartHandler).Assembly.GetName().Name);
+            appDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+            return appDlls;
+        }
+
+        private void ValidateEvaluatorSetting()
+        {
+            const string successIndication = "Evaluator is assigned with 512 MB of memory and 2 cores.";
+            string[] lines = File.ReadAllLines(GetLogFile(_stdout));
+            string[] successIndicators = lines.Where(s => s.Contains(successIndication)).ToArray();
+            Assert.IsTrue(successIndicators.Count() >= 1);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestSimpleEventHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestSimpleEventHandlers.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestSimpleEventHandlers.cs
new file mode 100644
index 0000000..fb8a011
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Bridge/TestSimpleEventHandlers.cs
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Examples.HelloCLRBridge;
+using Org.Apache.Reef.Examples.HelloCLRBridge.handlers;
+using Org.Apache.Reef.Examples.HelloCLRBridge.Handlers;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class TestSimpleEventHandlers : ReefFunctionalTest
+    {
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            CleanUp();
+            Init();
+        }
+
+        [TestCleanup]
+        public void TestCleanup()
+        {
+            Console.WriteLine("Post test check and clean up");
+            CleanUp();
+        }
+
+        //[TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Test Hello Handler on local runtime")]
+        [DeploymentItem(@".")]
+        [Timeout(180 * 1000)]
+        public void RunSimpleEventHandlerOnLocalRuntime()
+        {
+            IsOnLocalRuntiime = true;
+            TestRun(AssembliesToCopy(), DriverConfiguration());
+            ValidateSuccessForLocalRuntime(2);
+            ValidateEvaluatorSetting();
+        }
+
+        public IConfiguration DriverConfiguration()
+        {
+            return DriverBridgeConfiguration.ConfigurationModule
+                .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<AnotherHelloAllocatedEvaluatorHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnContextActive, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskMessage, GenericType<HelloTaskMessageHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorFailed, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskCompleted, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskFailed, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnTaskRunning, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorRequested, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnHttpEvent, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.OnEvaluatorCompleted, GenericType<HelloSimpleEventHandlers>.Class)
+                .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class)
+                .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString())
+                .Set(DriverBridgeConfiguration.CommandLineArguments, "submitContextAndTask") 
+                .Set(DriverBridgeConfiguration.OnDriverRestarted, GenericType<HelloRestartHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnDriverReconnect, GenericType<DefaultLocalHttpDriverConnection>.Class)
+                .Set(DriverBridgeConfiguration.OnDirverRestartContextActive, GenericType<HelloDriverRestartActiveContextHandler>.Class)
+                .Set(DriverBridgeConfiguration.OnDriverRestartTaskRunning, GenericType<HelloDriverRestartRunningTaskHandler>.Class)
+                .Build();
+        }
+
+        public HashSet<string> AssembliesToCopy()
+        {
+            HashSet<string> appDlls = new HashSet<string>();
+            appDlls.Add(typeof(HelloSimpleEventHandlers).Assembly.GetName().Name);
+            appDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+            appDlls.Add(typeof(INameServer).Assembly.GetName().Name);
+            return appDlls;
+        }
+
+        private void ValidateEvaluatorSetting()
+        {
+            const string successIndication = "Evaluator is assigned with 512 MB of memory and 2 cores.";
+            string[] lines = File.ReadAllLines(GetLogFile(_stdout));
+            string[] successIndicators = lines.Where(s => s.Contains(successIndication)).ToArray();
+            Assert.IsTrue(successIndicators.Count() >= 1);
+        }
+    }
+}
\ No newline at end of file


[10/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Protobuf/WakeRemoteProtosGen.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Protobuf/WakeRemoteProtosGen.cs b/lang/cs/Source/WAKE/Wake/Protobuf/WakeRemoteProtosGen.cs
new file mode 100644
index 0000000..e4b3f2b
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Protobuf/WakeRemoteProtosGen.cs
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: src/main/proto/RemoteProtocol.proto
+namespace Org.Apache.Reef.Wake.Remote.Proto.WakeRemoteProtos
+{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"WakeMessagePBuf")]
+  public partial class WakeMessagePBuf : global::ProtoBuf.IExtensible
+  {
+    public WakeMessagePBuf() {}
+    
+    private byte[] _data;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"data", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public byte[] data
+    {
+      get { return _data; }
+      set { _data = value; }
+    }
+    private long _seq;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"seq", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
+    public long seq
+    {
+      get { return _seq; }
+      set { _seq = value; }
+    }
+    private string _source = "";
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"source", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string source
+    {
+      get { return _source; }
+      set { _source = value; }
+    }
+    private string _sink = "";
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"sink", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string sink
+    {
+      get { return _sink; }
+      set { _sink = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"WakeTuplePBuf")]
+  public partial class WakeTuplePBuf : global::ProtoBuf.IExtensible
+  {
+    public WakeTuplePBuf() {}
+    
+    private string _className;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"className", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string className
+    {
+      get { return _className; }
+      set { _className = value; }
+    }
+    private byte[] _data;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"data", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public byte[] data
+    {
+      get { return _data; }
+      set { _data = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/AbstractObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/AbstractObserver.cs b/lang/cs/Source/WAKE/Wake/RX/AbstractObserver.cs
new file mode 100644
index 0000000..b452a24
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/AbstractObserver.cs
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+
+namespace Org.Apache.Reef.Wake.RX
+{
+    /// <summary>
+    /// An observer with logging-only onError and onCompleted() methods.
+    /// </summary>
+    /// <typeparam name="T">The observer type</typeparam>
+    public abstract class AbstractObserver<T> : IObserver<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(AbstractObserver<T>));
+
+        public virtual void OnError(Exception error)
+        {
+            LOGGER.Log(Level.Info, "The observer " + GetType() + "has received an Exception: " + error);
+        }
+
+        public virtual void OnCompleted()
+        {
+            LOGGER.Log(Level.Verbose, "The observer " + GetType() + "has received an onCompleted() ");
+        }
+
+        public abstract void OnNext(T arg1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/AbstractRxStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/AbstractRxStage.cs b/lang/cs/Source/WAKE/Wake/RX/AbstractRxStage.cs
new file mode 100644
index 0000000..20c7431
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/AbstractRxStage.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.RX
+{
+    /// <summary>
+    /// An Rx stage that implements metering
+    /// </summary>
+    public abstract class AbstractRxStage<T> : IRxStage<T>
+    {
+        //protected internal readonly Meter meter;
+
+        /// <summary>Constructs an abstact rxstage</summary>
+        /// <param name="meterName">the name of the meter</param>
+        public AbstractRxStage(string meterName)
+        {
+            //meter = new Meter(meterName);
+        }
+
+        /// <summary>Updates the meter</summary>
+        /// <param name="value">the event</param>
+        public virtual void OnNext(T value)
+        {
+            //meter.Mark(1);
+        }
+
+        public abstract void OnCompleted();
+
+        public abstract void OnError(Exception error);
+
+        public virtual void Dispose()
+        {
+            // no op
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/IRxStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/IRxStage.cs b/lang/cs/Source/WAKE/Wake/RX/IRxStage.cs
new file mode 100644
index 0000000..e756328
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/IRxStage.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.RX
+{
+    /// <summary>Stage that executes the observer</summary>
+    public interface IRxStage<T> : IObserver<T>, IStage
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/IStaticObservable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/IStaticObservable.cs b/lang/cs/Source/WAKE/Wake/RX/IStaticObservable.cs
new file mode 100644
index 0000000..577db4d
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/IStaticObservable.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Org.Apache.Reef.Wake.RX
+{
+    public interface IStaticObservable
+    {
+        //intentionally empty
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/ISubject.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/ISubject.cs b/lang/cs/Source/WAKE/Wake/RX/ISubject.cs
new file mode 100644
index 0000000..3679470
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/ISubject.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.RX
+{
+    /// <summary>A class implementing Observer> and StaticObservable</summary>
+    /// <typeparam name="In">The in type</typeparam>
+    /// <typeparam name="Out">The out type</typeparam>
+    public interface ISubject<In, Out> : IObserver<In>, IStaticObservable
+    {
+        // intentionally empty
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/Impl/PubSubSubject.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/Impl/PubSubSubject.cs b/lang/cs/Source/WAKE/Wake/RX/Impl/PubSubSubject.cs
new file mode 100644
index 0000000..d513020
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/Impl/PubSubSubject.cs
@@ -0,0 +1,180 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Subjects;
+using System.Reflection;
+using System.Text;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Wake.RX.Impl
+{
+    /// <summary>
+    /// Subject to provide publish/subscribe interface.
+    /// Subscribes to class Types and invokes handlers for a given
+    /// type on call to OnNext
+    /// </summary>
+    /// <typeparam name="T">The super type that all event types
+    /// inherit from</typeparam>
+    public class PubSubSubject<T> : IObserver<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(PubSubSubject<T>));
+
+        private Dictionary<Type, List<object>> _classToObserversMap;
+        private bool _completed;
+        private object _mutex;
+
+        /// <summary>
+        /// Constructs a pub-sub Subject
+        /// </summary>
+        public PubSubSubject()
+        {
+            _classToObserversMap = new Dictionary<Type, List<object>>();
+            _mutex = new object();
+        }
+
+        /// <summary>
+        /// Log on completion
+        /// </summary>
+        public void OnCompleted()
+        {
+            lock (_mutex)
+            {
+                _completed = true;
+            }
+        }
+
+        /// <summary>
+        /// Log Exception
+        /// </summary>
+        /// <param name="error"></param>
+        public void OnError(Exception error)
+        {
+            lock (_mutex)
+            {
+                _completed = true;
+            }
+        }
+
+        /// <summary>
+        /// Invoke the subscribed handlers for the event class type
+        /// </summary>
+        /// <param name="value">The event to process</param>
+        public void OnNext(T value)
+        {
+            if (value == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("value"), LOGGER);
+            }
+
+            lock (_mutex)
+            {
+                // If OnCompleted or OnError called, do nothing
+                if (_completed)
+                {
+                    return;
+                }
+
+                // Check that the event type has been subscribed
+                List<object> handlers;
+                if (!_classToObserversMap.TryGetValue(value.GetType(), out handlers))
+                {
+                    Exceptions.Throw(new ArgumentException("No event for type " + value.GetType()), LOGGER);
+                }
+
+                // Invoke each IObserver for the event type
+                foreach (object handler in handlers)
+                {
+                    Type handlerType = typeof(IObserver<>).MakeGenericType(new[] { value.GetType() });
+                    MethodInfo info = handlerType.GetMethod("OnNext");
+                    info.Invoke(handler, new[] { (object) value });
+                }
+            }
+        }
+
+        /// <summary>
+        /// Subscribe an IObserver for an event type
+        /// </summary>
+        /// <typeparam name="U">The event type</typeparam>
+        /// <param name="observer">The observer to handle the event</param>
+        /// <returns>An IDisposable object used to handle unsubscribing
+        /// the IObserver</returns>
+        public IDisposable Subscribe<U>(IObserver<U> observer) where U : T
+        {
+            lock (_mutex)
+            {
+                List<object> observers;
+                if (!_classToObserversMap.TryGetValue(typeof(U), out observers))
+                {
+                    observers = new List<object>();
+                    _classToObserversMap[typeof(U)] = observers;
+                }
+                observers.Add(observer);
+            }
+
+            return new DisposableResource<U>(_classToObserversMap, observer, _mutex);
+        }
+
+        /// <summary>
+        /// Utility class to handle disposing of an IObserver
+        /// </summary>
+        private class DisposableResource<U> : IDisposable
+        {
+            private Dictionary<Type, List<object>> _observersMap;
+            private IObserver<U> _observer;
+            private object _mutex;
+            private bool _disposed;
+            
+            public DisposableResource(Dictionary<Type, List<object>> observersMap, IObserver<U> observer, object mutex)
+            {
+                _observersMap = observersMap;
+                _observer = observer;
+                _mutex = mutex;
+                _disposed = false;
+            }
+
+            /// <summary>
+            /// Unsubscribe the IObserver from the observer map
+            /// </summary>
+            public void Dispose()
+            {
+                if (!_disposed)
+                {
+                    UnsubscribeObserver();
+                    _disposed = true;
+                }
+            }
+
+            private void UnsubscribeObserver()
+            {
+                lock (_mutex)
+                {
+                    List<object> observers;
+                    if (_observersMap.TryGetValue(typeof(U), out observers))
+                    {
+                        observers.Remove(_observer);
+                    }
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/Impl/RxSyncStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/Impl/RxSyncStage.cs b/lang/cs/Source/WAKE/Wake/RX/Impl/RxSyncStage.cs
new file mode 100644
index 0000000..4803f89
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/Impl/RxSyncStage.cs
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+ 
+using System;
+
+namespace Org.Apache.Reef.Wake.RX.Impl
+{
+    /// <summary>Stage that executes the observer synchronously</summary>
+    public class RxSyncStage<T> : AbstractRxStage<T>
+    {
+        private readonly IObserver<T> _observer;
+
+        /// <summary>Constructs a Rx synchronous stage</summary>
+        /// <param name="observer">the observer</param>
+        public RxSyncStage(IObserver<T> observer) : base(observer.GetType().FullName)
+        {
+            _observer = observer;
+        }
+
+        /// <summary>Provides the observer with the new value</summary>
+        /// <param name="value">the new value</param>
+        public override void OnNext(T value)
+        {
+            base.OnNext(value);
+            _observer.OnNext(value);
+        }
+
+        /// <summary>
+        /// Notifies the observer that the provider has experienced an error
+        /// condition.
+        /// </summary>
+        /// <param name="error">the error</param>
+        public override void OnError(Exception error)
+        {
+            _observer.OnError(error);
+        }
+
+        /// <summary>
+        /// Notifies the observer that the provider has finished sending push-based
+        /// notifications.
+        /// </summary>
+        public override void OnCompleted()
+        {
+            _observer.OnCompleted();
+        }
+
+        /// <summary>
+        /// Closes the stage
+        /// </summary>
+        public override void Dispose()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/Impl/RxThreadPoolStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/Impl/RxThreadPoolStage.cs b/lang/cs/Source/WAKE/Wake/RX/Impl/RxThreadPoolStage.cs
new file mode 100644
index 0000000..4986055
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/Impl/RxThreadPoolStage.cs
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Util;
+using System;
+
+namespace Org.Apache.Reef.Wake.RX.Impl
+{
+    /// <summary>Stage that executes the observer with a thread pool</summary>
+    public class RxThreadPoolStage<T> : AbstractRxStage<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(RxThreadPoolStage<T>));
+
+        private readonly IObserver<T> _observer;
+
+        private readonly ITaskService _taskService;
+
+        /// <summary>Constructs a Rx thread pool stage</summary>
+        /// <param name="observer">the observer to execute</param>
+        /// <param name="numThreads">the number of threads</param>
+        public RxThreadPoolStage(IObserver<T> observer, int numThreads) 
+            : base(observer.GetType().FullName)
+        {
+            _observer = observer;
+            if (numThreads <= 0)
+            {
+                Exceptions.Throw(new WakeRuntimeException("numThreads " + numThreads + " is less than or equal to 0"), LOGGER);
+            }
+            _taskService = new FixedThreadPoolTaskService(numThreads);
+        }
+
+        /// <summary>Provides the observer with the new value</summary>
+        /// <param name="value">the new value</param>
+        public override void OnNext(T value)
+        {
+            base.OnNext(value);
+            _taskService.Execute(new _Startable_58(this, value).Start);
+        }
+
+        /// <summary>
+        /// Notifies the observer that the provider has experienced an error
+        /// condition.
+        /// </summary>
+        /// <param name="error">the error</param>
+        public override void OnError(Exception error)
+        {
+            _taskService.Execute(new _Startable_75(this, error).Start);
+        }
+
+        /// <summary>
+        /// Notifies the observer that the provider has finished sending push-based
+        /// notifications.
+        /// </summary>
+        public override void OnCompleted()
+        {
+            _taskService.Execute(new _Startable_91(this).Start);
+        }
+
+        /// <summary>
+        /// Closes the stage
+        /// </summary>
+        public override void Dispose()
+        {
+            _taskService.Shutdown();
+        }
+
+        private sealed class _Startable_58 : IStartable
+        {
+            private readonly RxThreadPoolStage<T> _enclosing;
+            private readonly T _value;
+
+            public _Startable_58(RxThreadPoolStage<T> enclosing, T value)
+            {
+                _enclosing = enclosing;
+                _value = value;
+            }
+
+            public void Start()
+            {
+                _enclosing._observer.OnNext(_value);
+            }
+        }
+
+        private sealed class _Startable_75 : IStartable
+        {
+            private readonly RxThreadPoolStage<T> _enclosing;
+            private readonly Exception _error;
+
+            public _Startable_75(RxThreadPoolStage<T> enclosing, Exception error)
+            {
+                _enclosing = enclosing;
+                _error = error;
+            }
+
+            public void Start()
+            {
+                _enclosing._observer.OnError(_error);
+            }
+        }
+
+        private sealed class _Startable_91 : IStartable
+        {
+            private readonly RxThreadPoolStage<T> _enclosing;
+
+            public _Startable_91(RxThreadPoolStage<T> enclosing)
+            {
+                _enclosing = enclosing;
+            }
+
+            public void Start()
+            {
+                _enclosing._observer.OnCompleted();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/Impl/RxTimerStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/Impl/RxTimerStage.cs b/lang/cs/Source/WAKE/Wake/RX/Impl/RxTimerStage.cs
new file mode 100644
index 0000000..44dd77c
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/Impl/RxTimerStage.cs
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Timers;
+
+using Org.Apache.Reef.Wake.Impl;
+
+namespace Org.Apache.Reef.Wake.RX.Impl
+{
+    /// <summary>Timer stage that provides events to the observer periodically</summary>
+    public class RxTimerStage : IStage, IStaticObservable
+    {
+        private readonly Timer _timer;
+        private readonly PeriodicEvent _value = new PeriodicEvent();
+        private readonly IObserver<PeriodicEvent> _observer;
+
+        /// <summary>Constructs a Rx timer stage</summary>
+        /// <param name="observer">the observer</param>
+        /// <param name="period">the period in milli-seconds</param>
+        public RxTimerStage(IObserver<PeriodicEvent> observer, long period) 
+            : this(observer, 0, period)
+        {
+        }
+
+        /// <summary>Constructs a Rx timer stage</summary>
+        /// <param name="observer">the observer</param>
+        /// <param name="initialDelay">the initial delay in milli-seconds</param>
+        /// <param name="period">the period in milli-seconds</param>
+        public RxTimerStage(IObserver<PeriodicEvent> observer, long initialDelay, long period)
+        {
+            _observer = observer;
+            _timer = new Timer(period);
+            _timer.Elapsed += (sender, e) => OnTimedEvent(sender, e, _observer, _value);
+            _timer.Enabled = true;
+        }
+
+        /// <summary>
+        /// Closes the stage
+        /// </summary>
+        public void Dispose()
+        {
+            _timer.Stop();
+        }
+
+        private static void OnTimedEvent(object source, ElapsedEventArgs e, IObserver<PeriodicEvent> observer, PeriodicEvent value)
+        {
+            observer.OnNext(value);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/Impl/SimpleSubject.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/Impl/SimpleSubject.cs b/lang/cs/Source/WAKE/Wake/RX/Impl/SimpleSubject.cs
new file mode 100644
index 0000000..418dc98
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/Impl/SimpleSubject.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+ 
+using System;
+
+namespace Org.Apache.Reef.Wake.RX.Impl
+{
+    /// <summary>A Subject that relays all messages to its subscribers.</summary>
+    public class SimpleSubject<T> : ISubject<T, T>
+    {
+        private readonly IObserver<T> _observer;
+
+        /// <summary>Constructs a simple subject</summary>
+        /// <param name="observer">the observer</param>
+        public SimpleSubject(IObserver<T> observer)
+        {
+            _observer = observer;
+        }
+
+        /// <summary>Provides the observer with the new value</summary>
+        /// <param name="value">the new value</param>
+        public virtual void OnNext(T value)
+        {
+            _observer.OnNext(value);
+        }
+
+        /// <summary>Provides the observer with the error</summary>
+        /// <param name="error">the error</param>
+        public virtual void OnError(Exception error)
+        {
+            _observer.OnError(error);
+        }
+
+        /// <summary>
+        /// Provides the observer with it has finished sending push-based
+        /// notifications.
+        /// </summary>
+        public virtual void OnCompleted()
+        {
+            _observer.OnCompleted();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/RX/ObserverCompletedException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/RX/ObserverCompletedException.cs b/lang/cs/Source/WAKE/Wake/RX/ObserverCompletedException.cs
new file mode 100644
index 0000000..b562055
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/RX/ObserverCompletedException.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake.RX
+{
+    /// <summary>
+    /// It is illegal to call onError() or onCompleted() when a call to onNext() is
+    /// still outstanding, or to call onNext(), onError() or onCompleted() after a
+    /// call to onError() or onCompleted() has been dispatched.
+    /// </summary>
+    /// <remarks>
+    /// It is illegal to call onError() or onCompleted() when a call to onNext() is
+    /// still outstanding, or to call onNext(), onError() or onCompleted() after a
+    /// call to onError() or onCompleted() has been dispatched. Observers may throw
+    /// an ObserverCompleted exception whenever this API is violated. Violating the
+    /// API leaves the Observer (and any resources that it holds) in an undefined
+    /// state, and throwing ObserverCompleted exceptions is optional.
+    /// Callers receiving this exception should simply pass it up the stack to the
+    /// Aura runtime. They should not attempt to forward it on to upstream or
+    /// downstream stages. The easiest way to do this is to ignore the exception
+    /// entirely.
+    /// </remarks>
+    [System.Serializable]
+    public class ObserverCompletedException : InvalidOperationException
+    {
+        private const long serialVersionUID = 1L;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/ICodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/ICodec.cs b/lang/cs/Source/WAKE/Wake/Remote/ICodec.cs
new file mode 100644
index 0000000..25f0bce
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/ICodec.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    public interface ICodec
+    {
+    }
+
+    /// <summary>
+    /// Interface for serialization routines that translate back and forth between
+    /// byte arrays with low latency.
+    /// </summary>
+    /// <typeparam name="T">The codec type</typeparam>
+    public interface ICodec<T> : ICodec, IEncoder<T>, IDecoder<T>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/ICodecFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/ICodecFactory.cs b/lang/cs/Source/WAKE/Wake/Remote/ICodecFactory.cs
new file mode 100644
index 0000000..6ba2805
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/ICodecFactory.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote
+{
+    [DefaultImplementation(typeof(ByteCodecFactory))]
+    public interface ICodecFactory
+    {
+        object Create(); 
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IDecoder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IDecoder.cs b/lang/cs/Source/WAKE/Wake/Remote/IDecoder.cs
new file mode 100644
index 0000000..ddc72c8
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IDecoder.cs
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    public interface IDecoder
+    {
+    }
+
+    /// <summary>
+    /// Interface for serialization routines that translate back and forth between
+    /// byte arrays with low latency.
+    /// </summary>
+    /// <typeparam name="T">The decoder type</typeparam>
+    public interface IDecoder<T> : IDecoder
+    {
+        /// <summary>Decodes the given byte array into an object</summary>
+        /// <param name="data"></param>
+        /// <returns>the decoded object</returns>
+        T Decode(byte[] data);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IEncoder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IEncoder.cs b/lang/cs/Source/WAKE/Wake/Remote/IEncoder.cs
new file mode 100644
index 0000000..b2a743f
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IEncoder.cs
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    public interface IEncoder
+    {
+    }
+
+    /// <summary>
+    /// Interface for serialization routines that translate back and forth between
+    /// byte arrays with low latency.
+    /// </summary>
+    /// <typeparam name="T">The encoder type</typeparam>
+    public interface IEncoder<T> : IEncoder
+    {
+        /// <summary>Encodes the given object into a Byte Array</summary>
+        /// <param name="obj"></param>
+        /// <returns>a byte[] representation of the object</returns>
+        byte[] Encode(T obj);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/ILink.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/ILink.cs b/lang/cs/Source/WAKE/Wake/Remote/ILink.cs
new file mode 100644
index 0000000..b25ef4f
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/ILink.cs
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Wake.Remote.Impl;
+
+namespace Org.Apache.Reef.Wake.Remote
+{
+    /// <summary>
+    /// Represents a link between two endpoints
+    /// </summary>
+    public interface ILink<T> : IDisposable
+    {
+        /// <summary>
+        /// Returns the local socket address
+        /// </summary>
+        IPEndPoint LocalEndpoint { get; }
+
+        /// <summary>
+        /// Returns the remote socket address
+        /// </summary>
+        IPEndPoint RemoteEndpoint { get; }
+
+        /// <summary>
+        /// Writes the value to this link asynchronously
+        /// </summary>
+        /// <param name="value">The data to write</param>
+        /// <param name="token">The cancellation token</param>
+        Task WriteAsync(T value, CancellationToken token);
+
+        /// <summary>
+        /// Writes the value to this link synchronously
+        /// </summary>
+        /// <param name="value">The data to write</param>
+        void Write(T value);
+
+        /// <summary>
+        /// Reads the value from this link asynchronously
+        /// </summary>
+        /// <returns>The read data</returns>
+        /// <param name="token">The cancellation token</param>
+        Task<T> ReadAsync(CancellationToken token);
+
+        /// <summary>
+        /// Reads the value from this link synchronously
+        /// </summary>
+        /// <returns>The read data</returns>
+        T Read();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IRemoteEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IRemoteEvent.cs b/lang/cs/Source/WAKE/Wake/Remote/IRemoteEvent.cs
new file mode 100644
index 0000000..d693401
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IRemoteEvent.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+
+namespace Org.Apache.Reef.Wake.Remote
+{
+    public interface IRemoteEvent<T>
+    {
+        IPEndPoint LocalEndPoint { get; set; }
+
+        IPEndPoint RemoteEndPoint { get; set; }
+
+        string Source { get; }
+
+        string Sink { get; }
+
+        T Value { get; }
+
+        long Sequence { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifier.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifier.cs b/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifier.cs
new file mode 100644
index 0000000..1101774
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifier.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    /// <summary>
+    /// An identifier that represents a remote source
+    /// </summary>
+    public abstract class IRemoteIdentifier : IIdentifier
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifierFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifierFactory.cs b/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifierFactory.cs
new file mode 100644
index 0000000..fdea1e4
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IRemoteIdentifierFactory.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    /// <summary>Factory that creates a RemoteIdentifier</summary>
+    public interface IRemoteIdentifierFactory : IIdentifierFactory
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IRemoteManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IRemoteManager.cs b/lang/cs/Source/WAKE/Wake/Remote/IRemoteManager.cs
new file mode 100644
index 0000000..a572b04
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IRemoteManager.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Net;
+using Org.Apache.Reef.Wake.Remote.Impl;
+
+namespace Org.Apache.Reef.Wake.Remote
+{
+    public interface IRemoteManager<T> : IStage
+    {
+        IRemoteIdentifier Identifier { get; }
+
+        IPEndPoint LocalEndpoint { get; }
+
+        IObserver<T> GetRemoteObserver(RemoteEventEndPoint<T> dest);
+
+        IObserver<T> GetRemoteObserver(IPEndPoint remoteEndpoint);
+
+        IDisposable RegisterObserver(RemoteEventEndPoint<T> source, IObserver<T> theObserver);
+
+        IDisposable RegisterObserver(IPEndPoint remoteEndpoint, IObserver<T> theObserver);
+
+        IDisposable RegisterObserver(IObserver<IRemoteMessage<T>> theObserver);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/IRemoteMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/IRemoteMessage.cs b/lang/cs/Source/WAKE/Wake/Remote/IRemoteMessage.cs
new file mode 100644
index 0000000..4b3d2a3
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/IRemoteMessage.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    /// <summary>
+    /// Message received from a remote handler
+    /// </summary>
+    public interface IRemoteMessage<T>
+    {
+        /// <summary>
+        /// Returns a remote identifier of the sender
+        /// </summary>
+        /// <returns>The remote identifier</returns>
+        IRemoteIdentifier Identifier { get; }
+
+        /// <summary>
+        /// Returns an actual message
+        /// </summary>
+        /// <returns>The remote message</returns>
+        T Message { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/ISubscriptionManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/ISubscriptionManager.cs b/lang/cs/Source/WAKE/Wake/Remote/ISubscriptionManager.cs
new file mode 100644
index 0000000..8d859e2
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/ISubscriptionManager.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote
+{
+    public interface ISubscriptionManager
+    {
+        void Unsubscribe(object token);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodec.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodec.cs
new file mode 100644
index 0000000..e596ab7
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodec.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class ByteCodec : ICodec<byte[]>
+    {
+        [Inject]
+        public ByteCodec()
+        {
+        }
+
+        public byte[] Encode(byte[] obj)
+        {
+            return obj;
+        }
+
+        public byte[] Decode(byte[] data)
+        {
+            return data;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodecFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodecFactory.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodecFactory.cs
new file mode 100644
index 0000000..333f341
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/ByteCodecFactory.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class ByteCodecFactory : ICodecFactory
+    {
+        [Inject]
+        public ByteCodecFactory()
+        {
+        }
+
+        public object Create()
+        {
+            return new ByteCodec();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/Channel.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/Channel.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/Channel.cs
new file mode 100644
index 0000000..184da8a
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/Channel.cs
@@ -0,0 +1,258 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Performs low level network IO operations between hosts
+    /// </summary>
+    public class Channel
+    {
+        private NetworkStream _stream;
+
+        /// <summary>
+        /// Constructs a new Channel with the the connected NetworkStream.
+        /// </summary>
+        /// <param name="stream">The connected stream</param>
+        public Channel(NetworkStream stream)
+        {
+            if (stream == null)
+            {
+                throw new ArgumentNullException("stream");
+            }
+
+            _stream = stream;
+        }
+
+        /// <summary>
+        /// Sends a message to the connected client synchronously
+        /// </summary>
+        /// <param name="message">The message to send</param>
+        public void Write(byte[] message)
+        {
+            if (message == null)
+            {
+                throw new ArgumentNullException("message");
+            }
+
+            byte[] messageBuffer = GenerateMessageBuffer(message);
+            _stream.Write(messageBuffer, 0, messageBuffer.Length);
+        }
+
+        /// <summary>
+        /// Sends a message to the connected client asynchronously
+        /// </summary>
+        /// <param name="message">The message to send</param>
+        /// <param name="token">The cancellation token</param>
+        /// <returns>The awaitable write task</returns>
+        public async Task WriteAsync(byte[] message, CancellationToken token)
+        {
+            byte[] messageBuffer = GenerateMessageBuffer(message);
+            await _stream.WriteAsync(messageBuffer, 0, messageBuffer.Length, token);
+        }
+
+        /// <summary>
+        /// Reads an incoming message as a byte array synchronously.
+        /// The message length is read as the first four bytes.
+        /// </summary>
+        /// <returns>The byte array message</returns>
+        public byte[] Read()
+        {
+            int payloadLength = ReadMessageLength();
+            if (payloadLength == 0)
+            {
+                return null;
+            }
+
+            return ReadBytes(payloadLength);
+        }
+
+        /// <summary>
+        /// Reads an incoming message as a byte array asynchronously.
+        /// The message length is read as the first four bytes.
+        /// </summary>
+        /// <param name="token">The cancellation token</param>
+        /// <returns>The byte array message</returns>
+        public async Task<byte[]> ReadAsync(CancellationToken token)
+        {
+            int payloadLength = await GetMessageLengthAsync(token);
+            if (payloadLength == 0)
+            {
+                return null;
+            }
+
+            return await ReadBytesAsync(payloadLength, token);
+        }
+
+        /// <summary>
+        /// Helper method to read the specified number of bytes from the network stream.
+        /// </summary>
+        /// <param name="bytesToRead">The number of bytes to read</param>
+        /// <returns>The byte[] read from the network stream with the requested 
+        /// number of bytes, otherwise null if the operation failed.
+        /// </returns>
+        private byte[] ReadBytes(int bytesToRead)
+        {
+            int totalBytesRead = 0;
+            byte[] buffer = new byte[bytesToRead];
+
+            while (totalBytesRead < bytesToRead)
+            {
+                int bytesRead = _stream.Read(buffer, totalBytesRead, bytesToRead - totalBytesRead);
+                if (bytesRead == 0)
+                {
+                    // Read timed out or connection was closed
+                    return null;
+                }
+
+                totalBytesRead += bytesRead;
+            }
+
+            return buffer;
+        }
+
+        /// <summary>
+        /// Helper method to read the specified number of bytes from the network stream.
+        /// </summary>
+        /// <param name="bytesToRead">The number of bytes to read</param>
+        /// <param name="token">The cancellation token</param>
+        /// <returns>The byte[] read from the network stream with the requested 
+        /// number of bytes, otherwise null if the operation failed.
+        /// </returns>
+        private async Task<byte[]> ReadBytesAsync(int bytesToRead, CancellationToken token)
+        {
+            int bytesRead = 0;
+            byte[] buffer = new byte[bytesToRead];
+
+            while (bytesRead < bytesToRead)
+            {
+                int amountRead = await _stream.ReadAsync(buffer, bytesRead, bytesToRead - bytesRead, token);
+                if (amountRead == 0)
+                {
+                    // Read timed out or connection was closed
+                    return null;
+                }
+
+                bytesRead += amountRead;
+            }
+
+            return buffer;
+        }
+
+        /// <summary>
+        /// Generates the payload buffer containing the message along
+        /// with a header indicating the message length.
+        /// </summary>
+        /// <param name="message">The message to send</param>
+        /// <returns>The payload buffer</returns>
+        private byte[] GenerateMessageBuffer(byte[] message)
+        {
+            byte[] lengthBuffer1 = BitConverter.GetBytes(message.Length + 4);
+            byte[] lengthBuffer2 = BitConverter.GetBytes(message.Length);
+            if (BitConverter.IsLittleEndian)
+            {
+                Array.Reverse(lengthBuffer1);
+            }
+
+            int len = lengthBuffer1.Length + lengthBuffer2.Length + message.Length;
+            byte[] messageBuffer = new byte[len];
+
+            int bytesCopied = 0;
+            bytesCopied += CopyBytes(lengthBuffer1, messageBuffer, 0);
+            bytesCopied += CopyBytes(lengthBuffer2, messageBuffer, bytesCopied);
+            CopyBytes(message, messageBuffer, bytesCopied);
+
+            return messageBuffer;
+        }
+
+        /// <summary>
+        /// Reads the first four bytes from the stream and decode
+        /// it to get the message length in bytes
+        /// </summary>
+        /// <returns>The incoming message's length in bytes</returns>
+        private int ReadMessageLength()
+        {
+            byte[] lenBytes = ReadBytes(sizeof(int));
+            if (lenBytes == null)
+            {
+                return 0;
+            }
+            if (BitConverter.IsLittleEndian)
+            {
+                Array.Reverse(lenBytes);
+            }
+            if (BitConverter.ToInt32(lenBytes, 0) == 0)
+            {
+                return 0;
+            }
+                
+            byte[] msgLength = ReadBytes(sizeof(int));
+            return (msgLength == null) ? 0 : BitConverter.ToInt32(msgLength, 0);
+        }
+
+        /// <summary>
+        /// Reads the first four bytes from the stream and decode
+        /// it to get the message length in bytes
+        /// </summary>
+        /// <param name="token">The cancellation token</param>
+        /// <returns>The incoming message's length in bytes</returns>
+        private async Task<int> GetMessageLengthAsync(CancellationToken token)
+        {
+            byte[] lenBytes = await ReadBytesAsync(sizeof(int), token);
+            if (lenBytes == null)
+            {
+                return 0;
+            }
+            if (BitConverter.IsLittleEndian)
+            {
+                Array.Reverse(lenBytes);
+            }
+            if (BitConverter.ToInt32(lenBytes, 0) == 0)
+            {
+                return 0;
+            }
+                
+            byte[] msgLength = ReadBytes(sizeof(int));
+            return (msgLength == null) ? 0 : BitConverter.ToInt32(msgLength, 0);
+        }
+
+        /// <summary>
+        /// Copies the entire source buffer into the destination buffer the specified
+        /// destination offset.
+        /// </summary>
+        /// <param name="source">The source buffer to be copied</param>
+        /// <param name="dest">The destination buffer to copy to</param>
+        /// <param name="destOffset">The offset at the destination buffer to begin
+        /// copying.</param>
+        /// <returns>The number of bytes copied</returns>
+        private int CopyBytes(byte[] source, byte[] dest, int destOffset)
+        {
+            Buffer.BlockCopy(source, 0, dest, destOffset, source.Length);
+            return source.Length;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteManager.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteManager.cs
new file mode 100644
index 0000000..2bba3c8
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteManager.cs
@@ -0,0 +1,338 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Util;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Reactive;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Manages incoming and outgoing messages between remote hosts.
+    /// </summary>
+    public class DefaultRemoteManager<T> : IRemoteManager<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultRemoteManager<T>));
+
+        private ObserverContainer<T> _observerContainer;
+        private TransportServer<IRemoteEvent<T>> _server; 
+        private Dictionary<IPEndPoint, ProxyObserver> _cachedClients;
+        private ICodec<IRemoteEvent<T>> _codec;
+
+        /// <summary>
+        /// Constructs a DefaultRemoteManager listening on the specified address and any
+        /// available port.
+        /// </summary>
+        /// <param name="localAddress">The address to listen on</param>
+        /// <param name="codec">The codec used for serializing messages</param>
+        public DefaultRemoteManager(IPAddress localAddress, ICodec<T> codec) : this(localAddress, 0, codec)
+        {
+        }
+
+        /// <summary>
+        /// Constructs a DefaultRemoteManager listening on the specified IPEndPoint.
+        /// </summary>
+        /// <param name="localEndpoint">The endpoint to listen on</param>
+        /// <param name="codec">The codec used for serializing messages</param>
+        public DefaultRemoteManager(IPEndPoint localEndpoint, ICodec<T> codec)
+        {
+            if (localEndpoint == null)
+            {
+                throw new ArgumentNullException("localEndpoint");
+            }
+            if (localEndpoint.Port < 0)
+            {
+                throw new ArgumentException("Listening port must be greater than or equal to zero");
+            }
+            if (codec == null)
+            {
+                throw new ArgumentNullException("codec");
+            }
+
+            _codec = new RemoteEventCodec<T>(codec);
+            _observerContainer = new ObserverContainer<T>();
+            _cachedClients = new Dictionary<IPEndPoint, ProxyObserver>();
+
+            // Begin to listen for incoming messages
+            _server = new TransportServer<IRemoteEvent<T>>(localEndpoint, _observerContainer, _codec);
+            _server.Run();
+
+            LocalEndpoint = _server.LocalEndpoint;
+            Identifier = new SocketRemoteIdentifier(LocalEndpoint);
+        }
+
+        /// <summary>
+        /// Constructs a DefaultRemoteManager listening on the specified address and any
+        /// available port.
+        /// </summary>
+        /// <param name="localAddress">The address to listen on</param>
+        /// <param name="port">The port to listen on</param>
+        /// <param name="codec">The codec used for serializing messages</param>
+        public DefaultRemoteManager(IPAddress localAddress, int port, ICodec<T> codec)
+        {
+            if (localAddress == null)
+            {
+                throw new ArgumentNullException("localAddress");
+            }
+            if (port < 0)
+            {
+                throw new ArgumentException("Listening port must be greater than or equal to zero");
+            }
+            if (codec == null)
+            {
+                throw new ArgumentNullException("codec");
+            }
+
+            _observerContainer = new ObserverContainer<T>();
+            _codec = new RemoteEventCodec<T>(codec);
+            _cachedClients = new Dictionary<IPEndPoint, ProxyObserver>();
+
+            IPEndPoint localEndpoint = new IPEndPoint(localAddress, port);
+
+            // Begin to listen for incoming messages
+            _server = new TransportServer<IRemoteEvent<T>>(localEndpoint, _observerContainer, _codec);
+            _server.Run();
+
+            LocalEndpoint = _server.LocalEndpoint;
+            Identifier = new SocketRemoteIdentifier(LocalEndpoint);
+        }
+
+        /// <summary>
+        /// Constructs a DefaultRemoteManager. Does not listen for incoming messages.
+        /// </summary>
+        /// <param name="codec">The codec used for serializing messages</param>
+        public DefaultRemoteManager(ICodec<T> codec)
+        {
+            using (LOGGER.LogFunction("DefaultRemoteManager::DefaultRemoteManager"))
+            {
+                if (codec == null)
+                {
+                    throw new ArgumentNullException("codec");
+                }
+
+                _observerContainer = new ObserverContainer<T>();
+                _codec = new RemoteEventCodec<T>(codec);
+                _cachedClients = new Dictionary<IPEndPoint, ProxyObserver>();
+
+                LocalEndpoint = new IPEndPoint(NetworkUtils.LocalIPAddress, 0);
+                Identifier = new SocketRemoteIdentifier(LocalEndpoint);
+            }
+        }
+
+        /// <summary>
+        /// Gets the RemoteIdentifier for the DefaultRemoteManager
+        /// </summary>
+        public IRemoteIdentifier Identifier { get; private set; }
+
+        /// <summary>
+        /// Gets the local IPEndPoint for the DefaultRemoteManager
+        /// </summary>
+        public IPEndPoint LocalEndpoint { get; private set; }
+
+        /// <summary>
+        /// Returns an IObserver used to send messages to the remote host at
+        /// the specified IPEndpoint.
+        /// </summary>
+        /// <param name="remoteEndpoint">The IPEndpoint of the remote host</param>
+        /// <returns>An IObserver used to send messages to the remote host</returns>
+        public IObserver<T> GetRemoteObserver(RemoteEventEndPoint<T> remoteEndpoint)
+        {
+            if (remoteEndpoint == null)
+            {
+                throw new ArgumentNullException("remoteEndpoint");
+            }
+
+            SocketRemoteIdentifier id = remoteEndpoint.Id as SocketRemoteIdentifier;
+            if (id == null)
+            {
+                throw new ArgumentException("ID not supported");
+            }
+
+            return GetRemoteObserver(id.Addr);
+        }
+
+        /// <summary>
+        /// Returns an IObserver used to send messages to the remote host at
+        /// the specified IPEndpoint.
+        /// </summary>
+        /// <param name="remoteEndpoint">The IPEndpoint of the remote host</param>
+        /// <returns>An IObserver used to send messages to the remote host</returns>
+        public IObserver<T> GetRemoteObserver(IPEndPoint remoteEndpoint)
+        {
+            if (remoteEndpoint == null)
+            {
+                throw new ArgumentNullException("remoteEndpoint");
+            }
+
+            ProxyObserver remoteObserver;
+            if (!_cachedClients.TryGetValue(remoteEndpoint, out remoteObserver))
+            {
+                TransportClient<IRemoteEvent<T>> client = 
+                    new TransportClient<IRemoteEvent<T>>(remoteEndpoint, _codec, _observerContainer);
+
+                remoteObserver = new ProxyObserver(client);
+                _cachedClients[remoteEndpoint] = remoteObserver;
+            }
+
+            return remoteObserver;
+        }
+
+        /// <summary>
+        /// Registers an IObserver used to handle incoming messages from the remote host
+        /// at the specified IPEndPoint.
+        /// The IDisposable that is returned can be used to unregister the IObserver.
+        /// </summary>
+        /// <param name="remoteEndpoint">The IPEndPoint of the remote host</param>
+        /// <param name="observer">The IObserver to handle incoming messages</param>
+        /// <returns>An IDisposable used to unregister the observer with</returns>
+        public IDisposable RegisterObserver(RemoteEventEndPoint<T> remoteEndpoint, IObserver<T> observer)
+        {
+            if (remoteEndpoint == null)
+            {
+                throw new ArgumentNullException("remoteEndpoint");
+            }
+
+            SocketRemoteIdentifier id = remoteEndpoint.Id as SocketRemoteIdentifier;
+            if (id == null)
+            {
+                throw new ArgumentException("ID not supported");
+            }
+
+            return RegisterObserver(id.Addr, observer);
+        }
+
+        /// <summary>
+        /// Registers an IObserver used to handle incoming messages from the remote host
+        /// at the specified IPEndPoint.
+        /// The IDisposable that is returned can be used to unregister the IObserver.
+        /// </summary>
+        /// <param name="remoteEndpoint">The IPEndPoint of the remote host</param>
+        /// <param name="observer">The IObserver to handle incoming messages</param>
+        /// <returns>An IDisposable used to unregister the observer with</returns>
+        public IDisposable RegisterObserver(IPEndPoint remoteEndpoint, IObserver<T> observer)
+        {
+            if (remoteEndpoint == null)
+            {
+                throw new ArgumentNullException("remoteEndpoint");
+            }
+            if (observer == null)
+            {
+                throw new ArgumentNullException("observer");
+            }
+
+            return _observerContainer.RegisterObserver(remoteEndpoint, observer);
+        }
+
+        /// <summary>
+        /// Registers an IObserver used to handle incoming messages from the remote host
+        /// at the specified IPEndPoint.
+        /// The IDisposable that is returned can be used to unregister the IObserver.
+        /// </summary>
+        /// <param name="observer">The IObserver to handle incoming messages</param>
+        /// <returns>An IDisposable used to unregister the observer with</returns>
+        public IDisposable RegisterObserver(IObserver<IRemoteMessage<T>> observer)
+        {
+            if (observer == null)
+            {
+                throw new ArgumentNullException("observer");
+            }
+
+            return _observerContainer.RegisterObserver(observer);
+        }
+
+        /// <summary>
+        /// Release all resources for the DefaultRemoteManager.
+        /// </summary>
+        public void Dispose()
+        {
+            foreach (ProxyObserver cachedClient in _cachedClients.Values)
+            {
+                cachedClient.Dispose();
+            }
+
+            if (_server != null)
+            {
+                _server.Dispose();
+            }
+        }
+
+        /// <summary>
+        /// Observer to send messages to connected remote host
+        /// </summary>
+        private class ProxyObserver : IObserver<T>, IDisposable
+        {
+            private TransportClient<IRemoteEvent<T>> _client;
+            private int _messageCount;
+
+            /// <summary>
+            /// Create new ProxyObserver
+            /// </summary>
+            /// <param name="client">The connected transport client used to send
+            /// messages to remote host</param>
+            public ProxyObserver(TransportClient<IRemoteEvent<T>> client)
+            {
+                _client = client;
+                _messageCount = 0;
+            }
+
+            /// <summary>
+            /// Send the message to the remote host
+            /// </summary>
+            /// <param name="message">The message to send</param>
+            public void OnNext(T message)
+            {
+                IRemoteEvent<T> remoteEvent = new RemoteEvent<T>(_client.Link.LocalEndpoint, _client.Link.RemoteEndpoint, message)
+                {
+                    Sink = "default",
+                    Sequence = _messageCount
+                };
+
+                _messageCount++;
+                _client.Send(remoteEvent);
+            }
+
+            /// <summary>
+            /// Close underlying transport client
+            /// </summary>
+            public void Dispose()
+            {
+                _client.Dispose();
+            }
+
+            public void OnError(Exception error)
+            {
+                throw new NotImplementedException();
+            }
+
+            public void OnCompleted()
+            {
+                throw new NotImplementedException();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteMessage.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteMessage.cs
new file mode 100644
index 0000000..5b24276
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/DefaultRemoteMessage.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Remote.Impl
+{
+    class DefaultRemoteMessage<T> : IRemoteMessage<T>
+    {
+        public DefaultRemoteMessage(IRemoteIdentifier id, T message)
+        {
+            Identifier = id;
+            Message = message;
+        }
+
+        public IRemoteIdentifier Identifier { get; private set; }
+
+        public T Message { get; private set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/IPEndpointComparer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/IPEndpointComparer.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/IPEndpointComparer.cs
new file mode 100644
index 0000000..8d4b47d
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/IPEndpointComparer.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    /// <summary>
+    /// Class to compare two IPEndPoint objects.
+    /// </summary>
+    internal class IPEndPointComparer : IEqualityComparer<IPEndPoint>
+    {
+        public bool Equals(IPEndPoint x, IPEndPoint y)
+        {
+            if (ReferenceEquals(x, y))
+            {
+                return true;
+            }
+            if (x == null || y == null)
+            {
+                return false;
+            }
+
+            // If either port is 0, don't check port
+            if (x.Port == 0 || y.Port == 0)
+            {
+                return x.Address.Equals(y.Address);
+            }
+
+            return x.Equals(y);
+        }
+
+        public int GetHashCode(IPEndPoint obj)
+        {
+            return obj.Address.GetHashCode();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Remote/Impl/IntCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Remote/Impl/IntCodec.cs b/lang/cs/Source/WAKE/Wake/Remote/Impl/IntCodec.cs
new file mode 100644
index 0000000..e413023
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Remote/Impl/IntCodec.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Wake.Remote.Impl
+{
+    public class IntCodec : ICodec<int>
+    {
+        [Inject]
+        public IntCodec()
+        {
+        }
+
+        public byte[] Encode(int obj)
+        {
+            return BitConverter.GetBytes(obj);
+        }
+
+        public int Decode(byte[] data)
+        {
+            return BitConverter.ToInt32(data, 0);
+        }
+    }
+}


[14/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectorImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectorImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectorImpl.cs
new file mode 100644
index 0000000..6144f3e
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectorImpl.cs
@@ -0,0 +1,1091 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class InjectorImpl : IInjector
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(InjectorImpl));
+
+        IDictionary<INamedParameterNode, object> namedParameterInstances = new MonotonicTreeMap<INamedParameterNode, object>();
+        private ICsClassHierarchy classHierarchy;
+        private IConfiguration configuration;
+        readonly IDictionary<IClassNode, Object> instances = new MonotonicTreeMap<IClassNode, Object>();
+        private Aspect aspect;
+        private readonly ISet<IInjectionFuture<object>> pendingFutures = new HashSet<IInjectionFuture<object>>();
+
+        static readonly InjectionPlan BUILDING = new BuildingInjectionPlan(null); //TODO anonymous class
+
+
+        private bool concurrentModificationGuard = false;
+
+        private void AssertNotConcurrent()
+        {
+            if (concurrentModificationGuard)
+            {
+                //TODO
+                //throw new ConcurrentModificationException("Detected attempt to use Injector from within an injected constructor!");
+            }
+        }
+        public InjectorImpl(IConfiguration c)
+        {
+            this.configuration = c;
+            this.classHierarchy = (ICsClassHierarchy)c.GetClassHierarchy();
+        }
+
+        public object InjectFromPlan(InjectionPlan plan)
+        {
+            if (!plan.IsFeasible())
+            {
+                var ex = new InjectionException("Cannot inject " + plan.GetNode().GetFullName() + ": "
+                    + plan.ToCantInjectString());
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            if (plan.IsAmbiguous())
+            {
+                var ex = new InjectionException("Cannot inject " + plan.GetNode().GetFullName() + " "
+                    + plan.ToCantInjectString());
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            if (plan is InjectionFuturePlan)
+            {
+                InjectionFuturePlan fut = (InjectionFuturePlan)plan;
+                INode node = fut.GetNode();
+                string key = node.GetFullName();
+                try
+                {
+                    Type t = null;
+                    Type nodeType = classHierarchy.ClassForName(node.GetFullName());
+                    
+                    if (node is IClassNode)
+                    {
+                        t = nodeType; 
+                    }
+                    else if (node is INamedParameterNode)
+                    {
+                        var nn = (INamedParameterNode)node;
+                        t = classHierarchy.ClassForName(nn.GetFullArgName());
+                        if (nn.IsSet())
+                        {
+                            t = typeof (ISet<>).MakeGenericType(new Type[] {t});
+                        }
+                    }
+                    else
+                    {
+                        var ex = new ApplicationException("Unexpected node type. Wanted ClassNode or NamedParameterNode.  Got: " + node);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                    
+                    //Java - InjectionFuture<?> ret = new InjectionFuture<>(this, javaNamespace.classForName(fut.getNode().getFullName()));
+                    //C# - InjectionFuture<object> ret = new InjectionFutureImpl<object>(this, classHierarchy.ClassForName(fut.GetNode().GetFullName()));
+                    //We cannot simply create an object from generic with object as <T>
+                    //typeof(InjectionFutureImpl<>).MakeGenericType(t) will get the InjectionFutureImpl generic Type with <T> as t 
+                    //for ClassNode, t is the Type of the class, for NamedParamterNode, t is the Type of the argument
+                    //we then use reflection to invoke the constructor
+                    //To retain generic argument information??                   
+                    Type injectionFuture = typeof (InjectionFutureImpl<>).MakeGenericType(t);
+                    var constructor = injectionFuture.GetConstructor(new Type[] { typeof(IInjector), typeof(Type) });
+                    IInjectionFuture<object> ret = (IInjectionFuture<object>)constructor.Invoke(new object[] { this, nodeType }); 
+
+                    pendingFutures.Add(ret);
+                    return ret;
+                }
+                catch (TypeLoadException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InjectionException("Could not get class for " + key), LOGGER); 
+                }
+            }
+            else if (plan.GetNode() is IClassNode && null != GetCachedInstance((IClassNode)plan.GetNode()))
+            {
+                return GetCachedInstance((IClassNode)plan.GetNode());
+            }
+            else if (plan is CsInstance)
+            {
+                // TODO: Must be named parameter node.  Check.
+                //      throw new IllegalStateException("Instance from plan not in Injector's set of instances?!?");
+                return ((CsInstance)plan).instance;
+            }
+            else if (plan is Constructor)
+            {
+                Constructor constructor = (Constructor)plan;
+                object[] args = new object[constructor.GetArgs().Length];
+                InjectionPlan[] argPlans = constructor.GetArgs();
+
+                for (int i = 0; i < argPlans.Length; i++)
+                {
+                    args[i] = InjectFromPlan(argPlans[i]);
+                }
+
+                try
+                {
+                    concurrentModificationGuard = true;
+                    object ret = null;
+                    try
+                    {
+                        IConstructorDef def = (IConstructorDef)constructor.GetConstructorDef();
+                        ConstructorInfo c = GetConstructor(def);
+
+                        if (aspect != null)
+                        {
+                            ret = aspect.Inject(def, c, args);
+                        }
+                        else
+                        {
+                            ret = c.Invoke(args);
+                        }
+                    }
+                    catch (ArgumentException e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                        StringBuilder sb = new StringBuilder("Internal Tang error?  Could not call constructor " + constructor.GetConstructorDef() + " with arguments [");
+                        foreach (Object o in args)
+                        {
+                            sb.Append("\n\t" + o);
+                        }
+                        sb.Append("]");
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(sb.ToString(), e), LOGGER); 
+                    }
+                    if (ret is IExternalConstructor<object>)
+                    {
+                        ret = ((IExternalConstructor<object>)ret).NewInstance();
+                    }
+                    instances.Add(constructor.GetNode(), ret);
+                    return ret;
+                }
+                catch (TargetInvocationException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InjectionException("Could not invoke constructor: " + plan, e), LOGGER);
+                }
+                finally
+                {
+                    concurrentModificationGuard = false; 
+                }
+            }
+            else if (plan is Subplan)
+            {
+                Subplan ambiguous = (Subplan)plan;
+                return InjectFromPlan(ambiguous.GetDelegatedPlan());
+            }
+            else if (plan is SetInjectionPlan)
+            {
+                SetInjectionPlan setPlan = (SetInjectionPlan)plan;
+                INode n = setPlan.GetNode();
+                string typeOfSet = null;
+
+                // TODO: This doesn't work for sets of generics (e.g., Set<Foo<int>>
+                // because GetFullName and GetFullArgName strip generic info).
+                if (n is INamedParameterNode)
+                {
+                    INamedParameterNode np = (INamedParameterNode)n;
+                    typeOfSet = np.GetFullArgName();
+                }
+                else if (n is IClassNode)
+                {
+                    typeOfSet = n.GetFullName();
+                }
+                else
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Unknown node type :" + n.ToString()), LOGGER);
+                }
+
+                Type t = classHierarchy.ClassForName(typeOfSet);
+                // MakeGenericType(t = int: MonotonicHashSet<> -> MonotonicHashSet<int>
+                // Get constructor: MonotonicHashSet<int> -> public MonotonicHashSet<int>() { ... }
+                // Invoke: public MonotonicHashSet<int> -> new MonotonicHashSet<int>()
+
+                object ret = typeof(MonotonicHashSet<>).MakeGenericType(t).GetConstructor(new Type[] { }).Invoke(new object[] { }); //(this, classHierarchy.ClassForName(fut.GetNode().GetFullName()));
+
+                MethodInfo mf = ret.GetType().GetMethod("Add");
+
+                foreach (InjectionPlan subplan in setPlan.GetEntryPlans())
+                {
+//                    ret.Add(InjectFromPlan(subplan));
+                    mf.Invoke(ret, new object[] {InjectFromPlan(subplan)});
+                }
+                return ret;
+            }
+            else if (plan is ListInjectionPlan)
+            {
+                ListInjectionPlan listPlan = (ListInjectionPlan)plan;
+                INode n = listPlan.GetNode();
+                string typeOfList = null;
+
+                if (n is INamedParameterNode)
+                {
+                    INamedParameterNode np = (INamedParameterNode)n;
+                    typeOfList = np.GetFullArgName();
+                }
+                else if (n is IClassNode)
+                {
+                    typeOfList = n.GetFullName();
+                }
+                else
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Unknown node type :" + n.ToString()), LOGGER);
+                }
+
+                Type t = classHierarchy.ClassForName(typeOfList);
+                object ret = typeof(List<>).MakeGenericType(t).GetConstructor(new Type[] { }).Invoke(new object[] { }); 
+
+                MethodInfo mf = ret.GetType().GetMethod("Add");
+
+                foreach (InjectionPlan subplan in listPlan.GetEntryPlans())
+                {
+                    mf.Invoke(ret, new object[] { InjectFromPlan(subplan) });
+                }
+                return ret;
+            }
+            else
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Unknown plan type: " + plan), LOGGER);
+            }
+            return null; // should never reach here
+        }
+
+        private object GetCachedInstance(IClassNode cn)
+        {
+            if (cn.GetFullName().Equals(ReflectionUtilities.GetAssemblyQualifiedName(typeof(IInjector))))
+                //if (cn.GetFullName().Equals(ReflectionUtilities.NonGenericFullName(typeof(IInjector))))
+            {
+                return this.ForkInjector();// TODO: We should be insisting on injection futures here! .forkInjector();
+            }
+            else
+            {
+                object t = null;
+
+                instances.TryGetValue(cn, out t);
+
+                if (t != null && t is IInjectionFuture<object>)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Found an injection future in getCachedInstance: " + cn), LOGGER);
+                }
+                return t;
+            }
+        }
+
+        private ConstructorInfo GetConstructor(IConstructorDef constructor)
+        {
+            Type clazz = (Type)this.classHierarchy.ClassForName(constructor.GetClassName());
+            IConstructorArg[] args = constructor.GetArgs().ToArray();
+            Type[] parameterTypes = new Type[args.Length];
+            for (int i = 0; i < args.Length; i++)
+            {
+                if (args[i].IsInjectionFuture())
+                {
+                    parameterTypes[i] = typeof(IInjectionFuture<>).MakeGenericType(new Type[] { this.classHierarchy.ClassForName(args[i].Gettype()) });
+                }
+                else
+                {
+                    parameterTypes[i] = this.classHierarchy.ClassForName(args[i].Gettype());
+                }
+            }
+
+            ConstructorInfo cons = clazz.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, parameterTypes, null);
+            //TODO
+            //cons.setAccessible(true);
+
+            if (cons == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Failed to look up constructor: " + constructor.ToString()), LOGGER);
+            }
+            return cons;
+        }
+
+        private void BuildInjectionPlan(INode n, IDictionary<INode, InjectionPlan> memo)
+        {
+            if (memo.ContainsKey(n))
+            {
+                InjectionPlan p = null;
+                memo.TryGetValue(n, out p);
+                if (BUILDING == p)
+                {
+                    StringBuilder loopyList = new StringBuilder("[");
+                    foreach (INode node in memo.Keys)
+                    {
+                        InjectionPlan p1 = null;
+                        memo.TryGetValue(node, out p1);
+                        if (p1 == BUILDING)
+                        {
+                            loopyList.Append(" " + node.GetFullName());
+                        }
+                    }
+                    loopyList.Append(" ]");
+                    var ex = new ClassHierarchyException("Detected loopy constructor involving "
+                        + loopyList.ToString());
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                else
+                {
+                    return;
+                }
+            }
+            memo.Add(n, BUILDING);
+            InjectionPlan ip = null;
+            if (n is INamedParameterNode)
+            {
+                INamedParameterNode np = (INamedParameterNode)n;
+                object boundInstance = ParseBoundNamedParameter(np);
+                object defaultInstance = this.classHierarchy.ParseDefaultValue(np);
+                object instance = boundInstance != null ? boundInstance : defaultInstance;
+
+                if (instance is INode)
+                {
+                    BuildInjectionPlan((INode)instance, memo);
+                    InjectionPlan sp;
+                    memo.TryGetValue((INode)instance, out sp);
+                    ip = new Subplan(n, 0, new InjectionPlan[] { sp });
+                }
+                else if (instance is ISet<object>)
+                {
+                    ISet<object> entries = (ISet<object>)instance;
+                    ip = CreateSetInjectionPlan(n, memo, entries);
+                }
+                else if (instance is ISet<INode>)
+                {
+                    ISet<INode> entries = (ISet<INode>)instance;
+                    ip = CreateSetInjectionPlan(n, memo, entries);
+                }
+                else if (instance is IList<object>)
+                {
+                    IList<object> entries = (IList<object>)instance;
+                    ip = CreateListInjectionPlan(n, memo, entries);
+                }
+                else if (instance is IList<INode>)
+                {
+                    IList<INode> entries = (IList<INode>)instance;
+                    ip = CreateListInjectionPlan(n, memo, entries);
+                }
+                else
+                {
+                    ip = new CsInstance(np, instance);
+                }
+
+            }
+            else if (n is IClassNode)
+            {
+                IClassNode cn = (IClassNode)n;
+
+                // Any (or all) of the next four values might be null; that's fine.
+                object cached = GetCachedInstance(cn);
+                IClassNode boundImpl = this.configuration.GetBoundImplementation(cn);
+                IClassNode defaultImpl = ParseDefaultImplementation(cn);
+                IClassNode ec = this.configuration.GetBoundConstructor(cn);
+
+                ip = BuildClassNodeInjectionPlan(cn, cached, ec, boundImpl, defaultImpl, memo);
+            }
+            else if (n is IPackageNode)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException(
+                    "Request to instantiate Java package as object"), LOGGER);
+            }
+            else
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(
+                    "Type hierarchy contained unknown node type!:" + n), LOGGER);
+            }
+            memo[n] = ip;
+        }
+
+        private InjectionPlan CreateSetInjectionPlan<T>(INode n, IDictionary<INode, InjectionPlan> memo, ISet<T> entries)
+        {
+            ISet<InjectionPlan> plans = new MonotonicHashSet<InjectionPlan>();
+            CreateInjectionPlanForCollectionElements(n, memo, entries, plans);
+            return  new SetInjectionPlan(n, plans);
+        }
+
+        private void CreateInjectionPlanForCollectionElements<T>(INode n, IDictionary<INode, InjectionPlan> memo, ICollection<T> entries, ICollection<InjectionPlan> plans)
+        {
+            foreach (var entry in entries)
+            {
+                if (entry is IClassNode)
+                {
+                    BuildInjectionPlan((IClassNode) entry, memo);
+                    InjectionPlan p2 = null;
+                    memo.TryGetValue((INode) entry, out p2);
+                    if (p2 != null)
+                    {
+                        plans.Add(p2);
+                    }
+                }
+                else
+                {
+                    plans.Add(new CsInstance(n, entry));
+                }
+            }
+        }
+
+        private InjectionPlan CreateListInjectionPlan<T>(INode n, IDictionary<INode, InjectionPlan> memo, IList<T> entries)
+        {
+            IList<InjectionPlan> plans = new List<InjectionPlan>();
+            CreateInjectionPlanForCollectionElements(n, memo, entries, plans);
+            return new ListInjectionPlan(n, plans);
+        }
+
+        private InjectionPlan BuildClassNodeInjectionPlan(IClassNode cn,
+            object cachedInstance,
+            IClassNode externalConstructor,
+            IClassNode boundImpl,
+            IClassNode defaultImpl,
+            IDictionary<INode, InjectionPlan> memo)
+        {
+            if (cachedInstance != null)
+            {
+                return new CsInstance(cn, cachedInstance);
+            }
+            else if (externalConstructor != null)
+            {
+                BuildInjectionPlan(externalConstructor, memo);
+                InjectionPlan ip = null;
+                memo.TryGetValue(externalConstructor, out ip);
+                return new Subplan(cn, 0, new InjectionPlan[] { ip });
+            }
+            else if (boundImpl != null && !cn.Equals(boundImpl))
+            {
+                // We need to delegate to boundImpl, so recurse.
+                BuildInjectionPlan(boundImpl, memo);
+                InjectionPlan ip = null;
+                memo.TryGetValue(boundImpl, out ip);
+                return new Subplan(cn, 0, new InjectionPlan[] { ip });
+            }
+            else if (defaultImpl != null && !cn.Equals(defaultImpl))
+            {
+                BuildInjectionPlan(defaultImpl, memo);
+                InjectionPlan ip = null;
+                memo.TryGetValue(defaultImpl, out ip);
+                return new Subplan(cn, 0, new InjectionPlan[] { ip });
+            }
+            else
+            {
+                // if we're here and there is a bound impl or a default impl,
+                // then we're bound / defaulted to ourselves, so don't add
+                // other impls to the list of things to consider.
+                List<IClassNode> candidateImplementations = new List<IClassNode>();
+                candidateImplementations.Add(cn);
+                List<InjectionPlan> sub_ips = FilterCandidateConstructors(candidateImplementations, memo);
+                if (sub_ips.Count == 1)
+                {
+                    return WrapInjectionPlans(cn, sub_ips, false, -1);
+                }
+               return WrapInjectionPlans(cn, sub_ips, true, -1);
+            }
+        }
+
+        private List<InjectionPlan> FilterCandidateConstructors(
+                List<IClassNode> candidateImplementations,
+                IDictionary<INode, InjectionPlan> memo)
+        {
+            List<InjectionPlan> sub_ips = new List<InjectionPlan>();
+
+            #region each implementation
+            foreach (IClassNode thisCN in candidateImplementations)
+            {
+                List<InjectionPlan> constructors = new List<InjectionPlan>();
+                List<IConstructorDef> constructorList = new List<IConstructorDef>();
+                if (null != this.configuration.GetLegacyConstructor(thisCN))
+                {
+                    constructorList.Add(this.configuration.GetLegacyConstructor(thisCN));
+                }
+
+                foreach (var c in thisCN.GetInjectableConstructors())
+                {
+                    constructorList.Add(c);
+                }
+
+                #region each constructor
+                foreach (IConstructorDef def in constructorList)
+                {
+                    List<InjectionPlan> args = new List<InjectionPlan>();
+                    IConstructorArg[] defArgs = def.GetArgs().ToArray<IConstructorArg>();
+
+                    #region each argument
+                    foreach (IConstructorArg arg in defArgs)
+                    {
+                        if (!arg.IsInjectionFuture())
+                        {
+                            try
+                            {
+                                INode argNode = this.classHierarchy.GetNode(arg.GetName());
+                                BuildInjectionPlan(argNode, memo);
+                                InjectionPlan ip = null;
+                                memo.TryGetValue(argNode, out ip);
+                                args.Add(ip);
+                            }
+                            catch (NameResolutionException e)
+                            {
+                                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+
+                                var ex = new IllegalStateException("Detected unresolvable "
+                                + "constructor arg while building injection plan.  "
+                                + "This should have been caught earlier!", e);
+                                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                            }
+                        }
+                        else
+                        {
+                            try
+                            {
+                                args.Add(new InjectionFuturePlan(this.classHierarchy.GetNode(arg.GetName())));
+                            }
+                            catch (NameResolutionException e)
+                            {
+                                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                                var ex = new IllegalStateException("Detected unresolvable "
+                                + "constructor arg while building injection plan.  "
+                                + "This should have been caught earlier!", e);
+                                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                            }
+                        }
+                    }
+                    #endregion each argument
+
+                    Constructor constructor = new Constructor(thisCN, def, args.ToArray());
+                    constructors.Add(constructor);
+                }
+                #endregion each constructor
+
+                // The constructors are embedded in a lattice defined by
+                // isMoreSpecificThan().  We want to see if, amongst the injectable
+                // plans, there is a unique dominant plan, and select it.
+                // First, compute the set of injectable plans.
+                List<Int32> liveIndices = new List<Int32>();
+                for (int i = 0; i < constructors.Count; i++)
+                {
+                    if (constructors[i].GetNumAlternatives() > 0)
+                    {
+                        liveIndices.Add(i);
+                    }
+                }
+                // Now, do an all-by-all comparison, removing indices that are dominated
+                // by others.
+                int k = -1;
+                for (int i = 0; i < liveIndices.Count; i++)
+                {
+                    for (int j = i + 1; j < liveIndices.Count; j++)
+                    {
+                        IConstructorDef ci = ((Constructor)constructors[(liveIndices[i])]).GetConstructorDef();
+                        IConstructorDef cj = ((Constructor)constructors[(liveIndices[j])]).GetConstructorDef();
+
+                        if (ci.IsMoreSpecificThan(cj)) //ci's arguments is a superset of cj's
+                        {
+                            k = i;
+                        }
+                        else if (cj.IsMoreSpecificThan(ci))
+                        {
+                            k = j;
+                        }
+                    }
+                }
+                if (liveIndices.Count == 1)
+                {
+                    k = 0;
+                }
+                if (constructors.Count > 0)
+                {
+                    sub_ips.Add(WrapInjectionPlans(thisCN, constructors, false, k != -1 ? liveIndices[k] : -1));
+                }
+            }
+            #endregion each implementation
+            return sub_ips;
+        }
+
+
+        private InjectionPlan WrapInjectionPlans(IClassNode infeasibleNode,
+            List<InjectionPlan> list, bool forceAmbiguous, int selectedIndex)
+        {
+            if (list.Count == 0)
+            {
+                return new Subplan(infeasibleNode, new InjectionPlan[] { });
+            }
+            else if ((!forceAmbiguous) && list.Count == 1)
+            {
+                return list[0];
+            }
+            else
+            {
+                return new Subplan(infeasibleNode, selectedIndex, list.ToArray());
+            }
+        }
+
+        private IClassNode ParseDefaultImplementation(IClassNode cn)
+        {
+            if (cn.GetDefaultImplementation() != null)
+            {
+                try
+                {
+                    return (IClassNode)this.classHierarchy.GetNode(cn.GetDefaultImplementation());
+                }
+                catch (NameResolutionException e)
+                {
+                    var ex = new IllegalStateException("After validation, " + cn + " had a bad default implementation named " + cn.GetDefaultImplementation(), e);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, LOGGER);
+                }
+            }
+            return null;
+        }
+
+        private object ParseBoundNamedParameter(INamedParameterNode np)
+        {
+            ISet<object> boundSet = this.configuration.GetBoundSet((INamedParameterNode)np);
+            if (boundSet.Count != 0)
+            {
+                ISet<INode> ret3 = new MonotonicSet<INode>();
+                ISet<object> ret2 = new MonotonicSet<object>();
+                return ParseElementsInCollection(np, boundSet, ret3, ret2);
+            }
+
+            IList<object> boundList = this.configuration.GetBoundList((INamedParameterNode)np);
+            if (boundList != null && boundList.Count != 0)
+            {
+                IList<INode> ret3 = new List<INode>();
+                IList<object> ret2 = new List<object>();
+                return ParseElementsInCollection(np, boundList, ret3, ret2);
+            }
+
+            object ret = null;
+            if (namedParameterInstances.ContainsKey(np))
+            {
+                namedParameterInstances.TryGetValue(np, out ret);
+            }
+            else
+            {
+                string value = this.configuration.GetNamedParameter(np);
+                if (value == null)
+                {
+                    ret = null;
+                }
+                else
+                {
+                    try
+                    {
+                        ret = this.classHierarchy.Parse(np, value);
+                        namedParameterInstances.Add(np, ret);
+                    }
+                    catch (BindException e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(new IllegalStateException(
+                            "Could not parse pre-validated value", e), Level.Error, LOGGER); 
+                    }
+                }
+            }
+            return ret;
+        }
+
+        private object ParseElementsInCollection(INamedParameterNode np, ICollection<object> boundSet, ICollection<INode> ret3, ICollection<object> ret2)
+        {
+            foreach (object o in boundSet)
+            {
+                if (o is string)
+                {
+                    try
+                    {
+                        var r = this.classHierarchy.Parse(np, (string) o);
+                        if (r is INode)
+                        {
+                            ret3.Add((INode) r);
+                        }
+                        else
+                        {
+                            ret2.Add(r);
+                        }
+                    }
+                    catch (ParseException e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                        var ex =
+                            new IllegalStateException("Could not parse " + o + " which was passed into " + np +
+                                                      " FIXME: Parsability is not currently checked by bindSetEntry(Node,String)");
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                }
+                else if (o is INode)
+                {
+                    var o2 = o as INode;
+                    ret3.Add(o2);
+                }
+                else
+                {
+                    var ex =
+                        new IllegalStateException("Unexpected object " + o +
+                                                  " in bound set.  Should consist of nodes and strings");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+            }
+            if (ret2.Count > 0 && ret3.Count == 0)
+            {
+                return ret2;
+            }
+            if (ret3.Count > 0 && ret2.Count == 0)
+            {
+                return ret3;
+            }
+            if (ret2.Count > 0 && ret3.Count > 0)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Set contains different types of object"), LOGGER);
+            }
+            return ret2;
+        }
+
+        public object GetInstance(Type iface)
+        {
+            return GetInstance(ReflectionUtilities.GetAssemblyQualifiedName(iface));
+        }
+
+        public T GetInstance<T>() where T : class
+        {
+            return (T)GetInstance(ReflectionUtilities.GetAssemblyQualifiedName(typeof(T)));
+        }
+
+        private void CheckNamedParameter(Type t)
+        {
+            if (ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof (Name<>), t))
+            {
+                var ex = new InjectionException("GetInstance() called on Name "
+                                             + ReflectionUtilities.GetName(t)
+                                             + " Did you mean to call GetNamedInstance() instead?");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+        }
+
+        private object GetInstance(INode node)
+        {
+            InjectionPlan plan = (InjectionPlan)GetInjectionPlan(node);
+            object u = InjectFromPlan(plan);
+
+            while (pendingFutures.Count != 0)
+            {
+                IEnumerator<object> i = pendingFutures.GetEnumerator();
+                i.MoveNext();
+                IInjectionFuture<object> f = (IInjectionFuture<object>)i.Current;
+                pendingFutures.Remove(f);
+                f.Get();
+            }
+            return u;
+        }
+
+        public object GetInstance(string clazz)
+        {
+            CheckNamedParameter(ReflectionUtilities.GetTypeByName(clazz));
+            return GetInstance(classHierarchy.GetNode(clazz));
+        }
+
+        public U GetNamedInstance<T, U>(GenericType<T> clazz) where T : Name<U>
+        {
+            Type t = typeof(T);
+            return (U)GetInstance(classHierarchy.GetNode(t));
+        }
+
+        public U GetNamedInstance<T, U>() where T : Name<U>
+        {
+            Type t = typeof(T);
+            return (U)GetInstance(classHierarchy.GetNode(t));
+        }
+
+        public object GetNamedInstance(Type t)
+        {
+            if (!ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof (Name<>), t))
+            {
+                var ex = new ApplicationException(string.Format(CultureInfo.CurrentCulture, "The parameter {0} is not inherit from Name<>", t));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            return GetInstance(classHierarchy.GetNode(t));
+        }
+
+        public InjectionPlan GetInjectionPlan(Type name)
+        {
+            return GetInjectionPlan(this.classHierarchy.GetNode(name));
+        }
+
+        public InjectionPlan GetInjectionPlan(INode n)
+        {
+            AssertNotConcurrent();
+            IDictionary<INode, InjectionPlan> memo = new Dictionary<INode, InjectionPlan>();
+            BuildInjectionPlan(n, memo);
+
+            InjectionPlan p = null;
+            memo.TryGetValue(n, out p);
+
+            if (p != null)
+            {
+                return p;
+            }
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InjectionException("Fail to get injection plan" + n), LOGGER);
+            return null;//this line shouild be not reached as Throw throws exception
+        }
+
+        public bool IsInjectable(string name)
+        {
+            return GetInjectionPlan(this.classHierarchy.GetNode(name)).IsInjectable();
+        }
+
+        public bool IsParameterSet(string name)
+        {
+            InjectionPlan p = GetInjectionPlan(classHierarchy.GetNode(name));
+            return p.IsInjectable();
+        }
+
+        public bool IsInjectable(Type clazz)
+        {
+            AssertNotConcurrent();
+            try
+            {
+                return IsInjectable(ReflectionUtilities.GetAssemblyQualifiedName(clazz));
+            }
+            catch (NameResolutionException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Could not round trip " + clazz + " through ClassHierarchy", e), LOGGER);
+                return false;
+            }
+        }
+
+        public bool IsParameterSet(Type name)
+        {
+            return IsParameterSet(ReflectionUtilities.GetAssemblyQualifiedName(name));
+        }
+
+        public void BindAspect(Aspect a)
+        {
+            if (aspect != null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new BindException("Attempt to re-bind aspect! old=" + aspect + " new=" + a), LOGGER);
+            }
+            aspect = a;
+        }
+
+        public Aspect GetAspect()
+        {
+            return aspect;
+        }
+
+        public IInjector ForkInjector()
+        {
+            try
+            {
+                return ForkInjector(new ConfigurationImpl[0]);
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Error in forking injector.", e), LOGGER);
+                return null; 
+            }
+        }
+
+        public IInjector ForkInjector(IConfiguration[] configurations)
+        {
+            InjectorImpl ret;
+            ret = Copy(this, configurations);
+            return ret;
+        }
+
+        private static InjectorImpl Copy(InjectorImpl old, IConfiguration[] configurations)
+        {
+            InjectorImpl injector = null;
+            try
+            {
+                IConfigurationBuilder cb = old.configuration.newBuilder();
+                foreach (IConfiguration c in configurations)
+                {
+                    cb.AddConfiguration(c);
+                }
+                injector = new InjectorImpl(cb.Build());
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Unexpected error copying configuration!", e), LOGGER);
+            }
+
+            foreach (IClassNode cn in old.instances.Keys)
+            {
+                if (cn.GetFullName().Equals(ReflectionUtilities.GetAssemblyQualifiedName(typeof(IInjector)))
+                || cn.GetFullName().Equals(ReflectionUtilities.GetAssemblyQualifiedName(typeof(InjectorImpl))))
+                {
+                    // This would imply that we're treating injector as a singleton somewhere.  It should be copied fresh each time.
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(""), LOGGER);
+                }
+                try
+                {
+                    IClassNode new_cn = (IClassNode)injector.classHierarchy.GetNode(cn.GetFullName());
+
+                    object o = null;
+                    old.instances.TryGetValue(cn, out o);
+                    if (o != null)
+                    {
+                        injector.instances.Add(new_cn, o);
+                    }
+                }
+                catch (BindException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Could not resolve name "
+                        + cn.GetFullName() + " when copying injector", e), LOGGER);
+                }
+            }
+
+            foreach (INamedParameterNode np in old.namedParameterInstances.Keys)
+            {
+                // if (!builder.namedParameters.containsKey(np)) {
+                Object o = null;
+                old.namedParameterInstances.TryGetValue(np, out o);
+                INamedParameterNode new_np = (INamedParameterNode)injector.classHierarchy.GetNode(np.GetFullName());
+                injector.namedParameterInstances.Add(new_np, o);
+            }
+
+            // Fork the aspect (if any)
+            if (old.aspect != null)
+            {
+                injector.BindAspect(old.aspect.CreateChildAspect());
+            }
+            return injector;
+        }
+
+        void BindVolatileInstanceNoCopy<T>(GenericType<T> c, T o) 
+        {
+            AssertNotConcurrent();
+            INode n = this.classHierarchy.GetNode(typeof(T));
+            if (n is IClassNode) 
+            {
+                IClassNode cn = (IClassNode) n;
+                object old = GetCachedInstance(cn);
+                if (old != null) {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new BindException("Attempt to re-bind instance.  Old value was "
+                    + old + " new value is " + o), LOGGER);
+                }
+                instances.Add(cn, o);
+            } else {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Expected Class but got " + c
+                    + " (probably a named parameter)."), LOGGER);
+            }
+        }
+
+        //void BindVolatileParameterNoCopy(Class<? extends Name<T>> c, T o)
+        void BindVolatileParameterNoCopy<U, T>(GenericType<U> c, T o)
+            where U : Name<T>
+        {
+            INode n = this.classHierarchy.GetNode(typeof(U));
+            if (n is INamedParameterNode) 
+            {
+                INamedParameterNode np = (INamedParameterNode) n;
+                Object old = this.configuration.GetNamedParameter(np);
+                if(old != null) 
+                {
+                    // XXX need to get the binding site here!
+                    var ex = new BindException(
+                        "Attempt to re-bind named parameter " + ReflectionUtilities.GetAssemblyQualifiedName(typeof(U)) + ".  Old value was [" + old
+                            + "] new value is [" + o + "]");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                try 
+                {
+                    namedParameterInstances.Add(np, o);
+                } 
+                catch (ArgumentException e) 
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); 
+                    var ex = new BindException(
+                    "Attempt to re-bind named parameter " + ReflectionUtilities.GetAssemblyQualifiedName(typeof(U)) + ".  Old value was [" + old
+                    + "] new value is [" + o + "]");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+            } 
+            else 
+            {
+                var ex = new ArgumentException("Expected Name, got " + typeof(U) + " (probably a class)");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+        }
+
+        //public <T> void bindVolatileInstance(Class<T> c, T o) throws BindException {
+        public void BindVolatileInstance<T>(GenericType<T> iface, T inst)
+        {
+            BindVolatileInstanceNoCopy(iface, inst);
+        }
+
+        /// <summary>
+        /// Binds the volatile instance.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="inst">The inst.</param>
+        public void BindVolatileInstance<T>(T inst)
+        {
+            BindVolatileInstance<T>(GenericType<T>.Class, inst);
+        }
+
+        /// <summary>
+        /// Binds the volatile parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="inst">The inst.</param>
+        public void BindVolatileParameter<U, T>(GenericType<U> iface, T inst) where U : Name<T>
+        {
+            BindVolatileParameterNoCopy(iface, inst);
+        }
+
+        /// <summary>
+        /// Binds the volatile parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="inst">The inst.</param>
+        public void BindVolatileParameter<U, T>(T inst) where U : Name<T>
+        {
+            BindVolatileParameter(GenericType<U>.Class, inst);
+        }
+
+        //public T GetNamedParameter<U, T>(GenericType<U> name) where U : Name<T>
+        //{
+        //    return (T)GetNamedInstance(typeof(U));
+        //}
+
+        //public IInjector CreateChildInjector(IConfiguration[] configurations)
+        //{
+        //    return ForkInjector(configurations);
+        //}
+        /// <summary>
+        /// Gets the injection plan for a given class name
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        public InjectionPlan GetInjectionPlan(string name)
+        {
+            return GetInjectionPlan(this.classHierarchy.GetNode(name));
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/ListInjectionPlan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/ListInjectionPlan.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/ListInjectionPlan.cs
new file mode 100644
index 0000000..8a5ad49
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/ListInjectionPlan.cs
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using System.Text;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class ListInjectionPlan : InjectionPlan
+    {
+       private readonly IList<InjectionPlan> entries = new List<InjectionPlan>();
+       private readonly int numAlternatives;
+       private readonly bool isAmbiguous;
+       private readonly bool isInjectable;
+
+       public ListInjectionPlan(INode name, IList<InjectionPlan> entries) : base(name)
+       {
+            foreach (InjectionPlan ip in entries)
+            {
+                this.entries.Add(ip);
+            }
+            int numAlternatives = 1;
+            bool isAmbiguous = false;
+            bool isInjectable = true;
+            foreach (InjectionPlan ip in entries) 
+            {
+                numAlternatives *= ip.GetNumAlternatives();
+                isAmbiguous |= ip.IsAmbiguous();
+                isInjectable &= ip.IsInjectable();
+            }
+            this.numAlternatives = numAlternatives;
+            this.isAmbiguous = isAmbiguous;
+            this.isInjectable = isInjectable;
+       }
+
+       public override int GetNumAlternatives()
+       {
+           return numAlternatives;
+       }
+
+       public override bool IsAmbiguous()
+       {
+           return isAmbiguous;
+       }
+
+       public override bool IsInjectable()
+       {
+           return isInjectable;
+       }
+
+       public IList<InjectionPlan> GetEntryPlans()
+       {
+           return new List<InjectionPlan>(this.entries);
+       }
+
+       public override string ToAmbiguousInjectString()
+       {
+           StringBuilder sb = new StringBuilder(GetNode().GetFullName() + "(list) includes ambiguous plans [");
+           foreach (InjectionPlan ip in entries)
+           {
+               if (ip.IsAmbiguous())
+               {
+                   sb.Append("\n" + ip.ToAmbiguousInjectString());
+               }
+           }
+           sb.Append("]");
+           return sb.ToString();
+       }
+
+       public override string ToInfeasibleInjectString()
+       {
+           StringBuilder sb = new StringBuilder(GetNode().GetFullName() + "(list) includes infeasible plans [");
+           foreach (InjectionPlan ip in entries)
+           {
+               if (!ip.IsFeasible())
+               {
+                   sb.Append("\n" + ip.ToInfeasibleInjectString());
+               }
+           }
+           sb.Append("\n]");
+           return sb.ToString();
+       }
+
+       public override bool IsInfeasibleLeaf()
+       {
+           return false;
+       }
+
+       public override string ToShallowString()
+       {
+           StringBuilder sb = new StringBuilder("list { ");
+           foreach (InjectionPlan ip in entries)
+           {
+               sb.Append("\n" + ip.ToShallowString());
+           }
+           sb.Append("\n } ");
+           return null;
+       }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/SetInjectionPlan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/SetInjectionPlan.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/SetInjectionPlan.cs
new file mode 100644
index 0000000..1b530b6
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/SetInjectionPlan.cs
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System.Collections.Generic;
+using System.Text;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class SetInjectionPlan : InjectionPlan
+    {
+        private readonly ISet<InjectionPlan> entries = new MonotonicHashSet<InjectionPlan>();
+        private readonly int numAlternatives;
+        private readonly bool isAmbiguous;
+        private readonly bool isInjectable;
+
+       public SetInjectionPlan(INode name, ISet<InjectionPlan> entries) : base(name)
+       {
+            foreach (InjectionPlan ip in entries)
+            {
+                this.entries.Add(ip);
+            }
+            int numAlternatives = 1;
+            bool isAmbiguous = false;
+            bool isInjectable = true;
+            foreach (InjectionPlan ip in entries) 
+            {
+                numAlternatives *= ip.GetNumAlternatives();
+                isAmbiguous |= ip.IsAmbiguous();
+                isInjectable &= ip.IsInjectable();
+            }
+            this.numAlternatives = numAlternatives;
+            this.isAmbiguous = isAmbiguous;
+            this.isInjectable = isInjectable;
+        }
+
+       public override int GetNumAlternatives()
+       {
+           return numAlternatives;
+       }
+
+       public override bool IsAmbiguous()
+       {
+           return isAmbiguous;
+       }
+
+       public override bool IsInjectable()
+       {
+           return isInjectable;
+       }
+
+       //public override bool HasFutureDependency()
+       //{
+       //    return false;
+       //}
+
+       public ISet<InjectionPlan> GetEntryPlans()
+       {
+           return new MonotonicHashSet<InjectionPlan>(this.entries);
+       }
+
+       public override string ToAmbiguousInjectString() 
+        {
+            StringBuilder sb = new StringBuilder(GetNode().GetFullName() + "(set) includes ambiguous plans [");
+            foreach (InjectionPlan ip in entries) 
+            {
+                if(ip.IsAmbiguous()) 
+                {
+                    sb.Append("\n" + ip.ToAmbiguousInjectString());
+                }
+            }
+            sb.Append("]");
+            return sb.ToString();
+        }
+
+        public override string ToInfeasibleInjectString() 
+        {
+            StringBuilder sb = new StringBuilder(GetNode().GetFullName() + "(set) includes infeasible plans [");
+            foreach (InjectionPlan ip in entries) 
+            {
+                if(!ip.IsFeasible()) 
+                {
+                    sb.Append("\n" + ip.ToInfeasibleInjectString());
+                }
+            }
+            sb.Append("\n]");
+            return sb.ToString();
+        }
+
+        public override bool IsInfeasibleLeaf()
+        {
+            return false;
+        }
+
+        public override string ToShallowString() 
+        {
+            StringBuilder sb = new StringBuilder("set { ");
+            foreach (InjectionPlan ip in entries) 
+            {
+                sb.Append("\n" + ip.ToShallowString());
+            }
+            sb.Append("\n } ");
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Subplan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Subplan.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Subplan.cs
new file mode 100644
index 0000000..b0b0229
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Subplan.cs
@@ -0,0 +1,235 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class Subplan : InjectionPlan
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(Subplan));
+
+        InjectionPlan[] alternatives; //all implementatios on the same interface
+        int numAlternatives;
+        int selectedIndex; //the implementation that is bound
+
+        public Subplan(INode n, int selectedIndex, InjectionPlan[] alternatives)
+            : base(n)
+        {
+            this.alternatives = alternatives;
+            if (selectedIndex < -1 || selectedIndex >= alternatives.Length)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IndexOutOfRangeException(), LOGGER);
+            }
+            this.selectedIndex = selectedIndex;
+            if (selectedIndex != -1)   //one was bound
+            {
+                this.numAlternatives = alternatives[selectedIndex].GetNumAlternatives();
+            }
+            else // no one was bound, but anyone could be used
+            {
+                int numAlternatives = 0;
+                foreach (InjectionPlan a in alternatives)
+                {
+                    numAlternatives += a.GetNumAlternatives();
+                }
+                this.numAlternatives = numAlternatives;
+            }
+        }
+
+        public new ICollection<InjectionPlan> GetChildren() 
+        {
+            return new ReadOnlyCollection<InjectionPlan>(this.alternatives.OfType<InjectionPlan>().ToList());
+        }
+
+        public Subplan(INode n, InjectionPlan[] alternatives)
+            : this(n, -1, alternatives)
+        {           
+        }
+
+        public override int GetNumAlternatives()
+        {
+            return this.numAlternatives;
+        }
+
+        public override bool IsAmbiguous()
+        {
+            if (selectedIndex == -1)
+            {
+                return true;
+            }
+            return alternatives[selectedIndex].IsAmbiguous();
+        }
+
+        public override bool IsInjectable()
+        {
+            if (selectedIndex == -1)
+            {
+                return false;
+            }
+            else
+            {
+                return alternatives[selectedIndex].IsInjectable();
+            }
+        }
+
+        public override string ToString()
+        {
+            if (alternatives.Length == 1)
+            {
+                return GetNode().GetName() + " = " + alternatives[0];
+            }
+            else if (alternatives.Length == 0)
+            {
+                return GetNode().GetName() + ": no injectable constructors";
+            }
+            StringBuilder sb = new StringBuilder("[");
+            sb.Append(GetNode().GetName() + " = " + alternatives[0]);
+            for (int i = 1; i < alternatives.Length; i++)
+            {
+                sb.Append(" | " + alternatives[i]);
+            }
+            sb.Append("]");
+            return sb.ToString();
+        }
+
+        public override string ToShallowString()
+        {
+            if (alternatives.Length == 1)
+            {
+                return GetNode().GetName() + " = " + alternatives[0].ToShallowString();
+            }
+            else if (alternatives.Length == 0)
+            {
+                return GetNode().GetName() + ": no injectable constructors";
+            }
+            StringBuilder sb = new StringBuilder("[");
+            sb.Append(GetNode().GetName() + " = " + alternatives[0].ToShallowString());
+            for (int i = 1; i < alternatives.Length; i++)
+            {
+                sb.Append(" | " + alternatives[i].ToShallowString());
+            }
+            sb.Append("]");
+            return sb.ToString();
+        }
+
+        public int GetSelectedIndex()
+        {
+            return selectedIndex;
+        }
+
+        public InjectionPlan GetDelegatedPlan() 
+        {
+            if (selectedIndex != -1) 
+            {
+                return alternatives[selectedIndex];
+            }
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Error in getting GetDelegatedPlan."), LOGGER);
+            return null;
+        }
+
+        //public override bool HasFutureDependency()
+        //{
+        //    if (selectedIndex == -1)
+        //    {
+        //        throw new IllegalStateException("hasFutureDependency() called on ambiguous subplan!");
+        //    }
+        //    return alternatives[selectedIndex].HasFutureDependency();
+        //}
+
+        public override string ToAmbiguousInjectString()
+        {
+            if (alternatives.Length == 1) 
+            {
+                return alternatives[0].ToAmbiguousInjectString();
+            } 
+            else if (selectedIndex != -1) 
+            {
+                return alternatives[selectedIndex].ToAmbiguousInjectString();
+            } 
+            else 
+            {
+                IList<InjectionPlan> alts = new List<InjectionPlan>();
+                IList<InjectionPlan> ambig = new List<InjectionPlan>();
+                foreach (InjectionPlan alt in alternatives) 
+                {
+                    if (alt.IsFeasible()) 
+                    {
+                        alts.Add(alt);
+                    }
+                    if (alt.IsAmbiguous()) 
+                    {
+                        ambig.Add(alt);
+                    }
+                }
+                StringBuilder sb = new StringBuilder("Ambiguous subplan " + GetNode().GetFullName());
+                foreach (InjectionPlan alt in alts) 
+                {
+                    sb.Append("\n  " + alt.ToShallowString() + " ");
+                }
+                foreach (InjectionPlan alt in ambig) 
+                {
+                    sb.Append("\n  " + alt.ToShallowString() + " ");
+                }
+                sb.Append("\n]");
+                return sb.ToString();
+            }
+        }
+
+        public override string ToInfeasibleInjectString()
+        {
+            if (alternatives.Length == 1) 
+            {
+                return alternatives[0].ToInfeasibleInjectString();
+            }
+            else if (alternatives.Length == 0)
+            {
+                return "No known implementations / injectable constructors for "
+                + this.GetNode().GetFullName();
+            } 
+            else if (selectedIndex != -1) 
+            {
+                return alternatives[selectedIndex].ToInfeasibleInjectString();
+            } 
+            else 
+            {
+                return "Multiple infeasible plans: " + ToPrettyString();
+            }
+        }
+
+        public InjectionPlan[] GetPlans() 
+        {
+            InjectionPlan[] copy = new InjectionPlan[alternatives.Length];
+            Array.Copy(alternatives, copy, alternatives.Length); // not sure if it does deep copy??
+            return copy;
+        }
+
+        public override bool IsInfeasibleLeaf()
+        {
+            return false;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Tang/TangFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Tang/TangFactory.cs b/lang/cs/Source/TANG/Tang/Implementations/Tang/TangFactory.cs
new file mode 100644
index 0000000..c54f562
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Tang/TangFactory.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class TangFactory
+    {
+        public static ITang GetTang()
+        {
+            return new TangImpl();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Tang/TangImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Tang/TangImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/Tang/TangImpl.cs
new file mode 100644
index 0000000..5e0181b
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Tang/TangImpl.cs
@@ -0,0 +1,201 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class TangImpl : ITang
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TangImpl));
+
+        private static IDictionary<SetValuedKey, ICsClassHierarchy> defaultClassHierarchy = new Dictionary<SetValuedKey, ICsClassHierarchy>();
+
+        public IInjector NewInjector()
+        {
+            try
+            {
+                return NewInjector(new ConfigurationImpl[] {});
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Unexpected error from empty configuration", e), LOGGER);
+                return null;
+            }
+        }
+
+        public IInjector NewInjector(string[] assemblies, string configurationFileName)
+        {
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang.NewConfigurationBuilder(assemblies);
+            ConfigurationFile.AddConfigurationFromFile(cb1, configurationFileName);
+            IConfiguration conf = cb1.Build();
+
+            IInjector injector = tang.NewInjector(conf);
+            return injector;
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder(IConfiguration conf)
+        {
+            return NewConfigurationBuilder(new IConfiguration[] { conf });
+        }
+
+        //public IInjector NewInjector(string[] assemblies, IDictionary<string, string> configurations)
+        //{
+        //    ITang tang = TangFactory.GetTang();
+        //    ICsConfigurationBuilder cb1 = tang.NewConfigurationBuilder(assemblies);
+        //    ConfigurationFile.ProcessConfigData(cb1, configurations);
+        //    IConfiguration conf = cb1.Build();
+
+        //    IInjector injector = tang.NewInjector(conf);
+        //    return injector;
+        //}
+
+        public IInjector NewInjector(string[] assemblies, IDictionary<string, string> configurations)
+        {
+            IList<KeyValuePair<string, string>> conf = new List<KeyValuePair<string, string>>();
+            foreach (KeyValuePair<string, string> kp in configurations)
+            {
+                conf.Add(kp);
+            }
+            return NewInjector(assemblies, conf);
+        }
+
+        public IInjector NewInjector(string[] assemblies, IList<KeyValuePair<string, string>> configurations)
+        {
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang.NewConfigurationBuilder(assemblies);
+            ConfigurationFile.ProcessConfigData(cb1, configurations);
+            IConfiguration conf = cb1.Build();
+
+            IInjector injector = tang.NewInjector(conf);
+            return injector;
+        }
+
+        public IInjector NewInjector(IConfiguration[] confs)
+        {
+            return new InjectorImpl(new CsConfigurationBuilderImpl(confs).Build());
+        }
+
+        public IInjector NewInjector(IConfiguration conf)
+        {
+            //return new InjectorImpl(conf);
+            try
+            {
+                return NewInjector(new ConfigurationImpl[] { (ConfigurationImpl)conf });
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Unexpected error cloning configuration", e), LOGGER);
+                return null; 
+            }
+        }
+
+        public IClassHierarchy GetClassHierarchy(string[] assemblies)
+        {
+            return GetDefaultClassHierarchy(assemblies, new Type[] { });
+        }
+
+        public ICsClassHierarchy GetDefaultClassHierarchy()
+        {
+            return GetDefaultClassHierarchy(new string[0], new Type[0]);
+        }
+
+        public ICsClassHierarchy GetDefaultClassHierarchy(string[] assemblies, Type[] parameterParsers)
+        {
+            SetValuedKey key = new SetValuedKey(assemblies, parameterParsers);
+
+            ICsClassHierarchy ret = null;
+            defaultClassHierarchy.TryGetValue(key, out ret);
+            if (ret == null)
+            {
+                ret = new ClassHierarchyImpl(assemblies, parameterParsers);
+                defaultClassHierarchy.Add(key, ret);
+            }
+            return ret;
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder()
+        {
+            try 
+            {
+                return NewConfigurationBuilder(new string[0], new IConfiguration[0], new Type[0]);
+            } 
+            catch (BindException e) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(
+                    "Caught unexpeceted bind exception!  Implementation bug.", e), LOGGER);
+                return null;
+            }
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder(string[] assemblies)
+        {
+            try
+            {
+                return NewConfigurationBuilder(assemblies, new IConfiguration[0], new Type[0]);
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(
+                    "Caught unexpeceted bind exception!  Implementation bug.", e), LOGGER);
+                return null;
+            }
+        }
+
+        public IConfigurationBuilder NewConfigurationBuilder(IClassHierarchy classHierarchy)
+        {
+            return new ConfigurationBuilderImpl(classHierarchy);
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder(ICsClassHierarchy classHierarchy)
+        {
+            return new CsConfigurationBuilderImpl(classHierarchy);
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder(IConfiguration[] confs)
+        {
+            return NewConfigurationBuilder(new string[0], confs, new Type[0]);
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder(string[] assemblies, IConfiguration[] confs, Type[] parameterParsers)
+        {
+            return new CsConfigurationBuilderImpl(assemblies, confs, parameterParsers);
+        }
+
+        public ICsConfigurationBuilder NewConfigurationBuilder(Type[] parameterParsers) 
+        {
+            return NewConfigurationBuilder(new string[0], new IConfiguration[0], parameterParsers);
+        }
+
+        public static void Reset() 
+        {
+            defaultClassHierarchy = new Dictionary<SetValuedKey, ICsClassHierarchy>(); 
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/IAspect.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/IAspect.cs b/lang/cs/Source/TANG/Tang/Interface/IAspect.cs
new file mode 100644
index 0000000..2c19897
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/IAspect.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System.Reflection;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface Aspect
+    {
+        object Inject(IConstructorDef def, ConstructorInfo constructor, object[] args);
+        void InjectionFutureInstantiated<T>(IInjectionFuture<T> f, object t);
+        Aspect CreateChildAspect();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/IClassHierarchy.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/IClassHierarchy.cs b/lang/cs/Source/TANG/Tang/Interface/IClassHierarchy.cs
new file mode 100644
index 0000000..7428942
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/IClassHierarchy.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface IClassHierarchy
+    {
+        INode GetNode(string fullName);
+        INode GetNamespace();
+        bool IsImplementation(IClassNode inter, IClassNode impl);
+        IClassHierarchy Merge(IClassHierarchy ch);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/IConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/IConfiguration.cs b/lang/cs/Source/TANG/Tang/Interface/IConfiguration.cs
new file mode 100644
index 0000000..6903d19
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/IConfiguration.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface IConfiguration
+    {
+        IConfigurationBuilder newBuilder();
+        string GetNamedParameter(INamedParameterNode np);
+        IClassHierarchy GetClassHierarchy();
+
+        ISet<Object> GetBoundSet(INamedParameterNode np); //named parameter for a set
+        IList<Object> GetBoundList(INamedParameterNode np); //named parameter for a list
+
+        IClassNode GetBoundConstructor(IClassNode cn);
+        IClassNode GetBoundImplementation(IClassNode cn);
+        IConstructorDef GetLegacyConstructor(IClassNode cn);
+
+        ICollection<IClassNode> GetBoundImplementations();
+        ICollection<IClassNode> GetBoundConstructors();
+        ICollection<INamedParameterNode> GetNamedParameters();
+        ICollection<IClassNode> GetLegacyConstructors();
+
+        IEnumerator<KeyValuePair<INamedParameterNode, object>> GetBoundSets();
+        IDictionary<INamedParameterNode, IList<object>> GetBoundList();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/IConfigurationBuilder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/IConfigurationBuilder.cs b/lang/cs/Source/TANG/Tang/Interface/IConfigurationBuilder.cs
new file mode 100644
index 0000000..640b11d
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/IConfigurationBuilder.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface IConfigurationBuilder
+    {
+        void AddConfiguration(IConfiguration c); 
+        IClassHierarchy GetClassHierarchy();
+        IConfiguration Build();
+        void Bind(string iface, string impl);
+        void Bind(INode key, INode value);
+
+        void BindConstructor(IClassNode k, IClassNode v); //v extended from ExternalConstructor
+        string ClassPrettyDefaultString(string longName);
+        string ClassPrettyDescriptionString(string longName);
+
+        void RegisterLegacyConstructor(IClassNode cn, IList<IClassNode> args);
+        void RegisterLegacyConstructor(string cn, IList<string> args);
+        void RegisterLegacyConstructor(IClassNode c, IList<IConstructorArg> args);
+
+        void BindSetEntry(string iface, string impl);
+        void BindSetEntry(string iface, INode impl);
+        void BindSetEntry(INamedParameterNode iface, string impl);
+        void BindSetEntry(INamedParameterNode iface, INode impl);
+
+        void BindList(string iface, IList<string> impl);
+        void BindList(string iface, IList<INode> impl);
+        void BindList(INamedParameterNode iface, IList<INode> impl);
+        void BindList(INamedParameterNode iface, IList<string> impl);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/ICsClassHierarchy.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/ICsClassHierarchy.cs b/lang/cs/Source/TANG/Tang/Interface/ICsClassHierarchy.cs
new file mode 100644
index 0000000..07c94dc
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/ICsClassHierarchy.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface ICsClassHierarchy : IClassHierarchy
+    {
+        INode GetNode(Type c);
+        Type ClassForName(string name);
+        object Parse(INamedParameterNode name, string value);
+        object ParseDefaultValue(INamedParameterNode name);
+
+
+    }
+}


[17/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Exceptions/IllegalStateException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Exceptions/IllegalStateException.cs b/lang/cs/Source/TANG/Tang/Exceptions/IllegalStateException.cs
new file mode 100644
index 0000000..3e4bd19
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Exceptions/IllegalStateException.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Exceptions
+{
+    public class IllegalStateException : Exception
+    {
+        public IllegalStateException()
+            : base()
+        {
+        }
+
+        public IllegalStateException(String msg)
+            : base(msg)
+        {           
+        }
+
+        public IllegalStateException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Exceptions/InjectionException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Exceptions/InjectionException.cs b/lang/cs/Source/TANG/Tang/Exceptions/InjectionException.cs
new file mode 100644
index 0000000..c1e248f
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Exceptions/InjectionException.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Exceptions
+{
+    public class InjectionException : Exception
+    {
+        public InjectionException(String msg)
+            : base(msg)
+        {           
+        }
+
+        public InjectionException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Exceptions/NameResolutionException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Exceptions/NameResolutionException.cs b/lang/cs/Source/TANG/Tang/Exceptions/NameResolutionException.cs
new file mode 100644
index 0000000..45209ac
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Exceptions/NameResolutionException.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Exceptions
+{
+    public class NameResolutionException : BindException
+    {
+        //private static readonly long serialVersionUID = 1L;
+        public NameResolutionException(String name, String longestPrefix) :
+            base(string.Format("Could not resolve {0}.  Search ended at prefix {1}. This can happen due to typos in class names that are passed as strings, or because Tang uses Assembly loader other than the one that generated the class reference ((make sure you use the full name of a class)",
+                name, longestPrefix))
+        {
+        }
+
+        public NameResolutionException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Exceptions/ParseException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Exceptions/ParseException.cs b/lang/cs/Source/TANG/Tang/Exceptions/ParseException.cs
new file mode 100644
index 0000000..1c52463
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Exceptions/ParseException.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Exceptions
+{
+    public class ParseException : BindException
+    {
+       // private static readonly long serialVersionUID = 1L;
+        public ParseException(String message)
+            : base(message)
+        {           
+        }
+
+        public ParseException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/AvroConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/AvroConfiguration.cs b/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/AvroConfiguration.cs
new file mode 100644
index 0000000..8d1c952
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/AvroConfiguration.cs
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using Newtonsoft.Json;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    [KnownType(typeof(HashSet<ConfigurationEntry>))]
+    [DataContract(Name = "AvroConfiguration", Namespace = "org.apache.reef.tang.formats.avro")]
+    public class AvroConfiguration
+    {
+        public AvroConfiguration(HashSet<ConfigurationEntry> bindings)
+        {
+            this.Bindings = bindings;
+        }
+
+        public AvroConfiguration()
+        {
+        }
+
+        [DataMember]
+        public HashSet<ConfigurationEntry> Bindings { get; set; }
+
+        public static AvroConfiguration GetAvroConfigurationFromEmbeddedString(string jsonString)
+        {
+            return JsonConvert.DeserializeObject<AvroConfiguration>(jsonString);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/ConfigurationEntry.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/ConfigurationEntry.cs b/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/ConfigurationEntry.cs
new file mode 100644
index 0000000..bfa23cb
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationDataContract/ConfigurationEntry.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    [DataContract(Name = "ConfigurationEntry", Namespace = "org.apache.reef.tang.formats.avro")]
+    [KnownType(typeof(string))]
+    public class ConfigurationEntry
+    {
+        public ConfigurationEntry(string key, string value)
+        {
+            this.key = key;
+            this.value = value;
+        }
+
+        public ConfigurationEntry()
+        {
+        }
+
+        [DataMember]
+        public string key { get; set; }
+
+        [DataMember]
+        public string value { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationSerializer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationSerializer.cs b/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationSerializer.cs
new file mode 100644
index 0000000..e82e4e3
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/AvroConfigurationSerializer.cs
@@ -0,0 +1,324 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using Microsoft.Hadoop.Avro;
+using Microsoft.Hadoop.Avro.Container;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Newtonsoft.Json;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public class AvroConfigurationResolver : Microsoft.Hadoop.Avro.AvroPublicMemberContractResolver
+    {
+        public override TypeSerializationInfo ResolveType(Type type)
+        {
+            var serInfo = base.ResolveType(type);
+            serInfo.Aliases.Add("org.apache.reef.tang.formats.avro.AvroConfiguration");
+            serInfo.Aliases.Add("org.apache.reef.tang.formats.avro.Bindings");
+            serInfo.Aliases.Add("org.apache.reef.tang.formats.avro.ConfigurationEntry");
+
+            return serInfo;
+        }
+    }
+
+    public class AvroConfigurationSerializer : IConfigurationSerializer
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(AvroConfigurationResolver));
+
+        [Inject]
+        public AvroConfigurationSerializer()
+        {
+        }
+
+        public byte[] ToByteArray(IConfiguration c)
+        {
+            AvroConfiguration obj = ToAvroConfiguration(c);
+            return AvroSerialize(obj);
+        }
+
+        public string GetSchema()
+        {
+            var serializer = AvroSerializer.Create<AvroConfiguration>();
+            return serializer.WriterSchema.ToString();
+        }
+
+        public void ToFileStream(IConfiguration c, string fileName)
+        {
+            using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate))
+            {
+                byte[] data = ToByteArray(c);
+                fs.Write(data, 0, data.Length);
+            }
+        }
+
+        public void ToFile(IConfiguration c, string fileName)
+        {
+            var avronConfigurationData = ToAvroConfiguration(c);
+            using (var buffer = new MemoryStream())
+            {
+                using (var w = AvroContainer.CreateWriter<AvroConfiguration>(buffer, Codec.Null))
+                {
+                    using (var writer = new SequentialWriter<AvroConfiguration>(w, 24))
+                    {
+                        // Serialize the data to stream using the sequential writer
+                        writer.Write(avronConfigurationData);
+                    }
+                }
+
+                if (!WriteFile(buffer, fileName))
+                {
+                    var e = new ApplicationException("Error during file operation. Quitting method: " + fileName);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+            }          
+        }
+
+        public IConfiguration FromByteArray(byte[] bytes)
+        {
+            AvroConfiguration avroConf = AvroDeseriaize(bytes);
+            return FromAvro(avroConf);
+        }
+
+        public IConfiguration AddFromByteArray(ICsConfigurationBuilder cb, byte[] bytes)
+        {
+            AvroConfiguration avroConf = AvroDeseriaize(bytes);
+            return AddFromAvro(cb, avroConf);
+        }
+
+        public IConfiguration FromFileStream(string fileName)
+        {
+            byte[] bytes = File.ReadAllBytes(fileName);
+            AvroConfiguration avroConf = AvroDeseriaize(bytes);
+            return FromAvro(avroConf);
+        }
+
+        public IConfiguration FromFile(string fileName)
+        {
+            AvroConfiguration avroConf = AvroDeseriaizeFromFile(fileName);
+            return FromAvro(avroConf);
+        }
+
+        public string ToBase64String(IConfiguration c)
+        {
+            return Convert.ToBase64String(ToByteArray(c));
+        }
+
+        public IConfiguration FromBase64String(string serializedConfig)
+        {
+            var b = Convert.FromBase64String(serializedConfig);
+            return FromByteArray(b);
+        }
+
+        public string ToString(IConfiguration c)
+        {
+            byte[] bytes = ToByteArray(c);
+            AvroConfiguration avroConf = AvroDeseriaize(bytes);
+            string s = JsonConvert.SerializeObject(avroConf, Formatting.Indented);
+            return s;
+        }
+
+        public IConfiguration FromString(string josonString)
+        {
+            AvroConfiguration avroConf = JsonConvert.DeserializeObject<AvroConfiguration>(josonString);
+            return FromAvro(avroConf);
+        }
+
+        public AvroConfiguration AvroDeseriaizeFromFile(string fileName)
+        {
+            AvroConfiguration avroConf = null;
+            try
+            {
+                using (var buffer = new MemoryStream())
+                {
+                    if (!ReadFile(buffer, fileName))
+                    {
+                        var e = new ApplicationException("Error during file operation. Quitting method : " + fileName);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+
+                    buffer.Seek(0, SeekOrigin.Begin);
+                    //AvroSerializerSettings settings = new AvroSerializerSettings();
+                    //settings.Resolver = new AvroConfigurationResolver();
+                    //using (var reader = new SequentialReader<AvroConfiguration>(AvroContainer.CreateReader<AvroConfiguration>(buffer, true, settings, new CodecFactory())))
+                    using (var reader = new SequentialReader<AvroConfiguration>(AvroContainer.CreateReader<AvroConfiguration>(buffer, true))) 
+                    {
+                        var results = reader.Objects;
+
+                        if (results != null)
+                        {
+                            avroConf = (AvroConfiguration)results.First();
+                        }
+                    }
+                }
+            }
+            catch (SerializationException ex)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                var e = new ApplicationException("Cannot deserialize the file: " + fileName, ex);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+
+            return avroConf;
+        }
+
+        public IConfiguration FromAvro(AvroConfiguration avroConfiguration)
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+
+            return AddFromAvro(cb, avroConfiguration);
+        }
+
+        public IConfiguration FromAvro(AvroConfiguration avroConfiguration, IClassHierarchy classHierarchy)
+        {
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(classHierarchy);
+
+            return AddFromAvro(cb, avroConfiguration);
+        }
+
+        public AvroConfiguration ToAvroConfiguration(IConfiguration c)
+        {
+            ConfigurationImpl conf = (ConfigurationImpl)c;
+            HashSet<ConfigurationEntry> l = new HashSet<ConfigurationEntry>();
+
+            foreach (IClassNode opt in conf.GetBoundImplementations())
+            {
+                l.Add(new ConfigurationEntry(opt.GetFullName(), conf.GetBoundImplementation(opt).GetFullName()));
+            }
+
+            foreach (IClassNode opt in conf.GetBoundConstructors())
+            {
+                l.Add(new ConfigurationEntry(opt.GetFullName(), conf.GetBoundConstructor(opt).GetFullName()));
+            }
+            foreach (INamedParameterNode opt in conf.GetNamedParameters())
+            {
+                l.Add(new ConfigurationEntry(opt.GetFullName(), conf.GetNamedParameter(opt)));
+            }
+            foreach (IClassNode cn in conf.GetLegacyConstructors())
+            {
+                StringBuilder sb = new StringBuilder();
+                ConfigurationFile.Join(sb, "-", conf.GetLegacyConstructor(cn).GetArgs().ToArray<IConstructorArg>());
+                l.Add(new ConfigurationEntry(cn.GetFullName(), ConfigurationBuilderImpl.INIT + '(' + sb.ToString() + ')'));
+            }
+
+            IEnumerator bs = conf.GetBoundSets();
+            while (bs.MoveNext())
+            {
+                KeyValuePair<INamedParameterNode, object> e = (KeyValuePair<INamedParameterNode, object>)bs.Current;
+
+                string val = null;
+                if (e.Value is string)
+                {
+                    val = (string)e.Value;
+                }
+                else if (e.Value is INode)
+                {
+                    val = ((INode)e.Value).GetFullName();
+                }
+                else
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(), LOGGER);
+                }
+
+                l.Add(new ConfigurationEntry(e.Key.GetFullName(), val));
+            }
+
+            return new AvroConfiguration(l);
+        }
+        
+        private byte[] AvroSerialize(AvroConfiguration obj)
+        {
+            var serializer = AvroSerializer.Create<AvroConfiguration>();
+            using (MemoryStream stream = new MemoryStream())
+            {
+                serializer.Serialize(stream, obj);
+                return stream.GetBuffer();
+            }
+        }
+
+        private AvroConfiguration AvroDeseriaize(string serializedConfig)
+        {
+            return AvroDeseriaize(Convert.FromBase64String(serializedConfig));
+        }
+
+        private AvroConfiguration AvroDeseriaize(byte[] serializedBytes)
+        {
+            var serializer = AvroSerializer.Create<AvroConfiguration>();
+            using (var stream = new MemoryStream(serializedBytes))
+            {
+                return serializer.Deserialize(stream);
+            }
+        }
+
+        private bool ReadFile(MemoryStream outputStream, string path)
+        {
+            try
+            {
+                byte[] data = File.ReadAllBytes(path);
+                outputStream.Write(data, 0, data.Length);
+                return true;
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                return false;
+            }
+        }
+
+        private bool WriteFile(MemoryStream inputStream, string path)
+        {
+            try
+            {
+                using (FileStream fs = File.Create(path))
+                {
+                    inputStream.WriteTo(fs);
+                }
+                return true;
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                return false;
+            }
+        }
+
+        private IConfiguration AddFromAvro(IConfigurationBuilder cb, AvroConfiguration avroConfiguration)
+        {
+            IList<KeyValuePair<string, string>> settings = new List<KeyValuePair<string, string>>();
+
+            foreach (ConfigurationEntry e in avroConfiguration.Bindings)
+            {
+                settings.Add(new KeyValuePair<string, string>(e.key, e.value));
+            }
+            ConfigurationFile.ProcessConfigData(cb, settings);   //TODO
+            return cb.Build();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/ConfigurationFile.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/ConfigurationFile.cs b/lang/cs/Source/TANG/Tang/Formats/ConfigurationFile.cs
new file mode 100644
index 0000000..506cc85
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/ConfigurationFile.cs
@@ -0,0 +1,371 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public class ConfigurationFile
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ConfigurationFile));
+
+        //#region Avro serialization
+        //public static string AvroSerialize(IConfiguration c)
+        //{
+        //    var obj = new ConfigurationDataContract(ToConfigurationStringList(c));
+        //    var serializer = AvroSerializer.Create<ConfigurationDataContract>();
+        //    var schema = serializer.WriterSchema.ToString();
+
+        //    var stream = new MemoryStream();
+        //    serializer.Serialize(stream, obj);
+        //    return Convert.ToBase64String(stream.GetBuffer());
+        //}
+
+        //public static void AvroDeseriaize(IConfigurationBuilder conf, string serializedConfig)
+        //{
+        //    var serializer2 = AvroSerializer.Create<ConfigurationDataContract>();
+        //    ConfigurationDataContract confgDataObj;
+        //    using (var stream2 = new MemoryStream(Convert.FromBase64String(serializedConfig)))
+        //    {
+        //        confgDataObj = serializer2.Deserialize(stream2);
+        //    }
+
+        //    IList<KeyValuePair<string, string>> settings = new List<KeyValuePair<string, string>>();
+
+        //    foreach (string line in confgDataObj.Bindings)
+        //    {
+        //        string[] p = line.Split('=');
+        //        settings.Add(new KeyValuePair<string, string>(p[0], p[1]));
+        //    }
+        //    ProcessConfigData(conf, settings);
+        //}
+
+        //public static IConfiguration AvroDeseriaize(string serializedConfig)
+        //{
+        //    ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+        //    AvroDeseriaize(cb, serializedConfig);
+        //    return cb.Build();
+        //}
+
+        //public static IConfiguration AvroDeseriaizeFromFile(string configFileName)
+        //{
+        //    ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+        //    AddConfigurationFromFileUsingAvro(cb, configFileName);
+        //    return cb.Build();
+        //}
+
+        //public static void WriteConfigurationFileUsingAvro(IConfiguration c, string fileName)
+        //{
+        //    using (FileStream aFile = new FileStream(fileName, FileMode.OpenOrCreate))
+        //    {
+        //        using (StreamWriter sw = new StreamWriter(aFile))
+        //        {
+        //            sw.Write(AvroSerialize(c));
+        //        }
+        //    }
+        //}
+
+        //public static void AddConfigurationFromFileUsingAvro(IConfigurationBuilder conf, string configFileName)
+        //{
+        //    string serializedString;
+        //    using (StreamReader reader = new StreamReader(configFileName))
+        //    {
+        //        serializedString = reader.ReadLine();
+        //    }
+        //    AvroDeseriaize(conf, serializedString);
+        //}
+        //#endregion Avro serialization
+
+        #region text file serialization
+        public static void WriteConfigurationFile(IConfiguration c, string fileName)
+        {
+            using (FileStream aFile = new FileStream(fileName, FileMode.Create))
+            {
+                using (StreamWriter sw = new StreamWriter(aFile))
+                {
+                    sw.Write(ToConfigurationString(c));
+                }
+            }
+        }
+
+        public static String ToConfigurationString(IConfiguration c) 
+        {
+            StringBuilder sb = new StringBuilder();
+            foreach (string s in ToConfigurationStringList(c)) 
+            {
+                sb.Append(s);
+                sb.Append('\n');
+            }
+            return sb.ToString();
+        }
+
+        private static string GetFullName(INode n)
+        {
+            string s = n.GetFullName();
+            Type t = ReflectionUtilities.GetTypeByName(s);
+            return t.FullName;
+        }
+    
+
+        private static string GetFullName(string name)
+        {
+            try
+            {
+                Type t = ReflectionUtilities.GetTypeByName(name);
+                return t.FullName;
+            }
+            catch (ApplicationException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, LOGGER);
+                return name;//if name is not a type, return as it was
+                
+            }
+        }
+
+        private static string GetAssemlyName(string s)
+        {
+            try
+            {
+                Type t = ReflectionUtilities.GetTypeByName(s);
+                return ReflectionUtilities.GetAssemblyQualifiedName(t);
+            }
+            catch (ApplicationException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, LOGGER);
+                return s;//if name is not a type, return as it was
+            }
+        }
+
+        public static HashSet<String> ToConfigurationStringList(IConfiguration c) 
+        {
+            ConfigurationImpl conf = (ConfigurationImpl) c;
+            HashSet<string> l = new HashSet<string>();
+            foreach (IClassNode opt in conf.GetBoundImplementations()) 
+            {
+//                l.Add(opt.GetFullName() + '=' + Escape(conf.GetBoundImplementation(opt).GetFullName()));
+                l.Add(GetFullName(opt) + '=' + Escape(GetFullName(conf.GetBoundImplementation(opt))));
+            }
+            
+            foreach (IClassNode opt in conf.GetBoundConstructors()) 
+            {
+//                l.Add(opt.GetFullName() + '=' + Escape(conf.GetBoundConstructor(opt).GetFullName()));
+                l.Add(GetFullName(opt) + '=' + Escape(GetFullName(conf.GetBoundConstructor(opt))));
+            }
+            foreach (INamedParameterNode opt in conf.GetNamedParameters()) 
+            {
+//                l.Add(opt.GetFullName() + '=' + Escape(conf.GetNamedParameter(opt)));
+                l.Add(GetFullName(opt) + '=' + Escape(GetFullName(conf.GetNamedParameter(opt))));
+            }
+            foreach (IClassNode cn in conf.GetLegacyConstructors())
+            {
+                StringBuilder sb = new StringBuilder();
+                Join(sb, "-", conf.GetLegacyConstructor(cn).GetArgs().ToArray<IConstructorArg>());
+                l.Add(GetFullName(cn) + Escape('=' + ConfigurationBuilderImpl.INIT + '(' + sb.ToString() + ')'));
+                //l.Add(cn.GetFullName() + Escape('=' + ConfigurationBuilderImpl.INIT + '(' + sb.ToString() + ')'));
+                //s.append(cn.getFullName()).append('=').append(ConfigurationBuilderImpl.INIT).append('(');
+                //      .append(")\n");
+            }
+
+
+            IEnumerator bs = conf.GetBoundSets();
+            while (bs.MoveNext())
+            {
+                KeyValuePair<INamedParameterNode, object> e = (KeyValuePair<INamedParameterNode, object>)bs.Current;
+
+            //}
+            //foreach (KeyValuePair<INamedParameterNode, object> e in conf.GetBoundSets()) 
+            //{
+                string val = null;
+                if (e.Value is string) 
+                {
+                    val = GetFullName((string)e.Value);
+                } 
+                else if (e.Value is INode) 
+                {
+//                    val = ((INode)e.Value).GetFullName();
+                    val = GetFullName((INode)e.Value);
+                } 
+                else 
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(), LOGGER);
+                }
+                
+//                l.Add(e.Key.GetFullName() + '=' + Escape(val));
+                l.Add(GetFullName(e.Key) + '=' + Escape(val));
+                //      s.append(e.getKey().getFullName()).append('=').append(val).append("\n");
+            }
+
+            return l;//s.toString();
+        }
+
+        public static IConfiguration GetConfiguration(string configString)
+        {
+            byte[] array = Encoding.Default.GetBytes(configString);
+            return GetConfiguration(array);
+        }
+
+        public static IConfiguration GetConfiguration(byte[] configStream)
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            AddConfigurationFromStream(cb, configStream);
+            return cb.Build();
+        }
+
+        public static void AddConfigurationFromStream(IConfigurationBuilder conf, byte[] configData)
+        {
+            using (StreamReader reader = new StreamReader(new MemoryStream(configData), Encoding.Default))
+            {
+                 AddConfiguration(conf, reader);
+            }
+        }
+
+        public static void AddConfigurationFromFile(IConfigurationBuilder conf, string configFileName)
+        {            
+            using (StreamReader reader = new StreamReader(configFileName))
+            {
+                 AddConfiguration(conf, reader);
+            }
+        }
+
+        public static void AddConfigurationFromString(IConfigurationBuilder conf, string configData)
+        {
+            byte[] array = Encoding.ASCII.GetBytes(configData);
+            AddConfigurationFromStream(conf, array);
+        }
+
+        private static void AddConfiguration(IConfigurationBuilder conf, StreamReader reader)
+        {
+            //IDictionary<string, string> settings = new Dictionary<string, string>();
+            IList<KeyValuePair<string, string>> settings = new List<KeyValuePair<string, string>>();
+
+            while (!reader.EndOfStream)
+            {
+                string line = reader.ReadLine();
+                string[] p = line.Split('=');
+                if (p.Length == 2)
+                {
+                    settings.Add(new KeyValuePair<string, string>(GetAssemlyName(p[0]), GetAssemlyName(p[1])));
+                } 
+                else if (p.Length > 2)
+                {
+                    string v = line.Substring(p[0].Length + 1, line.Length - p[0].Length - 1);
+                    settings.Add(new KeyValuePair<string, string>(GetAssemlyName(p[0]), GetAssemlyName(v)));
+                }
+                else
+                {
+                    var e = new ApplicationException("Config data is not in format of KeyValuePair: " + line);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }  
+            }
+            ProcessConfigData(conf, settings);
+        }
+
+        public static IDictionary<string, string> FromFile(string fileName)
+        {
+            IDictionary<string, string> property = new Dictionary<string, string>();
+            using (StreamReader sr = new StreamReader(fileName))
+            {
+                while (!sr.EndOfStream)
+                {
+                    string line = sr.ReadLine();
+                    string[] p = line.Split('=');
+                    property.Add(ConfigurationFile.GetAssemlyName(p[0]), ConfigurationFile.GetAssemlyName(p[1]));
+                }
+            }
+            return property;
+        }
+
+        public static void ProcessConfigData(IConfigurationBuilder conf, IList<KeyValuePair<string, string>> settings)
+        {
+            foreach (KeyValuePair<string, string> kv in settings)
+            {
+                try
+                {
+                    conf.Bind(kv.Key, kv.Value);
+                }
+                catch (BindException ex)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                    var e = new BindException("Failed to process configuration tuple: [" + kv.Key + "=" + kv.Value + "]", ex);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                catch (ClassHierarchyException ex)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                    var e = new ClassHierarchyException("Failed to process configuration tuple: [" + kv.Key + "=" + kv.Value + "]", ex);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        public static void ProcessConfigData(IConfigurationBuilder conf, IDictionary<string, string> settings)
+        {
+            IList<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+
+            foreach (KeyValuePair<string, string> kv in settings)
+            {
+                list.Add(kv);
+            }
+
+            ProcessConfigData(conf, list);
+        }
+ 
+       /**
+        * Replace any \'s in the input string with \\. and any "'s with \".
+        * @param in
+        * @return
+        */
+        private static string Escape(string str) 
+        {
+            return str;  //TODO
+            // After regexp escaping \\\\ = 1 slash, \\\\\\\\ = 2 slashes.
+
+            // Also, the second args of replaceAll are neither strings nor regexps, and
+            // are instead a special DSL used by Matcher. Therefore, we need to double
+            // escape slashes (4 slashes) and quotes (3 slashes + ") in those strings.
+            // Since we need to write \\ and \", we end up with 8 and 7 slashes,
+            // respectively.
+            //return in.ReplaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\\\"");
+        }
+
+        public static StringBuilder Join(StringBuilder sb, String sep, IConstructorArg[] types) 
+        {
+            if (types.Length > 0) 
+            {
+                sb.Append(types[0].GetType());
+                for (int i = 1; i < types.Length; i++) 
+                {
+                    sb.Append(sep).Append(types[i].GetType());
+                }
+            }
+            return sb;
+        }
+        #endregion text file serialization
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/ConfigurationModule.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/ConfigurationModule.cs b/lang/cs/Source/TANG/Tang/Formats/ConfigurationModule.cs
new file mode 100644
index 0000000..a75428b
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/ConfigurationModule.cs
@@ -0,0 +1,302 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    /**
+     * Allows applications to bundle sets of configuration options together into 
+     * discrete packages.  Unlike more conventional approaches,
+     * ConfigurationModules store such information in static data structures that
+     * can be statically discovered and sanity-checked. 
+     * 
+     * @see Org.Apache.Reef.Tang.Formats.TestConfigurationModule for more information and examples.
+     *
+     */
+    public class ConfigurationModule
+    {
+        public readonly ConfigurationModuleBuilder Builder;
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ConfigurationModule));
+        private readonly MonotonicHashSet<FieldInfo> reqSet = new MonotonicHashSet<FieldInfo>();
+        private readonly MonotonicHashMap<object, Type> setImpls = new MonotonicHashMap<object, Type>();
+        private readonly MonotonicMultiHashMap<object, Type> setImplSets = new MonotonicMultiHashMap<object, Type>();
+        private readonly MonotonicMultiHashMap<object, string> setLateImplSets = new MonotonicMultiHashMap<object, string>();
+        private readonly MonotonicMultiHashMap<object, string> setParamSets = new MonotonicMultiHashMap<object, string>();
+        private readonly MonotonicHashMap<object, string> setLateImpls = new MonotonicHashMap<object, string>();
+        private readonly MonotonicHashMap<object, string> setParams = new MonotonicHashMap<object, string>();
+
+        private readonly MonotonicHashMap<object, IList<Type>> setImplLists = new MonotonicHashMap<object, IList<Type>>();
+        private readonly MonotonicHashMap<object, IList<string>> setParamLists = new MonotonicHashMap<object, IList<string>>();
+        private readonly MonotonicHashMap<object, IList<string>> setLateImplLists = new MonotonicHashMap<object, IList<string>>();
+        
+        public ConfigurationModule(ConfigurationModuleBuilder builder) 
+        {
+            this.Builder = builder.DeepCopy();
+        }
+
+         //public final <T> ConfigurationModule set(Impl<T> opt, Class<? extends T> impl)
+        public ConfigurationModule Set<T, U>(IImpl<T> opt, GenericType<U> impl) 
+            where U : T 
+        {
+            Type implType = typeof(U);
+            
+            ConfigurationModule c = DeepCopy();
+            c.ProcessSet(opt);
+            if (c.Builder.SetOpts.Contains(opt)) 
+            {
+                c.setImplSets.Add(opt, implType);
+            } 
+            else 
+            {
+                c.setImpls.Add(opt, implType);
+            }
+            return c;
+        }
+
+        public ConfigurationModule Set<T>(IImpl<T> opt, string impl) 
+        {
+            ConfigurationModule c = DeepCopy();
+            c.ProcessSet(opt);
+            if (c.Builder.SetOpts.Contains(opt)) 
+            {
+                c.setLateImplSets.Add(opt, impl);
+            } 
+            else 
+            {
+                c.setLateImpls.Add(opt, impl);
+            }
+            return c;
+        }
+
+        public ConfigurationModule Set<T, U>(IParam<T> opt, GenericType<U> val) 
+            where U : T
+        {
+            Type t = typeof(U);
+            string n = ReflectionUtilities.GetAssemblyQualifiedName(t);
+            return Set(opt, n);
+        }
+
+        public ConfigurationModule Set(IParam<bool> opt, bool val)
+        {
+            return Set(opt, val);
+        }
+
+        ////TODO
+        ////public readonly ConfigurationModule set(Param<? extends Number> opt, Number val) 
+        ////{
+        ////    return set(opt, val);
+        ////}
+
+        public ConfigurationModule Set<T>(IParam<T> opt, string val) 
+        {
+            //var o = (IParam<object>)opt;
+            ConfigurationModule c = DeepCopy();
+            c.ProcessSet(opt);
+            if (c.Builder.SetOpts.Contains(opt)) 
+            {
+                c.setParamSets.Add(opt, val);
+            } 
+            else 
+            {
+                c.setParams.Add(opt, val);
+            }
+            return c;
+        }
+
+        public ConfigurationModule Set<T>(IImpl<IList<T>> opt, IList<string> impl)
+        {
+            ConfigurationModule c = DeepCopy();
+            c.ProcessSet(opt);
+            c.setLateImplLists.Add(opt, impl);
+            return c;
+        }
+
+        public ConfigurationModule Set<T>(IParam<IList<T>> opt, IList<string> impl)
+        {
+            ConfigurationModule c = DeepCopy();
+            c.ProcessSet(opt);
+            c.setParamLists.Add(opt, impl);
+            return c;
+        }
+
+        public ConfigurationModule Set<T>(IImpl<IList<T>> opt, IList<Type> impl)
+        {
+            ConfigurationModule c = DeepCopy();
+            c.ProcessSet(opt);
+            c.setImplLists.Add(opt, impl);
+            return c;
+        }
+
+        public IConfiguration Build()
+        {
+            ConfigurationModule c = DeepCopy();
+    
+            if (!c.reqSet.ContainsAll(c.Builder.ReqDecl)) 
+            {
+                ISet<FieldInfo> missingSet = new MonotonicHashSet<FieldInfo>();
+                foreach (FieldInfo f in c.Builder.ReqDecl) 
+                {
+                    if (!c.reqSet.Contains(f)) 
+                    {
+                        missingSet.Add(f);
+                    }
+                }
+                var e = new BindException(
+                    "Attempt to build configuration before setting required option(s): "
+                    + Builder.ToString(missingSet));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+  
+            foreach (Type clazz in c.Builder.FreeImpls.Keys) 
+            {
+                object i = c.Builder.FreeImpls.Get(clazz);
+                if (c.setImpls.ContainsKey(i))
+                {
+                    var cb = (ICsInternalConfigurationBuilder)c.Builder.B;
+                    cb.Bind(clazz, c.setImpls.Get(i));
+                } 
+                else if (c.setLateImpls.ContainsKey(i)) 
+                {
+                    c.Builder.B.Bind(ReflectionUtilities.GetAssemblyQualifiedName(clazz), c.setLateImpls.Get(i));
+                } 
+                else if (c.setImplSets.ContainsKey(i) || c.setLateImplSets.ContainsKey(i))
+                {
+                    foreach (Type clz in c.setImplSets.GetValuesForKey(i))
+                    {
+                        ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder) c.Builder.B;
+                        b.BindSetEntry(clazz, clz);
+                    }
+                    foreach (string s in c.setLateImplSets.GetValuesForKey(i))
+                    {
+                        ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder) c.Builder.B;
+                        b.BindSetEntry(clazz, s);
+                    }
+                } 
+                else if (c.setImplLists.ContainsKey(i))
+                {
+                    ICsConfigurationBuilder b = (ICsConfigurationBuilder) c.Builder.B;
+                    b.BindList(clazz, setImplLists.Get(i));
+                }
+                else if (c.setLateImplLists.ContainsKey(i))
+                {
+                    ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.Builder.B;
+                    b.BindList(clazz, setLateImplLists.Get(i));
+                }
+            }
+            
+            //for (Class<? extends Name<?>> clazz : c.builder.freeParams.Keys) {
+            foreach (Type clazz in c.Builder.FreeParams.Keys) 
+            {
+                object p = c.Builder.FreeParams.Get(clazz);
+                string s = c.setParams.Get(p);
+                bool foundOne = false;
+                if (s != null) 
+                {
+                    ICsConfigurationBuilder cb = c.Builder.B;
+                    cb.BindNamedParameter(clazz, s);
+                    foundOne = true;
+                }
+
+                IList<string> paramListStr = c.setParamLists.Get(p);
+                if (paramListStr != null)
+                {
+                    ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.Builder.B;
+                    b.BindList(clazz, paramListStr);
+                    foundOne = true;
+                }
+
+                foreach (string paramStr in c.setParamSets.GetValuesForKey(p)) 
+                {
+                    ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.Builder.B;
+                    b.BindSetEntry(clazz, paramStr);   
+                    foundOne = true;
+                }
+
+                if (!foundOne) 
+                {
+                    //if (!(p is OptionalParameter<object>)) //p: OptionalParameter<int>, "is" doesn't work here for generic type object
+                    if (!ReflectionUtilities.IsInstanceOfGeneric(p, typeof(OptionalParameter<>)))
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(), LOGGER);
+                    }
+                }
+            }
+            return c.Builder.B.Build();
+        }
+
+        public void AssertStaticClean() 
+        {
+            if (!(
+                setImpls.IsEmpty() &&
+                setParams.IsEmpty()) &&
+                setImplSets.IsEmpty() &&
+                setLateImplSets.IsEmpty() &&
+                setParamSets.IsEmpty() &&
+                setImplLists.IsEmpty() &&
+                setLateImplLists.IsEmpty() &&
+                setParamLists.IsEmpty() &&
+                setLateImpls.IsEmpty())
+            {
+                var e = new ClassHierarchyException("Detected statically set ConfigurationModule Parameter / Implementation.  set() should only be used dynamically.  Use bind...() instead.");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+        }
+
+        private ConfigurationModule DeepCopy()
+        {
+            ConfigurationModule cm = new ConfigurationModule(Builder.DeepCopy());
+            cm.setImpls.AddAll(setImpls);
+            cm.setParams.AddAll(setParams);
+            cm.setImplSets.AddAll(setImplSets);
+            cm.setParamSets.AddAll(setParamSets);
+            cm.setLateImplSets.AddAll(setLateImplSets);
+            cm.setImplLists.AddAll(setImplLists);
+            cm.setParamLists.AddAll(setParamLists);
+            cm.setLateImplLists.AddAll(setLateImplLists);
+            cm.setLateImpls.AddAll(setLateImpls);
+            cm.reqSet.AddAll(reqSet);
+            return cm;
+        }
+
+        private void ProcessSet(object impl)
+        {
+            FieldInfo f;
+            Builder.Map.TryGetValue(impl, out f);
+            if (f == null)
+            { 
+                var e = new ClassHierarchyException("Unknown Impl/Param when setting " + impl.GetType().Name + ".  Did you pass in a field from some other module?");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            if (!reqSet.Contains(f))
+            {
+                reqSet.Add(f);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/ConfigurationModuleBuilder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/ConfigurationModuleBuilder.cs b/lang/cs/Source/TANG/Tang/Formats/ConfigurationModuleBuilder.cs
new file mode 100644
index 0000000..e9640d5
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/ConfigurationModuleBuilder.cs
@@ -0,0 +1,519 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public class ConfigurationModuleBuilder
+    {
+        public readonly ICsConfigurationBuilder B = TangFactory.GetTang().NewConfigurationBuilder();
+        public readonly MonotonicHashSet<FieldInfo> ReqDecl = new MonotonicHashSet<FieldInfo>();
+        public readonly MonotonicHashSet<FieldInfo> OptDecl = new MonotonicHashSet<FieldInfo>();
+        public readonly MonotonicHashSet<object> SetOpts = new MonotonicHashSet<object>();
+        public readonly MonotonicHashMap<object, FieldInfo> Map = new MonotonicHashMap<object, FieldInfo>();
+        public readonly MonotonicHashMap<Type, object> FreeImpls = new MonotonicHashMap<Type, object>();
+        public readonly MonotonicHashMap<Type, object> FreeParams = new MonotonicHashMap<Type, object>(); //Type must extends from Name<>
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ConfigurationModuleBuilder));
+        private static readonly ISet<Type> ParamBlacklist = new MonotonicHashSet<Type>(new Type[] { typeof(IParam<>), typeof(IImpl<>) });
+        private static readonly ISet<string> ParamTypes =
+            new MonotonicHashSet<string>(new string[] { typeof(RequiredImpl<>).Name, typeof(OptionalImpl<>).Name, typeof(RequiredParameter<>).Name, typeof(OptionalParameter<>).Name });
+
+        private readonly MonotonicHashSet<FieldInfo> reqUsed = new MonotonicHashSet<FieldInfo>();
+        private readonly MonotonicHashSet<FieldInfo> optUsed = new MonotonicHashSet<FieldInfo>();
+        private readonly MonotonicHashMap<Type, string> lateBindClazz = new MonotonicHashMap<Type, string>();
+
+        public ConfigurationModuleBuilder()
+        {
+            foreach (FieldInfo f in GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
+            {
+                Type t = f.FieldType;
+                if (ParamBlacklist.Contains(t)) 
+                {
+                    var e = new ClassHierarchyException(
+                    "Found a field of type " + t + " which should be a Required/Optional Parameter/Implementation instead");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                } 
+                if (ParamTypes.Contains(t.Name)) 
+                {
+                    if (!f.IsPublic) 
+                    {
+                        var e = new ClassHierarchyException("Found a non-public configuration option in " + GetType() + ": " + f);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                
+                    if (!f.IsStatic) 
+                    {
+                        var e = new ClassHierarchyException("Found a non-static configuration option in " + GetType() + ": " + f);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                    if (!f.IsInitOnly)
+                    {
+                        var e = new ClassHierarchyException("Found a non-readonly configuration option in " + GetType() + ": " + f);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                    object o = null;
+                    try 
+                    {
+                        o = f.GetValue(null);
+                    } 
+                    catch (ArgumentException e)  
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                        var ex = new ClassHierarchyException("Could not look up field instance in " + GetType() + " field: " + f, e);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                    catch (FieldAccessException e) 
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                        var ex = new ClassHierarchyException("Could not look up field instance in " + GetType() + " field: " + f, e);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+
+                    if (Map.ContainsKey(o)) 
+                    {
+                        FieldInfo fi;
+                        Map.TryGetValue(o, out fi);
+                        var e = new ClassHierarchyException("Detected aliased instances in class " + GetType() + " for fields " + fi + " and " + f);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                    if (ReflectionUtilities.IsGenericTypeof(typeof(RequiredImpl<>), t) || ReflectionUtilities.IsGenericTypeof(typeof(RequiredParameter<>), t))  
+                    {
+                        ReqDecl.Add(f);
+                    } 
+                    else 
+                    {
+                        OptDecl.Add(f);
+                    }
+                    Map.Add(o, f);
+               }
+            }
+        }
+
+        private ConfigurationModuleBuilder(ConfigurationModuleBuilder c)
+        {
+            try
+            {
+                B.AddConfiguration(c.B.Build());
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                var ex = new ClassHierarchyException("Build error in ConfigurationModuleBuilder: " + e);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            ReqDecl.UnionWith(c.ReqDecl);
+            OptDecl.UnionWith(c.OptDecl);
+            reqUsed.UnionWith(c.reqUsed);
+            optUsed.UnionWith(c.optUsed);
+            SetOpts.UnionWith(c.SetOpts);
+            Map.AddAll(c.Map);
+            FreeImpls.AddAll(c.FreeImpls);
+            FreeParams.AddAll(c.FreeParams);
+            lateBindClazz.AddAll(c.lateBindClazz);
+        }
+
+        public ConfigurationModuleBuilder Merge(ConfigurationModule d) 
+        {
+            if (d == null) 
+            {
+                var e = new NullReferenceException("If merge() was passed a static final field that is initialized to non-null, then this is almost certainly caused by a circular class dependency.");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            try 
+            {
+                d.AssertStaticClean();
+            } 
+            catch (ClassHierarchyException ex) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                var e = new ClassHierarchyException(ReflectionUtilities.GetAssemblyQualifiedName(GetType()) + ": detected attempt to merge with ConfigurationModule that has had set() called on it", ex);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            ConfigurationModuleBuilder c = DeepCopy();
+            try 
+            {
+                c.B.AddConfiguration(d.Builder.B.Build());
+            } 
+            catch (BindException ex) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                var e = new ClassHierarchyException("Error in AddConfiguration in Merge: " + ex);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            c.ReqDecl.AddAll(d.Builder.ReqDecl);
+            c.OptDecl.AddAll(d.Builder.OptDecl);
+            c.reqUsed.AddAll(d.Builder.reqUsed);
+            c.optUsed.AddAll(d.Builder.optUsed);
+            c.SetOpts.AddAll(d.Builder.SetOpts);
+            //c.ListOpts.AddAll(d.Builder.ListOpts);
+            c.Map.AddAll(d.Builder.Map);
+            c.FreeImpls.AddAll(d.Builder.FreeImpls);
+            c.FreeParams.AddAll(d.Builder.FreeParams);
+            c.lateBindClazz.AddAll(d.Builder.lateBindClazz);
+    
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindSetEntry<U, T>(GenericType<U> iface, string impl) 
+            where U : Name<ISet<T>>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try 
+            {
+                ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.B;
+                b.BindSetEntry(typeof(U), impl);
+            } 
+            catch (BindException ex) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                var e = new ClassHierarchyException("Error in BindSetEntry: " + ex);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindSetEntry<U, V, T>(GenericType<U> iface, GenericType<V> impl) 
+            where U : Name<ISet<T>> 
+            where V : T
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try 
+            {
+                c.B.BindSetEntry<U, V, T>(iface, impl);
+            } 
+            catch (BindException ex) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER);
+                var e = new ClassHierarchyException("Error in BindSetEntry: " + ex);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindSetEntry<U, T>(GenericType<U> iface, IImpl<T> opt) 
+            where U : Name<ISet<T>> 
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            Type ifaceType = typeof(U);
+
+            c.ProcessUse(opt);
+            c.FreeImpls.Add(ifaceType, opt);  
+            
+            if (!SetOpts.Contains(opt)) 
+            { 
+                c.SetOpts.Add(opt); 
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindSetEntry<U, T>(GenericType<U> iface, IParam<T> opt)
+            where U : Name<ISet<T>>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            Type ifaceType = typeof(U);
+            c.ProcessUse(opt);
+
+            c.FreeParams.Add(ifaceType, opt);
+            if (!SetOpts.Contains(opt)) 
+            { 
+                c.SetOpts.Add(opt); 
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindList<U, T>(GenericType<U> iface, IList<string> impl)
+            where U : Name<IList<T>>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try
+            {
+                ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.B;
+                b.BindList(typeof(U), impl);
+            }
+            catch (BindException ex)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(new ClassHierarchyException("Error in BindList: " + ex), Level.Error, LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindList<U, T>(GenericType<U> iface, IImpl<IList<T>> opt)
+            where U : Name<IList<T>>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            Type ifaceType = typeof(U);
+
+            c.ProcessUse(opt);
+            c.FreeImpls.Add(ifaceType, opt);
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindList<U, T>(GenericType<U> iface, IParam<IList<T>> opt)
+            where U : Name<IList<T>>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            Type ifaceType = typeof(U);
+            c.ProcessUse(opt);
+
+            c.FreeParams.Add(ifaceType, opt);
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindImplementation<U, T>(GenericType<U> iface, GenericType<T> impl) 
+            where T : U
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try 
+            {
+                c.B.BindImplementation(iface, impl);
+            } 
+            catch (BindException e) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                 Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindImplementation: ", e), LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindImplementation<T>(GenericType<T> iface, string impl) 
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+
+            c.lateBindClazz.Add(typeof(T), impl);
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindImplementation<U, T>(GenericType<T> iface, IImpl<U> opt) 
+            where U : T
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            c.ProcessUse(opt);
+            Type ifaceType = typeof(T);
+            c.FreeImpls.Add(ifaceType, opt);
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> name, string value) 
+            where U : Name<T>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try 
+            {
+                c.B.BindNamedParameter<U, T>(name, value);
+            } 
+            catch (BindException e) 
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindNamedParameter: ", e), LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> name, IParam<T> opt)
+            where U : Name<T>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            c.ProcessUse(opt);
+            Type nameType = typeof(U);
+            c.FreeParams.Add(nameType, opt);
+            return c;
+        }
+
+        //public final <T> ConfigurationModuleBuilder bindNamedParameter(Class<? extends Name<T>> iface, Class<? extends T> impl)  
+        //if V is T, you'd better to use public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> iface, GenericType<T> impl) defined below
+        public ConfigurationModuleBuilder BindNamedParameter<U, V, T>(GenericType<U> iface, GenericType<V> impl)
+            where U : Name<T>
+            where V : T
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try
+            {
+                c.B.BindNamedParameter<U, V, T>(iface, impl);
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindNamedParameter: ", e), LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> iface, GenericType<T> impl)
+            where U : Name<T>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try
+            {
+                c.B.BindNamedParameter<U, T, T>(iface, impl);
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindNamedParameter: ", e), LOGGER);
+            }
+            return c;
+        }
+
+        // public final <T> ConfigurationModuleBuilder bindNamedParameter(Class<? extends Name<T>> iface, Impl<? extends T> opt)
+        //if ValueType is T, you would better to use public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> iface, IImpl<T> opt)
+        public ConfigurationModuleBuilder BindNamedParameter<U, V, T>(GenericType<U> iface, IImpl<V> opt)
+            where U : Name<T>
+            where V : T
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            c.ProcessUse(opt);
+            Type ifaceType = typeof(U);
+            c.FreeImpls.Add(ifaceType, opt);
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> iface, IImpl<T> opt)
+            where U : Name<T>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            c.ProcessUse(opt);
+            Type ifaceType = typeof(U);
+            c.FreeImpls.Add(ifaceType, opt);
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindConstructor<T, U>(GenericType<T> clazz, GenericType<U> constructor)
+            where U : IExternalConstructor<T>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            try
+            {
+               c.B.BindConstructor<T, U>(clazz, constructor);
+            }
+            catch (BindException e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindConstructor: ", e), LOGGER);
+            }
+            return c;
+        }
+
+        public ConfigurationModuleBuilder BindConstructor<T, U>(GenericType<T> cons, IImpl<U> v)
+            where U : IExternalConstructor<T>
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+            c.ProcessUse(v);
+            Type consType = typeof(T);
+            var i = (IImpl<object>)v;
+            c.FreeImpls.Add(consType, i);
+            return c;
+        }
+
+        public ConfigurationModule Build()
+        {
+            ConfigurationModuleBuilder c = DeepCopy();
+    
+            if (!(c.reqUsed.ContainsAll(c.ReqDecl) && c.optUsed.ContainsAll(c.OptDecl))) 
+            {
+                ISet<FieldInfo> fset = new MonotonicHashSet<FieldInfo>();
+                foreach (FieldInfo f in c.ReqDecl) 
+                {
+                    if (!c.reqUsed.Contains(f)) 
+                    {
+                        fset.Add(f);
+                    }
+                }
+                foreach (FieldInfo f in c.OptDecl) 
+                {
+                    if (!c.optUsed.Contains(f)) 
+                    {
+                        fset.Add(f);
+                    }
+                }
+                var e = new ClassHierarchyException(
+                    "Found declared options that were not used in binds: "
+                    + ToString(fset));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            foreach (Type clz in c.lateBindClazz.Keys) 
+            {
+                try 
+                {
+                    c.B.Bind(ReflectionUtilities.GetAssemblyQualifiedName(clz), c.lateBindClazz.Get(clz));
+                } 
+                catch (NameResolutionException e) 
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    var ex = new ClassHierarchyException("ConfigurationModule refers to unknown class: " + c.lateBindClazz.Get(clz), e);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                } 
+                catch (BindException e) 
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    var ex = new ClassHierarchyException("bind failed while initializing ConfigurationModuleBuilder", e);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+            }
+            return new ConfigurationModule(c);
+        }
+
+        public ConfigurationModuleBuilder DeepCopy() 
+        {
+            return new ConfigurationModuleBuilder(this);
+        }
+
+        public string ToString(ISet<FieldInfo> s) 
+        {
+            StringBuilder sb = new StringBuilder("{");
+            bool first = true;
+            foreach (FieldInfo f in s) 
+            {
+                sb.Append((first ? " " : ", ") + f.Name);
+                first = false;
+            }
+            sb.Append(" }");
+            return sb.ToString();
+        }
+
+        private void ProcessUse(object impl)
+        {
+            FieldInfo f;
+            Map.TryGetValue(impl, out f);
+            if (f == null)
+            {
+                var e = new ClassHierarchyException("Unknown Impl/Param when binding " + impl.GetType().Name + ".  Did you pass in a field from some other module?");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            if (!reqUsed.Contains(f))
+            {
+                reqUsed.Add(f);
+            }
+            if (!optUsed.Contains(f))
+            {
+                optUsed.Add(f);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/IConfigurationSerializer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/IConfigurationSerializer.cs b/lang/cs/Source/TANG/Tang/Formats/IConfigurationSerializer.cs
new file mode 100644
index 0000000..ec3baac
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/IConfigurationSerializer.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    [DefaultImplementation(typeof(AvroConfigurationSerializer), "default")]
+    public interface IConfigurationSerializer
+    {
+        void ToFileStream(IConfiguration c, string fileName);
+
+        void ToFile(IConfiguration c, string fileName);
+
+        byte[] ToByteArray(IConfiguration c);
+
+        string ToBase64String(IConfiguration c);
+
+        string ToString(IConfiguration c);
+
+        IConfiguration FromFileStream(string fileName);
+
+        IConfiguration FromFile(string fileName);
+
+        IConfiguration FromByteArray(byte[] bytes);
+
+        IConfiguration FromBase64String(string serializedConfig);
+
+        IConfiguration FromString(string josonString);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/IImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/IImpl.cs b/lang/cs/Source/TANG/Tang/Formats/IImpl.cs
new file mode 100644
index 0000000..70a454d
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/IImpl.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public interface IImpl<T>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/IParam.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/IParam.cs b/lang/cs/Source/TANG/Tang/Formats/IParam.cs
new file mode 100644
index 0000000..fa2f93b
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/IParam.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public interface IParam<T>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/OptionalImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/OptionalImpl.cs b/lang/cs/Source/TANG/Tang/Formats/OptionalImpl.cs
new file mode 100644
index 0000000..5ba77aa
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/OptionalImpl.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public sealed class OptionalImpl<T> : IImpl<T> 
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/OptionalParameter.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/OptionalParameter.cs b/lang/cs/Source/TANG/Tang/Formats/OptionalParameter.cs
new file mode 100644
index 0000000..35f0993
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/OptionalParameter.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public sealed class OptionalParameter<T> : IParam<T> 
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/Provides.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/Provides.cs b/lang/cs/Source/TANG/Tang/Formats/Provides.cs
new file mode 100644
index 0000000..aa5b99b
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/Provides.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public sealed class Provides<T> 
+    { 
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/RequiredImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/RequiredImpl.cs b/lang/cs/Source/TANG/Tang/Formats/RequiredImpl.cs
new file mode 100644
index 0000000..4181dce
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/RequiredImpl.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public sealed class RequiredImpl<T> : IImpl<T> 
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Formats/RequiredParameter.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Formats/RequiredParameter.cs b/lang/cs/Source/TANG/Tang/Formats/RequiredParameter.cs
new file mode 100644
index 0000000..7c13dd3
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Formats/RequiredParameter.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Formats
+{
+    public sealed class RequiredParameter<T> : IParam<T> 
+    {
+    }
+}


[13/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/ICsConfigurationBuilder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/ICsConfigurationBuilder.cs b/lang/cs/Source/TANG/Tang/Interface/ICsConfigurationBuilder.cs
new file mode 100644
index 0000000..c6e6864
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/ICsConfigurationBuilder.cs
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface ICsConfigurationBuilder : IConfigurationBuilder
+    {
+        /// <summary>
+        /// Binds the named parameter.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <param name="value">The value.</param>
+        ICsConfigurationBuilder BindNamedParameter(Type name, string value);  //name must extend from Name<T>
+
+        /// <summary>
+        /// Binds the class impl as the implementation of the interface iface
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsConfigurationBuilder BindImplementation(Type iface, Type impl);
+
+        /// <summary>
+        /// Binds the List entry.
+        /// </summary>
+        /// <param name="iface">The iface. It is a Name of IList</param>
+        /// <param name="impl">The impl.</param>
+        ICsConfigurationBuilder BindList(Type iface, IList<Type> impl);
+
+        /// <summary>
+        /// Binds the named parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="name">The name.</param>
+        /// <param name="value">The value.</param>
+        ICsConfigurationBuilder BindNamedParameter<U, T>(GenericType<U> name, string value)
+            where U : Name<T>;
+
+        /// <summary>
+        /// Binds the named parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="V"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsConfigurationBuilder BindNamedParameter<U, V, T>(GenericType<U> iface, GenericType<V> impl)
+            where U : Name<T>
+            where V : T;
+
+        /// <summary>
+        /// Binds the implementation.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsConfigurationBuilder BindImplementation<U, T>(GenericType<U> iface, GenericType<T> impl)
+            where T : U;
+
+        //public <T> void bindConstructor(Class<T> c, Class<? extends ExternalConstructor<? extends T>> v) throws BindException;
+        ICsConfigurationBuilder BindConstructor<T, U>(GenericType<T> c, GenericType<U> v)
+            where U : IExternalConstructor<T>;
+  
+        //public <T> void bindSetEntry(Class<? extends Name<Set<T>>> iface, String value) throws BindException;
+        ICsConfigurationBuilder BindSetEntry<U, T>(GenericType<U> iface, string value)
+            where U : Name<ISet<T>>;
+
+         //public <T> void bindSetEntry(Class<? extends Name<Set<T>>> iface, Class<? extends T> impl) throws BindException;
+        ICsConfigurationBuilder BindSetEntry<U, V, T>(GenericType<U> iface, GenericType<V> impl)
+            where U : Name<ISet<T>>
+            where V : T;
+
+        ICsConfigurationBuilder BindList<U, V, T>(GenericType<U> iface, IList<GenericType<V>> impl)
+            where U : Name<IList<T>>
+            where V : T;
+
+        ICsConfigurationBuilder BindList<U, T>(GenericType<U> iface, IList<string> impl)
+            where U : Name<IList<T>>;
+
+        ICsConfigurationBuilder BindNamedParameter<U, V, T>()
+            where U : Name<T>
+            where V : T;
+
+        ICsConfigurationBuilder BindNamedParam<TName, TType>(string str) where TName : Name<TType>;
+
+        ICsConfigurationBuilder BindStringNamedParam<T>(string str) where T : Name<string>;
+
+        ICsConfigurationBuilder BindIntNamedParam<T>(string str) where T : Name<int>;
+
+        ICsConfigurationBuilder BindImplementation<T1, T2>() where T2 : T1;
+
+        ICsConfigurationBuilder BindSetEntry<T1, T2, T3>() where T1 : Name<ISet<T3>> where T2 : T3;
+
+        ICsConfigurationBuilder BindSetEntry<U, T>(string value) where U : Name<ISet<T>>;
+
+        ICsConfigurationBuilder BindList<U, T>(IList<string> impl) where U : Name<IList<T>>;
+
+        ICsConfigurationBuilder BindConstructor<T, U>() where U : IExternalConstructor<T>;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/ICsInternalConfigurationBuilder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/ICsInternalConfigurationBuilder.cs b/lang/cs/Source/TANG/Tang/Interface/ICsInternalConfigurationBuilder.cs
new file mode 100644
index 0000000..5386edf
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/ICsInternalConfigurationBuilder.cs
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    internal interface ICsInternalConfigurationBuilder : ICsConfigurationBuilder
+    {
+        /// <summary>
+        /// Bind named parameters, implementations or external constructors, depending
+        /// on the types of the classes passed in.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsInternalConfigurationBuilder Bind(Type iface, Type impl);
+
+        /// <summary>
+        /// Binds the named parameter.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsInternalConfigurationBuilder BindNamedParameter(Type iface, Type impl);
+
+        /// <summary>
+        /// Binds an external constructor.
+        /// </summary>
+        /// <param name="c">The c.</param>
+        /// <param name="v">The v.</param>
+        ICsInternalConfigurationBuilder BindConstructor(Type c, Type v);
+
+        /// <summary>
+        /// Binds the set entry.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="value">The value.</param>
+        ICsInternalConfigurationBuilder BindSetEntry(Type iface, string value);
+
+        /// <summary>
+        /// Binds the set entry.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsInternalConfigurationBuilder BindSetEntry(Type iface, Type impl);
+
+        /// <summary>
+        /// Binds the List entry.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        ICsInternalConfigurationBuilder BindList(Type iface, IList<string> impl);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/IExternalConstructor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/IExternalConstructor.cs b/lang/cs/Source/TANG/Tang/Interface/IExternalConstructor.cs
new file mode 100644
index 0000000..eb7bc84
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/IExternalConstructor.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Interface
+{
+    public interface IExternalConstructor<out T>
+    {
+        T NewInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/IInjector.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/IInjector.cs b/lang/cs/Source/TANG/Tang/Interface/IInjector.cs
new file mode 100644
index 0000000..282a9d1
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/IInjector.cs
@@ -0,0 +1,180 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface IInjector
+    {
+        /// <summary>
+        /// Gets an instance of iface, or the implementation that has been bound to it.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <returns></returns>
+        object GetInstance(Type iface);
+
+        /// <summary>
+        /// Gets the instance for a given class
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <returns></returns>
+        T GetInstance<T>() where T : class;
+
+        /// <summary>
+        /// Gets the instance for a given class name
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <returns></returns>
+        object GetInstance(string iface);
+
+        /// <summary>
+        /// Get an instance of the named parameter. 
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <typeparam name="U"></typeparam>
+        /// <param name="clazz">The clazz.</param>
+        /// <returns></returns>
+        U GetNamedInstance<T, U>(GenericType<T> clazz) where T : Name<U>;
+
+        /// <summary>
+        /// Get an instance of the named parameter. 
+        /// </summary>
+        /// <param name="t">t, it must inherit from Name</param>
+        /// <returns></returns>
+        object GetNamedInstance(Type t);
+
+        /// <summary>
+        /// Gets the injection plan.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        InjectionPlan GetInjectionPlan(Type name);
+
+        /// <summary>
+        /// Gets the injection plan for a given class name
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        InjectionPlan GetInjectionPlan(String name);
+
+        /// <summary>
+        /// Binds the aspect.
+        /// </summary>
+        /// <param name="a">A.</param>
+        void BindAspect(Aspect a);
+
+        /// <summary>
+        /// Gets the aspect.
+        /// </summary>
+        /// <returns></returns>
+        Aspect GetAspect();
+
+        /// <summary>
+        /// Determines whether the specified name is injectable.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns>
+        ///   <c>true</c> if the specified name is injectable; otherwise, <c>false</c>.
+        /// </returns>
+        bool IsInjectable(string name);
+
+        /// <summary>
+        /// Determines whether [is parameter set] [the specified name].
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns>
+        ///   <c>true</c> if [is parameter set] [the specified name]; otherwise, <c>false</c>.
+        /// </returns>
+        bool IsParameterSet(String name);
+
+        /// <summary>
+        /// Determines whether the specified clazz is injectable.
+        /// </summary>
+        /// <param name="clazz">The clazz.</param>
+        /// <returns>
+        ///   <c>true</c> if the specified clazz is injectable; otherwise, <c>false</c>.
+        /// </returns>
+        bool IsInjectable(Type clazz);
+
+        /// <summary>
+        /// Determines whether [is parameter set] [the specified name].
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns>
+        ///   <c>true</c> if [is parameter set] [the specified name]; otherwise, <c>false</c>.
+        /// </returns>
+        bool IsParameterSet(Type name);
+
+        /// <summary>
+        /// Forks the injector.
+        /// </summary>
+        /// <returns></returns>
+        IInjector ForkInjector();
+
+        /// <summary>
+        /// Forks the injector.
+        /// </summary>
+        /// <param name="configurations">The configurations.</param>
+        /// <returns></returns>
+        IInjector ForkInjector(IConfiguration[] configurations);
+
+        /// <summary>
+        /// Binds the volatile instance.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="inst">The inst.</param>
+        void BindVolatileInstance<T>(GenericType<T> iface, T inst);
+
+        /// <summary>
+        /// Binds the volatile parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="inst">The inst.</param>
+        void BindVolatileParameter<U, T>(GenericType<U> iface, T inst) where U : Name<T>;
+
+        /// <summary>
+        /// Gets the named instance.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <typeparam name="U"></typeparam>
+        /// <returns></returns>
+        U GetNamedInstance<T, U>() where T : Name<U>;
+
+        /// <summary>
+        /// Binds the volatile instance.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="inst">The inst.</param>
+        void BindVolatileInstance<T>(T inst);
+
+        /// <summary>
+        /// Binds the volatile parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="inst">The inst.</param>
+        void BindVolatileParameter<U, T>(T inst) where U : Name<T>;
+      }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Interface/ITang.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Interface/ITang.cs b/lang/cs/Source/TANG/Tang/Interface/ITang.cs
new file mode 100644
index 0000000..673662f
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Interface/ITang.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Interface
+{
+    public interface ITang
+    {
+        IInjector NewInjector();
+        IInjector NewInjector(IConfiguration[] confs);
+        IInjector NewInjector(IConfiguration confs);
+        IInjector NewInjector(string[] assemblies, string configurationFileName);
+        IInjector NewInjector(string[] assemblies, IDictionary<string, string> configurations);
+        IInjector NewInjector(string[] assemblies, IList<KeyValuePair<string, string>> configurations);
+        IClassHierarchy GetClassHierarchy(string[] assemblies);
+        ICsClassHierarchy GetDefaultClassHierarchy();
+        ICsClassHierarchy GetDefaultClassHierarchy(string[] assemblies, Type[] parameterParsers);
+
+        ICsConfigurationBuilder NewConfigurationBuilder();
+        ICsConfigurationBuilder NewConfigurationBuilder(string[] assemblies);
+        ICsConfigurationBuilder NewConfigurationBuilder(IConfiguration[] confs);
+        ICsConfigurationBuilder NewConfigurationBuilder(IConfiguration conf);
+        ICsConfigurationBuilder NewConfigurationBuilder(string[] assemblies, IConfiguration[] confs, Type[] parameterParsers);
+        IConfigurationBuilder NewConfigurationBuilder(IClassHierarchy classHierarchy);
+        ICsConfigurationBuilder NewConfigurationBuilder(ICsClassHierarchy classHierarchy);
+
+        ICsConfigurationBuilder NewConfigurationBuilder(Type[] parameterParsers);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Properties/AssemblyInfo.cs b/lang/cs/Source/TANG/Tang/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..eb9116c
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tang")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tang")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("9be5f89c-7b7e-4236-ac54-10fda8eef58e")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferClassHierarchy.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferClassHierarchy.cs b/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferClassHierarchy.cs
new file mode 100644
index 0000000..15ae379
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferClassHierarchy.cs
@@ -0,0 +1,473 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using ProtoBuf;
+
+namespace Org.Apache.Reef.Tang.Protobuf
+{
+    public class ProtocolBufferClassHierarchy : IClassHierarchy
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ProtocolBufferClassHierarchy));
+
+        private IPackageNode rootNode;
+        private IDictionary<string, INode> lookupTable = new Dictionary<string, INode>();
+
+        public static void Serialize(string fileName, IClassHierarchy classHierarchy)
+        {
+            ClassHierarchyProto.Node node = Serialize(classHierarchy);
+
+            using (var file = File.Create(fileName))
+            {
+                Serializer.Serialize<ClassHierarchyProto.Node>(file, node);
+            }
+        }
+
+        public static ClassHierarchyProto.Node Serialize(IClassHierarchy classHierarchy)
+        {
+            return SerializeNode(classHierarchy.GetNamespace());
+        }
+
+        private static ClassHierarchyProto.Node SerializeNode(INode n)
+        {
+            IList<ClassHierarchyProto.Node> children = new List<ClassHierarchyProto.Node>();
+
+            foreach (INode child in n.GetChildren())
+            {
+                children.Add(SerializeNode(child));
+            }
+
+            if (n is IClassNode)
+            {
+                IClassNode cn = (IClassNode)n;
+                IList<IConstructorDef> injectable = cn.GetInjectableConstructors();
+                IList<IConstructorDef> all = cn.GetAllConstructors();
+                IList<IConstructorDef> others = new List<IConstructorDef>(all);
+
+                foreach (var c in injectable)
+                {
+                    others.Remove(c);
+                }
+
+                IList<ClassHierarchyProto.ConstructorDef> injectableConstructors = new List<ClassHierarchyProto.ConstructorDef>();
+                foreach (IConstructorDef inj in injectable)
+                {
+                    injectableConstructors.Add(SerializeConstructorDef(inj));
+                }
+
+                IList<ClassHierarchyProto.ConstructorDef> otherConstructors = new List<ClassHierarchyProto.ConstructorDef>();
+                foreach (IConstructorDef other in others)
+                {
+                    otherConstructors.Add(SerializeConstructorDef(other));
+                }
+
+                List<string> implFullNames = new List<string>();
+                foreach (IClassNode impl in cn.GetKnownImplementations())
+                {
+                    implFullNames.Add(impl.GetFullName());  //we use class fully qualifed name 
+                }
+
+                return NewClassNode(cn.GetName(), cn.GetFullName(),
+                    cn.IsInjectionCandidate(), cn.IsExternalConstructor(), cn.IsUnit(),
+                    injectableConstructors, otherConstructors, implFullNames, children);
+            }
+            if (n is INamedParameterNode)
+            {
+                INamedParameterNode np = (INamedParameterNode)n;
+                return NewNamedParameterNode(np.GetName(), np.GetFullName(),
+                    np.GetSimpleArgName(), np.GetFullArgName(), np.IsSet(), np.IsList(), np.GetDocumentation(),
+                    np.GetShortName(), np.GetDefaultInstanceAsStrings(), children);
+            }
+            if (n is IPackageNode)
+            {
+                return NewPackageNode(n.GetName(), n.GetFullName(), children);
+            }
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Encountered unknown type of Node: " + n), LOGGER);
+            return null;
+        }
+
+        private static ClassHierarchyProto.ConstructorDef SerializeConstructorDef(IConstructorDef def)
+        {
+            IList<ClassHierarchyProto.ConstructorArg> args = new List<ClassHierarchyProto.ConstructorArg>();
+            foreach (IConstructorArg arg in def.GetArgs())
+            {
+                args.Add(NewConstructorArg(arg.Gettype(), arg.GetNamedParameterName(), arg.IsInjectionFuture()));
+            }
+            return newConstructorDef(def.GetClassName(), args);
+        }
+
+        private static ClassHierarchyProto.ConstructorArg NewConstructorArg(
+            string fullArgClassName, string namedParameterName, bool isFuture)
+        {
+            ClassHierarchyProto.ConstructorArg constArg = new ClassHierarchyProto.ConstructorArg();
+            constArg.full_arg_class_name = fullArgClassName;
+            constArg.named_parameter_name = namedParameterName;
+            constArg.is_injection_future = isFuture;
+            return constArg;
+        }
+
+        private static ClassHierarchyProto.ConstructorDef newConstructorDef(
+             String fullClassName, IList<ClassHierarchyProto.ConstructorArg> args)
+        {
+            ClassHierarchyProto.ConstructorDef constDef = new ClassHierarchyProto.ConstructorDef();
+            constDef.full_class_name = fullClassName;
+            foreach (ClassHierarchyProto.ConstructorArg arg in args)
+            {
+                constDef.args.Add(arg);
+            }
+
+            return constDef;
+        }
+
+        private static ClassHierarchyProto.Node NewClassNode(String name,
+            String fullName, bool isInjectionCandidate,
+            bool isExternalConstructor, bool isUnit,
+            IList<ClassHierarchyProto.ConstructorDef> injectableConstructors,
+            IList<ClassHierarchyProto.ConstructorDef> otherConstructors,
+            IList<String> implFullNames, IList<ClassHierarchyProto.Node> children)
+        {
+            ClassHierarchyProto.ClassNode classNode = new ClassHierarchyProto.ClassNode();
+            classNode.is_injection_candidate = isInjectionCandidate;
+            foreach (var ic in injectableConstructors)
+            {
+                classNode.InjectableConstructors.Add(ic);
+            }
+
+            foreach (var oc in otherConstructors)
+            {
+                classNode.OtherConstructors.Add(oc);
+            }
+            foreach (var implFullName in implFullNames)
+            {
+                classNode.impl_full_names.Add(implFullName);
+            }
+
+            ClassHierarchyProto.Node n = new ClassHierarchyProto.Node();
+            n.name = name;
+            n.full_name = fullName;
+            n.class_node = classNode;
+
+            foreach (var c in children)
+            {
+                n.children.Add(c);
+            }
+
+            return n;
+        }
+
+        private static ClassHierarchyProto.Node NewNamedParameterNode(string name,
+            string fullName, string simpleArgClassName, string fullArgClassName,
+            bool isSet, bool isList, string documentation, // can be null
+            string shortName, // can be null
+            string[] instanceDefault, // can be null
+            IList<ClassHierarchyProto.Node> children)
+        {
+            ClassHierarchyProto.NamedParameterNode namedParameterNode = new ClassHierarchyProto.NamedParameterNode();
+            namedParameterNode.simple_arg_class_name = simpleArgClassName;
+            namedParameterNode.full_arg_class_name = fullArgClassName;
+            namedParameterNode.is_set = isSet;
+            namedParameterNode.is_list = isList;
+
+            if (documentation != null)
+            {
+                namedParameterNode.documentation = documentation;
+            }
+
+            if (shortName != null)
+            {
+                namedParameterNode.short_name = shortName;
+            }
+
+            foreach (var id in instanceDefault)
+            {
+                namedParameterNode.instance_default.Add(id);
+            }
+
+            ClassHierarchyProto.Node n = new ClassHierarchyProto.Node();
+            n.name = name;
+            n.full_name = fullName;
+            n.named_parameter_node = namedParameterNode;
+
+            foreach (var c in children)
+            {
+                n.children.Add(c);
+            }
+
+            return n;
+        }
+
+        private static ClassHierarchyProto.Node NewPackageNode(string name,
+            string fullName, IList<ClassHierarchyProto.Node> children)
+        {
+            ClassHierarchyProto.PackageNode packageNode = new ClassHierarchyProto.PackageNode();
+            ClassHierarchyProto.Node n = new ClassHierarchyProto.Node();
+            n.name = name;
+            n.full_name = fullName;
+            n.package_node = packageNode;
+
+            foreach (var c in children)
+            {
+                n.children.Add(c);
+            }
+
+            return n;
+        }
+
+        public static IClassHierarchy DeSerialize(string fileName)
+        {
+            ClassHierarchyProto.Node root;
+
+            using (var file = File.OpenRead(fileName))
+            {
+                root = Serializer.Deserialize<ClassHierarchyProto.Node>(file);
+            }
+
+            return new ProtocolBufferClassHierarchy(root);
+        }
+
+        public ProtocolBufferClassHierarchy()  //create a ProtocolBufferClassHierarchy with empty nodes and lookup table. It can be used to merge other class hierarchy to it
+        {
+            this.rootNode = new PackageNodeImpl();
+        }
+
+        public ProtocolBufferClassHierarchy(ClassHierarchyProto.Node root)
+        {
+            this.rootNode = new PackageNodeImpl();
+            if (root.package_node == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Expected a package node.  Got: " + root), LOGGER); 
+            }
+            // Register all the classes.
+            foreach (ClassHierarchyProto.Node child in root.children)
+            {
+                ParseSubHierarchy(rootNode, child);
+            }
+            
+            BuildHashTable(rootNode);
+
+            foreach (ClassHierarchyProto.Node child in root.children)
+            {
+                WireUpInheritanceRelationships(child);
+            }
+        }
+
+        public void BuildHashTable(INode n)
+        {
+            foreach (INode child in n.GetChildren())
+            {
+                lookupTable.Add(child.GetFullName(), child);
+                BuildHashTable(child);
+            }
+        }
+
+        private static void ParseSubHierarchy(INode parent, ClassHierarchyProto.Node n)
+        {
+            INode parsed = null;
+            if (n.package_node != null)
+            {
+                parsed = new PackageNodeImpl(parent, n.name, n.full_name);
+            }
+            else if (n.named_parameter_node != null)
+            {
+                ClassHierarchyProto.NamedParameterNode np = n.named_parameter_node;
+                parsed = new NamedParameterNodeImpl(parent, n.name,
+                    n.full_name, np.full_arg_class_name, np.simple_arg_class_name,
+                    np.is_set, np.is_list, np.documentation, np.short_name,
+                    np.instance_default.ToArray());
+            }
+            else if (n.class_node != null)
+            {
+                ClassHierarchyProto.ClassNode cn = n.class_node;
+                IList<IConstructorDef> injectableConstructors = new List<IConstructorDef>();
+                IList<IConstructorDef> allConstructors = new List<IConstructorDef>();
+
+                foreach (ClassHierarchyProto.ConstructorDef injectable in cn.InjectableConstructors)
+                {
+                    IConstructorDef def = ParseConstructorDef(injectable, true);
+                    injectableConstructors.Add(def);
+                    allConstructors.Add(def);
+                }
+                foreach (ClassHierarchyProto.ConstructorDef other in cn.OtherConstructors)
+                {
+                    IConstructorDef def = ParseConstructorDef(other, false);
+                    allConstructors.Add(def);
+
+                }
+
+                IConstructorDef[] dummy = new ConstructorDefImpl[0];
+                parsed = new ClassNodeImpl(parent, n.name, n.full_name,
+                cn.is_unit, cn.is_injection_candidate,
+                cn.is_external_constructor, injectableConstructors,
+                allConstructors, cn.default_implementation);
+            }
+            else
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Bad protocol buffer: got abstract node" + n), LOGGER); 
+            }
+
+            foreach (ClassHierarchyProto.Node child in n.children)
+            {
+                ParseSubHierarchy(parsed, child);
+            }
+        }
+
+        private static IConstructorDef ParseConstructorDef(ClassHierarchyProto.ConstructorDef def, bool isInjectable)
+        {
+            IList<IConstructorArg> args = new List<IConstructorArg>();
+            foreach (ClassHierarchyProto.ConstructorArg arg in def.args)
+            {
+                args.Add(new ConstructorArgImpl(arg.full_arg_class_name, arg.named_parameter_name, arg.is_injection_future));
+            }
+            return new ConstructorDefImpl(def.full_class_name, args.ToArray(), isInjectable);
+        }
+
+        private void WireUpInheritanceRelationships(ClassHierarchyProto.Node n)
+        {
+            if (n.class_node != null)
+            {
+                ClassHierarchyProto.ClassNode cn = n.class_node;
+                IClassNode iface = null;
+                try
+                {
+                    iface = (IClassNode)GetNode(n.full_name);
+                }
+                catch (NameResolutionException e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    var ex = new IllegalStateException("When reading protocol buffer node "
+                        + n.full_name + " does not exist.  Full record is " + n, e);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); 
+                }
+                foreach (String impl in cn.impl_full_names)
+                {
+                    try
+                    {
+                        iface.PutImpl((IClassNode)GetNode(impl));
+                    }
+                    catch (NameResolutionException e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                        var ex = new IllegalStateException("When reading protocol buffer node "
+                            + n + " refers to non-existent implementation:" + impl);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); 
+
+                    }
+                    catch (InvalidCastException e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                        try
+                        {
+                            var ex = new IllegalStateException(
+                                "When reading protocol buffer node " + n
+                                + " found implementation" + GetNode(impl)
+                                + " which is not a ClassNode!");
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                        }
+                        catch (NameResolutionException ne)
+                        {
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ne, Level.Error, LOGGER);
+                            var ex = new IllegalStateException(
+                                "Got 'cant happen' exception when producing error message for " + e);
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                        }
+                    }
+                }
+            }
+        }
+
+        public INode GetNode(String fullName)
+        {
+            INode ret;
+            lookupTable.TryGetValue(fullName, out ret);
+            if (ret == null)
+            {
+                var ex = new NameResolutionException(fullName, "Cannot resolve the name from the class hierarchy during deserialization: " + fullName);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            return ret;
+        }
+
+        public INode GetNamespace()
+        {
+            return rootNode;
+        }
+
+        public bool IsImplementation(IClassNode inter, IClassNode impl)
+        {
+            return impl.IsImplementationOf(inter);
+        }
+
+        public IClassHierarchy Merge(IClassHierarchy ch)
+        {
+            if (this == ch)
+            {
+                return this;
+            }
+
+            if (!(ch is ProtocolBufferClassHierarchy))
+            {         
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException(
+                                                            "Cannot merge ExternalClassHierarchies yet!"), LOGGER);
+            }
+
+            ProtocolBufferClassHierarchy pch = (ProtocolBufferClassHierarchy)ch;
+            foreach (var pair in pch.lookupTable)
+            {
+                if (!this.lookupTable.ContainsKey(pair.Key))
+                {
+                    this.lookupTable.Add(pair);
+                }
+            }
+
+            foreach (INode n in ch.GetNamespace().GetChildren())
+            {
+                if (!rootNode.Contains(n.GetFullName()))
+                {
+                    if (n is INamedParameterNode)
+                    {
+                        INamedParameterNode np = (INamedParameterNode) n;
+                        new NamedParameterNodeImpl(this.rootNode, np.GetName(),
+                                                   np.GetFullName(), np.GetFullArgName(), np.GetSimpleArgName(),
+                                                   np.IsSet(), np.IsList(), np.GetDocumentation(), np.GetShortName(),
+                                                   np.GetDefaultInstanceAsStrings().ToArray());
+                    }
+                    else if (n is IClassNode)
+                    {
+                        IClassNode cn = (IClassNode) n;
+                        new ClassNodeImpl(rootNode, cn.GetName(), cn.GetFullName(),
+                                          cn.IsUnit(), cn.IsInjectionCandidate(),
+                                          cn.IsExternalConstructor(), cn.GetInjectableConstructors(),
+                                          cn.GetAllConstructors(), cn.GetDefaultImplementation());
+                    }
+                }
+            }
+
+            return this;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferInjectionPlan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferInjectionPlan.cs b/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferInjectionPlan.cs
new file mode 100644
index 0000000..8d503ae
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Protobuf/ProtocolBufferInjectionPlan.cs
@@ -0,0 +1,204 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using ProtoBuf;
+
+namespace Org.Apache.Reef.Tang.Protobuf
+{
+    public class ProtocolBufferInjectionPlan
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ProtocolBufferInjectionPlan));
+
+        private static InjectionPlanProto.InjectionPlan NewConstructor(string fullName, List<InjectionPlanProto.InjectionPlan> plans) 
+        {
+            InjectionPlanProto.Constructor cconstr = new InjectionPlanProto.Constructor();
+            foreach (InjectionPlanProto.InjectionPlan p in plans)
+            {
+                cconstr.args.Add(p);
+            }
+
+            InjectionPlanProto.InjectionPlan plan = new InjectionPlanProto.InjectionPlan();
+            plan.name = fullName;
+            plan.constructor = cconstr;
+            return plan;
+        }
+
+        private static InjectionPlanProto.InjectionPlan NewSubplan(string fullName, int selectedPlan, List<InjectionPlanProto.InjectionPlan> plans) 
+        {
+            InjectionPlanProto.Subplan subPlan = new InjectionPlanProto.Subplan();
+
+            subPlan.selected_plan = selectedPlan;
+            foreach (InjectionPlanProto.InjectionPlan p in plans)
+            {
+                subPlan.plans.Add(p);
+            }
+
+            InjectionPlanProto.InjectionPlan plan = new InjectionPlanProto.InjectionPlan();
+            plan.name = fullName;
+            plan.subplan = subPlan;
+            return plan;
+        }
+
+        private static InjectionPlanProto.InjectionPlan NewInstance(string fullName, string value)
+        {
+            InjectionPlanProto.Instance instance = new InjectionPlanProto.Instance();
+            instance.value = value;
+
+            InjectionPlanProto.InjectionPlan plan = new InjectionPlanProto.InjectionPlan();
+            plan.name = fullName;
+            plan.instance = instance;
+            return plan;
+
+        }
+
+        public static void Serialize(string fileName, InjectionPlan ip)
+        {
+            InjectionPlanProto.InjectionPlan plan = Serialize(ip);
+
+            using (var file = File.Create(fileName))
+            {
+                Serializer.Serialize<InjectionPlanProto.InjectionPlan>(file, plan);
+            }
+        }
+
+        public static InjectionPlanProto.InjectionPlan Serialize(InjectionPlan ip) 
+        {
+            if (ip is Constructor) 
+            {
+                Constructor cons = (Constructor) ip;
+                InjectionPlan[] args = cons.GetArgs();
+                InjectionPlanProto.InjectionPlan[] protoArgs = new InjectionPlanProto.InjectionPlan[args.Length];
+                for (int i = 0; i < args.Length; i++) 
+                {
+                    protoArgs[i] = Serialize(args[i]);
+                }
+                return NewConstructor(ip.GetNode().GetFullName(), protoArgs.ToList<InjectionPlanProto.InjectionPlan>());
+            } 
+            if (ip is Subplan) 
+            {
+                Subplan sp = (Subplan) ip;
+                InjectionPlan[] args = sp.GetPlans();
+                InjectionPlanProto.InjectionPlan[] subPlans = new InjectionPlanProto.InjectionPlan[args.Length];
+                for (int i = 0; i < args.Length; i++) 
+                {
+                    subPlans[i] = Serialize(args[i]);
+                }
+                return NewSubplan(ip.GetNode().GetFullName(), sp.GetSelectedIndex(), subPlans.ToList<InjectionPlanProto.InjectionPlan>());
+
+            } 
+            if (ip is CsInstance) 
+            {
+                CsInstance ji = (CsInstance) ip;
+                return NewInstance(ip.GetNode().GetFullName(), ji.GetInstanceAsString());
+            } 
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(
+                    "Encountered unknown type of InjectionPlan: " + ip), LOGGER);
+            return null;
+        }
+
+        public static InjectionPlan DeSerialize(string fileName, IClassHierarchy ch)
+        {
+            InjectionPlanProto.InjectionPlan protoPlan;
+
+            using (var file = File.OpenRead(fileName))
+            {
+                protoPlan = Serializer.Deserialize<InjectionPlanProto.InjectionPlan>(file);
+            }
+
+            return Deserialize(ch, protoPlan);
+        }
+
+        public static InjectionPlan Deserialize(IClassHierarchy ch, InjectionPlanProto.InjectionPlan ip) 
+        {
+            string fullName = ip.name;
+            if (ip.constructor != null) 
+            {
+                InjectionPlanProto.Constructor cons = ip.constructor;
+                IClassNode cn = (IClassNode) ch.GetNode(fullName);
+
+                InjectionPlanProto.InjectionPlan[] protoBufArgs = cons.args.ToArray();
+
+                IClassNode[] cnArgs = new IClassNode[protoBufArgs.Length];
+
+                for (int i = 0; i < protoBufArgs.Length; i++) 
+                {
+                    INode no = ch.GetNode(protoBufArgs[i].name);
+                    if (no is IClassNode)
+                    {
+                        cnArgs[i] = (IClassNode)no;
+                    }
+                    else if (no is INamedParameterNode)
+                    {
+                        INamedParameterNode np = (INamedParameterNode)no;
+                        cnArgs[i] = (IClassNode)ch.GetNode(np.GetFullArgName());
+                    }
+                }
+
+                InjectionPlan[] ipArgs = new InjectionPlan[protoBufArgs.Length];
+
+                for (int i = 0; i < protoBufArgs.Length; i++) 
+                {
+                    ipArgs[i] = (InjectionPlan) Deserialize(ch, protoBufArgs[i]);
+                }
+
+                IConstructorDef constructor = cn.GetConstructorDef(cnArgs);
+                return new Constructor(cn, constructor, ipArgs);
+            }
+            if (ip.instance != null) 
+            {
+                InjectionPlanProto.Instance ins = ip.instance;
+                object instance = Parse(ip.name, ins.value);
+                return new CsInstance(ch.GetNode(ip.name), instance);
+            } 
+            if (ip.subplan != null) 
+            {
+                InjectionPlanProto.Subplan subplan = ip.subplan;
+                InjectionPlanProto.InjectionPlan[] protoBufPlans = subplan.plans.ToArray();
+          
+                InjectionPlan[] subPlans = new InjectionPlan[protoBufPlans.Length];
+                for (int i = 0; i < protoBufPlans.Length; i++) 
+                {
+                    subPlans[i] = (InjectionPlan) Deserialize(ch, protoBufPlans[i]);
+                }
+                INode n = ch.GetNode(fullName);
+                return new Subplan(n, subPlans);
+            } 
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Encountered unknown type of InjectionPlan: " + ip), LOGGER);
+            return null;
+        }
+
+        private static object Parse(String type, String value)
+        {
+            // XXX this is a placeholder for now.  We need a parser API that will
+            // either produce a live java object or (partially) validate stuff to
+            // see if it looks like the target language will be able to handle this
+            // type + value.
+            return value;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Protobuf/class_hierarchy.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Protobuf/class_hierarchy.cs b/lang/cs/Source/TANG/Tang/Protobuf/class_hierarchy.cs
new file mode 100644
index 0000000..62ffa08
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Protobuf/class_hierarchy.cs
@@ -0,0 +1,274 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: class_hierarchy.proto
+namespace ClassHierarchyProto
+{
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Node")]
+  public partial class Node : global::ProtoBuf.IExtensible
+  {
+    public Node() {}
+    
+    private string _name;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string name
+    {
+      get { return _name; }
+      set { _name = value; }
+    }
+    private string _full_name;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"full_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string full_name
+    {
+      get { return _full_name; }
+      set { _full_name = value; }
+    }
+    private ClassNode _class_node = null;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"class_node", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public ClassNode class_node
+    {
+      get { return _class_node; }
+      set { _class_node = value; }
+    }
+    private NamedParameterNode _named_parameter_node = null;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"named_parameter_node", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public NamedParameterNode named_parameter_node
+    {
+      get { return _named_parameter_node; }
+      set { _named_parameter_node = value; }
+    }
+    private PackageNode _package_node = null;
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"package_node", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue(null)]
+    public PackageNode package_node
+    {
+      get { return _package_node; }
+      set { _package_node = value; }
+    }
+    private readonly global::System.Collections.Generic.List<Node> _children = new global::System.Collections.Generic.List<Node>();
+    [global::ProtoBuf.ProtoMember(6, Name=@"children", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<Node> children
+    {
+      get { return _children; }
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ClassNode")]
+  public partial class ClassNode : global::ProtoBuf.IExtensible
+  {
+    public ClassNode() {}
+    
+    private bool _is_injection_candidate;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"is_injection_candidate", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool is_injection_candidate
+    {
+      get { return _is_injection_candidate; }
+      set { _is_injection_candidate = value; }
+    }
+    private bool _is_external_constructor;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"is_external_constructor", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool is_external_constructor
+    {
+      get { return _is_external_constructor; }
+      set { _is_external_constructor = value; }
+    }
+    private bool _is_unit;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"is_unit", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool is_unit
+    {
+      get { return _is_unit; }
+      set { _is_unit = value; }
+    }
+    private readonly global::System.Collections.Generic.List<ConstructorDef> _InjectableConstructors = new global::System.Collections.Generic.List<ConstructorDef>();
+    [global::ProtoBuf.ProtoMember(4, Name=@"InjectableConstructors", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<ConstructorDef> InjectableConstructors
+    {
+      get { return _InjectableConstructors; }
+    }
+  
+    private readonly global::System.Collections.Generic.List<ConstructorDef> _OtherConstructors = new global::System.Collections.Generic.List<ConstructorDef>();
+    [global::ProtoBuf.ProtoMember(5, Name=@"OtherConstructors", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<ConstructorDef> OtherConstructors
+    {
+      get { return _OtherConstructors; }
+    }
+  
+    private readonly global::System.Collections.Generic.List<string> _impl_full_names = new global::System.Collections.Generic.List<string>();
+    [global::ProtoBuf.ProtoMember(6, Name=@"impl_full_names", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<string> impl_full_names
+    {
+      get { return _impl_full_names; }
+    }
+  
+    private string _default_implementation = "";
+    [global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"default_implementation", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string default_implementation
+    {
+      get { return _default_implementation; }
+      set { _default_implementation = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NamedParameterNode")]
+  public partial class NamedParameterNode : global::ProtoBuf.IExtensible
+  {
+    public NamedParameterNode() {}
+    
+    private string _simple_arg_class_name;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"simple_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string simple_arg_class_name
+    {
+      get { return _simple_arg_class_name; }
+      set { _simple_arg_class_name = value; }
+    }
+    private string _full_arg_class_name;
+    [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"full_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string full_arg_class_name
+    {
+      get { return _full_arg_class_name; }
+      set { _full_arg_class_name = value; }
+    }
+    private bool _is_set;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"is_set", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool is_set
+    {
+      get { return _is_set; }
+      set { _is_set = value; }
+    }
+    private bool _is_list;
+    [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"is_list", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool is_list
+    {
+      get { return _is_list; }
+      set { _is_list = value; }
+    }
+    private string _documentation = "";
+    [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"documentation", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string documentation
+    {
+      get { return _documentation; }
+      set { _documentation = value; }
+    }
+    private string _short_name = "";
+    [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"short_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string short_name
+    {
+      get { return _short_name; }
+      set { _short_name = value; }
+    }
+    private readonly global::System.Collections.Generic.List<string> _instance_default = new global::System.Collections.Generic.List<string>();
+    [global::ProtoBuf.ProtoMember(7, Name=@"instance_default", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<string> instance_default
+    {
+      get { return _instance_default; }
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"PackageNode")]
+  public partial class PackageNode : global::ProtoBuf.IExtensible
+  {
+    public PackageNode() {}
+    
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ConstructorDef")]
+  public partial class ConstructorDef : global::ProtoBuf.IExtensible
+  {
+    public ConstructorDef() {}
+    
+    private string _full_class_name;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"full_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string full_class_name
+    {
+      get { return _full_class_name; }
+      set { _full_class_name = value; }
+    }
+    private readonly global::System.Collections.Generic.List<ConstructorArg> _args = new global::System.Collections.Generic.List<ConstructorArg>();
+    [global::ProtoBuf.ProtoMember(2, Name=@"args", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public global::System.Collections.Generic.List<ConstructorArg> args
+    {
+      get { return _args; }
+    }
+  
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+  [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ConstructorArg")]
+  public partial class ConstructorArg : global::ProtoBuf.IExtensible
+  {
+    public ConstructorArg() {}
+    
+    private string _full_arg_class_name;
+    [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"full_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public string full_arg_class_name
+    {
+      get { return _full_arg_class_name; }
+      set { _full_arg_class_name = value; }
+    }
+    private string _named_parameter_name = "";
+    [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"named_parameter_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    [global::System.ComponentModel.DefaultValue("")]
+    public string named_parameter_name
+    {
+      get { return _named_parameter_name; }
+      set { _named_parameter_name = value; }
+    }
+    private bool _is_injection_future;
+    [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"is_injection_future", DataFormat = global::ProtoBuf.DataFormat.Default)]
+    public bool is_injection_future
+    {
+      get { return _is_injection_future; }
+      set { _is_injection_future = value; }
+    }
+    private global::ProtoBuf.IExtension extensionObject;
+    global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+      { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+  }
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Protobuf/injection_plan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Protobuf/injection_plan.cs b/lang/cs/Source/TANG/Tang/Protobuf/injection_plan.cs
new file mode 100644
index 0000000..d7a30dc
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Protobuf/injection_plan.cs
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// Generated from: injection_plan.proto
+namespace InjectionPlanProto
+{
+    [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"InjectionPlan")]
+    public partial class InjectionPlan : global::ProtoBuf.IExtensible
+    {
+        public InjectionPlan() { }
+
+        private string _name;
+        [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        public string name
+        {
+            get { return _name; }
+            set { _name = value; }
+        }
+        private Constructor _constructor = null;
+        [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name = @"constructor", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        [global::System.ComponentModel.DefaultValue(null)]
+        public Constructor constructor
+        {
+            get { return _constructor; }
+            set { _constructor = value; }
+        }
+        private Instance _instance = null;
+        [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name = @"instance", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        [global::System.ComponentModel.DefaultValue(null)]
+        public Instance instance
+        {
+            get { return _instance; }
+            set { _instance = value; }
+        }
+        private Subplan _subplan = null;
+        [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name = @"subplan", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        [global::System.ComponentModel.DefaultValue(null)]
+        public Subplan subplan
+        {
+            get { return _subplan; }
+            set { _subplan = value; }
+        }
+        private global::ProtoBuf.IExtension extensionObject;
+        global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+        { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+    }
+
+    [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"Subplan")]
+    public partial class Subplan : global::ProtoBuf.IExtensible
+    {
+        public Subplan() { }
+
+        private int _selected_plan = default(int);
+        [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name = @"selected_plan", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
+        [global::System.ComponentModel.DefaultValue(default(int))]
+        public int selected_plan
+        {
+            get { return _selected_plan; }
+            set { _selected_plan = value; }
+        }
+        private readonly global::System.Collections.Generic.List<InjectionPlan> _plans = new global::System.Collections.Generic.List<InjectionPlan>();
+        [global::ProtoBuf.ProtoMember(2, Name = @"plans", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        public global::System.Collections.Generic.List<InjectionPlan> plans
+        {
+            get { return _plans; }
+        }
+
+        private global::ProtoBuf.IExtension extensionObject;
+        global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+        { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+    }
+
+    [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"Constructor")]
+    public partial class Constructor : global::ProtoBuf.IExtensible
+    {
+        public Constructor() { }
+
+        private readonly global::System.Collections.Generic.List<InjectionPlan> _args = new global::System.Collections.Generic.List<InjectionPlan>();
+        [global::ProtoBuf.ProtoMember(1, Name = @"args", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        public global::System.Collections.Generic.List<InjectionPlan> args
+        {
+            get { return _args; }
+        }
+
+        private global::ProtoBuf.IExtension extensionObject;
+        global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+        { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+    }
+
+    [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"Instance")]
+    public partial class Instance : global::ProtoBuf.IExtensible
+    {
+        public Instance() { }
+
+        private string _value;
+        [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
+        public string value
+        {
+            get { return _value; }
+            set { _value = value; }
+        }
+        private global::ProtoBuf.IExtension extensionObject;
+        global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
+        { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Tang.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Tang.csproj b/lang/cs/Source/TANG/Tang/Tang.csproj
new file mode 100644
index 0000000..bb88f2c
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Tang.csproj
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{97DBB573-3994-417A-9F69-FFA25F00D2A6}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Tang</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Tang</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.Tang\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\bin\Release\Microsoft.Tang\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Annotations\DefaultImplementation.cs" />
+    <Compile Include="Annotations\Inject.cs" />
+    <Compile Include="Annotations\Name.cs" />
+    <Compile Include="Annotations\NamedParameter.cs" />
+    <Compile Include="Annotations\Parameter.cs" />
+    <Compile Include="Annotations\Unit.cs" />
+    <Compile Include="Exceptions\BindException.cs" />
+    <Compile Include="Exceptions\ClassHierarchyException.cs" />
+    <Compile Include="Exceptions\IllegalStateException.cs" />
+    <Compile Include="Exceptions\InjectionException.cs" />
+    <Compile Include="Exceptions\NameResolutionException.cs" />
+    <Compile Include="Exceptions\ParseException.cs" />
+    <Compile Include="Formats\AvroConfigurationDataContract\AvroConfiguration.cs" />
+    <Compile Include="Formats\AvroConfigurationDataContract\ConfigurationEntry.cs" />
+    <Compile Include="Formats\AvroConfigurationSerializer.cs" />
+    <Compile Include="Formats\ConfigurationFile.cs" />
+    <Compile Include="Formats\ConfigurationModule.cs" />
+    <Compile Include="Formats\ConfigurationModuleBuilder.cs" />
+    <Compile Include="Formats\IConfigurationSerializer.cs" />
+    <Compile Include="Formats\IImpl.cs" />
+    <Compile Include="Formats\IParam.cs" />
+    <Compile Include="Formats\OptionalImpl.cs" />
+    <Compile Include="Formats\OptionalParameter.cs" />
+    <Compile Include="Formats\Provides.cs" />
+    <Compile Include="Formats\RequiredImpl.cs" />
+    <Compile Include="Formats\RequiredParameter.cs" />
+    <Compile Include="Implementations\ClassHierarchy\AbstractNode.cs" />
+    <Compile Include="Implementations\ClassHierarchy\ClassHierarchyImpl.cs" />
+    <Compile Include="Implementations\ClassHierarchy\ClassNodeImpl.cs" />
+    <Compile Include="Implementations\ClassHierarchy\ConstructorArgImpl.cs" />
+    <Compile Include="Implementations\ClassHierarchy\ConstructorDefImpl.cs" />
+    <Compile Include="Implementations\ClassHierarchy\NamedParameterNodeImpl.cs" />
+    <Compile Include="Implementations\ClassHierarchy\NodeFactory.cs" />
+    <Compile Include="Implementations\ClassHierarchy\PackageNodeImpl.cs" />
+    <Compile Include="Implementations\ClassHierarchy\ParameterParser.cs" />
+    <Compile Include="Implementations\Configuration\ConfigurationBuilderImpl.cs" />
+    <Compile Include="Implementations\Configuration\ConfigurationImpl.cs" />
+    <Compile Include="Implementations\Configuration\Configurations.cs" />
+    <Compile Include="Implementations\Configuration\CsConfigurationBuilderImpl.cs" />
+    <Compile Include="Implementations\Configuration\CsConfigurationImpl.cs" />
+    <Compile Include="Implementations\InjectionPlan\Constructor.cs" />
+    <Compile Include="Implementations\InjectionPlan\CsInstance.cs" />
+    <Compile Include="Implementations\InjectionPlan\InjectionFuture.cs" />
+    <Compile Include="Implementations\InjectionPlan\InjectionFuturePlan.cs" />
+    <Compile Include="Implementations\InjectionPlan\InjectionPlan.cs" />
+    <Compile Include="Implementations\InjectionPlan\InjectorImpl.cs" />
+    <Compile Include="Implementations\InjectionPlan\ListInjectionPlan.cs" />
+    <Compile Include="Implementations\InjectionPlan\SetInjectionPlan.cs" />
+    <Compile Include="Implementations\InjectionPlan\Subplan.cs" />
+    <Compile Include="Implementations\Tang\TangFactory.cs" />
+    <Compile Include="Implementations\Tang\TangImpl.cs" />
+    <Compile Include="Interface\IAspect.cs" />
+    <Compile Include="Interface\IClassHierarchy.cs" />
+    <Compile Include="Interface\IConfiguration.cs" />
+    <Compile Include="Interface\IConfigurationBuilder.cs" />
+    <Compile Include="Interface\ICsClassHierarchy.cs" />
+    <Compile Include="Interface\ICsConfigurationBuilder.cs" />
+    <Compile Include="Interface\ICsInternalConfigurationBuilder.cs" />
+    <Compile Include="Interface\IExternalConstructor.cs" />
+    <Compile Include="Interface\IInjector.cs" />
+    <Compile Include="Interface\ITang.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Protobuf\class_hierarchy.cs" />
+    <Compile Include="Protobuf\injection_plan.cs" />
+    <Compile Include="Protobuf\ProtocolBufferClassHierarchy.cs" />
+    <Compile Include="Protobuf\ProtocolBufferInjectionPlan.cs" />
+    <Compile Include="Types\IClassNode.cs" />
+    <Compile Include="Types\IConstructorArg.cs" />
+    <Compile Include="Types\IConstructorDef.cs" />
+    <Compile Include="Types\INamedParameterNode.cs" />
+    <Compile Include="Types\INode.cs" />
+    <Compile Include="Types\IPackageNode.cs" />
+    <Compile Include="Types\ITraversable.cs" />
+    <Compile Include="Util\AbstractMonotonicMultiMap.cs" />
+    <Compile Include="Util\AssemblyLoader.cs" />
+    <Compile Include="Util\GenericType.cs" />
+    <Compile Include="Util\MonotonicHashMap.cs" />
+    <Compile Include="Util\MonotonicHashSet.cs" />
+    <Compile Include="Util\MonotonicMultiHashMap.cs" />
+    <Compile Include="Util\MonotonicMultiMap.cs" />
+    <Compile Include="Util\MonotonicSet.cs" />
+    <Compile Include="Util\MonotonicTreeMap.cs" />
+    <Compile Include="Util\ReflectionUtilities.cs" />
+    <Compile Include="Util\SetValuedKey.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/IClassNode.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/IClassNode.cs b/lang/cs/Source/TANG/Tang/Types/IClassNode.cs
new file mode 100644
index 0000000..080bc2d
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/IClassNode.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Types
+{
+    public interface IClassNode : INode
+    {
+        IList<IConstructorDef> GetInjectableConstructors();
+        IConstructorDef GetConstructorDef(IList<IClassNode> args);
+        IList<IConstructorDef> GetAllConstructors();
+
+        void PutImpl(IClassNode impl);
+        ISet<IClassNode> GetKnownImplementations();
+        string GetDefaultImplementation();
+        bool IsUnit();
+        bool IsInjectionCandidate();
+        bool IsExternalConstructor();
+        bool IsImplementationOf(IClassNode inter);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/IConstructorArg.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/IConstructorArg.cs b/lang/cs/Source/TANG/Tang/Types/IConstructorArg.cs
new file mode 100644
index 0000000..a754b0a
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/IConstructorArg.cs
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Types
+{
+    public interface IConstructorArg
+    {
+        string GetName();
+
+        string Gettype();
+
+        bool IsInjectionFuture();
+
+        string GetNamedParameterName();  
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/IConstructorDef.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/IConstructorDef.cs b/lang/cs/Source/TANG/Tang/Types/IConstructorDef.cs
new file mode 100644
index 0000000..b5074a2
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/IConstructorDef.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Types
+{
+    public interface IConstructorDef : IComparable
+    {
+        string GetClassName();
+
+        IList<IConstructorArg> GetArgs();
+
+        bool IsMoreSpecificThan(IConstructorDef def);
+
+        bool TakesParameters(IList<IClassNode> paramTypes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/INamedParameterNode.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/INamedParameterNode.cs b/lang/cs/Source/TANG/Tang/Types/INamedParameterNode.cs
new file mode 100644
index 0000000..a92ded6
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/INamedParameterNode.cs
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Types
+{
+    public interface INamedParameterNode : INode
+    {
+        string GetDocumentation();
+
+        string GetShortName();
+
+        string[] GetDefaultInstanceAsStrings();
+
+        string GetSimpleArgName();
+
+        string GetFullArgName();
+
+        bool IsSet();
+
+        bool IsList();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/INode.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/INode.cs b/lang/cs/Source/TANG/Tang/Types/INode.cs
new file mode 100644
index 0000000..dc8b55c
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/INode.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Types
+{
+    public interface INode : IComparable<INode>, ITraversable<INode> 
+    {        
+        string GetName();
+
+        string GetFullName();
+
+        bool Contains(string key);
+
+        INode Get(string key);
+
+        INode GetParent();
+
+        void Add(INode node);
+    }
+}


[15/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Configuration/Configurations.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Configuration/Configurations.cs b/lang/cs/Source/TANG/Tang/Implementations/Configuration/Configurations.cs
new file mode 100644
index 0000000..c61fbd7
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Configuration/Configurations.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+
+namespace Org.Apache.Reef.Tang.Implementations.Configuration
+{
+    public class Configurations
+    {
+        public static IConfiguration Merge(params IConfiguration[] configurations) 
+        {
+            return TangFactory.GetTang().NewConfigurationBuilder(configurations).Build();
+        }
+
+        public static IConfiguration MergeDeserializedConfs(params IConfiguration[] configurations)
+        {
+            IClassHierarchy ch; 
+
+            if (configurations != null && configurations.Length > 0)
+            {
+                ch = configurations[0].GetClassHierarchy();
+            }
+            else
+            {
+                ch = new ProtocolBufferClassHierarchy();               
+            }
+           
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(ch);
+
+            foreach (IConfiguration tc in configurations)
+            {
+                cb.AddConfiguration(((ConfigurationImpl)tc));
+            }
+
+            return cb.Build();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationBuilderImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationBuilderImpl.cs
new file mode 100644
index 0000000..70ff1b7
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationBuilderImpl.cs
@@ -0,0 +1,489 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class CsConfigurationBuilderImpl : ConfigurationBuilderImpl, ICsInternalConfigurationBuilder
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(CsConfigurationBuilderImpl));
+
+        #region Constructors
+        public CsConfigurationBuilderImpl(string[] assemblies, IConfiguration[] confs, Type[] parsers) : base(assemblies,confs,parsers)
+        {
+        }
+
+        public CsConfigurationBuilderImpl(IConfiguration[] confs) : base(confs)
+        {
+        }
+
+        public CsConfigurationBuilderImpl(CsConfigurationBuilderImpl impl) : base(impl)
+        {
+        }
+
+        public CsConfigurationBuilderImpl(ICsClassHierarchy classHierarchy)
+            : base(classHierarchy)
+        {
+        }
+        
+        public CsConfigurationBuilderImpl(string[] assemblies)
+            : base(assemblies)
+        {
+        }
+        #endregion Constructors
+
+        #region ICsConfigurationBuilder
+        /// <summary>
+        /// Builds this instance.
+        /// </summary>
+        /// <returns></returns>
+        public CsConfigurationImpl build()
+        {
+            return new CsConfigurationImpl(new CsConfigurationBuilderImpl(this));
+        }
+
+        /// <summary>
+        /// Binds a string to a named parameter.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <param name="value">The value.</param>
+        /// <returns></returns>
+        /// <exception cref="BindException">Detected type mismatch when setting named parameter  + name
+        ///                     +   Expected NamedParameterNode, but namespace contains a  + np</exception>
+        public ICsConfigurationBuilder BindNamedParameter(Type name, string value)
+        {
+            if (value == null)
+            {
+                var ex = new IllegalStateException(string.Format(CultureInfo.CurrentCulture, "The value null set to the named parameter {0} is illegel.", name));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            INode np = GetNode(name);
+            if (np is INamedParameterNode)
+            {
+                BindParameter((INamedParameterNode)np, value);
+            }
+            else
+            {
+                var ex = new BindException(
+                    "Detected type mismatch when setting named parameter " + name
+                    + "  Expected NamedParameterNode, but namespace contains a " + np);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            return this;
+        }
+
+        /// <summary>
+        /// Binds the class impl as the implementation of the interface iface
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindImplementation(Type iface, Type impl)
+        {
+            INode cn = GetNode(iface);
+            INode dn = GetNode(impl);
+            if (!(cn is IClassNode))
+            {
+                var ex = new BindException(
+                    "bindImplementation passed interface that resolved to " + cn
+                    + " expected a ClassNode<?>");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            if (!(dn is IClassNode))
+            {
+                var ex = new BindException(
+                    "bindImplementation passed implementation that resolved to " + dn
+                    + " expected a ClassNode<?>");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            BindImplementation((IClassNode)cn, (IClassNode)dn);
+            return this;
+        }
+
+        /// <summary>
+        /// Binds the implementation to the interface
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindImplementation<U, T>(GenericType<U> iface, GenericType<T> impl)
+            where T : U
+        {
+            return BindImplementation(typeof(U), typeof(T));
+        }
+
+        /// <summary>
+        /// Binds a value to a named parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="name">The name.</param>
+        /// <param name="value">The value.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindNamedParameter<U, T>(GenericType<U> name, string value)
+            where U : Name<T>
+        {
+            return BindNamedParameter(typeof(U), value);
+        }
+
+        /// <summary>
+        /// Binds an implementaion to a named parameter.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="V"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindNamedParameter<U, V, T>(GenericType<U> iface, GenericType<V> impl)
+            where U : Name<T>
+            where V : T
+        {
+            return ((ICsInternalConfigurationBuilder)this).BindNamedParameter(typeof(U), typeof(V));
+        }
+
+        /// <summary>
+        /// Binds an external constructor.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <typeparam name="U"></typeparam>
+        /// <param name="c">The c.</param>
+        /// <param name="v">The v.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindConstructor<T, U>(GenericType<T> c, GenericType<U> v)
+            where U : IExternalConstructor<T>
+        {
+            return ((ICsInternalConfigurationBuilder)this).BindConstructor(typeof(T), typeof(U));
+        }
+
+        //public <T> void bindSetEntry(Class<? extends Name<Set<T>>> iface, String value) throws BindException;
+        /// <summary>
+        /// Binds a string value to a named parameter of ISet.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="value">The value.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindSetEntry<U, T>(GenericType<U> iface, string value)
+            where U : Name<ISet<T>>
+        {
+            return ((ICsInternalConfigurationBuilder)this).BindSetEntry(typeof(U), value);
+        }
+
+        //public <T> void bindSetEntry(Class<? extends Name<Set<T>>> iface, Class<? extends T> impl) throws BindException;
+        /// <summary>
+        /// Binds an implementaion of T to a named parameter of ISet of T.
+        /// </summary>
+        /// <typeparam name="U"></typeparam>
+        /// <typeparam name="V"></typeparam>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        public ICsConfigurationBuilder BindSetEntry<U, V, T>(GenericType<U> iface, GenericType<V> impl)
+            where U : Name<ISet<T>>
+            where V : T
+        {
+            return ((ICsInternalConfigurationBuilder)this).BindSetEntry(typeof(U), typeof(V));
+        }
+
+        public ICsConfigurationBuilder BindList<U, V, T>(GenericType<U> iface, IList<GenericType<V>> impl)
+            where U : Name<IList<T>>
+            where V : T
+        {
+            IList<Type> implTypes = new List<Type>();
+            foreach (var item in impl)
+            {
+                implTypes.Add(item.TypeT);
+            }
+            return ((ICsInternalConfigurationBuilder)this).BindList(typeof(U), implTypes); 
+        }
+
+        public ICsConfigurationBuilder BindList<U, T>(GenericType<U> iface, IList<string> impl)
+            where U : Name<IList<T>>
+        {
+            return ((ICsInternalConfigurationBuilder)this).BindList(typeof(U), impl); 
+        }
+
+        public ICsConfigurationBuilder BindList(Type iface, IList<Type> implList)
+        {
+            INode n = GetNode(iface);
+            IList<INode> result = new List<INode>();
+
+            if (!(n is INamedParameterNode))
+            {
+                var ex = new BindException("BindList got an interface that resolved to " + n + "; expected a NamedParameter");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            Type listType = ReflectionUtilities.GetInterfaceTarget(typeof(Name<>), iface);
+            if (!ReflectionUtilities.IsGenericTypeof(typeof(IList<>), listType))
+            {
+                var ex = new BindException("BindList got a NamedParameter that takes a " + listType + "; expected List<...>");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            if (implList != null && implList.Count > 0)
+            {
+                Type valType = ReflectionUtilities.GetInterfaceTarget(typeof(IList<>), listType);
+
+                foreach (var item in implList)
+                {
+                    if (!valType.IsAssignableFrom((Type)item))
+                    {
+                        var ex =
+                            new BindException("BindList got implementation " + item +
+                                                " that is incompatible with expected type " + valType);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                    result.Add(GetNode(item));
+                }
+            }
+
+            BindList((INamedParameterNode)n, result);
+            return this;
+        }
+        #endregion ICsConfigurationBuilder
+
+        #region ICsInternalConfigurationBuilder
+        /// <summary>
+        /// Bind named parameters, implementations or external constructors, depending
+        /// on the types of the classes passed in.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        ICsInternalConfigurationBuilder ICsInternalConfigurationBuilder.Bind(Type iface, Type impl)
+        {
+            Bind(GetNode(iface), GetNode(impl));
+            return this;
+        }
+
+        /// <summary>
+        /// Binds an implementation for a named parameter.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        /// <exception cref="BindException">Type mismatch when setting named parameter  + ifaceN
+        ///                     +  Expected NamedParameterNode</exception>
+        ICsInternalConfigurationBuilder ICsInternalConfigurationBuilder.BindNamedParameter(Type iface, Type impl)
+        {
+            INode ifaceN = GetNode(iface);
+            INode implN = GetNode(impl);
+            if (!(ifaceN is INamedParameterNode))
+            {
+                var ex = new BindException("Type mismatch when setting named parameter " + ifaceN
+                    + " Expected NamedParameterNode");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            Bind(ifaceN, implN);
+            return this;
+        }
+
+        //public <T> void bindSetEntry(Class<? extends Name<Set<T>>> iface, String value) throws BindException;
+        /// <summary>
+        /// Binds a string value to to a named parameter of ISet entry
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="value">The value.</param>
+        /// <returns></returns>
+        /// <exception cref="BindException">BindSetEntry got an interface that resolved to  + n + ; expected a NamedParameter</exception>
+        ICsInternalConfigurationBuilder ICsInternalConfigurationBuilder.BindSetEntry(Type iface, string value)
+        {
+            INode n = GetNode(iface);
+
+            if (!(n is INamedParameterNode))
+            {
+                var ex = new BindException("BindSetEntry got an interface that resolved to " + n + "; expected a NamedParameter");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            Type setType = ReflectionUtilities.GetInterfaceTarget(typeof(Name<>), iface);
+
+            //check if setType is ISet
+            if (ReflectionUtilities.GetInterfaceTarget(typeof(ISet<>), setType) == null)
+            {
+                var ex = new BindException("BindSetEntry got a NamedParameter that takes a " + setType + "; expected Set<...>");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            //    Type valType = ReflectionUtilities.getInterfaceTarget(Set.class, setType);
+            BindSetEntry((INamedParameterNode)n, value);
+            return this;
+        }
+
+        //public <T> void bindSetEntry(Class<? extends Name<Set<T>>> iface, Class<? extends T> impl) throws BindException;
+        /// <summary>
+        /// Binds an implementaion to a named parameter of ISset entry.
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="impl">The impl.</param>
+        /// <returns></returns>
+        /// <exception cref="BindException">BindSetEntry got an interface that resolved to  + n + ; expected a NamedParameter</exception>
+        ICsInternalConfigurationBuilder ICsInternalConfigurationBuilder.BindSetEntry(Type iface, Type impl)
+        {
+            INode n = GetNode(iface);
+            INode m = GetNode(impl);
+
+            if (!(n is INamedParameterNode))
+            {
+                var ex = new BindException("BindSetEntry got an interface that resolved to " + n + "; expected a NamedParameter");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            Type setType = ReflectionUtilities.GetInterfaceTarget(typeof(Name<>), iface);
+
+            //if (!ReflectionUtilities.GetRawClass(setType).Equals(typeof(ISet<>)))
+            if (!ReflectionUtilities.IsGenericTypeof(typeof(ISet<>), setType))
+            {
+                var ex = new BindException("BindSetEntry got a NamedParameter that takes a " + setType + "; expected Set<...>");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            Type valType = ReflectionUtilities.GetInterfaceTarget(typeof(ISet<>), setType);
+
+            if (!valType.IsAssignableFrom(impl))
+            //if (!ReflectionUtilities.GetRawClass(valType).IsAssignableFrom(impl))
+            {
+                var ex = new BindException("BindSetEntry got implementation " + impl + " that is incompatible with expected type " + valType);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            BindSetEntry((INamedParameterNode)n, m);
+            return this;
+        }
+
+        ICsInternalConfigurationBuilder ICsInternalConfigurationBuilder.BindList(Type iface, IList<string> implList)
+        {
+            INode n = GetNode(iface);
+
+            if (!(n is INamedParameterNode))
+            {
+                var ex = new BindException("BindList got an interface that resolved to " + n + "; expected a NamedParameter");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            Type listType = ReflectionUtilities.GetInterfaceTarget(typeof(Name<>), iface);
+            if (!ReflectionUtilities.IsGenericTypeof(typeof(IList<>), listType))
+            {
+                var ex = new BindException("BindList got a NamedParameter that takes a " + listType + "; expected List<...>");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            BindList((INamedParameterNode)n, implList);
+            return this;
+        }
+
+        //public <T> void bindConstructor(Class<T> c, Class<? extends ExternalConstructor<? extends T>> v) throws BindException;
+        /// <summary>
+        /// Binds an external constructor.
+        /// </summary>
+        /// <param name="c">The c.</param>
+        /// <param name="v">The v.</param>
+        /// <returns></returns>
+        /// <exception cref="BindException">BindConstructor got class that resolved to  + n + ; expected ClassNode</exception>
+        ICsInternalConfigurationBuilder ICsInternalConfigurationBuilder.BindConstructor(Type c, Type v)
+        {
+            INode n = GetNode(c);
+            INode m = GetNode(v);
+
+            if (!(n is IClassNode))
+            {
+                var ex = new BindException("BindConstructor got class that resolved to " + n + "; expected ClassNode");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            if (!(m is IClassNode))
+            {
+                var ex = new BindException("BindConstructor got class that resolved to " + m + "; expected ClassNode");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            BindConstructor((IClassNode)n, (IClassNode)m);
+            return this;
+        }
+        #endregion ICsInternalConfigurationBuilder
+
+        #region extension methods
+        
+        public ICsConfigurationBuilder BindNamedParam<TName, TType>(string str) where TName : Name<TType>
+        {
+            return BindNamedParameter<TName, TType>(GenericType<TName>.Class, str);
+        }
+
+        public ICsConfigurationBuilder BindStringNamedParam<T>(string str) where T : Name<string>
+        {
+            return BindNamedParameter<T, string>(GenericType<T>.Class, str);
+        }
+
+        public ICsConfigurationBuilder BindIntNamedParam<T>(string str) where T : Name<int>
+        {
+            return BindNamedParameter<T, int>(GenericType<T>.Class, str);
+        }
+
+        public ICsConfigurationBuilder BindNamedParameter<U, V, T>()
+            where U : Name<T>
+            where V : T
+        {
+            return BindNamedParameter<U, V, T>(GenericType<U>.Class, GenericType<V>.Class);
+        }
+
+        public ICsConfigurationBuilder BindSetEntry<T1, T2, T3>()
+            where T1 : Name<ISet<T3>>
+            where T2 : T3
+        {
+            return BindSetEntry<T1, T2, T3>(GenericType<T1>.Class, GenericType<T2>.Class);
+        }
+
+        public ICsConfigurationBuilder BindSetEntry<U, T>(string value) where U : Name<ISet<T>>
+        {
+            return BindSetEntry<U, T>(GenericType<U>.Class, value);
+        }
+
+        public ICsConfigurationBuilder BindImplementation<T1, T2>() where T2 : T1
+        {
+            return BindImplementation(GenericType<T1>.Class, GenericType<T2>.Class);
+        }
+
+        public ICsConfigurationBuilder BindList<U, T>(IList<string> impl) where U : Name<IList<T>>
+        {
+            return BindList<U, T>(GenericType<U>.Class, impl);
+        }
+
+        public ICsConfigurationBuilder BindConstructor<T, U>() where U : IExternalConstructor<T>
+        {
+            return BindConstructor<T, U>(GenericType<T>.Class, GenericType<U>.Class);
+        }
+
+        #endregion extension methods
+
+        private INode GetNode(Type c)
+        {
+            return ((ICsClassHierarchy)ClassHierarchy).GetNode(c);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationImpl.cs b/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationImpl.cs
new file mode 100644
index 0000000..1964792
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/Configuration/CsConfigurationImpl.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class CsConfigurationImpl : ConfigurationImpl
+    {
+        public CsConfigurationImpl(CsConfigurationBuilderImpl builder) : base(builder)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Constructor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Constructor.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Constructor.cs
new file mode 100644
index 0000000..77845e8
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/Constructor.cs
@@ -0,0 +1,217 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    //Base case for an injection plan. A plan for a class. 
+    public class Constructor : InjectionPlan
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(Constructor));
+
+        IConstructorDef constructor;  //which constructor to use
+        InjectionPlan[] args; //constructor arguments in which we already got injectionPlan for each (nested cases)
+        int numAlternatives;
+        bool isAmbiguous;
+        bool isInjectable;
+
+        public InjectionPlan[] GetArgs() 
+        {
+            return args;
+        }
+
+        public new ICollection<InjectionPlan> GetChildren() 
+        {
+            return new ReadOnlyCollection<InjectionPlan>(this.args.OfType<InjectionPlan>().ToList());
+        }
+
+        public IConstructorDef GetConstructorDef()
+        {
+            return constructor;
+        }
+
+        public Constructor(IClassNode classNode,
+            IConstructorDef constructor, InjectionPlan[] args) : base(classNode)
+        {
+            this.constructor = constructor;
+            this.args = args;
+            int curAlternatives = 1;
+            bool curAmbiguous = false;
+            bool curInjectable = true;
+            foreach (InjectionPlan plan in args) 
+            {
+                curAlternatives *= plan.GetNumAlternatives();
+                curAmbiguous |= plan.IsAmbiguous();
+                curInjectable &= plan.IsInjectable();
+            }
+            this.numAlternatives = curAlternatives;
+            this.isAmbiguous = curAmbiguous;
+            this.isInjectable = curInjectable;
+        }
+
+        public new IClassNode GetNode() 
+        {
+            return (IClassNode) node;
+        }
+
+        public override int GetNumAlternatives() 
+        {
+            return numAlternatives;
+        }
+
+        public override bool IsAmbiguous() 
+        {
+            return isAmbiguous;
+        }
+
+        public override bool IsInjectable() 
+        {
+            return isInjectable;
+        }
+        
+        public override string ToString() 
+        {
+            StringBuilder sb = new StringBuilder("new " + GetNode().GetName() + '(');
+            if (args.Length > 0) 
+            {
+                sb.Append(args[0]);
+                for (int i = 1; i < args.Length; i++) 
+                {
+                    sb.Append(", " + args[i]);
+                }
+            }
+            sb.Append(')');
+            return sb.ToString();
+        }
+
+        private String ShallowArgString(InjectionPlan arg) 
+        {
+            if (arg is Constructor || arg is Subplan) 
+            {
+                return arg.GetType().Name + ": " + arg.GetNode().GetName();
+            } 
+            else 
+            {
+                return arg.ToShallowString();
+            }
+        }
+
+        public override string ToShallowString() 
+        {
+            StringBuilder sb = new StringBuilder("new " + GetNode().GetName() + '(');
+            if (args.Length > 0) 
+            {
+                sb.Append(ShallowArgString(args[0]));
+                for (int i = 1; i < args.Length; i++) 
+                {
+                    sb.Append(", " + ShallowArgString(args[i]));
+                }
+            }
+            sb.Append(')');
+            return sb.ToString();
+        }
+
+        public override string ToAmbiguousInjectString() 
+        {
+
+            if (!isAmbiguous) 
+            {
+                var ex = new ArgumentException(GetNode().GetFullName() + " is NOT ambiguous.");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            StringBuilder sb = new StringBuilder(GetNode().GetFullName() + " has ambiguous arguments: [ ");
+
+            foreach (InjectionPlan plan in args) 
+            {
+                if (plan.IsAmbiguous()) 
+                {
+                    sb.Append(plan.ToAmbiguousInjectString());
+                }
+            }
+
+            sb.Append(']');
+            return sb.ToString();
+        }
+
+        public override string ToInfeasibleInjectString() 
+        {
+            IList<InjectionPlan> leaves = new List<InjectionPlan>();
+
+            foreach (InjectionPlan ip in args) 
+            {
+                if (!ip.IsFeasible()) 
+                {
+                    if (ip.IsInfeasibleLeaf()) 
+                    {
+                        leaves.Add(ip);
+                    } else 
+                    {
+                        return ip.ToInfeasibleInjectString();
+                    }
+                }
+            }
+
+            if (leaves.Count == 0) 
+            {
+                var ex = new ArgumentException(GetNode().GetFullName() + " has NO infeasible leaves.");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+
+            if (leaves.Count == 1) 
+            {
+                return GetNode().GetFullName() + " missing argument " + leaves[0].GetNode().GetFullName();
+            } 
+            else 
+            {
+                StringBuilder sb = new StringBuilder(GetNode().GetFullName() + " missing arguments: [ ");
+                foreach (InjectionPlan leaf in leaves) 
+                {
+                    sb.Append(leaf.GetNode().GetFullName() + ' ');
+                }
+                sb.Append(']');
+                return sb.ToString();
+            }
+        }
+
+        public override bool IsInfeasibleLeaf() 
+        {
+            return false;
+        }
+
+        //public override bool HasFutureDependency() 
+        //{
+        //    foreach (InjectionPlan p in args) 
+        //    {
+        //        if(p.HasFutureDependency()) 
+        //        {
+        //            return true;
+        //        }
+        //    }
+        //    return false;
+        //}
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/CsInstance.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/CsInstance.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/CsInstance.cs
new file mode 100644
index 0000000..eae1011
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/CsInstance.cs
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class CsInstance : InjectionPlan
+    {
+        public readonly object instance;
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(CsInstance));
+
+        public CsInstance(INode name, object instance) : base(name)
+        {
+            this.instance = instance;
+        }
+        public override int GetNumAlternatives()
+        {
+            return instance == null ? 0 : 1;
+        }
+
+        public override string ToString()
+        {
+            return GetNode() + " = " + instance;
+        }
+
+        public override bool IsAmbiguous()
+        {
+            return false;
+        }
+
+        public override bool IsInjectable()
+        {
+            return instance != null;
+        }
+
+        public string GetInstanceAsString()
+        {
+            return instance.ToString();
+        }
+
+        //public override bool HasFutureDependency()
+        //{
+        //    return false;
+        //}
+
+        public override string ToAmbiguousInjectString()
+        {
+            var ex = new ArgumentException("toAmbiguousInjectString called on CsInstance!" + this.ToString());
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            return null;
+        }
+
+        public override string ToInfeasibleInjectString()
+        {
+            return GetNode() + " is not bound.";
+        }
+
+        public override bool IsInfeasibleLeaf()
+        {
+            return true;
+        }
+
+        public override string ToShallowString()
+        {
+            return ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuture.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuture.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuture.cs
new file mode 100644
index 0000000..f849eae
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuture.cs
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+
+    public interface IInjectionFuture<out T>
+    {
+        T Get();
+    }
+
+    public class InjectionFutureImpl<T> : IInjectionFuture<T>
+    {
+        protected readonly InjectorImpl injector;
+        private readonly Type iface; //entend from T
+        private readonly T instance; 
+
+        //public InjectionFuture()
+        //{
+        //    injector = null;
+        //    iface = null;
+        //    instance = null;
+        //}
+
+        public InjectionFutureImpl(IInjector injector, Type iface) 
+        {
+            this.injector = (InjectorImpl)injector;
+            this.iface = iface;
+            this.instance = default(T);
+        }
+
+        public InjectionFutureImpl(T instance)
+        {
+            this.injector = null;
+            this.iface = null;
+            this.instance = instance;
+        }
+
+        //public bool Cancel(bool mayInterruptIfRunning) 
+        //{
+        //    return false;
+        //}
+
+        //public bool IsCancelled()
+        //{
+        //    return false;
+        //}
+
+        //public bool IsDone()
+        //{
+        //    return true;
+        //}
+
+        public T Get() 
+        {
+            if (instance != null) return instance;
+            lock(injector) 
+            {
+                T t;
+                if (ReflectionUtilities.IsAssignableFromIgnoreGeneric(typeof(Name<>), iface))
+                {
+                    t = (T)injector.GetNamedInstance(iface);
+                } 
+                else 
+                {
+                    t = (T)injector.GetInstance(iface);
+                }
+                Aspect a = injector.GetAspect();
+                if(a != null) 
+                {
+                    a.InjectionFutureInstantiated(this, t);
+                }
+                return t;
+            }
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuturePlan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuturePlan.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuturePlan.cs
new file mode 100644
index 0000000..e452701
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionFuturePlan.cs
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    public class InjectionFuturePlan : InjectionPlan
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(InjectionFuturePlan));
+
+        public InjectionFuturePlan(INode name) : base (name)
+        {
+        }
+
+        public override int GetNumAlternatives()
+        {
+            return 1;
+        }
+
+        public override bool IsAmbiguous()
+        {
+            return false;
+        }
+
+        public override bool IsInjectable()
+        {
+            return true;
+        }
+
+        //public override bool HasFutureDependency()
+        //{
+        //    return true;
+        //}
+
+        public override string ToAmbiguousInjectString()
+        {
+            throw new NotSupportedException("InjectionFuturePlan cannot be ambiguous!");
+        }
+
+        public override string ToInfeasibleInjectString()
+        {
+            throw new NotSupportedException("InjectionFuturePlan is always feasible!");
+        }
+
+        public override bool IsInfeasibleLeaf()
+        {
+            return false;
+        }
+
+        public override string ToShallowString()
+        {
+            return "InjectionFuture<"+GetNode().GetFullName()+">";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionPlan.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionPlan.cs b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionPlan.cs
new file mode 100644
index 0000000..6796b46
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Implementations/InjectionPlan/InjectionPlan.cs
@@ -0,0 +1,222 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Tang.Implementations
+{
+    //contains the data for injecting a Node such as which Constructor to use, what are the arguments
+    public abstract class InjectionPlan : ITraversable<InjectionPlan> 
+    {
+        protected INode node;
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(InjectionPlan));
+
+        public InjectionPlan(INode node) 
+        {
+            this.node = node;
+        }
+
+        public INode GetNode() 
+        {
+            return node;
+        }
+
+        /// <summary>
+        /// Get child elements of the injection plan tree. By default, returns an empty list.
+        /// </summary>
+        /// <returns>An empty list</returns>
+        public ICollection<InjectionPlan> GetChildren()
+        {
+            return new List<InjectionPlan>();
+        }
+
+        public abstract int GetNumAlternatives();
+
+        public bool IsFeasible()
+        {
+            return GetNumAlternatives() > 0;
+        }
+
+        abstract public bool IsAmbiguous();
+
+        abstract public bool IsInjectable();
+
+        //abstract public bool HasFutureDependency();
+
+        protected void pad(StringBuilder sb, int n)
+        {
+            for (int i = 0; i < n; i++)
+            {
+                sb.Append("  ");
+            }
+        }
+
+        private static void Newline(StringBuilder pretty, int indent)
+        {
+            pretty.Append('\n');
+            for (int j = 0; j < indent * 2; j++)
+            {
+                pretty.Append(' ');
+            }
+        }
+
+        public String ToPrettyString()
+        {
+            String ugly = node.GetFullName() + ":\n" + ToString();
+            StringBuilder pretty = new StringBuilder();
+            int currentIndent = 1;
+            for (int i = 0; i < ugly.Length; i++)
+            {
+                char c = ugly[i];
+                if (c == '(')
+                {
+                    if (ugly[i + 1] == ')')
+                    {
+                        pretty.Append("()");
+                        i++;
+                    }
+                    else
+                    {
+                        Newline(pretty, currentIndent);
+                        currentIndent++;
+                        pretty.Append(c);
+                        pretty.Append(' ');
+                    }
+                }
+                else if (c == '[')
+                {
+                    if (ugly[i + 1] == ']')
+                    {
+                        pretty.Append("[]");
+                        i++;
+                    }
+                    else
+                    {
+                        Newline(pretty, currentIndent);
+                        currentIndent++;
+                        pretty.Append(c);
+                        pretty.Append(' ');
+                    }
+                }
+                else if (c == ')' || c == ']')
+                {
+                    currentIndent--;
+                    Newline(pretty, currentIndent);
+                    pretty.Append(c);
+                }
+                else if (c == '|')
+                {
+                    Newline(pretty, currentIndent);
+                    pretty.Append(c);
+                }
+                else if (c == ',')
+                {
+                    currentIndent--;
+                    Newline(pretty, currentIndent);
+                    pretty.Append(c);
+                    currentIndent++;
+                }
+                else
+                {
+                    pretty.Append(c);
+                }
+            }
+            return pretty.ToString();
+        }
+
+        public string ToCantInjectString() 
+        {
+            if (!IsFeasible()) 
+            {
+                return ToInfeasibleInjectString();
+            } 
+            if (IsAmbiguous()) 
+            {
+                return ToAmbiguousInjectString();
+            } 
+            var ex = new ArgumentException(
+                "toCantInjectString() called on injectable constructor:"
+                + this.ToPrettyString());
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            return null;
+        }
+
+        public abstract string ToAmbiguousInjectString();
+
+        public abstract string ToInfeasibleInjectString();
+
+        public abstract bool IsInfeasibleLeaf();
+
+        public abstract string ToShallowString();
+
+    }
+
+    public class BuildingInjectionPlan : InjectionPlan
+    {
+
+        public BuildingInjectionPlan(INode node)
+            : base(node)
+        {
+        }
+
+        public override int GetNumAlternatives()
+        {
+            throw new NotSupportedException();
+        }
+
+        public override bool IsAmbiguous()
+        {
+            throw new NotSupportedException();
+        }
+
+        public override bool IsInjectable()
+        {
+            throw new NotSupportedException();
+        }
+
+        //public override bool HasFutureDependency()
+        //{
+        //    throw new NotSupportedException();
+        //}
+
+        public override string ToAmbiguousInjectString()
+        {
+            throw new NotSupportedException();
+        }
+
+        public override string ToInfeasibleInjectString()
+        {
+            throw new NotSupportedException();
+        }
+
+        public override bool IsInfeasibleLeaf()
+        {
+            throw new NotSupportedException();
+        }
+
+        public override string ToShallowString()
+        {
+            throw new NotSupportedException();
+        }
+    }
+}


[12/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs b/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs
new file mode 100644
index 0000000..9c4e0e4
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Types
+{
+    public interface IPackageNode : INode
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/ITraversable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Types/ITraversable.cs b/lang/cs/Source/TANG/Tang/Types/ITraversable.cs
new file mode 100644
index 0000000..cd7c3c8
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Types/ITraversable.cs
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Types
+{
+    public interface ITraversable<T> where T : ITraversable<T>
+    {
+        ICollection<T> GetChildren();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs b/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs
new file mode 100644
index 0000000..3019d93
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs
@@ -0,0 +1,263 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public abstract class AbstractMonotonicMultiMap<K, V> : ICollection<KeyValuePair<K, V>>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(AbstractMonotonicMultiMap<K, V>));
+
+        private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
+
+        private IDictionary<K, ISet<V>> map;
+
+        private int size = 0;
+
+        public AbstractMonotonicMultiMap(IDictionary<K, ISet<V>> map)
+        {
+            this.map = map;
+        }
+
+        public ICollection<K> Keys
+        {
+            get { return map.Keys; }
+        }
+
+        public int Count
+        {
+            get { return size; }
+        }
+
+        public bool IsReadOnly
+        {
+            get { throw new NotImplementedException(); }
+        }
+
+        public void Add(K key, V val)
+        {
+            _lock.EnterWriteLock();
+            try
+            {
+                ISet<V> vals;
+                map.TryGetValue(key, out vals);
+
+                if (vals == null)
+                {
+                    vals = new MonotonicHashSet<V>();
+                    map.Add(key, vals);
+                }
+                vals.Add(val);
+                size++;
+            }
+            finally
+            {
+                if (_lock.IsWriteLockHeld)
+                {
+                    _lock.ExitWriteLock();
+                }
+            }
+        }
+
+        public ISet<V> GetValuesForKey(K key)
+        {
+            _lock.EnterReadLock();
+            try
+            {
+                ISet<V> ret;
+                map.TryGetValue(key, out ret);
+                if (ret == null)
+                {
+                    return new MonotonicHashSet<V>();
+                }
+                return ret;
+            }
+            finally
+            {
+                if (_lock.IsReadLockHeld)
+                {
+                    _lock.ExitReadLock();
+                }
+            }
+        }
+
+        public bool Contains(K key, V val)
+        {
+            _lock.EnterReadLock();
+            try
+            {
+                ISet<V> vals;
+                map.TryGetValue(key, out vals);
+
+                if (vals != null)
+                {
+                    return vals.Contains(val);
+                }
+                return false;
+            }
+            finally
+            {
+                if (_lock.IsReadLockHeld)
+                {
+                    _lock.ExitReadLock();
+                }
+            }
+        }
+
+        public bool Add(KeyValuePair<K, V> e)
+        {
+            Add(e.Key, e.Value);
+            return true;
+        }
+
+        public bool AddAll(ICollection<KeyValuePair<K, V>> c) // where T : KeyValuePair<K, V>
+        {
+            bool ret = false;
+            foreach (KeyValuePair<K, V> e in c) 
+            {
+                Add(e);
+                ret = true;
+            }
+            return ret;
+        }
+
+        public void Clear()
+        {
+            throw new NotSupportedException("MonotonicMultiMap cannot be cleared!");
+        }
+
+        public bool Contains(object o) 
+        {
+            KeyValuePair<K, V> e = (KeyValuePair<K, V>)o;
+            return Contains((K)e.Key, (V)e.Value);
+        }
+
+        public bool ContainsAll<T>(ICollection<T> c) 
+        {
+            foreach (object o in c) 
+            {
+                if (!Contains(o)) 
+                { 
+                    return false; 
+                }
+            }
+            return true;
+        }
+
+        public bool IsEmpty()
+        {
+            return size == 0;
+        }
+
+        public ISet<V> Values() 
+        {
+            _lock.EnterReadLock();
+
+            try
+            {
+                ISet<V> s = new HashSet<V>();
+                foreach (KeyValuePair<K, V> e in this)
+                {
+                    s.Add(e.Value);
+                }
+                return s;
+            }
+            finally
+            {
+                if (_lock.IsReadLockHeld)
+                {
+                    _lock.ExitReadLock();
+                }
+            }
+        }
+
+        public int Size()
+        {
+            return size;
+        }
+
+        public bool ContainsKey(K k)
+        {
+            _lock.EnterReadLock();
+
+            try
+            {
+                if (map.ContainsKey(k))
+                {
+                    return (GetValuesForKey(k).Count != 0);
+                }
+                return false;
+            }
+            finally 
+            {                
+                if (_lock.IsReadLockHeld)
+                {
+                    _lock.ExitReadLock();
+                }
+            }
+        }
+
+        void ICollection<KeyValuePair<K, V>>.Add(KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void CopyTo(KeyValuePair<K, V>[] array, int arrayIndex)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool Remove(KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool Contains(KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
+        {
+            _lock.EnterReadLock();
+
+            try
+            {
+                return map.SelectMany(kvp => kvp.Value, (kvp, v) => new KeyValuePair<K, V>(kvp.Key, v)).GetEnumerator();
+            }
+            finally
+            {
+                if (_lock.IsReadLockHeld)
+                {
+                    _lock.ExitReadLock();
+                }
+            }
+        }
+
+        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs b/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs
new file mode 100644
index 0000000..8f9175c
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class AssemblyLoader
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(AssemblyLoader));
+
+        public IList<Assembly> Assemblies { get; set; }
+
+        public AssemblyLoader(string[] files)
+        {
+            Assemblies = new List<Assembly>();
+            foreach (var a in files)
+            {
+                Assemblies.Add(Assembly.Load(a));
+            }
+        }
+
+        public Type GetType(string name)
+        {           
+            Type t = Type.GetType(name);
+            if (t == null)
+            {
+                foreach (var a in Assemblies)
+                {
+                    t = a.GetType(name);
+                    if (t != null)
+                    {
+                        return t;
+                    }
+                }
+
+                foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
+                {
+                    t = a.GetType(name);
+                    if (t != null)
+                        break;
+                }
+            }
+
+            if (t == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Not able to get Type from the name provided: " + name), LOGGER);
+            }
+            return t;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/GenericType.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/GenericType.cs b/lang/cs/Source/TANG/Tang/Util/GenericType.cs
new file mode 100644
index 0000000..d6a4ea0
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/GenericType.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class GenericType<T>
+    {
+        public static readonly GenericType<T> Class = null;
+
+        public Type TypeT 
+        {
+            get { return typeof(T); }
+        }
+
+        public override bool Equals(object obj)
+        {
+            GenericType<T> other = obj as GenericType<T>;
+            if (other == null)
+            {
+                return false;
+            }
+
+            return TypeT == other.TypeT;
+        }
+
+        public override int GetHashCode()
+        {
+            return TypeT.GetHashCode();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs
new file mode 100644
index 0000000..0d1deb5
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class MonotonicHashMap<T, U> : Dictionary<T, U>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicHashMap<T, U>));
+
+        public new void Add(T key, U value)
+        {
+            U old;
+            TryGetValue(key, out old);
+            if (old != null)
+            {
+                var ex = new ArgumentException("Attempt to re-add: [" + key + "] old value: " + old + " new value " + value);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            base.Add(key, value);
+        }
+
+        public void AddAll(IDictionary<T, U> m) 
+        {
+            foreach (T t in m.Keys) 
+            {
+                if (ContainsKey(t)) 
+                {
+                   U old;
+                   m.TryGetValue(t, out old);
+                   Add(t, old); // guaranteed to throw.
+                }
+            }
+            foreach (T t in m.Keys) 
+            {
+                U old;
+                m.TryGetValue(t, out old);
+                Add(t, old);
+            }
+        }
+
+        public bool IsEmpty()
+        {
+            return Count == 0;
+        }
+
+        public U Get(T key)
+        {
+            U val;
+            TryGetValue(key, out val);
+            return val;
+        }
+
+        public new void Clear() 
+        {
+            throw new NotSupportedException();
+        }
+
+        public new bool Remove(T key)
+        {
+            throw new NotSupportedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs
new file mode 100644
index 0000000..20706ef
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class MonotonicHashSet<T> : HashSet<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicHashSet<T>));
+        private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
+
+        public MonotonicHashSet()
+        {           
+        }
+
+        public MonotonicHashSet(IEnumerable<T> collection)
+            : base(collection)
+        {
+        }
+
+        public MonotonicHashSet(T[] collection)
+            : base(collection.ToList())
+        {
+        }
+
+        public new bool Add(T e)
+        {
+            _lock.EnterWriteLock();
+
+            try
+            {
+                if (Contains(e))
+                {
+                    var ex = new ArgumentException("Attempt to re-add " + e
+                                                   + " to MonotonicSet!");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                return base.Add(e);
+            }
+            finally
+            {
+                if (_lock.IsWriteLockHeld)
+                {
+                    _lock.ExitWriteLock();
+                }
+            }
+        }
+
+        public bool AddAll(ICollection<T> c)
+        {
+            _lock.EnterWriteLock();
+            try
+            {
+                foreach (T t in c)
+                {
+                    if (Contains(t))
+                    {
+                        var ex = new ArgumentException("Attempt to re-add " + t
+                                                       + " to MonotonicSet!");
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                    }
+                    base.Add(t);
+                }
+            }
+            finally
+            {
+                if (_lock.IsWriteLockHeld)
+                {
+                    _lock.ExitWriteLock();
+                }
+            }
+            return c.Count != 0;
+        }
+
+        public bool ContainsAll(ICollection<T> c)
+        {
+            _lock.EnterReadLock();
+
+            try
+            {
+                foreach (T t in c)
+                {
+                    if (!Contains(t))
+                    {
+                        return false;
+                    }
+                }
+            }
+            finally
+            {
+                if (_lock.IsReadLockHeld)
+                {
+                    _lock.ExitReadLock();
+                }
+            }
+            return true;
+        }
+
+        public new void Clear() 
+        {
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to clear MonotonicSet!"), LOGGER);
+        }
+ 
+        public bool Remove(object o) 
+        {
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to remove " + o + " from MonotonicSet!"), LOGGER);
+            return false;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs
new file mode 100644
index 0000000..cc039aa
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class MonotonicMultiHashMap<K, V> : AbstractMonotonicMultiMap<K, V> 
+    {
+        public MonotonicMultiHashMap() : base(new MonotonicHashMap<K, ISet<V>>())
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs
new file mode 100644
index 0000000..50d4c6a
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class MonotonicMultiMap<K, V> : AbstractMonotonicMultiMap<K, V> 
+    {
+        public MonotonicMultiMap() : base(new MonotonicTreeMap<K, ISet<V>>())
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs
new file mode 100644
index 0000000..2d52d0f
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class MonotonicSet<T> : SortedSet<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicSet<T>));
+
+        //private static readonly long serialVersionUID = 1L;
+        public MonotonicSet() : base()
+        {
+        }
+
+        //public MonotonicSet(SortedSet<T> c) : base(c.Comparer)
+        //{
+        //    AddAll(c);
+        //}
+
+        public MonotonicSet(ICollection<T> c)
+            : base(c)
+        {
+        }
+
+        public MonotonicSet(IComparer<T> c)
+            : base(c)
+        {
+        }
+
+        public new bool Add(T e) //TODO
+        {
+            if (this.Contains(e))
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Attempt to re-add " + e
+                    + " to MonotonicSet!"), LOGGER);
+            }
+            return base.Add(e);
+        }
+
+        public bool AddAll(ICollection<T> c)
+        {
+            foreach (T t in c)
+            {
+                this.Add(t);
+            }
+            return c.Count != 0;
+        }
+
+        public bool ContainsAll(ICollection<T> c)
+        {
+            foreach (T t in c)
+            {
+                if (!this.Contains(t))
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        public bool AddAllIgnoreDuplicates(ICollection<T> c) 
+        {
+            bool ret = false;
+            foreach (T t in c) 
+            {
+                if (!Contains(t)) 
+                {
+                    Add(t);
+                    ret = true;
+                }
+            }
+            return ret;
+        }
+
+        public override void Clear() 
+        {
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to clear MonotonicSet!"), LOGGER);
+        }
+
+        public bool Remove(Object o)
+        {
+            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to remove " + o
+                + " from MonotonicSet!"), LOGGER);
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs
new file mode 100644
index 0000000..623f249
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class MonotonicTreeMap<TKey, TVal> : SortedDictionary<TKey, TVal> 
+    {
+        private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicTreeMap<TKey, TVal>));
+
+        public new void Add(TKey key, TVal value) 
+        {
+            _lock.EnterWriteLock();
+            try
+            {
+                TVal val;
+                if (base.TryGetValue(key, out val))
+                {
+                    var ex = new ArgumentException("Attempt to re-add: [" + key
+                                                   + "]\n old value: " + val + " new value " + value);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                else
+                {
+                    base.Add(key, value);
+                }
+            }
+            finally
+            {
+                if (_lock.IsWriteLockHeld)
+                {
+                    _lock.ExitWriteLock();
+                }
+            }
+        }
+
+        public new void Clear() //TODO
+        {
+            throw new NotSupportedException();
+        }
+
+        public new void Remove(TKey key) //TODO
+        {
+            throw new NotSupportedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs b/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs
new file mode 100644
index 0000000..fec364d
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs
@@ -0,0 +1,594 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    public class ReflectionUtilities
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ReflectionUtilities));
+
+        public static readonly string Regexp = "[\\.\\+]";
+
+        /// <summary>
+        /// Gets the AssemblyQualifiedName from the Type. This name is used in ClassHierarchy
+        /// as a key when add a node as a child to parent. THe name is used as FullName in a Node
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        /// <exception cref="System.ArgumentException">null is passed in FullName() in ReflectionUtilities</exception>
+        public static string GetAssemblyQualifiedName(Type name)
+        {
+            if (name == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("null is passed in FullName() in ReflectionUtilities"), LOGGER);
+            }
+
+            Type t = EnsureInterfaceType(name);
+
+            if (t.AssemblyQualifiedName == null && t.Name == null && t.FullName == null)
+            {
+                LOGGER.Log(Level.Warning, "The type's name is null: " + t.ToString());
+            }
+
+            if (t.AssemblyQualifiedName == null && t.Name != null)
+            {
+                    return t.Name;
+            }
+
+            return t.AssemblyQualifiedName;
+        }
+
+        /// <summary>
+        /// It returns Type.FullName. This name is used as Name in a Node. 
+        /// It is not unique for a generic type with different type of arguments.
+        /// It is used for toString or debug info as AssemblyQualifiedName is really long
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        public static string GetName(Type name)
+        {
+            if (name.FullName != null)
+            {
+                return name.FullName;
+            }
+
+            //The following lines should be not reached by C# syntax definition. However, it happens  for some generic type such as AbstractObserver<T>
+            //It results in name as null. When null name in the class node gets deserialzed, as name is required filed in class hierarchy proto buffer schame,
+            //it causes exception during deserialization. The code below is to use first portion of AssemblyQualifiedName for the name of the node node in case type.name is null. 
+            string[] parts = GetAssemblyQualifiedName(name).Split(',');
+            return parts[0];
+        }
+
+        /// <summary>
+        /// Gets the interface target.
+        // Foo<T> ,  given Foo<T> and Foo return T
+        // example class Foo : Bar<U>, Bas<T>
+        // iface: Bar, type: Foo, return U
+        // iface: Bas, type: Foo, return T
+        // class ACons implements IExternalConstructor<A> 
+        // iface: IExternalConstructor<>, type: ACons return A
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="type">The type.</param>
+        /// <returns></returns>
+        public static Type GetInterfaceTarget(Type iface, Type type)
+        {
+            foreach (Type t in ReflectionUtilities.ClassAndAncestors(type))
+            {
+                if (IsGenericTypeof(iface, t))
+                {
+                    return t.GetGenericArguments()[0]; //verify it
+                }
+            }
+            return null;
+        }
+
+        public static Type GetInterfaceTargetForType(Type iface, Type type)
+        {
+            if (IsGenericTypeof(iface, type))
+            {
+                return type.GetGenericArguments()[0]; //verify it
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// Determines whether [is generic typeof] [the specified iface].
+        /// </summary>
+        /// <param name="iface">The iface.</param>
+        /// <param name="type">The type.</param>
+        /// <returns>
+        ///   <c>true</c> if [is generic typeof] [the specified iface]; otherwise, <c>false</c>.
+        /// </returns>
+        /// <exception cref="System.ApplicationException"></exception>
+        public static bool IsGenericTypeof(Type iface, Type type)
+        {
+            if (iface == null || type == null)
+            {
+                var ex = new ApplicationException(string.Format(CultureInfo.CurrentCulture,
+                                                             "The type passed in IsGenericTypeof is null: iface : {0} type: {1}. ",
+                                                             iface, type));
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            if (type.IsGenericType)
+            {
+                if (GetAssemblyQualifiedName(iface).Equals(GetAssemblyQualifiedNameForGeneric(type)))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// Classes the and ancestors.
+        /// </summary>
+        /// <param name="c">The c.</param>
+        /// <returns></returns>
+        public static IEnumerable<Type> ClassAndAncestors(Type c)
+        {
+            List<Type> workQueue = new List<Type>();
+            workQueue.Add(c); //including itself
+
+            foreach (Type t in c.GetInterfaces())
+            {
+                workQueue.Add(t);
+            }
+
+            Type b = c.BaseType;
+            while (b != null)
+            {
+                workQueue.Add(b);
+                b = b.BaseType;
+            }
+
+            if (c.IsInterface)
+            {
+                workQueue.Add(typeof (object));
+            }
+
+            return workQueue;
+        }
+
+        public static IEnumerable<Type> ClassAndAncestorsExcludeSelf(Type c)
+        {
+            List<Type> workQueue = new List<Type>();
+            //workQueue.Add(c); //including itself
+
+            foreach (Type t in c.GetInterfaces())
+            {
+                workQueue.Add(t);
+            }
+
+            Type b = c.BaseType;
+            while (b != null)
+            {
+                workQueue.Add(b);
+                b = b.BaseType;
+            }
+
+            if (c.IsInterface)
+            {
+                workQueue.Add(typeof(object));
+            }
+
+            return workQueue;
+        }
+
+        /// <summary>
+        /// Boxes the class.
+        /// </summary>
+        /// <param name="c">The c.</param>
+        /// <returns></returns>
+        /// <exception cref="System.NotSupportedException">Encountered unknown primitive type!</exception>
+        public static Type BoxClass(Type c)
+        {
+            if (c.IsPrimitive && c != typeof (Type))
+            {
+                if (c == typeof (bool))
+                {
+                    return typeof (Boolean);
+                }
+                else if (c == typeof (byte))
+                {
+                    return typeof (Byte);
+                }
+                else if (c == typeof (char))
+                {
+                    return typeof (Char);
+                }
+                else if (c == typeof (short))
+                {
+                    return typeof (Int16);
+                }
+                else if (c == typeof (int))
+                {
+                    return typeof (Int32);
+                }
+                else if (c == typeof (long))
+                {
+                    return typeof (Int64);
+                }
+                else if (c == typeof (float))
+                {
+                    return typeof (Single);
+                }
+                else if (c == typeof (double))
+                {
+                    return typeof (Double);
+                }
+                else
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException(
+                        "Encountered unknown primitive type!"), LOGGER);
+                    return c;
+                }
+            }
+            else
+            {
+                return c;
+            }
+        }
+
+        /// <summary>
+        /// Determines whether the specified to is coercable.
+        //  public static boolean isCoercable(Class<?> to, Class<?> from) castable from to both are numbers and from has a few bits or subclass relationship
+        /// </summary>
+        /// <param name="to">To.</param>
+        /// <param name="from">From.</param>
+        /// <returns>
+        ///   <c>true</c> if the specified to is coercable; otherwise, <c>false</c>.
+        /// </returns>
+        public static bool IsCoercable(Type to, Type from)
+        {
+            to = BoxClass(to);
+            from = BoxClass(from);
+            //TODO
+            //if (Number.class.isAssignableFrom(to)
+            //    && Number.class.isAssignableFrom(from)) {
+            //return sizeof.get(from) <= sizeof.get(to);
+            return to.IsAssignableFrom(from);
+            //return IsAssignableFromIgnoreGeneric(to, from);
+        }
+
+        /// <summary>
+        /// Determines whether [is assignable from ignore generic] [the specified to].
+        /// </summary>
+        /// <param name="to">To.</param>
+        /// <param name="from">From.</param>
+        /// <returns>
+        ///   <c>true</c> if [is assignable from ignore generic] [the specified to]; otherwise, <c>false</c>.
+        /// </returns>
+        public static bool IsAssignableFromIgnoreGeneric(Type to, Type from)
+        {
+            var f = ClassAndAncestors(from);
+            foreach (Type t in f)
+            {
+                if (GetAssemblyQualifiedName(to).Equals(GetAssemblyQualifiedNameForGeneric(t)))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// Ensures the type of the interface. For generic types, full name could be null. In this case, we need to 
+        /// get GetGenericTypeDefinition for the type so that to rerain all teh type information
+        /// </summary>
+        /// <param name="interf">The interf.</param>
+        /// <returns></returns>
+        public static Type EnsureInterfaceType(Type interf)
+        {
+            if (interf != null && interf.IsGenericType && null == interf.FullName)
+            {
+                return interf.GetGenericTypeDefinition(); //this is to test if this line is ever reached
+            }
+            return interf;
+        }
+
+        /// <summary>
+        /// Gets the assembly qualified name for generic.
+        /// </summary>
+        /// <param name="t">The t.</param>
+        /// <returns></returns>
+        public static string GetAssemblyQualifiedNameForGeneric(Type t)
+        {
+            Type t1 = t;
+            if (t.IsGenericType)
+            {
+                t1 = t.GetGenericTypeDefinition();
+            }
+            return t1.AssemblyQualifiedName;
+        }
+
+        /// <summary>
+        /// Determines whether [is instance of generic] [the specified p].
+        /// </summary>
+        /// <param name="p">The p.</param>
+        /// <param name="t">The t.</param>
+        /// <returns>
+        ///   <c>true</c> if [is instance of generic] [the specified p]; otherwise, <c>false</c>.
+        /// </returns>
+        public static bool IsInstanceOfGeneric(object p, Type t)
+        {
+            foreach (var g in ReflectionUtilities.ClassAndAncestors(p.GetType()))
+            {
+                if (GetAssemblyQualifiedNameForGeneric(t).Equals(GetAssemblyQualifiedNameForGeneric(g)))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// Gets the name of the type by.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        /// <exception cref="System.ApplicationException">Not able to get Type from the name provided:  +  name</exception>
+        public static Type GetTypeByName(string name)
+        {
+            Type t = null;
+
+            t = Type.GetType(name);
+
+            if (t == null)
+            {
+                foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
+                {
+                    t = a.GetType(name);
+                    if (t != null)
+                        break;
+                }
+            }
+            if (t == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Not able to get Type from the name provided: " + name), LOGGER);
+            }
+
+            return t;
+        }
+
+        /// <summary>
+        /// Gets the enclosing classes.
+        /// </summary>
+        /// <param name="t">The t.</param>
+        /// <returns></returns>
+        public static Type[] GetEnclosingClasses(Type t)
+        {
+            IList<Type> l = new List<Type>();
+            l.Add(t);
+            Type current = t.DeclaringType;
+            while (current != null)
+            {
+                l.Add(current);
+                current = current.DeclaringType;
+            }
+            return l.Reverse().ToArray();
+        }
+
+        /// <summary>
+        /// Gets the enclosing class names.
+        /// </summary>
+        /// <param name="t">The t.</param>
+        /// <returns></returns>
+        /// <exception cref="System.ApplicationException">The Type passed to GetEnclosingClassShortNames is null</exception>
+        public static string[] GetEnclosingClassNames(Type t)
+        {
+            if (t == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("The Type passed to GetEnclosingClassShortNames is null"), LOGGER);
+            }
+            Type[] ts = GetEnclosingClasses(t);
+            string[] result = new string[ts.Length];
+            for (int i = 0; i < ts.Length; i++)
+            {
+                result[i] = GetAssemblyQualifiedName(ts[i]);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Gets the enclosing class names.
+        /// </summary>
+        /// <param name="fullName">The full name.</param>
+        /// <returns></returns>
+        /// <exception cref="System.ApplicationException">The name passed to GetEnclosingClassShortNames is null</exception>
+        public static string[] GetEnclosingClassNames(string fullName)
+        {
+            if (fullName == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("The name passed to GetEnclosingClassShortNames is null"), LOGGER);
+            }
+            Type t = ReflectionUtilities.GetTypeByName(fullName);
+            return GetEnclosingClassNames(t);
+        }
+
+        /// <summary>
+        /// Gets the named parameter target or null.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        /// <returns></returns>
+        /// <exception cref="ClassHierarchyException">Named parameter  + GetName(type) +  implements 
+        ///                                   + multiple interfaces.  It is only allowed to implement Name</exception>
+        public static Type GetNamedParameterTargetOrNull(Type type)
+        {
+            var npAnnotation = type.GetCustomAttribute<NamedParameterAttribute>();
+            if (npAnnotation != null)
+            {
+                Type[] intfs = type.GetInterfaces();
+                if (intfs.Length > 1)
+                {
+                    var ex = new ClassHierarchyException("Named parameter " + GetName(type) + " implements "
+                                  + "multiple interfaces.  It is only allowed to implement Name<T>");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+
+                }
+                else if (intfs.Length == 0 || !IsName(intfs[0]))
+                {
+                    var ex = new ClassHierarchyException("Found illegal [NamedParameter " + GetName(type)
+                                  + " does not implement Name<T>");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                Type[] args = intfs[0].GetGenericArguments();
+                if (args.Length > 1)
+                {
+                    var ex = new ClassHierarchyException("Found illegal [NamedParameter " + GetName(type)
+                        + " that has more than one arguments");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                if (args.Length == 0)
+                {
+                    var ex = new ClassHierarchyException("Found illegal [NamedParameter " + GetName(type)
+                        + " that has no argument");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                if (HasConstructor(type) || HasInjectableConstructor(type))
+                {
+                    var ex = new ClassHierarchyException("Named parameter " + GetName(type) + " has "
+                                  + (HasInjectableConstructor(type) ? "an injectable" : "a") + " constructor. "
+                                  + " Named parameters must not declare any constructors.");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+
+                return args[0];               
+            }
+
+            if (ImplementName(type)) //Implement Name<> but no  [NamedParameter] attribute
+            {
+                var ex = new ClassHierarchyException("Named parameter " + GetName(type)
+                                  + " is missing its [NamedParameter] attribute.");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            return null;
+        }
+
+        public static IEnumerable<Type> GetInterfaces(Type type, bool includeInherited)
+        {
+            if (includeInherited || type.BaseType == null)
+                return type.GetInterfaces();
+            else
+                return type.GetInterfaces().Except(type.BaseType.GetInterfaces());
+        }
+
+        // Here is a more elaborate hack to test for annonymous type:
+        // http://stackoverflow.com/questions/2483023/how-to-test-if-a-type-is-anonymous
+        // compiler generated classes are always recreatable and need not additional references to check for.
+        public static bool IsAnnonymousType(Type type)
+        {
+            if (type != null)
+            {
+                // HACK: The only way to detect anonymous types right now.
+                return Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false)
+                       && type.IsGenericType && type.Name.Contains("AnonymousType")
+                       && (type.Name.StartsWith("<>", true, CultureInfo.CurrentCulture) || type.Name.StartsWith("VB$", true, CultureInfo.CurrentCulture))
+                       && (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic;
+            }
+            return false;
+        }
+
+        private static bool ImplementName(Type type)
+        {
+            foreach (Type t in type.GetInterfaces())
+            {
+                if (IsName(t))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        private static bool IsName(Type t)
+        {
+            if (t.IsGenericType)
+            {
+                return t.GetGenericTypeDefinition().AssemblyQualifiedName.Equals(typeof (Name<>).AssemblyQualifiedName);
+            }
+            return false;
+        }
+
+        private static bool HasConstructor(Type type)
+        {
+            bool hasConstructor = false;
+
+            ConstructorInfo[] constructors =
+                type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+
+            if (constructors.Length > 1)
+            {
+                hasConstructor = true;
+            }
+
+            if (constructors.Length == 1)
+            {
+                ConstructorInfo c = constructors[0];
+                ParameterInfo[] p = c.GetParameters();
+                if (p.Length > 1)
+                {
+                    // Multiple args. Definitely not implicit.
+                    hasConstructor = true;
+                }
+                else if (p.Length == 1)
+                {
+                    // One arg. Could be an inner class, in which case the compiler
+                    // included an implicit one parameter constructor that takes the
+                    // enclosing type.
+                    if (p[0].ParameterType != type.DeclaringType)
+                    {
+                        hasConstructor = true;
+                    }
+                }
+            }
+            return hasConstructor;
+        }
+
+        private static bool HasInjectableConstructor(Type type)
+        {
+            bool isInjectable = false;
+
+            ConstructorInfo[] constructors =
+                type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+
+            foreach (ConstructorInfo c in constructors)
+            {
+                foreach (Attribute a in c.GetCustomAttributes())
+                {
+                    if (a is InjectAttribute)
+                    {
+                        isInjectable = true;
+                    }
+                }
+            }
+            return isInjectable;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs b/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs
new file mode 100644
index 0000000..4c3090e
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Org.Apache.Reef.Tang.Util
+{
+    class SetValuedKey
+    {
+        public IList<object> key;
+
+        public SetValuedKey(object[] ts, object[] us)
+        {
+            key = ts.ToList<object>();
+            foreach (var o in us)
+            {
+                key.Add(o);
+            }
+        }
+
+        public override int GetHashCode()
+        {
+            int i = 0;
+            foreach (object t in key)
+            {
+                i += t.GetHashCode();
+            }
+            return i;
+        }
+
+        public override bool Equals(Object o)
+        {
+            SetValuedKey other = (SetValuedKey)o;
+            if (other.key.Count != this.key.Count) { return false; }
+            for (int i = 0; i < this.key.Count; i++)
+            {
+                if (this.key[i].Equals(other.key[i]))
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/packages.config b/lang/cs/Source/TANG/Tang/packages.config
new file mode 100644
index 0000000..933b7e1
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/packages.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj b/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj
new file mode 100644
index 0000000..c3ddf65
--- /dev/null
+++ b/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{34A9CD98-0D15-4CA0-AEA5-E53593A31047}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Tools.ClassHierarchyBuilder</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Tools.ClassHierarchyBuilder</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.Tools.ClassHierarchyBuilder\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\bin\Release\Microsoft.Reef.Tools.ClassHierarchyBuilder</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\REEF\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\REEF\reef-tasks\Tasks\Tasks.csproj">
+      <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+      <Name>Tasks</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs b/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs
new file mode 100644
index 0000000..32a85d0
--- /dev/null
+++ b/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+using Org.Apache.Reef.Tang.Types;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+
+namespace Org.Apache.Reef.Tools
+{
+    public class ClassHierarchyBuilder
+    {
+        /// <summary>
+        /// This program generates class hierarchy bin file for the list of dlls, plus a defalut list
+        /// The default list include: ITask, StreamTask1, HelloTask and ShellTask, please remove if not needed
+        /// </summary>
+        /// <param name="args"> additional dlls needed to build class hierarchy </param>
+        public static void Main(string[] args)
+        {
+            const string DllSubfix = ".dll";
+            const string ClassHierarchyBinFileName = "task.bin";
+
+            List<string> taskDlls = new List<string>();
+
+            foreach (string arg in args)
+            {
+                string assemblyName = arg;
+                if (!arg.EndsWith(DllSubfix, StringComparison.OrdinalIgnoreCase))
+                {
+                    assemblyName += DllSubfix;
+                }
+                if (!File.Exists(assemblyName))
+                {
+                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "invalid argument: assembly {0} cannot be found", assemblyName));
+                }
+                taskDlls.Add(arg);
+            }
+
+            taskDlls.Add(GetAssemblyName(typeof(ITask)));
+            taskDlls.Add(GetAssemblyName(typeof(HelloTask)));
+            taskDlls.Add(GetAssemblyName(typeof(ShellTask)));
+            taskDlls.Add(GetAssemblyName(typeof(StreamTask1)));
+
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(taskDlls.ToArray());
+
+            // the following is verification only
+            // to verify that a class indeeded has been added to the class hierarchy, check the class name
+            IClassNode streamTaskClassNode = (IClassNode)ns.GetNode(typeof(StreamTask1).AssemblyQualifiedName);
+            IClassNode helloTaskClassNode = (IClassNode)ns.GetNode(typeof(HelloTask).AssemblyQualifiedName);
+            IClassNode shellTaskClassNode = (IClassNode)ns.GetNode(typeof(ShellTask).AssemblyQualifiedName);
+
+            ProtocolBufferClassHierarchy.Serialize(ClassHierarchyBinFileName, ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize(ClassHierarchyBinFileName);
+
+            IClassNode retrievedStreamTaskClassNode = (IClassNode)ch.GetNode(typeof(StreamTask1).AssemblyQualifiedName);
+            IClassNode retrievedHelloTaskClassNode = (IClassNode)ch.GetNode(typeof(HelloTask).AssemblyQualifiedName);
+            IClassNode retrievedShellTaskClassNode = (IClassNode)ch.GetNode(typeof(ShellTask).AssemblyQualifiedName);
+
+            if (!streamTaskClassNode.GetFullName().Equals(retrievedStreamTaskClassNode.GetFullName()) ||
+                !helloTaskClassNode.GetFullName().Equals(retrievedHelloTaskClassNode.GetFullName()) ||
+                !shellTaskClassNode.GetFullName().Equals(retrievedShellTaskClassNode.GetFullName()))              
+            {
+                Console.WriteLine("Node deseriliazed is not equal");
+            }
+            else
+            {
+                Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Class hierarchy written to [{0}].", Directory.GetCurrentDirectory()));
+            }
+        }
+
+        private static string GetAssemblyName(Type type)
+        {
+            return type.Assembly.GetName().Name;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs b/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..02de849
--- /dev/null
+++ b/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ClassHierarchyBuilder")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ClassHierarchyBuilder")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8a034f16-c6c7-497a-b3c0-f8cfea1635e9")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs b/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..2fb7d69
--- /dev/null
+++ b/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ReefAll")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ReefAll")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("def59cbf-1539-414c-a518-486d1553077c")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ReefAll/ReefAll.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Tools/ReefAll/ReefAll.csproj b/lang/cs/Source/Tools/ReefAll/ReefAll.csproj
new file mode 100644
index 0000000..4f60fe6
--- /dev/null
+++ b/lang/cs/Source/Tools/ReefAll/ReefAll.csproj
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.All</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.All</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.All\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\bin\Release\Microsoft.Reef.All\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\REEF\reef-applications\Evaluator\Evaluator.csproj">
+      <Project>{1b983182-9c30-464c-948d-f87eb93a8240}</Project>
+      <Name>Evaluator</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\REEF\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\REEF\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\REEF\reef-io\NetWork\NetWork.csproj">
+      <Project>{883ce800-6a6a-4e0a-b7fe-c054f4f2c1dc}</Project>
+      <Name>NetWork</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/AvroUtils.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/AvroUtils.cs b/lang/cs/Source/Utilities/AvroUtils.cs
new file mode 100644
index 0000000..1db652d
--- /dev/null
+++ b/lang/cs/Source/Utilities/AvroUtils.cs
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Hadoop.Avro;
+
+namespace Org.Apache.Reef.Utilities
+{
+    public class AvroUtils
+    {
+        /// <summary>
+        /// Convert an object to byte array using Avro serializiation
+        /// </summary>
+        /// <param name="obj">The object to serialize</param>
+        /// <returns>The serialized object in a byte array</returns>
+        public static byte[] AvroSerialize<T>(T obj)
+        {
+            IAvroSerializer<T> serializer = AvroSerializer.Create<T>();
+            using (MemoryStream stream = new MemoryStream())
+            {
+                serializer.Serialize(stream, obj);
+                return stream.GetBuffer();
+            }
+        }
+
+        /// <summary>
+        /// Converts a byte array to an object using Avro deserialization.
+        /// </summary>
+        /// <param name="data">The byte array to deserialize</param>
+        /// <returns>The deserialized object</returns>
+        public static T AvroDeserialize<T>(byte[] data)
+        {
+            IAvroSerializer<T> deserializer = AvroSerializer.Create<T>();
+            using (MemoryStream stream = new MemoryStream(data))
+            {
+                return deserializer.Deserialize(stream);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/ByteUtilities.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/ByteUtilities.cs b/lang/cs/Source/Utilities/ByteUtilities.cs
new file mode 100644
index 0000000..655e9d2
--- /dev/null
+++ b/lang/cs/Source/Utilities/ByteUtilities.cs
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Text;
+
+namespace Org.Apache.Reef.Utilities
+{
+    public class ByteUtilities
+    {
+        public static byte[] StringToByteArrays(string s)
+        {
+            return Encoding.UTF8.GetBytes(s);
+        }
+
+        public static string ByteArrarysToString(byte[] b)
+        {
+            return Encoding.UTF8.GetString(b);
+        }
+
+        public static byte[] CopyBytesFrom(byte[] from)
+        {
+            int length = Buffer.ByteLength(from);
+            byte[] to = new byte[length];
+            Buffer.BlockCopy(from, 0, to, 0, length);
+            return to;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs b/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs
new file mode 100644
index 0000000..c0a4d6e
--- /dev/null
+++ b/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Utilities.Diagnostics
+{
+    public class DiagnosticsMessages
+    {
+        public const string ExceptionThrowing = "ExceptionThrowing";
+
+        public const string ExceptionCaught = "ExceptionCaught";
+
+        public const string DumperTimeout = "DumperTimeout";
+
+        public const string DumperError = "DumperError";
+
+        public const string CallingDumper = "CallingDumper";
+
+        public const string DumperException = "DumperException";
+    }
+}


[22/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedTask.cs
new file mode 100644
index 0000000..5b34349
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/FailedTask.cs
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class FailedTask : IFailedTask
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(FailedTask));
+        
+        public FailedTask(IFailedTaskClr2Java failedTaskClr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            Parse(failedTaskClr2Java);
+            FailedTaskClr2Java = failedTaskClr2Java;
+            ActiveContextClr2Java = failedTaskClr2Java.GetActiveContext();
+        }
+
+        public Optional<string> Reason { get; set; }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public string Id { get; set; }
+
+        public string Message { get; set; }
+
+        public Optional<string> Description { get; set; }
+
+        public Optional<Exception> Cause { get; set; }
+
+        public Optional<byte[]> Data { get; set; }
+
+        [DataMember]
+        private IFailedTaskClr2Java FailedTaskClr2Java { get; set; }
+
+        [DataMember]
+        private IActiveContextClr2Java ActiveContextClr2Java { get; set; }
+
+        /// <summary>
+        /// Access the context the task ran (and crashed) on, if it could be recovered.
+        /// An ActiveContext is given when the task fails but the context remains alive.
+        /// On context failure, the context also fails and is surfaced via the FailedContext event.
+        /// Note that receiving an ActiveContext here is no guarantee that the context (and evaluator)
+        /// are in a consistent state. Application developers need to investigate the reason available
+        /// via getCause() to make that call.
+        /// return the context the Task ran on.
+        /// </summary>
+        public Optional<IActiveContext> GetActiveContext()
+        {
+            IActiveContext activeContext = new ActiveContext(ActiveContextClr2Java);
+            return ActiveContextClr2Java == null ? Optional<IActiveContext>.Empty() : Optional<IActiveContext>.Of(activeContext);
+        }
+
+        public Exception AsError()
+        {
+            throw new NotImplementedException();
+        }
+
+        private void Parse(IFailedTaskClr2Java failedTaskClr2Java)
+        {
+            string serializedInfo = failedTaskClr2Java.GetString();
+            LOGGER.Log(Level.Verbose, "serialized failed task: " + serializedInfo);
+            Dictionary<string, string> settings = new Dictionary<string, string>();
+            string[] components = serializedInfo.Split(',');
+            foreach (string component in components)
+            {
+                string[] pair = component.Trim().Split('=');
+                if (pair == null || pair.Length != 2)
+                {
+                    Exceptions.Throw(new ArgumentException("invalid component to be used as key-value pair:", component), LOGGER);
+                }
+                settings.Add(pair[0], pair[1]);
+            }
+
+            string id;
+            if (!settings.TryGetValue("Identifier", out id))
+            {
+                Exceptions.Throw(new ArgumentException("cannot find Identifier entry."), LOGGER);
+            }
+            Id = id;
+
+            string msg;
+            if (!settings.TryGetValue("Message", out msg))
+            {
+                LOGGER.Log(Level.Verbose, "no Message in Failed Task.");
+                msg = string.Empty;
+            }
+            Message = msg;
+
+            string description;
+            if (!settings.TryGetValue("Description", out description))
+            {
+                LOGGER.Log(Level.Verbose, "no Description in Failed Task.");
+                description = string.Empty;
+            }
+            Description = string.IsNullOrWhiteSpace(description) ? Optional<string>.Empty() : Optional<string>.Of(description);
+
+            string cause;
+            if (!settings.TryGetValue("Cause", out cause))
+            {
+                LOGGER.Log(Level.Verbose, "no Cause in Failed Task.");
+                cause = string.Empty;
+            }
+            Reason = string.IsNullOrWhiteSpace(cause) ? Optional<string>.Empty() : Optional<string>.Of(cause);
+
+            string rawData;
+            if (!settings.TryGetValue("Data", out rawData))
+            {
+                LOGGER.Log(Level.Verbose, "no Data in Failed Task.");
+                rawData = string.Empty;
+            }
+            Data = string.IsNullOrWhiteSpace(rawData) ? Optional<byte[]>.Empty() : Optional<byte[]>.Of(ByteUtilities.StringToByteArrays(rawData));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/RunningTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/RunningTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/RunningTask.cs
new file mode 100644
index 0000000..a9efa29
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/RunningTask.cs
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class RunningTask : IRunningTask
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(RunningTask));
+        private IRunningTaskClr2Java _runningTaskClr2Java;
+        private IActiveContextClr2Java _activeContextClr2Java;
+
+        public RunningTask(IRunningTaskClr2Java runningTaskClr2Java)
+        {
+            using (LOGGER.LogFunction("RunningTask::RunningTask"))
+            {
+                _runningTaskClr2Java = runningTaskClr2Java;
+                _activeContextClr2Java = runningTaskClr2Java.GetActiveContext();
+            }
+        }
+
+        public Context.IActiveContext ActiveContext
+        {
+            get
+            {
+                return new ActiveContext(_activeContextClr2Java);
+            }
+            
+            set
+            {
+                ActiveContext = value;
+            }
+        }
+
+        public string Id
+        {
+            get
+            {
+                return _runningTaskClr2Java.GetId();
+            }
+
+            set
+            {
+                Id = value;
+            }
+        }
+
+        public void Send(byte[] message)
+        {
+            _runningTaskClr2Java.Send(message);
+        }
+
+        public void OnNext(byte[] message)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Suspend(byte[] message)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Suspend()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Dispose(byte[] message)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Dispose()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/SuspendedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/SuspendedTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/SuspendedTask.cs
new file mode 100644
index 0000000..33f7b8f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/SuspendedTask.cs
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using System;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    internal class SuspendedTask : ISuspendedTask
+    {
+        internal SuspendedTask(ISuspendedTaskClr2Java suspendedTaskClr2Java)
+        {
+            InstanceId = Guid.NewGuid().ToString("N");
+            SuspendedTaskClr2Java = suspendedTaskClr2Java;
+            ActiveContextClr2Java = suspendedTaskClr2Java.GetActiveContext();
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        public byte[] Message
+        {
+            get
+            {
+                return SuspendedTaskClr2Java.Get();
+            }
+
+            set
+            {
+            }
+        }
+
+        public string Id
+        {
+            get
+            {
+                return SuspendedTaskClr2Java.GetId();
+            }
+
+            set
+            {
+            }
+        }
+
+        public IActiveContext ActiveContext
+        {
+            get
+            {
+                return new ActiveContext(ActiveContextClr2Java);
+            }
+
+            set
+            {
+            }
+        }
+
+        [DataMember]
+        private ISuspendedTaskClr2Java SuspendedTaskClr2Java { get; set; }
+
+        [DataMember]
+        private IActiveContextClr2Java ActiveContextClr2Java { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/TaskMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/TaskMessage.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/TaskMessage.cs
new file mode 100644
index 0000000..f12039e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/events/TaskMessage.cs
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Task;
+using System;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    /// <summary>
+    /// TaskMessage which wraps ITaskMessageClr2Java
+    /// </summary>
+    [DataContract]
+    internal class TaskMessage : ITaskMessage
+    {
+        private ITaskMessageClr2Java _taskMessageClr2Java;
+        private byte[] _message;
+        private string _instanceId;
+
+        public TaskMessage(ITaskMessageClr2Java clr2Java, byte[] message)
+        {
+            _instanceId = Guid.NewGuid().ToString("N");
+            _taskMessageClr2Java = clr2Java;
+            _message = message;
+        }
+
+        [DataMember]
+        public string InstanceId
+        {
+            get { return _instanceId; }
+            set { _instanceId = value; }
+        }
+
+        [DataMember]
+        public string TaskId
+        {
+            get { return _taskMessageClr2Java.GetId(); }
+            set { }
+        }
+
+        [DataMember]
+        public byte[] Message
+        {
+            get { return _message; }
+            set { _message = value; } 
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfiguration.cs
new file mode 100644
index 0000000..451ad2a
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfiguration.cs
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.Events;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Diagnostics.CodeAnalysis;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "static field, typical usage in configurations")]
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    public class ContextConfiguration : ConfigurationModuleBuilder
+    {
+        /// <summary>
+        ///  The identifier of the context.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredParameter<string> Identifier = new RequiredParameter<string>();
+
+        /// <summary>
+        ///  for context start. Defaults to logging if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IContextStart>> OnContextStart = new OptionalImpl<IObserver<IContextStart>>();
+
+        /// <summary>
+        /// for context stop. Defaults to logging if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IContextStop>> OnContextStop = new OptionalImpl<IObserver<IContextStop>>();
+
+        /// <summary>
+        ///  to be informed right before a Task enters its call() method.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ITaskStart>> OnTaskStart = new OptionalImpl<IObserver<ITaskStart>>();
+
+        /// <summary>
+        ///  to be informed right after a Task exits its call() method.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ITaskStop>> OnTaskStop = new OptionalImpl<IObserver<ITaskStop>>();
+
+        /// <summary>
+        ///  Source of messages to be called whenever the evaluator is about to make a heartbeat.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IContextMessageSource> OnSendMessage = new OptionalImpl<IContextMessageSource>();
+
+        /// <summary>
+        ///   Driver has sent the context a message, and this parameter is used to register a handler on the context for processing that message.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IContextMessageHandler> OnMessage = new OptionalImpl<IContextMessageHandler>();
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new ContextConfiguration()
+                    .BindNamedParameter(GenericType<ContextConfigurationOptions.ContextIdentifier>.Class, Identifier)
+                    .BindSetEntry(GenericType<ContextConfigurationOptions.StartHandlers>.Class, OnContextStart)
+                    .BindSetEntry(GenericType<ContextConfigurationOptions.StopHandlers>.Class, OnContextStop)
+                    .BindSetEntry(GenericType<ContextConfigurationOptions.ContextMessageSources>.Class, OnSendMessage)
+                    .BindSetEntry(GenericType<ContextConfigurationOptions.ContextMessageHandlers>.Class, OnMessage)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.StartHandlers>.Class, OnTaskStart)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.StopHandlers>.Class, OnTaskStop)
+                    .Build();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfigurationOptions.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfigurationOptions.cs
new file mode 100644
index 0000000..66d7de7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/ContextConfigurationOptions.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.Events;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    /// <summary>
+    ///  Configuration parameters for ContextConfiguration module.
+    /// </summary>
+    public class ContextConfigurationOptions : ConfigurationModuleBuilder 
+    {
+        [NamedParameter(documentation: "The identifier for the context.")]
+        public class ContextIdentifier : Name<string>
+        {
+        }
+
+        [NamedParameter(documentation: "The set of event handlers for the ContextStart event", defaultClasses: new[] { typeof(DefaultContextStartHandler) })]
+        public class StartHandlers : Name<ISet<IObserver<IContextStart>>>
+        {
+        }
+
+        [NamedParameter(documentation: "The set of event handlers for the ContextStop event", defaultClasses: new[] { typeof(DefaultContextStopHandler) })]
+        public class StopHandlers : Name<ISet<IObserver<IContextStop>>>
+        {
+        }
+
+        [NamedParameter(documentation: "The set of ContextMessageSource implementations called during heartbeats.", defaultClasses: new[] { typeof(DefaultContextMessageSource) })]
+        public class ContextMessageSources : Name<ISet<IContextMessageSource>>
+        {
+        }
+
+        [NamedParameter(documentation: "The set of Context message handlers.")]
+        public class ContextMessageHandlers : Name<ISet<IContextMessageHandler>>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/EvaluatorContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/EvaluatorContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/EvaluatorContext.cs
new file mode 100644
index 0000000..1bd8b18
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/EvaluatorContext.cs
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class EvaluatorContext : IActiveContext
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorContext));
+        
+        private string _identifier;
+
+        private Optional<string> _parentId;
+
+        private EvaluatorManager _evaluatorManager;
+
+        private bool _disposed = false;
+
+        public EvaluatorContext(EvaluatorManager evaluatorManager, string id, Optional<string> parentId)
+        {
+            _identifier = id;
+            _parentId = parentId;
+            _evaluatorManager = evaluatorManager;
+        }
+
+        public string Id
+        {
+            get
+            {
+                return _identifier;
+            }
+
+            set
+            {
+            }
+        }
+
+        public string EvaluatorId
+        {
+            get
+            {
+                return _evaluatorManager.Id;
+            }
+
+            set
+            {
+            }
+        }
+
+        public Optional<string> ParentId
+        {
+            get
+            {
+                return _parentId;
+            }
+
+            set
+            {
+            }
+        }
+
+        public IEvaluatorDescriptor EvaluatorDescriptor
+        {
+            get
+            {
+                return _evaluatorManager.EvaluatorDescriptor;
+            }
+
+            set
+            {
+            }
+        }
+
+        public void Dispose()
+        {
+            if (_disposed)
+            {
+                var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Active context [{0}] already closed", _identifier));
+                Exceptions.Throw(e, LOGGER);
+            }
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submit close context: RunningEvaluator id [{0}] for context id [{1}]", EvaluatorId, Id));
+            RemoveContextProto removeContextProto = new RemoveContextProto();
+            removeContextProto.context_id = Id;
+            ContextControlProto contextControlProto = new ContextControlProto();
+            contextControlProto.remove_context = removeContextProto;
+            _evaluatorManager.Handle(contextControlProto);
+            _disposed = true;
+        }
+
+        public ClosedContext GetClosedContext(IActiveContext parentContext)
+        {
+            //return new ClosedContext(parentContext, EvaluatorId, Id, ParentId, EvaluatorDescriptor);
+            throw new NotImplementedException();
+        }
+
+        public FailedContext GetFailedContext(Optional<IActiveContext> parentContext, Exception cause)
+        {
+            //return new FailedContext(parentContext, Id, cause, EvaluatorId, ParentId, EvaluatorDescriptor);
+            throw new NotImplementedException();
+        }
+
+        public void SubmitTask(IConfiguration taskConf)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void SubmitContext(IConfiguration contextConfiguration)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void SubmitContextAndService(IConfiguration contextConfiguration, IConfiguration serviceConfiguration)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void SendMessage(byte[] message)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/IActiveContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/IActiveContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IActiveContext.cs
new file mode 100644
index 0000000..b511e25
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IActiveContext.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using System;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    public interface IActiveContext : IDisposable, IContext, ITaskSubmittable, IContextSubmittable
+    {
+        void SendMessage(byte[] message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/IClosedContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/IClosedContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IClosedContext.cs
new file mode 100644
index 0000000..8ea7cc2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IClosedContext.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Context
+{
+    public interface IClosedContext : IContext
+    {
+        IActiveContext ParentContext { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/IContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/IContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IContext.cs
new file mode 100644
index 0000000..d47b9ea
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IContext.cs
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    /// <summary>
+    /// A common base interface for Contexts, available or failed.
+    /// </summary>
+    public interface IContext : IIdentifiable
+    {
+        /// <summary>
+        /// the identifier of the Evaluator this EvaluatorContext is instantiated on.
+        /// </summary>
+        string EvaluatorId { get; set; }
+
+        /// <summary>
+        /// ID of the parent context, if there is any.
+        /// </summary>
+        Optional<string> ParentId { get; set; }
+
+        /// <summary>
+        /// descriptor of the Evaluator this Context is on.
+        /// </summary>
+        IEvaluatorDescriptor EvaluatorDescriptor { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/IFailedContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/IFailedContext.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IFailedContext.cs
new file mode 100644
index 0000000..7f9b94e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/IFailedContext.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    public interface IFailedContext : IContext
+    {
+         Optional<IActiveContext> ParentContext { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextMessageSource.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextMessageSource.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextMessageSource.cs
new file mode 100644
index 0000000..9b4f3a3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextMessageSource.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    /// <summary>
+    /// Default ContextMessageSource: return nothing.
+    /// </summary>
+    public class DefaultContextMessageSource : IContextMessageSource
+    {
+        public Optional<Common.Context.ContextMessage> Message
+        {
+            get
+            {
+                return Optional<Common.Context.ContextMessage>.Empty();
+            }
+
+            set
+            {
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStartHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStartHandler.cs
new file mode 100644
index 0000000..94af51e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStartHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Events;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+   /// <summary>
+    /// Default handler for ContextStart
+   /// </summary>
+    public class DefaultContextStartHandler : IObserver<IContextStart>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextStartHandler));
+
+        public void OnNext(IContextStart contextStart)
+        {
+            LOGGER.Log(Level.Info, "DefaultContextStartHandler received for context: " + contextStart.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStopHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStopHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStopHandler.cs
new file mode 100644
index 0000000..a7f0220
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/context/defaults/DefaultContextStopHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Events;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+
+namespace Org.Apache.Reef.Driver.Context
+{
+    /// <summary>
+    /// Default event handler for ContextStop
+    /// </summary>
+    public class DefaultContextStopHandler : IObserver<IContextStop>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextStopHandler));
+
+        public void OnNext(IContextStop contextStop)
+        {
+            LOGGER.Log(Level.Info, "DefaultContextStopHandler received for context: " + contextStop.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/contract/IBridgeContract.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/contract/IBridgeContract.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/contract/IBridgeContract.cs
new file mode 100644
index 0000000..424fdb8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/contract/IBridgeContract.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Contract
+{
+    public interface IBridgeContract
+    {
+        string InstanceId { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseHandler.cs
new file mode 100644
index 0000000..a69200f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseHandler.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default handler for close messages from the client: logging it
+    /// </summary>
+    public class DefaultClientCloseHandler : IObserver<byte[]>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultClientCloseHandler));
+
+        [Inject]
+        public DefaultClientCloseHandler()
+        {
+        }
+
+        public void OnNext(byte[] value)
+        {
+            LOGGER.Log(Level.Info, "Closing the Client");
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseWithMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseWithMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseWithMessageHandler.cs
new file mode 100644
index 0000000..16e004c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientCloseWithMessageHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default handler for close messages from the client: Throw an Exception.
+    /// </summary>
+    public class DefaultClientCloseWithMessageHandler : IObserver<byte[]>
+    {
+        [Inject]
+        public DefaultClientCloseWithMessageHandler()
+        {
+        }
+        
+        public void OnNext(byte[] value)
+        {
+            Exceptions.Throw(new InvalidOperationException("No handler bound for client Close With Message event:" + ByteUtilities.ByteArrarysToString(value)), 
+                Logger.GetLogger(typeof(DefaultClientCloseWithMessageHandler)));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientMessageHandler.cs
new file mode 100644
index 0000000..61689d0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultClientMessageHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// DDefault event handler for Client messages: Logging it.
+    /// </summary>
+    public class DefaultClientMessageHandler : IObserver<byte[]>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultClientMessageHandler));
+        
+        [Inject]
+        public DefaultClientMessageHandler()
+        {
+        }
+
+        public void OnNext(byte[] value)
+        {
+            LOGGER.Log(Level.Info, "Received message: " + ByteUtilities.ByteArrarysToString(value));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextActiveHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextActiveHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextActiveHandler.cs
new file mode 100644
index 0000000..bc0b482
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextActiveHandler.cs
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default handler for ActiveContext: Close it.
+    /// </summary>
+    public class DefaultContextActiveHandler : IObserver<IActiveContext>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextActiveHandler));
+        
+        [Inject]
+        public DefaultContextActiveHandler()
+        {
+        }
+
+        public void OnNext(IActiveContext value)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received ActiveContext :[{0}], closing it", value.Id));
+            value.Dispose();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextClosureHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextClosureHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextClosureHandler.cs
new file mode 100644
index 0000000..62e8966
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextClosureHandler.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default event handler for ClosedContext: Logging it.
+    /// </summary>
+    public class DefaultContextClosureHandler : IObserver<IClosedContext>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextClosureHandler));
+        
+        [Inject]
+        public DefaultContextClosureHandler()
+        {
+        }
+
+        public void OnNext(IClosedContext value)
+        {
+            LOGGER.Log(Level.Info, "Received ClosedContext :" + value.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextFailureHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextFailureHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextFailureHandler.cs
new file mode 100644
index 0000000..cb1621b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextFailureHandler.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    ///  Default event handler used for FailedContext: It crashes the driver.
+    /// </summary>
+    public class DefaultContextFailureHandler : IObserver<IFailedContext>
+    {
+        [Inject]
+        public DefaultContextFailureHandler()
+        {
+        }
+
+        public void OnNext(IFailedContext value)
+        {
+            throw new InvalidOperationException("No handler bound for FailedContext: " + value.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextMessageHandler.cs
new file mode 100644
index 0000000..f5b7ad2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultContextMessageHandler.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// efault event handler for ContextMessage: Logging it.
+    /// </summary>
+    public class DefaultContextMessageHandler : IObserver<IContextMessage>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextMessageHandler));
+
+        [Inject]
+        public DefaultContextMessageHandler()
+        {
+        }
+
+        public void OnNext(IContextMessage value)
+        {
+            LOGGER.Log(Level.Info, "Received ContextMessage: " + ByteUtilities.ByteArrarysToString(value.Message));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultCustomTraceListener.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultCustomTraceListener.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultCustomTraceListener.cs
new file mode 100644
index 0000000..f197298
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultCustomTraceListener.cs
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System.Diagnostics;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    public class DefaultCustomTraceListener : TraceListener
+    {
+        private readonly TraceListener _listener; 
+
+        [Inject]
+        public DefaultCustomTraceListener()
+        {
+            _listener = new ConsoleTraceListener();
+        }
+
+        public override void Write(string message)
+        {
+            _listener.Write(message);
+        }
+
+        public override void WriteLine(string message)
+        {
+            _listener.WriteLine(message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartContextActiveHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartContextActiveHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartContextActiveHandler.cs
new file mode 100644
index 0000000..314a132
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartContextActiveHandler.cs
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default handler for ActiveContext received during driver restart: Close it.
+    /// </summary>
+    public class DefaultDriverRestartContextActiveHandler : IObserver<IActiveContext>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverRestartContextActiveHandler));
+        
+        [Inject]
+        public DefaultDriverRestartContextActiveHandler()
+        {
+        }
+
+        public void OnNext(IActiveContext value)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received ActiveContext during driver restart:[{0}], closing it", value.Id));
+            value.Dispose();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartHandler.cs
new file mode 100644
index 0000000..3603f61
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    ///  Default event handler for driver restart: Logging it.
+    /// </summary>
+    public class DefaultDriverRestartHandler : IObserver<StartTime>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverRestartHandler));
+        
+        [Inject]
+        public DefaultDriverRestartHandler()
+        {
+        }
+
+        public void OnNext(StartTime startTime)
+        {
+            LOGGER.Log(Level.Info, "Driver restarted at" + new DateTime(startTime.TimeStamp));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartTaskRunningHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartTaskRunningHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartTaskRunningHandler.cs
new file mode 100644
index 0000000..461b3bb
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultDriverRestartTaskRunningHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    ///  Default event handler for TaskRuntime received during driver restart: Logging it.
+    /// </summary>
+    public class DefaultDriverRestartTaskRunningHandler : IObserver<IRunningTask>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverRestartTaskRunningHandler));
+        
+        [Inject]
+        public DefaultDriverRestartTaskRunningHandler()
+        {
+        }
+
+        public void OnNext(IRunningTask runningTask)
+        {
+            LOGGER.Log(Level.Info, "Received TaskRuntime during driver restart: " + runningTask.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorAllocationHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorAllocationHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorAllocationHandler.cs
new file mode 100644
index 0000000..07a5828
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorAllocationHandler.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default handler for AllocatedEvaluator: close it.
+    /// </summary>
+    public class DefaultEvaluatorAllocationHandler : IObserver<IAllocatedEvaluator>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultEvaluatorAllocationHandler));
+        
+        [Inject]
+        public DefaultEvaluatorAllocationHandler()
+        {
+        }
+
+        public void OnNext(IAllocatedEvaluator value)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received AllocatedEvaluator : {0}, closing", value.Id));
+            value.Dispose();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorCompletionHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorCompletionHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorCompletionHandler.cs
new file mode 100644
index 0000000..6297f64
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorCompletionHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default event handler for CompletedEvaluator: Logging it.
+    /// </summary>
+    public class DefaultEvaluatorCompletionHandler : IObserver<ICompletedEvaluator>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultEvaluatorCompletionHandler));
+        
+        [Inject]
+        public DefaultEvaluatorCompletionHandler()
+        {
+        }
+
+        public void OnNext(ICompletedEvaluator value)
+        {
+            LOGGER.Log(Level.Info, "Received CompletedEvaluator: " + value.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorFailureHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorFailureHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorFailureHandler.cs
new file mode 100644
index 0000000..ccd8d4c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorFailureHandler.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    ///  Default event handler used for FailedEvaluator: It crashes the driver.
+    /// </summary>
+    public class DefaultEvaluatorFailureHandler : IObserver<IFailedEvaluator>
+    {        
+        [Inject]
+        public DefaultEvaluatorFailureHandler()
+        {
+        }
+
+        public void OnNext(IFailedEvaluator value)
+        {
+            var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Evaluator {0} failed, and no handler is bound for FailedEvaluator.", value.Id));
+            Exceptions.Throw(e, Logger.GetLogger(typeof(DefaultEvaluatorFailureHandler)));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorRequestorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorRequestorHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorRequestorHandler.cs
new file mode 100644
index 0000000..2b70281
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultEvaluatorRequestorHandler.cs
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default handler for close messages from the client: logging it
+    /// </summary>
+    public class DefaultEvaluatorRequestorHandler : IObserver<IEvaluatorRequestor>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultClientCloseHandler));
+
+        [Inject]
+        public DefaultEvaluatorRequestorHandler()
+        {
+        }
+
+        public void OnNext(IEvaluatorRequestor value)
+        {
+            LOGGER.Log(Level.Info, "Default evaluator requstor: requesting 1 evaluator with 512 MB");
+            int evaluatorsNumber = 1;
+            int memory = 512;
+            string rack = "WonderlandRack";
+            EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, rack);
+
+            value.Submit(request);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultHttpHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultHttpHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultHttpHandler.cs
new file mode 100644
index 0000000..2dc874b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultHttpHandler.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Net;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    public class DefaultHttpHandler : IHttpHandler
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultHttpHandler));
+
+        [Inject]
+        public DefaultHttpHandler()
+        {
+        }
+
+        public string GetSpecification()
+        {
+            return "Ping";
+        }
+
+        public void OnHttpRequest(ReefHttpRequest requet, ReefHttpResponse response) 
+        {
+            LOGGER.Log(Level.Info, "OnHttpRequest in DefaultHttpHandler is called.");
+            response.Status = HttpStatusCode.OK;
+            response.OutputStream = ByteUtilities.StringToByteArrays("Byte array returned from DefaultHttpHandler in CLR!!!");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskCompletionHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskCompletionHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskCompletionHandler.cs
new file mode 100644
index 0000000..5093c85
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskCompletionHandler.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// efault event handler for CompletedTask: Log it and close the context.
+    /// </summary>
+    public class DefaultTaskCompletionHandler : IObserver<ICompletedTask>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultTaskCompletionHandler));
+        
+        [Inject]
+        public DefaultTaskCompletionHandler()
+        {
+        }
+
+        public void OnNext(ICompletedTask value)
+        {
+            IActiveContext activeContext = value.ActiveContext;
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received CompletedTask: {0} :: CLOSING context: {1}", value.Id, activeContext.Id));
+            activeContext.Dispose();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskFailureHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskFailureHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskFailureHandler.cs
new file mode 100644
index 0000000..99c7f8d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskFailureHandler.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default event handler used for FailedTask: It crashes the driver.
+    /// </summary>
+    public class DefaultTaskFailureHandler : IObserver<IFailedTask>
+    {
+        [Inject]
+        public DefaultTaskFailureHandler()
+        {
+        }
+
+        public void OnNext(IFailedTask value)
+        {
+            throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Task {0} has failed, and no handler was bound for IFailedTask", value.Id) );
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskMessageHandler.cs
new file mode 100644
index 0000000..855085b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskMessageHandler.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default event handler for TaskMessage: Logging it.
+    /// </summary>
+    public class DefaultTaskMessageHandler : IObserver<ITaskMessage>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultTaskMessageHandler));
+        
+        [Inject]
+        public DefaultTaskMessageHandler()
+        {
+        }
+
+        public void OnNext(ITaskMessage value)
+        {
+            LOGGER.Log(Level.Info, "Default TaskMessage handler received message: " + value.Message);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}


[06/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchy.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchy.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchy.cs
new file mode 100644
index 0000000..49f9802
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchy.cs
@@ -0,0 +1,717 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Examples;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestClassHierarchy
+    {
+        public static IClassHierarchy ns;
+
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            TangImpl.Reset();
+            ns = TangFactory.GetTang().GetClassHierarchy(new string[] { FileNames.Examples, FileNames.Common, FileNames.Tasks });
+       }
+
+        [ClassCleanup]
+        public static void ClassCleanup()
+        {
+        }
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+        }
+
+        [TestCleanup()]
+        public void TestCleanup()
+        {
+        }
+
+        [TestMethod]
+        public void TestString()
+        {
+            INode n = null;
+            try
+            {
+                n = ns.GetNode("System");
+            }
+            catch (ApplicationException)
+            {
+            }
+            catch (NameResolutionException)
+            {
+            }
+            Assert.IsNull(n);
+
+            Assert.IsNotNull(ns.GetNode(typeof(System.String).AssemblyQualifiedName));
+
+            string msg = null;  
+            try
+            {
+                ns.GetNode("org.apache");
+                msg = "Didn't get expected exception";
+            }
+            catch (ApplicationException)
+            {
+            }
+            catch (NameResolutionException)
+            {
+
+            }
+            Assert.IsNull(msg, msg);  
+        }
+
+        [TestMethod]
+        public void TestInt()
+        {
+            INode n = null;
+            try
+            {
+                n = ns.GetNode("System");
+            }
+            catch (ApplicationException)
+            {
+            }
+            catch (NameResolutionException)
+            {
+            }
+            Assert.IsNull(n);
+
+            Assert.IsNotNull(ns.GetNode(typeof(System.Int32).AssemblyQualifiedName));
+
+            string msg = null;      
+            try
+            {
+                ns.GetNode("org.apache");
+                msg = "Didn't get expected exception";
+            }
+            catch (ApplicationException)
+            {
+            }
+            catch (NameResolutionException)
+            {
+
+            }
+            Assert.IsNull(msg, msg);        
+        }
+
+        [TestMethod]
+        public void TestSimpleConstructors()
+        {
+            IClassNode cls = (IClassNode)ns.GetNode(typeof(SimpleConstructors).AssemblyQualifiedName);
+            Assert.IsTrue(cls.GetChildren().Count == 0);
+            IList<IConstructorDef> def = cls.GetInjectableConstructors();
+            Assert.AreEqual(3, def.Count);
+        }
+
+        [TestMethod]
+        public void TestTimer()
+        {
+            IClassNode timerClassNode = (IClassNode)ns.GetNode(typeof(Timer).AssemblyQualifiedName);
+            INode secondNode = ns.GetNode(typeof(Timer.Seconds).AssemblyQualifiedName);
+            Assert.AreEqual(secondNode.GetFullName(), ReflectionUtilities.GetAssemblyQualifiedName(typeof(Timer.Seconds)));
+
+        }
+
+        [TestMethod]
+        public void TestNamedParameterConstructors()
+        {
+            var node = ns.GetNode(typeof(NamedParameterConstructors).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), ReflectionUtilities.GetAssemblyQualifiedName(typeof(NamedParameterConstructors)));
+        }
+
+        [TestMethod]
+        public void TestArray()
+        {
+            Type t = (new string[0]).GetType();
+            INode node = ns.GetNode(t.AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), t.AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestRepeatConstructorArg()
+        {
+            TestNegativeCase(typeof(RepeatConstructorArg),
+                "Repeated constructor parameter detected.  Cannot inject constructor RepeatConstructorArg(int,int).");
+        }
+
+        [TestMethod]
+        public void TestRepeatConstructorArgClasses()
+        {
+            TestNegativeCase(typeof(RepeatConstructorArgClasses),
+                "Repeated constructor parameter detected.  Cannot inject constructor RepeatConstructorArgClasses(A, A).");
+        }
+
+        [TestMethod]
+        public void testLeafRepeatedConstructorArgClasses()
+        {
+            INode node = ns.GetNode(typeof(LeafRepeatedConstructorArgClasses).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(LeafRepeatedConstructorArgClasses).AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestNamedRepeatConstructorArgClasses()
+        {
+            INode node = ns.GetNode(typeof(NamedRepeatConstructorArgClasses).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(NamedRepeatConstructorArgClasses).AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestResolveDependencies() 
+        {
+            ns.GetNode(typeof(SimpleConstructors).AssemblyQualifiedName);
+            Assert.IsNotNull(ns.GetNode(typeof(string).AssemblyQualifiedName));
+        }
+
+        [TestMethod]
+        public void TestDocumentedLocalNamedParameter()
+        {
+            var node = ns.GetNode(typeof(DocumentedLocalNamedParameter).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), ReflectionUtilities.GetAssemblyQualifiedName(typeof(DocumentedLocalNamedParameter)));
+        }
+
+        [TestMethod]
+        public void TestNamedParameterTypeMismatch()
+        {
+            TestNegativeCase(typeof(NamedParameterTypeMismatch),
+                "Named parameter type mismatch in NamedParameterTypeMismatch. Constructor expects a System.String but Foo is a System.Int32.");
+        }
+
+        [TestMethod]
+        public void TestUnannotatedName()
+        {
+            TestNegativeCase(typeof(UnannotatedName),
+                "Named parameter UnannotatedName is missing its [NamedParameter] attribute.");
+        }
+
+        [TestMethod]
+        public void TestAnnotatedNotName()
+        {
+            TestNegativeCase(typeof(AnnotatedNotName),
+                "Found illegal [NamedParameter] AnnotatedNotName does not implement Name<T>.");
+        }
+
+        [TestMethod]
+        public void TestAnnotatedNameWrongInterface()
+        {
+            TestNegativeCase(typeof(AnnotatedNameWrongInterface),
+                "Found illegal [NamedParameter] AnnotatedNameWrongInterface does not implement Name<T>.");
+        }
+
+        [TestMethod]
+        public void TestAnnotatedNameMultipleInterfaces()
+        {
+            TestNegativeCase(typeof(AnnotatedNameMultipleInterfaces),
+                "Named parameter Org.Apache.Reef.Tang.Implementation.AnnotatedNameMultipleInterfaces implements multiple interfaces.  It is only allowed to implement Name<T>.");
+        }
+
+        [TestMethod]
+        public void TestUnAnnotatedNameMultipleInterfaces()
+        {
+            TestNegativeCase(typeof(UnAnnotatedNameMultipleInterfaces),
+                "Named parameter Org.Apache.Reef.Tang.Implementation.UnAnnotatedNameMultipleInterfaces is missing its @NamedParameter annotation.");
+        }
+
+        [TestMethod]
+        public void TestNameWithConstructor()
+        {
+            TestNegativeCase(typeof(NameWithConstructor),
+                "Named parameter Org.Apache.Reef.Tang.Implementation.NameWithConstructor has a constructor.  Named parameters must not declare any constructors.");
+        }
+
+        [TestMethod]
+        public void TestNameWithZeroArgInject()
+        {
+            TestNegativeCase(typeof(NameWithZeroArgInject),
+                "Named parameter Org.Apache.Reef.Tang.Implementation.NameWithZeroArgInject has an injectable constructor.  Named parameters must not declare any constructors.");
+        }
+
+        [TestMethod]
+        public void TestInjectNonStaticLocalArgClass()
+        {
+            var node = ns.GetNode(typeof(InjectNonStaticLocalArgClass).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(InjectNonStaticLocalArgClass).AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestInjectNonStaticLocalType()
+        {
+            var node = ns.GetNode(typeof(InjectNonStaticLocalType).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(InjectNonStaticLocalType).AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestOKShortNames()
+        {
+            var node = ns.GetNode(typeof(ShortNameFooA).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(ShortNameFooA).AssemblyQualifiedName);
+        }
+
+        public void TestConflictingShortNames()
+        {
+            string msg = null;
+            try
+            {
+                var nodeA = ns.GetNode(typeof(ShortNameFooA).AssemblyQualifiedName);
+                var nodeB = ns.GetNode(typeof(ShortNameFooB).AssemblyQualifiedName);
+                msg = 
+                    "ShortNameFooA and ShortNameFooB have the same short name" +
+                    nodeA.GetName() + nodeB.GetName();
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+            }
+            Assert.IsNull(msg, msg);
+        }
+
+        [TestMethod]
+        public void TestRoundTripInnerClassNames()
+        {
+            INode node = ns.GetNode(typeof(Nested.Inner).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(Nested.Inner).AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestRoundTripAnonInnerClassNames()
+        {
+            INode node1 = ns.GetNode(typeof(AnonNested.X1).AssemblyQualifiedName);
+            INode node2 = ns.GetNode(typeof(AnonNested.Y1).AssemblyQualifiedName);
+            Assert.AreNotEqual(node1.GetFullName(), node2.GetFullName());
+
+            Type t1 = ReflectionUtilities.GetTypeByName(node1.GetFullName());
+            Type t2 = ReflectionUtilities.GetTypeByName(node2.GetFullName());
+
+            Assert.AreNotSame(t1, t2);
+        }
+
+        [TestMethod]
+        public void TestNameCantBindWrongSubclassAsDefault()
+        {
+            TestNegativeCase(typeof(BadName),
+            "class org.apache.reef.tang.implementation.BadName defines a default class Int32 with a type that does not extend of its target's type string");
+        }
+
+
+        [TestMethod]
+        public void TestNameCantBindWrongSubclassOfArgumentAsDefault()
+        {
+            TestNegativeCase(typeof(BadNameForGeneric),
+                        "class BadNameForGeneric defines a default class Int32 with a type that does not extend of its target's string in ISet<string>");
+        }
+
+        [TestMethod]
+        public void TestNameCantBindSubclassOfArgumentAsDefault()
+        {
+            INode node = ns.GetNode(typeof(GoodNameForGeneric).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), typeof(GoodNameForGeneric).AssemblyQualifiedName);
+        }
+
+        [TestMethod]
+        public void TestInterfaceCantBindWrongImplAsDefault()
+        {
+            TestNegativeCase(typeof(IBadIfaceDefault),
+                             "interface IBadIfaceDefault declares its default implementation to be non-subclass class string");
+        }
+
+        private void TestNegativeCase(Type clazz, string message)
+        {
+            string msg = null;
+            try
+            {
+                var node = ns.GetNode(typeof(IBadIfaceDefault).AssemblyQualifiedName);
+                msg = message + node.GetName();
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg, msg);
+        }
+
+        [TestMethod]
+        public void TestParseableDefaultClassNotOK()
+        {
+            TestNegativeCase(typeof(BadParsableDefaultClass),
+                 "Named parameter BadParsableDefaultClass defines default implementation for parsable type System.string");
+        }
+
+        [TestMethod]
+        public void testGenericTorture1()
+        {
+            g(typeof(GenericTorture1));
+        }
+        [TestMethod]
+        public void testGenericTorture2()
+        {
+            g(typeof(GenericTorture2));
+        }
+        [TestMethod]
+        public void testGenericTorture3()
+        {
+            g(typeof(GenericTorture3));
+        }
+        [TestMethod]
+        public void testGenericTorture4()
+        {
+            g(typeof(GenericTorture4));
+        }
+
+        public string s(Type t)
+        {
+            return ReflectionUtilities.GetAssemblyQualifiedName(t);
+        }
+        public INode g(Type t)
+        {
+            INode n = ns.GetNode(s(t)); 
+            Assert.IsNotNull(n);
+            return n;
+        }
+
+        [TestMethod]
+        public void TestHelloTaskNode()
+        {
+            var node = ns.GetNode(typeof(Org.Apache.Reef.Tasks.HelloTask).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), ReflectionUtilities.GetAssemblyQualifiedName(typeof(Org.Apache.Reef.Tasks.HelloTask)));
+        }
+
+        [TestMethod]
+        public void TestITackNode()
+        {
+            var node = ns.GetNode(typeof(Org.Apache.Reef.Tasks.ITask).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), ReflectionUtilities.GetAssemblyQualifiedName(typeof(Org.Apache.Reef.Tasks.ITask)));
+        }
+
+        [TestMethod]
+        public void TestNamedParameterIdentifier()
+        {
+            var node = ns.GetNode(typeof(Org.Apache.Reef.Tasks.TaskConfigurationOptions.Identifier).AssemblyQualifiedName);
+            Assert.AreEqual(node.GetFullName(), ReflectionUtilities.GetAssemblyQualifiedName(typeof(Org.Apache.Reef.Tasks.TaskConfigurationOptions.Identifier)));
+        }
+        [TestMethod]
+        public void TestInterface()
+        {
+            g(typeof(A));
+            g(typeof(MyInterface<int>));
+            g(typeof(MyInterface<string>));
+            g(typeof(B));
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+
+            cb.BindImplementation(GenericType<MyInterface<string>>.Class, GenericType<MyImplString>.Class);
+            cb.BindImplementation(GenericType<MyInterface<int>>.Class, GenericType<MyImplInt>.Class);
+            IConfiguration conf = cb.Build();
+            IInjector i = tang.NewInjector(conf);
+
+            var a = (A)i.GetInstance(typeof(A));
+            var implString = (MyImplString)i.GetInstance(typeof(MyImplString));
+            var implInt = (MyImplString)i.GetInstance(typeof(MyImplString));
+            var b = (B)i.GetInstance(typeof(B));
+            var c = (C)i.GetInstance(typeof(C));
+
+            Assert.IsNotNull(a);
+            Assert.IsNotNull(implString);
+            Assert.IsNotNull(implInt);
+            Assert.IsNotNull(b);
+            Assert.IsNotNull(c);
+        }
+    }
+
+    [NamedParameter]
+    class GenericTorture1 : Name<ISet<string>> {
+    }
+    [NamedParameter]
+    class GenericTorture2 : Name<ISet<ISet<string>>>
+    {
+    }
+    [NamedParameter]
+    class GenericTorture3 : Name<IDictionary<ISet<string>, ISet<string>>>
+    {
+    }
+    [NamedParameter]
+    class GenericTorture4 : Name<IDictionary<string, string>>
+    {
+    }
+
+    public interface MyInterface<T>
+    {
+
+    }
+
+    public class RepeatConstructorArg
+    {
+        [Inject]
+        public RepeatConstructorArg(int x, int y)
+        {
+        }
+    }
+
+    public class RepeatConstructorArgClasses
+    {
+        [Inject]
+        public RepeatConstructorArgClasses(A x, A y)
+        {
+        }
+    }
+
+    public class A : MyInterface<int>, MyInterface<string>
+    {
+        [Inject]
+        A()
+        {
+        }
+    }
+
+    public class MyImplString : MyInterface<string>
+    {
+        [Inject]
+        public MyImplString()
+        {
+        }
+    }
+
+    public class B
+    {
+        [Inject]
+        public B(MyInterface<string> b)
+        {
+        }
+    }
+
+    public class MyImplInt : MyInterface<int>
+    {
+        [Inject]
+        public MyImplInt()
+        {
+        }
+    }
+    public class C
+    {
+        [Inject]
+        public C(MyInterface<int> b)
+        {
+        }
+    }
+    public class LeafRepeatedConstructorArgClasses
+    {
+
+        public static class A
+        {
+            public class AA
+            {
+            }
+        }
+
+        public static class B
+        {
+            public class AA
+            {
+            }
+        }
+
+        public class C
+        {
+            [Inject]
+            public C(A.AA a, B.AA b)
+            {
+            }
+        }
+    }
+
+    class D
+    {        
+    }
+    [NamedParameter]
+    class D1 : Name<D> 
+    {
+    }
+
+    [NamedParameter]
+    class D2 : Name<D> 
+    {
+    }
+
+    class NamedRepeatConstructorArgClasses 
+    {
+        [Inject]
+        public NamedRepeatConstructorArgClasses([Parameter(typeof(D1))] D x, [Parameter(typeof(D2))] D y) 
+        {
+        }
+    }
+
+    class NamedParameterTypeMismatch 
+    {
+        [NamedParameter(Documentation = "doc.stuff", DefaultValue = "1")]
+        class Foo : Name<Int32> 
+        {
+        }
+
+        [Inject]
+        public NamedParameterTypeMismatch([Parameter(Value = typeof(Foo))] string s) 
+        {
+        }
+    }
+
+    class UnannotatedName : Name<string> {
+    }
+
+    interface I1 
+    {
+    }
+
+    [NamedParameter(Documentation = "c")]
+    class AnnotatedNotName 
+    {
+    }
+
+    [NamedParameter(Documentation = "c")]
+    class AnnotatedNameWrongInterface : I1 
+    {
+    }
+
+    class UnAnnotatedNameMultipleInterfaces : Name<object>, I1 
+    {
+    }
+
+    [NamedParameter(Documentation = "c")]
+    class AnnotatedNameMultipleInterfaces : Name<object>, I1 
+    {
+    }
+
+    [NamedParameter(Documentation = "c")]
+    class NameWithConstructor : Name<object> 
+    {
+        private NameWithConstructor(int i) 
+        {
+        }
+    }
+
+    [NamedParameter]
+    class NameWithZeroArgInject : Name<object> 
+    {
+        [Inject]
+        public NameWithZeroArgInject() 
+        {
+        }
+    }
+
+    class InjectNonStaticLocalArgClass
+    {
+        class NonStaticLocal
+        {
+        }
+
+        [Inject]
+        InjectNonStaticLocalArgClass(NonStaticLocal x)
+        {
+        }
+    }
+
+    class InjectNonStaticLocalType
+    {
+        class NonStaticLocal
+        {
+            [Inject]
+            NonStaticLocal(NonStaticLocal x)
+            {
+            }
+        }
+    }
+
+    [NamedParameter(ShortName = "foo")]
+    public class ShortNameFooA : Name<String>
+    {
+    }
+
+    //when same short name is used, exception would throw when building the class hierarchy
+    [NamedParameter(ShortName = "foo")]
+    public class ShortNameFooB : Name<Int32>
+    {
+    }
+
+    class Nested
+    {
+        public class Inner
+        {
+        }
+    }
+
+    class AnonNested 
+    {
+        public interface X 
+        {
+        }
+
+        public class X1 : X
+        {
+            //int i;
+        }
+
+        public class Y1 : X
+        {
+            //int j;
+        }
+
+        public static X XObj = new X1();
+        public static X YObj = new Y1();
+    }
+
+    //Negative case: Int32 doesn't match string
+    [NamedParameter(DefaultClass = typeof(Int32))]
+    class BadName : Name<string>
+    {        
+    }
+
+    //Negative case: Int32 doesn't match string in the ISet
+    [NamedParameter(DefaultClass = typeof(Int32))]
+    class BadNameForGeneric : Name<ISet<string>>
+    {
+    }
+
+    //Positive case: type matched. ISet is not in parsable list
+    [NamedParameter(DefaultClass = typeof(string))]
+    class GoodNameForGeneric : Name<ISet<string>>
+    {
+    }
+
+    [DefaultImplementation(typeof(string))]
+    interface IBadIfaceDefault
+    {        
+    }
+
+    //negative case: type matched. However, string is in the parsable list and DefaultClass is not null. 
+    [NamedParameter(DefaultClass = typeof(string))]
+    class BadParsableDefaultClass : Name<string>
+    {        
+    }
+ }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchyRoundTrip.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchyRoundTrip.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchyRoundTrip.cs
new file mode 100644
index 0000000..e8c48f6
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestClassHierarchyRoundTrip.cs
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Globalization;
+using System.IO;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Protobuf;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Examples;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestClassHierarchyRoundTrip : TestClassHierarchy
+    {
+        private void setup1()
+        {
+            TangImpl.Reset();
+            ns = TangFactory.GetTang().GetClassHierarchy(new string[] { FileNames.Examples, FileNames.Common, FileNames.Tasks });
+        }
+
+        private void setup2()
+        {
+            TangImpl.Reset();
+            ns = new ProtocolBufferClassHierarchy(ProtocolBufferClassHierarchy.Serialize(ns));
+        }
+
+        private void setup3()
+        {
+            TangImpl.Reset();
+            try
+            {
+                ProtocolBufferClassHierarchy.Serialize("testProto.bin", ns);
+                ns = ProtocolBufferClassHierarchy.DeSerialize("testProto.bin");
+            }
+            catch (IOException e)
+            {
+                Assert.Fail(string.Format(CultureInfo.CurrentCulture, "IOException when serialize/deserialize proto buffer file", e));
+            }
+        }
+
+        //[TestMethod]
+        //public new void TestString() 
+        //{
+        //    setup1();
+        //    base.TestSimpleConstructors();
+        //    setup2();
+        //    base.TestSimpleConstructors();
+        //    setup3();
+        //    base.TestSimpleConstructors();
+        //}
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestGeneric.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestGeneric.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestGeneric.cs
new file mode 100644
index 0000000..80a95fe
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestGeneric.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Examples;
+using Org.Apache.Reef.Tang.Implementations;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.RX;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestGeneric
+    {
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            TangImpl.Reset();
+        }
+
+        [TestMethod]
+        public void TestGenericClassWithT()
+        {
+            List<string> appDlls = new List<string>();
+            appDlls.Add(typeof(GenericArgument<>).Assembly.GetName().Name);
+            appDlls.Add(typeof(AbstractObserver<>).Assembly.GetName().Name);
+            TangFactory.GetTang().GetClassHierarchy(appDlls.ToArray());
+        }
+    }  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestMultipleInterface.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestMultipleInterface.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestMultipleInterface.cs
new file mode 100644
index 0000000..3567a4b
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestMultipleInterface.cs
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestMultipleInterface
+    {
+        [TestMethod]
+        public void TestFoo()
+        {
+            var ch = TangFactory.GetTang().GetDefaultClassHierarchy();
+            var fNode = ch.GetNode(typeof(Org.Apache.Reef.Tang.Test.ClassHierarchy.Foo));
+            var bNode = ch.GetNode(typeof(Org.Apache.Reef.Tang.Test.ClassHierarchy.Bar));
+            var fbNode = ch.GetNode(typeof(Org.Apache.Reef.Tang.Test.ClassHierarchy.BarFoo));
+        }
+    }
+
+    public class Foo : IObserver<int>
+    {
+        [Inject]
+        public Foo()
+        {
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(int value)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public class Bar : IObserver<string>
+    {
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(string value)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public class BarFoo : IObserver<string>, IObserver<int>
+    {
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(string value)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(int value)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestParameterParser.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestParameterParser.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestParameterParser.cs
new file mode 100644
index 0000000..efd1ba7
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestParameterParser.cs
@@ -0,0 +1,323 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestParameterParser
+    {
+        [TestMethod]
+        public void ParseIntTest()
+        {
+            var parser = new ParameterParser();
+            Int32 o = (Int32)parser.Parse(typeof(Int32), "4");
+
+        }
+
+        [TestMethod]
+        public void ParseBoolTest()
+        {
+            var parser = new ParameterParser();
+            Boolean o = (Boolean)parser.Parse(typeof(Boolean), "false");
+        }
+
+        [TestMethod]
+        public void ParseLongTest()
+        {
+            var parser = new ParameterParser();
+            long o = (long)parser.Parse(typeof(long), "8675309");
+        }
+
+        [TestMethod]
+        public void ParseStringTest()
+        {
+            var parser = new ParameterParser();
+            string o = (string)parser.Parse(typeof(string), "hello");
+        }
+
+        [TestMethod]
+        public void ParseDoubleTest()
+        {
+            var parser = new ParameterParser();
+            Double o = (Double)parser.Parse(typeof(double), "12.6");
+        }
+
+        [TestMethod]
+        public void ParseCharTest()
+        {
+            var parser = new ParameterParser();
+            Char o = (Char)parser.Parse(typeof(char), "c");
+        }
+
+        [TestMethod]
+        public void ParseByteTest()
+        {
+            var parser = new ParameterParser();
+            Byte o = (Byte)parser.Parse(typeof(byte), "8");
+        }
+
+        [TestMethod]
+        public void ParseShortTest()
+        {
+            var parser = new ParameterParser();
+            Int16 o = (Int16)parser.Parse(typeof(short), "8");
+        }
+
+        [TestMethod]
+        public void ParseFloatTest()
+        {
+            var parser = new ParameterParser();
+            Single o = (Single)parser.Parse(typeof(float), "8.567");
+        }
+
+        [TestMethod]
+        public void ParseByteArrayTest()
+        {
+            var parser = new ParameterParser();
+            byte[] o = (byte[])parser.Parse(typeof(byte[]), "hello");
+        }
+
+        [TestMethod]
+        public void ParameterParserTest()
+        {
+            ParameterParser p = new ParameterParser();
+            p.AddParser(typeof(FooParser));
+            Foo f = (Foo)p.Parse(typeof(Foo), "woot");
+            Assert.AreEqual(f.s, "woot");
+        }
+        
+        [TestMethod]
+        public void TestUnregisteredParameterParser() 
+        {
+            ParameterParser p = new ParameterParser();
+            
+            //p.AddParser(typeof(FooParser));
+            Foo f = null;
+            try
+            {
+                f = (Foo) p.Parse(typeof (Foo), "woot");
+            }
+            catch (NotSupportedException)
+            {
+            }
+            Assert.IsNull(f);           
+        }
+
+       [TestMethod]
+        public void TestReturnSubclass() 
+       {
+            ParameterParser p = new ParameterParser();
+            p.AddParser(typeof(BarParser));
+            Bar f = (Bar)p.Parse(typeof(Foo), "woot");
+            Assert.AreEqual(f.s, "woot");    
+        }
+
+        [TestMethod]
+        public void TestGoodMerge()
+        {
+            ParameterParser old = new ParameterParser();
+            old.AddParser(typeof(BarParser));
+            ParameterParser nw = new ParameterParser();
+            nw.MergeIn(old);
+            Bar f = (Bar)nw.Parse(typeof(Foo), "woot");
+            Assert.AreEqual(f.s, "woot");   
+        }
+
+        [TestMethod]
+        public void TestGoodMerge2()
+        {
+            ParameterParser old = new ParameterParser();
+            old.AddParser(typeof(BarParser));
+            ParameterParser nw = new ParameterParser();
+            nw.AddParser(typeof(BarParser));
+            nw.MergeIn(old);
+            Bar f = (Bar)nw.Parse(typeof(Foo), "woot");
+            Assert.AreEqual(f.s, "woot");   
+        }
+
+        [TestMethod]
+        public void TestBadMerge()
+        {
+            string msg = null;
+            try
+            {
+                ParameterParser old = new ParameterParser();
+                old.AddParser(typeof(BarParser));
+                ParameterParser nw = new ParameterParser();
+                nw.AddParser(typeof(FooParser));
+                nw.MergeIn(old);
+                msg = "Conflict detected when merging parameter parsers! To parse org.apache.reef.tang.implementation.java.TestParameterParser$Foo I have a: TestParameterParser$FooParser the other instance has a: TestParameterParser$BarParser";
+            }
+            catch (ArgumentException)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void testEndToEnd() 
+        {
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new Type[] {typeof(BarParser) });
+            cb.BindNamedParameter<SomeNamedFoo, Foo>(GenericType<SomeNamedFoo>.Class, "hdfs://woot");
+            ILikeBars ilb = tang.NewInjector(cb.Build()).GetInstance<ILikeBars>();
+            Assert.IsNotNull(ilb);
+        }
+
+        [TestMethod]
+        public void TestDelegatingParser()
+        {
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { }, new IConfiguration[] { }, new Type[] { typeof(TypeParser) });
+
+            ICsConfigurationBuilder cb2 = tang.NewConfigurationBuilder(new IConfiguration[] { cb.Build() });
+
+            cb2.BindNamedParameter<ParseName, ParseableType>(GenericType<ParseName>.Class, "a"); //ParseName : Name<ParseableType>
+
+            ParseableType t = (ParseableType)tang.NewInjector(cb2.Build()).GetNamedInstance(typeof(ParseName));
+            Assert.IsTrue(t is ParseTypeA);
+
+            cb2 = tang.NewConfigurationBuilder(cb.Build());
+            cb2.BindNamedParameter<ParseNameB, ParseTypeB>(GenericType<ParseNameB>.Class, "b"); //ParseNameB : Name<ParseTypeB : ParseableType>
+            cb2.BindNamedParameter<ParseNameA, ParseableType>(GenericType<ParseNameA>.Class, "a"); //ParseNameA : Name<ParseableType>
+
+            tang.NewInjector(cb2.Build()).GetInstance(typeof(NeedsA));
+            tang.NewInjector(cb2.Build()).GetInstance(typeof(NeedsB));
+        }
+
+        class FooParser : IExternalConstructor<Foo>
+        {
+            private Foo foo;
+            [Inject]
+            public FooParser(string s)
+            {
+                this.foo = new Foo(s);
+            }
+
+            public Foo NewInstance()
+            {
+                return foo;
+            }
+        }
+
+        class BarParser : IExternalConstructor<Foo>
+        {
+            private Bar bar;
+            [Inject]
+            public BarParser(String s)
+            {
+                this.bar = new Bar(s);
+            }
+            public Foo NewInstance()
+            {
+                return bar;
+            }
+        }
+
+        class Foo
+        {
+            public readonly string s;
+            public Foo(string s) { this.s = s; }
+        }
+        class Bar : Foo
+        {
+            public Bar(string s) : base(s) { }
+        }
+
+        [NamedParameter]
+        class SomeNamedFoo : Name<Foo> { }
+
+        class ILikeBars
+        {
+            [Inject]
+            ILikeBars([Parameter(typeof(SomeNamedFoo))] Foo bar)
+            {
+                Bar b = (Bar)bar;
+                Assert.AreEqual(b.s, "hdfs://woot");
+            }
+        }
+
+        class ParseableType
+        {
+        }
+
+        class ParseTypeA : ParseableType
+        {
+        }
+
+        class ParseTypeB : ParseableType
+        {
+        }
+
+        class TypeParser : IExternalConstructor<ParseableType>
+        {
+            ParseableType instance;
+            [Inject]
+            public TypeParser(String s)
+            {
+                if (s.Equals("a")) { instance = new ParseTypeA(); }
+                if (s.Equals("b")) { instance = new ParseTypeB(); }
+            }
+
+            public ParseableType NewInstance()
+            {
+                return instance;
+            }
+        }
+
+        [NamedParameter]
+        class ParseName : Name<ParseableType>
+        {
+        }
+
+        [NamedParameter]
+        class ParseNameA : Name<ParseableType>
+        {
+        }
+
+        [NamedParameter]
+        class ParseNameB : Name<ParseTypeB>
+        {
+        }
+
+        class NeedsA
+        {
+            [Inject]
+            public NeedsA([Parameter(typeof(ParseNameA))] ParseableType a)
+            {
+                Assert.IsTrue(a is ParseTypeA);
+            }
+        }
+
+        class NeedsB
+        {
+            [Inject]
+            public NeedsB([Parameter(typeof(ParseNameB))] ParseTypeB b)
+            {
+                Assert.IsTrue(b is ParseTypeB);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestSerilization.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestSerilization.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestSerilization.cs
new file mode 100644
index 0000000..9313fb1
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestSerilization.cs
@@ -0,0 +1,234 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Examples;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestSerilization
+    {
+        static Assembly asm = null;
+
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            asm = Assembly.Load(FileNames.Examples);
+            Assembly.Load(FileNames.Examples);
+        }
+
+        [ClassCleanup]
+        public static void ClassCleanup()
+        {
+        }
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+        }
+
+        [TestCleanup()]
+        public void TestCleanup()
+        {
+        }
+
+        [TestMethod]
+        public void TestSerializeClassHierarchy()
+        {            
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(Timer).Assembly.GetName().Name });
+            ProtocolBufferClassHierarchy.Serialize("node.bin", ns);
+        }
+
+        [TestMethod]
+        public void TestDeSerializeClassHierarchy()
+        {
+            Type timerType = typeof (Timer);
+            Type SecondType = typeof (Timer.Seconds);
+            Type simpleCOnstuctorType = typeof (SimpleConstructors);
+
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(Timer).Assembly.GetName().Name });
+            IClassNode timerClassNode = (IClassNode)ns.GetNode(timerType.AssemblyQualifiedName);
+            INode secondNode = (INode)ns.GetNode(SecondType.AssemblyQualifiedName);
+            IClassNode SimpleConstructorsClassNode = (IClassNode)ns.GetNode(simpleCOnstuctorType.AssemblyQualifiedName);
+
+            ProtocolBufferClassHierarchy.Serialize("node.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("node.bin");
+
+            IClassNode timerClassNode2 = (IClassNode)ch.GetNode(timerType.AssemblyQualifiedName);
+            INode secondNode2 = ch.GetNode(SecondType.AssemblyQualifiedName);
+            IClassNode SimpleConstructorsClassNode2 = (IClassNode)ch.GetNode(simpleCOnstuctorType.AssemblyQualifiedName);
+
+            Assert.AreEqual(timerClassNode.GetFullName(), timerClassNode2.GetFullName());
+            Assert.AreEqual(secondNode.GetFullName(), secondNode2.GetFullName());
+            Assert.AreEqual(SimpleConstructorsClassNode.GetFullName(), SimpleConstructorsClassNode2.GetFullName());
+
+            Assert.IsTrue(SimpleConstructorsClassNode2.GetChildren().Count == 0);
+            IList<IConstructorDef> def = SimpleConstructorsClassNode2.GetInjectableConstructors();
+            Assert.AreEqual(3, def.Count);
+        }
+
+        [TestMethod]
+        public void TestDeSerializeClassHierarchyForTask()
+        {
+            Type streamTask1Type = typeof (Org.Apache.Reef.Tasks.StreamTask1);
+            Type helloTaskType = typeof (Org.Apache.Reef.Tasks.HelloTask);
+
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(Org.Apache.Reef.Tasks.HelloTask).Assembly.GetName().Name });
+            IClassNode StreamTask1ClassNode = (IClassNode)ns.GetNode(streamTask1Type.AssemblyQualifiedName);
+            IClassNode HelloTaskClassNode = (IClassNode)ns.GetNode(helloTaskType.AssemblyQualifiedName);
+
+            ProtocolBufferClassHierarchy.Serialize("task.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("task.bin");
+            IClassNode StreamTask1ClassNode2 = (IClassNode)ch.GetNode(streamTask1Type.AssemblyQualifiedName);
+            IClassNode HelloTaskClassNode2 = (IClassNode)ch.GetNode(helloTaskType.AssemblyQualifiedName);
+
+            Assert.AreEqual(StreamTask1ClassNode.GetFullName(), StreamTask1ClassNode2.GetFullName());
+            Assert.AreEqual(HelloTaskClassNode.GetFullName(), HelloTaskClassNode2.GetFullName());
+        }
+
+        [TestMethod]
+        [DeploymentItem(@".")]
+        public void TestDeSerializeClassHierarchyFromJava()
+        {
+            //the file comes from Java TestClassHierarchyRoundTrip SetUp3 testSimpleConstructors
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("simpleConstructorJavaProto.bin");
+            IClassNode simpleConstructorNode = (IClassNode)ch.GetNode("org.apache.reef.tang.implementation.SimpleConstructors");
+            Assert.AreEqual(simpleConstructorNode.GetChildren().Count, 0);
+            Assert.AreEqual(simpleConstructorNode.GetInjectableConstructors().Count, 3);
+        }
+
+        [TestMethod]
+        public void TestSerializeClassHierarchyForAvro()
+        {
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(Microsoft.Hadoop.Avro.AvroSerializer).Assembly.GetName().Name });
+            Assert.IsNotNull(ns);
+            ProtocolBufferClassHierarchy.Serialize("avro.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("avro.bin");
+            Assert.IsNotNull(ch);
+        }
+
+        [TestMethod]
+        public void TestDeSerializeClassHierarchyAndBind()
+        {
+            Type streamTask1Type = typeof(Org.Apache.Reef.Tasks.StreamTask1);
+            Type helloTaskType = typeof(Org.Apache.Reef.Tasks.HelloTask);
+
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(Org.Apache.Reef.Tasks.HelloTask).Assembly.GetName().Name });
+            IClassNode StreamTask1ClassNode = (IClassNode)ns.GetNode(streamTask1Type.AssemblyQualifiedName);
+            IClassNode HelloTaskClassNode = (IClassNode)ns.GetNode(helloTaskType.AssemblyQualifiedName);
+
+            ProtocolBufferClassHierarchy.Serialize("task.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("task.bin");
+            IClassNode StreamTask1ClassNode2 = (IClassNode)ch.GetNode(streamTask1Type.AssemblyQualifiedName);
+            IClassNode HelloTaskClassNode2 = (IClassNode)ch.GetNode(helloTaskType.AssemblyQualifiedName);
+
+            Assert.AreEqual(StreamTask1ClassNode.GetName(), StreamTask1ClassNode2.GetName());
+            Assert.AreEqual(HelloTaskClassNode.GetName(), HelloTaskClassNode2.GetName());
+
+            //have to use original class hierarchy for the merge. ClassHierarchy from ProtoBuffer doesn't support merge. 
+            IConfigurationBuilder cb = TangFactory.GetTang()
+                  .NewConfigurationBuilder(ns);
+            cb.AddConfiguration(TaskConfiguration.ConfigurationModule
+             .Set(TaskConfiguration.Identifier, "Hello_From_Streaming1")
+             .Set(TaskConfiguration.Task, GenericType<Org.Apache.Reef.Tasks.StreamTask1>.Class)
+             .Build());
+
+            IConfiguration taskConfiguration = cb.Build();
+            StreamTask1 st = TangFactory.GetTang().NewInjector(taskConfiguration).GetInstance<StreamTask1>();
+            Assert.IsNotNull(st);
+        }
+
+        [TestMethod]
+        public void TestSerirializeInjectionPlanForTimer()
+        {
+            Type timerType = typeof(Timer);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindNamedParameter<Timer.Seconds, Int32>(GenericType < Timer.Seconds>.Class, "2");
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            InjectionPlan ip = injector.GetInjectionPlan(timerType);
+            ProtocolBufferInjectionPlan.Serialize("timerplan.bin", ip);
+            var ch = conf.GetClassHierarchy();
+            var ip1 = ProtocolBufferInjectionPlan.DeSerialize("timerplan.bin", ch);
+            Assert.IsNotNull(ip1);
+        }
+
+        [TestMethod]
+        public void TestSerirializeInjectionPlanForSimpleConstructor()
+        {
+            Type simpleConstructorType = typeof(SimpleConstructors);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            InjectionPlan ip = injector.GetInjectionPlan(simpleConstructorType);
+
+            ProtocolBufferInjectionPlan.Serialize("plan.bin", ip);
+            var ch = conf.GetClassHierarchy();
+            var ipRecovered = ProtocolBufferInjectionPlan.DeSerialize("plan.bin", ch);
+            Assert.IsNotNull(ipRecovered);
+        }
+
+        [TestMethod]
+        public void TestGenericClass()
+        {
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(Timer).Assembly.GetName().Name });
+
+            Type t = typeof(Timer);
+            IClassNode EventClassNode = (IClassNode)ns.GetNode(t.AssemblyQualifiedName);
+            ProtocolBufferClassHierarchy.Serialize("event.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("event.bin");
+            IClassNode EventClassNode1 = (IClassNode)ns.GetNode(t.AssemblyQualifiedName);
+            Assert.AreEqual(EventClassNode.GetName(), EventClassNode1.GetName());
+        }
+
+        [TestMethod]
+        public void TestGenericArgument()
+        {
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { typeof(ClassWithGenericArgument<>).Assembly.GetName().Name });
+
+            Type t = typeof(ClassWithGenericArgument<>);
+            IClassNode classNode = (IClassNode)ns.GetNode(t.AssemblyQualifiedName);
+            var cons = classNode.GetAllConstructors();
+            foreach (var c in cons)
+            {
+                var args = c.GetArgs();
+                foreach (var a in args)
+                {
+                    Assert.IsNotNull(a.GetName());
+                }
+            }
+            ProtocolBufferClassHierarchy.Serialize("generic.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("generic.bin");
+            IClassNode classNode1 = (IClassNode)ns.GetNode(t.AssemblyQualifiedName);
+            Assert.AreEqual(classNode.GetName(), classNode1.GetName());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Configuration/TestAvroConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Configuration/TestAvroConfiguration.cs b/lang/cs/Tests/TangTests/Configuration/TestAvroConfiguration.cs
new file mode 100644
index 0000000..7f7a80d
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Configuration/TestAvroConfiguration.cs
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Configuration
+{
+    [TestClass]
+    public class TestAvroConfiguration
+    {
+        [TestMethod]
+        public void TestFromJsonString()
+        {
+            IConfigurationSerializer serializerImpl = (IConfigurationSerializer)TangFactory.GetTang().NewInjector().GetInstance(typeof(IConfigurationSerializer));
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            IConfiguration conf = cb.Build();
+            string jsonStr = serializerImpl.ToString(conf);
+
+            IConfiguration c = serializerImpl.FromString(jsonStr);
+            Assert.IsNotNull(c);
+
+            string jsonStr2 = serializerImpl.ToString(c);
+
+            IConfiguration c1 = serializerImpl.FromString(jsonStr2);
+            Assert.IsNotNull(c1);
+        }
+
+        private AvroConfiguration ToAvroConfiguration()
+        {
+            var a = new AvroConfiguration();
+            HashSet<ConfigurationEntry> b = new HashSet<ConfigurationEntry>();
+            ConfigurationEntry e1 = new ConfigurationEntry();
+            e1.key = "a";
+            e1.value = "a1";
+            ConfigurationEntry e2 = new ConfigurationEntry();
+            e2.key = "b";
+            e2.value = "b1=b2";
+            b.Add(e1);
+            b.Add(e2);
+            a.Bindings = b;
+            return a;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Configuration/TestAvroSerializerRoundTrip.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Configuration/TestAvroSerializerRoundTrip.cs b/lang/cs/Tests/TangTests/Configuration/TestAvroSerializerRoundTrip.cs
new file mode 100644
index 0000000..37c583d
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Configuration/TestAvroSerializerRoundTrip.cs
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Test.SmokeTest;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Configuration
+{
+    internal class TestAvroSerializerRoundTrip
+    {
+        [TestClass]
+        public class AvroConfigurationTest : RoundTripTest
+        {
+            public override IConfiguration RoundTrip(IConfiguration configuration)
+            {
+                AvroConfiguration aConf = new AvroConfigurationSerializer().ToAvroConfiguration(configuration);
+                return new AvroConfigurationSerializer().FromAvro(aConf);
+            }
+        }
+
+        [TestClass]
+        public class ByteArrayTest : RoundTripTest
+        {
+            public override IConfiguration RoundTrip(IConfiguration configuration)
+            {
+                AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+                byte[] theBytes = serializer.ToByteArray(configuration);
+                return serializer.FromByteArray(theBytes);
+            }
+        }
+
+        [TestClass]
+        public class FileTest : RoundTripTest
+        {
+            public override IConfiguration RoundTrip(IConfiguration configuration)
+            {
+                AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+                serializer.ToFile(configuration, "TangTest.avroconf");
+                return serializer.FromFile("TangTest.avroconf");
+            }
+        }
+
+        [TestClass]
+        public class StringTest : RoundTripTest
+        {
+            public override IConfiguration RoundTrip(IConfiguration configuration)
+            {
+                AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+                return serializer.FromString(serializer.ToString(configuration));
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Configuration/TestConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Configuration/TestConfiguration.cs b/lang/cs/Tests/TangTests/Configuration/TestConfiguration.cs
new file mode 100644
index 0000000..1e96cc3
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Configuration/TestConfiguration.cs
@@ -0,0 +1,566 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Examples;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Implementations.Configuration;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Tang.Test.ScenarioTest;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Configuration
+{
+    [TestClass]
+    public class TestConfiguration
+    {
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+        }
+
+        [TestMethod]
+        public void TestDeserializedConfigMerge()
+        {
+            Type activityInterfaceType = typeof(ITask);
+            ITang tang = TangFactory.GetTang();
+
+            ICsConfigurationBuilder cb1 = tang.NewConfigurationBuilder();
+            cb1.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            cb1.BindNamedParameter<TaskConfigurationOptions.Identifier, string>(
+                GenericType<TaskConfigurationOptions.Identifier>.Class, "Hello Task");
+            IConfiguration conf1 = cb1.Build();
+            var serializer = new AvroConfigurationSerializer();
+            serializer.ToFile(conf1, "task.config");
+
+            ICsConfigurationBuilder cb2 = tang.NewConfigurationBuilder();
+            cb2.BindNamedParameter<Timer.Seconds, Int32>(GenericType<Timer.Seconds>.Class, "2");
+            IConfiguration conf2 = cb2.Build();
+            serializer.ToFile(conf2, "timer.config");
+
+            ProtocolBufferClassHierarchy.Serialize("TaskTimer.bin", conf1.GetClassHierarchy());
+            IClassHierarchy ns = ProtocolBufferClassHierarchy.DeSerialize("TaskTimer.bin");
+
+            AvroConfiguration taskAvroconfiguration = serializer.AvroDeseriaizeFromFile("task.config");
+            IConfiguration taskConfiguration = serializer.FromAvro(taskAvroconfiguration, ns);
+
+            AvroConfiguration timerAvroconfiguration = serializer.AvroDeseriaizeFromFile("timer.config");
+            IConfiguration timerConfiguration = serializer.FromAvro(timerAvroconfiguration, ns);
+
+            IConfiguration merged = Configurations.MergeDeserializedConfs(taskConfiguration, timerConfiguration);
+
+            var b = merged.newBuilder().Build();
+        }
+
+        [TestMethod]
+        public void TestActivityConfiguration()
+        {
+            Type activityInterfaceType = typeof (ITask);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Common, FileNames.Tasks });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            cb.BindNamedParameter<TaskConfigurationOptions.Identifier, string>(
+                GenericType<TaskConfigurationOptions.Identifier>.Class, "Hello Task");
+            IConfiguration conf = cb.Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "TaskConf.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("TaskConf.txt");
+
+            ITang tang1 = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Common, FileNames.Tasks });
+            ConfigurationFile.AddConfigurationFromFile(cb1, "TaskConf.txt");
+            IConfiguration conf1 = cb1.Build();
+
+            IInjector injector = tang1.NewInjector(conf1);
+            var activityRef = (ITask) injector.GetInstance(activityInterfaceType);
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestMultipleConfiguration()
+        {
+            Type activityInterfaceType = typeof (ITask);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Common, FileNames.Tasks });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            cb.BindNamedParameter<TaskConfigurationOptions.Identifier, string>(
+                GenericType<TaskConfigurationOptions.Identifier>.Class, "Hello Task");
+            IConfiguration conf = cb.Build();
+
+            IConfiguration httpConfiguraiton = HttpHandlerConfiguration.CONF
+                .Set(HttpHandlerConfiguration.P, GenericType<HttpServerReefEventHandler>.Class)
+                .Set(HttpHandlerConfiguration.P, GenericType<HttpServerNrtEventHandler>.Class)
+                .Build();
+
+            IInjector injector = TangFactory.GetTang().NewInjector(new IConfiguration[] {conf, httpConfiguraiton});
+            var activityRef = (ITask) injector.GetInstance(activityInterfaceType);
+            Assert.IsNotNull(activityRef);
+
+            RuntimeClock clock = injector.GetInstance<RuntimeClock>();
+            var rh = clock.ClockRuntimeStartHandler.Get();
+            Assert.AreEqual(rh.Count, 1);
+        }
+
+        [TestMethod]
+        public void TestActivityConfigWithSeperateAssembly()
+        {
+            Type activityInterfaceType = typeof (ITask);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Common, FileNames.Tasks });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            IConfiguration conf = cb.Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "TaskConf1.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("TaskConf1.txt");
+
+            IInjector injector = tang.NewInjector(new string[] { FileNames.Common, FileNames.Tasks }, "TaskConf1.txt");
+            var activityRef = (ITask) injector.GetInstance(activityInterfaceType);
+
+            //combined line sample
+            var o = (ITask) TangFactory.GetTang()
+                   .NewInjector(new string[] { FileNames.Common, FileNames.Tasks }, "TaskConf1.txt")
+                   .GetInstance(typeof (ITask));
+
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestGetConfgiFromProtoBufClassHierarchy()
+        {
+            Type iTaskType = typeof(Org.Apache.Reef.Tasks.ITask);
+            Type helloTaskType = typeof(Org.Apache.Reef.Tasks.HelloTask);
+            Type identifierType = typeof (TaskConfigurationOptions.Identifier);
+
+            IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(new string[] { FileNames.Common, FileNames.Tasks });
+            ProtocolBufferClassHierarchy.Serialize("Task.bin", ns);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize("Task.bin");
+            ITang tang = TangFactory.GetTang();
+            IConfigurationBuilder cb = tang.NewConfigurationBuilder(ch);
+            cb.Bind(iTaskType.AssemblyQualifiedName, helloTaskType.AssemblyQualifiedName);
+            cb.Bind(identifierType.AssemblyQualifiedName, "Hello Task");
+            IConfiguration conf = cb.Build();
+            ConfigurationFile.WriteConfigurationFile(conf, "taskConf2.txt");
+        }
+
+        [TestMethod]
+        public void TestActivityConfig()
+        {
+            Type activityInterfaceType = typeof (ITask);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples, FileNames.Common, FileNames.Tasks });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            IConfiguration conf = cb.Build();
+            ConfigurationFile.WriteConfigurationFile(conf, "TaskConf.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("TaskConf.txt");
+
+            IInjector injector = tang.NewInjector(new string[] { FileNames.Common, FileNames.Tasks }, "TaskConf.txt");
+            var activityRef = (ITask) injector.GetInstance(activityInterfaceType);
+
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestActivityConfigWithString()
+        {
+            Type activityInterfaceType = typeof (ITask);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples, FileNames.Common, FileNames.Tasks });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            IConfiguration conf = cb.Build();
+
+            string s = ConfigurationFile.ToConfigurationString(conf);
+            ICsConfigurationBuilder cb2 = tang.NewConfigurationBuilder(new string[] { FileNames.Examples, FileNames.Common, FileNames.Tasks });
+            ConfigurationFile.AddConfigurationFromString(cb2, s);
+            IConfiguration conf2 = cb2.Build();
+
+            IInjector injector = tang.NewInjector(conf2);
+            var activityRef = (ITask) injector.GetInstance(activityInterfaceType);
+
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestTweetConfiguration()
+        {
+            Type tweeterType = typeof (Tweeter);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindImplementation(GenericType<ITweetFactory>.Class, GenericType<MockTweetFactory>.Class);
+            cb.BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class);
+            cb.BindNamedParameter<Tweeter.PhoneNumber, long>(GenericType<Tweeter.PhoneNumber>.Class, "8675309");
+            IConfiguration conf = cb.Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "tweeterConf.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("tweeterConf.txt");
+            ITang tang1 = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            ConfigurationFile.AddConfigurationFromFile(cb1, "tweeterConf.txt");
+            IConfiguration conf1 = cb1.Build();
+
+            IInjector injector = tang1.NewInjector(conf1);
+            var tweeter = (Tweeter) injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+        }
+
+        [TestMethod]
+        public void TestTweetConfig()
+        {
+            Type tweeterType = typeof (Tweeter);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindImplementation(GenericType<ITweetFactory>.Class, GenericType<MockTweetFactory>.Class);
+            cb.BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class);
+            cb.BindNamedParameter<Tweeter.PhoneNumber, long>(GenericType<Tweeter.PhoneNumber>.Class, "8675309");
+            IConfiguration conf = cb.Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "tweeterConf.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("tweeterConf.txt");
+
+            IInjector injector = tang.NewInjector(new string[] { FileNames.Examples }, "tweeterConf.txt");
+            var tweeter = (Tweeter) injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+        }
+
+
+        [TestMethod]
+        public void TestTweetConfigWithAvroThroughFile()
+        {
+            Type tweeterType = typeof (Tweeter);
+            ITang tang = TangFactory.GetTang();
+            IConfiguration conf = tang.NewConfigurationBuilder(new string[] { FileNames.Examples })
+                                      .BindImplementation(GenericType<ITweetFactory>.Class,
+                                                          GenericType<MockTweetFactory>.Class)
+                                      .BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class)
+                                      .BindNamedParameter<Tweeter.PhoneNumber, long>(
+                                          GenericType<Tweeter.PhoneNumber>.Class, "8675309")
+                                      .Build();
+
+            var serializer = new AvroConfigurationSerializer();
+            serializer.ToFileStream(conf, "tweeterConfAvro.bin");
+            IConfiguration conf2 = serializer.FromFileStream("tweeterConfAvro.bin");
+
+            IInjector injector = tang.NewInjector(conf2);
+            var tweeter = (Tweeter) injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+        }
+
+        [TestMethod]
+        public void TestTweetConfigAddConfigurationFromString()
+        {
+            Type tweeterType = typeof (Tweeter);
+            ITang tang = TangFactory.GetTang();
+            IConfiguration conf = tang.NewConfigurationBuilder(new string[] { FileNames.Examples })
+                                      .BindImplementation(GenericType<ITweetFactory>.Class,
+                                                          GenericType<MockTweetFactory>.Class)
+                                      .BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class)
+                                      .BindNamedParameter<Tweeter.PhoneNumber, long>(
+                                          GenericType<Tweeter.PhoneNumber>.Class, "8675309")
+                                      .Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "tweeterConf.txt");
+            string s = ConfigurationFile.ToConfigurationString(conf);
+            ICsConfigurationBuilder cb2 = tang.NewConfigurationBuilder();
+            ConfigurationFile.AddConfigurationFromString(cb2, s);
+            IConfiguration conf2 = cb2.Build();
+
+            IInjector injector = tang.NewInjector(conf2);
+            var tweeter = (Tweeter) injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+        }
+
+        [TestMethod]
+        public void TestTweetConfigWithAvroSerialization()
+        {
+            Type tweeterType = typeof (Tweeter);
+            ITang tang = TangFactory.GetTang();
+            IConfiguration conf = tang.NewConfigurationBuilder(new string[] { FileNames.Examples })
+                                      .BindImplementation(GenericType<ITweetFactory>.Class,
+                                                          GenericType<MockTweetFactory>.Class)
+                                      .BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class)
+                                      .BindNamedParameter<Tweeter.PhoneNumber, long>(
+                                          GenericType<Tweeter.PhoneNumber>.Class, "8675309")
+                                      .Build();
+
+            var serializer = new AvroConfigurationSerializer();
+            byte[] bytes = serializer.ToByteArray(conf);
+            IConfiguration conf2 = serializer.FromByteArray(bytes);
+
+            IInjector injector = tang.NewInjector(conf2);
+            var tweeter = (Tweeter) injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+        }
+
+        [TestMethod]
+        public void TestTweetConfigGetConfigurationFromString()
+        {
+            Type tweeterType = typeof (Tweeter);
+            ITang tang = TangFactory.GetTang();
+            IConfiguration conf = tang.NewConfigurationBuilder(new string[] { FileNames.Examples })
+                                      .BindImplementation(GenericType<ITweetFactory>.Class,
+                                                          GenericType<MockTweetFactory>.Class)
+                                      .BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class)
+                                      .BindNamedParameter<Tweeter.PhoneNumber, long>(
+                                          GenericType<Tweeter.PhoneNumber>.Class, "8675309")
+                                      .Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "tweeterConf.txt");
+            string s = ConfigurationFile.ToConfigurationString(conf);
+            IConfiguration conf2 = ConfigurationFile.GetConfiguration(s);
+
+            IInjector injector = tang.NewInjector(conf2);
+            var tweeter = (Tweeter) injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+        }
+
+        [TestMethod]
+        public void TestTweetInvalidBinding()
+        {
+            string msg = null;
+            try
+            {
+                TangFactory.GetTang().NewConfigurationBuilder(new string[] { FileNames.Examples })
+                           .BindImplementation(typeof (ITweetFactory), typeof (MockSMS))
+                           .Build();
+            }
+            catch (ArgumentException e)
+            {
+                msg = e.Message;
+            }
+            Assert.IsNotNull(msg);
+        }
+
+        [TestMethod]
+        public void TestTimerConfiguration()
+        {
+            Type timerType = typeof (Timer);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindNamedParameter<Timer.Seconds, Int32>(GenericType<Timer.Seconds>.Class, "2");
+            IConfiguration conf = cb.Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "timerConf.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("timerConf.txt");
+
+            ITang tang1 = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            ConfigurationFile.AddConfigurationFromFile(cb1, "timerConf.txt");
+            IConfiguration conf1 = cb1.Build();
+
+            IInjector injector = tang.NewInjector(conf1);
+            var timer = (Timer) injector.GetInstance(timerType);
+
+            Assert.IsNotNull(timer);
+
+            timer.sleep();
+        }
+
+        [TestMethod]
+        public void TestDocumentLoadNamedParameterConfiguration()
+        {
+            Type documentedLocalNamedParameterType = typeof (DocumentedLocalNamedParameter);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindNamedParameter<DocumentedLocalNamedParameter.Foo, string>(
+                GenericType<DocumentedLocalNamedParameter.Foo>.Class, "Hello");
+            IConfiguration conf = cb.Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "docLoadConf.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("docLoadConf.txt");
+
+            ITang tang1 = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            ConfigurationFile.AddConfigurationFromFile(cb1, "docLoadConf.txt");
+            IConfiguration conf1 = cb1.Build();
+
+            IInjector injector = tang1.NewInjector(conf1);
+            var doc = (DocumentedLocalNamedParameter) injector.GetInstance(documentedLocalNamedParameterType);
+
+            Assert.IsNotNull(doc);
+            var s = doc.ToString();
+        }
+
+        [TestMethod]
+        public void TestTimerConfigurationWithClassHierarchy()
+        {
+            Type timerType = typeof (Timer);
+            ClassHierarchyImpl classHierarchyImpl = new ClassHierarchyImpl(FileNames.Examples);
+
+            ITang tang = TangFactory.GetTang();
+            IConfiguration conf = tang.NewConfigurationBuilder(classHierarchyImpl)
+                                      .BindNamedParameter<Timer.Seconds, Int32>(GenericType<Timer.Seconds>.Class, "1")
+                                      .Build();
+
+            ConfigurationFile.WriteConfigurationFile(conf, "timerConfH.txt");
+            IDictionary<string, string> p = ConfigurationFile.FromFile("timerConfH.txt");
+
+            ITang tang1 = TangFactory.GetTang();
+            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            ConfigurationFile.AddConfigurationFromFile(cb1, "timerConfH.txt");
+            IConfiguration conf1 = cb1.Build();
+
+            IInjector injector = tang1.NewInjector(conf1);
+            var timer = (Timer) injector.GetInstance(timerType);
+
+            Assert.IsNotNull(timer);
+            timer.sleep();
+        }
+
+        [TestMethod]
+        public void TestSetConfig()
+        {
+            IConfiguration conf = TangFactory.GetTang().NewConfigurationBuilder()
+                .BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "four")
+                .BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "five")
+                .BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "six")
+                .Build();
+
+            Box b = (Box) TangFactory.GetTang().NewInjector(conf).GetInstance(typeof (Box));
+            ConfigurationFile.WriteConfigurationFile(conf, "SetOfNumbersConf.txt");
+
+            string s = ConfigurationFile.ToConfigurationString(conf);
+            IConfiguration conf2 = ConfigurationFile.GetConfiguration(s);
+
+            Box b2 = (Box) TangFactory.GetTang().NewInjector(conf2).GetInstance(typeof (Box));
+            ISet<string> actual = b2.Numbers;
+
+            Assert.IsTrue(actual.Contains("four"));
+            Assert.IsTrue(actual.Contains("five"));
+            Assert.IsTrue(actual.Contains("six"));
+        }
+
+        [TestMethod]
+        public void TestSetConfigWithAvroSerialization()
+        {
+            IConfiguration conf = TangFactory.GetTang().NewConfigurationBuilder()
+                    .BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "four")
+                    .BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "five")
+                    .BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "six")
+                    .Build();
+
+            Box b = (Box) TangFactory.GetTang().NewInjector(conf).GetInstance(typeof (Box));
+
+            var serializer = new AvroConfigurationSerializer();
+            byte[] bytes = serializer.ToByteArray(conf);
+            IConfiguration conf2 = serializer.FromByteArray(bytes);
+
+            Box b2 = (Box) TangFactory.GetTang().NewInjector(conf2).GetInstance(typeof (Box));
+            ISet<string> actual = b2.Numbers;
+
+            Assert.IsTrue(actual.Contains("four"));
+            Assert.IsTrue(actual.Contains("five"));
+            Assert.IsTrue(actual.Contains("six"));
+        }
+
+        [TestMethod]
+        public void TestNullStringVaue()
+        {
+            string msg = null;
+            try
+            {
+                TangFactory.GetTang().NewConfigurationBuilder()
+                    .BindNamedParameter<NamedParamterNoDefault.NamedString, string>(GenericType<NamedParamterNoDefault.NamedString>.Class, null)
+                    .Build();
+            }
+            catch (IllegalStateException e)
+            {
+                msg = e.Message;
+            }
+            Assert.IsNotNull(msg);
+        }
+
+        [TestMethod]
+        public void TestSetConfigNullValue()
+        {
+            string msg = null;
+            try
+            {
+                TangFactory.GetTang().NewConfigurationBuilder()
+                    .BindSetEntry<SetOfNumbersNoDefault, string>(GenericType<SetOfNumbersNoDefault>.Class, null)
+                    .BindSetEntry<SetOfNumbersNoDefault, string>(GenericType<SetOfNumbersNoDefault>.Class, "five")
+                    .BindSetEntry<SetOfNumbersNoDefault, string>(GenericType<SetOfNumbersNoDefault>.Class, "six")
+                    .Build();
+            }
+            catch (IllegalStateException e)
+            {
+                msg = e.Message;
+            }
+            Assert.IsNotNull(msg);
+        }
+    }
+
+    [NamedParameter(DefaultValues = new string[] {"one", "two", "three"})]
+    class SetOfNumbers : Name<ISet<string>>
+    {
+    }
+
+    class Box
+    {
+        public ISet<string> Numbers;
+
+        [Inject]
+        Box([Parameter(typeof (SetOfNumbers))] ISet<string> numbers)
+        {
+            this.Numbers = numbers;
+        }
+    }
+
+    [NamedParameter]
+    class SetOfNumbersNoDefault : Name<ISet<string>>
+    {
+    }
+
+    class BoxNoDefault
+    {
+        public ISet<string> Numbers;
+
+        [Inject]
+        BoxNoDefault([Parameter(typeof(SetOfNumbersNoDefault))] ISet<string> numbers)
+        {
+            this.Numbers = numbers;
+        }
+    }
+
+    class NamedParamterNoDefault
+    {
+        private string str;
+
+        [NamedParameter]
+        public class NamedString : Name<string>
+        {
+        }
+
+        [Inject]
+        NamedParamterNoDefault([Parameter(typeof (NamedString))] string str)
+        {
+            this.str = str;
+        }
+
+        public string GetString()
+        {
+            return str;
+        }
+    }
+}
\ No newline at end of file


[26/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/CloseEventImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/CloseEventImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/CloseEventImpl.cs
new file mode 100644
index 0000000..e3a13b8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/CloseEventImpl.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Common
+{
+    public class CloseEventImpl : ICloseEvent
+    {
+        public CloseEventImpl()
+        {
+            Value = Optional<byte[]>.Empty();
+        }
+
+        public CloseEventImpl(byte[] bytes)
+        {
+            Value = Optional<byte[]>.OfNullable(bytes);
+        }
+
+        public Optional<byte[]> Value
+        {
+            get { return Value; }
+            set { value = Value; } 
+        }
+
+        public override string ToString()
+        {
+            return "CloseEvent{value=" + Value.ToString() + "}";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/DriverMessageImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/DriverMessageImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/DriverMessageImpl.cs
new file mode 100644
index 0000000..034df50
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/DriverMessageImpl.cs
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Common.Runtime.Evaluator
+{
+    public class DriverMessageImpl : IDriverMessage
+    {
+        private Optional<byte[]> _value;
+ 
+        public DriverMessageImpl()
+        {
+            _value = Optional<byte[]>.Empty();
+        }
+
+        public DriverMessageImpl(byte[] bytes)
+        {
+            _value = Optional<byte[]>.OfNullable(bytes);
+        }
+
+        public Optional<byte[]> Message
+        {
+            get
+            {
+                return _value;
+            }
+        }
+
+        public override string ToString()
+        {
+            return "DriverMessage [value=" + ByteUtilities.ByteArrarysToString(_value.Value) + "]";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/SuspendEventImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/SuspendEventImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/SuspendEventImpl.cs
new file mode 100644
index 0000000..c75b09f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/SuspendEventImpl.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Common
+{
+    public class SuspendEventImpl : ICloseEvent
+    {
+        public SuspendEventImpl()
+        {
+            Value = Optional<byte[]>.Empty();
+        }
+
+        public SuspendEventImpl(byte[] bytes)
+        {
+            Value = Optional<byte[]>.OfNullable(bytes);
+        }
+
+        public Optional<byte[]> Value
+        {
+            get { return Value; }
+            set { value = Value; }
+        }
+
+        public override string ToString()
+        {
+            return "SuspendEvent{value=" + Value.ToString() + "}";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskClientCodeException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskClientCodeException.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskClientCodeException.cs
new file mode 100644
index 0000000..65b8be9
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskClientCodeException.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Common.Task
+{
+    public class TaskClientCodeException : Exception
+    {
+        private readonly string _taskId;
+
+        private readonly string _contextId;
+
+        /// <summary>
+        /// construct the exception that caused the Task to fail
+        /// </summary>
+        /// <param name="taskId"> the id of the failed task.</param>
+        /// <param name="contextId"> the id of the context the failed Task was executing in.</param>
+        /// <param name="message"> the error message </param>
+        /// <param name="cause"> the exception that caused the Task to fail.</param>
+        public TaskClientCodeException(
+                string taskId,
+                string contextId,
+                string message,
+                Exception cause)
+            : base(message, cause)
+        {
+            _taskId = taskId;
+            _contextId = contextId;
+        }
+
+        public string TaskId 
+        {
+            get { return _taskId; }
+        }
+
+        public string ContextId
+        {
+            get { return _contextId; }
+        }
+
+        public static string GetTaskIdentifier(IConfiguration c)
+        {
+            // TODO: update after TANG is available
+            return string.Empty;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskLifeCycle.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskLifeCycle.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskLifeCycle.cs
new file mode 100644
index 0000000..30acc2e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskLifeCycle.cs
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Wake;
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Common
+{
+    public class TaskLifeCycle
+    {
+        private readonly HashSet<IObserver<ITaskStop>> _taskStopHandlers;
+        private readonly HashSet<IObserver<ITaskStart>> _taskStartHandlers;
+        private readonly ITaskStart _taskStart;
+        private readonly ITaskStop _taskStop;
+
+        // INJECT
+        public TaskLifeCycle(
+            HashSet<IObserver<ITaskStop>> taskStopHandlers,
+            HashSet<IObserver<ITaskStart>> taskStartHandlers,
+            TaskStartImpl taskStart,
+            TaskStopImpl taskStop)
+        {
+            _taskStartHandlers = taskStartHandlers;
+            _taskStopHandlers = taskStopHandlers;
+            _taskStart = taskStart;
+            _taskStop = taskStop;
+        }
+
+        public TaskLifeCycle()
+        {
+            _taskStartHandlers = new HashSet<IObserver<ITaskStart>>();
+            _taskStopHandlers = new HashSet<IObserver<ITaskStop>>();
+        }
+        
+        public void Start() 
+        {
+            foreach (IObserver<ITaskStart> startHandler in _taskStartHandlers) 
+            {
+                startHandler.OnNext(_taskStart);
+            }
+        }
+
+        public void Stop() 
+        {
+            foreach (IObserver<ITaskStop> stopHandler in _taskStopHandlers)
+            {
+                stopHandler.OnNext(_taskStop);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskRuntime.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskRuntime.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskRuntime.cs
new file mode 100644
index 0000000..05d6eec
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskRuntime.cs
@@ -0,0 +1,328 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Common.Runtime.Evaluator;
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common
+{
+    public class TaskRuntime : IObserver<ICloseEvent>, IObserver<ISuspendEvent>, IObserver<IDriverMessage>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TaskRuntime));
+        
+        private readonly ITask _task;
+
+        private readonly IInjector _injector;
+
+        // The memento given by the task configuration
+        private readonly Optional<byte[]> _memento;
+
+        private readonly HeartBeatManager _heartBeatManager;
+
+        private readonly TaskStatus _currentStatus;
+
+        private readonly INameClient _nameClient;
+
+        public TaskRuntime(IInjector taskInjector, string contextId, string taskId, HeartBeatManager heartBeatManager, string memento = null)
+        {
+            _injector = taskInjector;
+            _heartBeatManager = heartBeatManager;
+
+            Optional<ISet<ITaskMessageSource>> messageSources = Optional<ISet<ITaskMessageSource>>.Empty();
+            try
+            {
+                _task = _injector.GetInstance<ITask>();
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(new InvalidOperationException("Unable to inject task.", e), Level.Error, "Unable to inject task.", LOGGER);
+            }
+            try
+            {
+                ITaskMessageSource taskMessageSource = _injector.GetInstance<ITaskMessageSource>();
+                messageSources = Optional<ISet<ITaskMessageSource>>.Of(new HashSet<ITaskMessageSource>() { taskMessageSource });
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, "Cannot inject task message source with error: " + e.StackTrace, LOGGER);
+                // do not rethrow since this is benign
+            }
+            try
+            {
+                _nameClient = _injector.GetInstance<INameClient>();
+                _heartBeatManager.EvaluatorSettings.NameClient = _nameClient;
+            }
+            catch (InjectionException)
+            {
+                LOGGER.Log(Level.Warning, "Cannot inject name client from task configuration.");
+                // do not rethrow since user is not required to provide name client
+            }
+
+            LOGGER.Log(Level.Info, "task message source injected");
+            _currentStatus = new TaskStatus(_heartBeatManager, contextId, taskId, messageSources);
+            _memento = memento == null ?
+                Optional<byte[]>.Empty() : Optional<byte[]>.Of(ByteUtilities.StringToByteArrays(memento));
+        }
+
+        public string TaskId
+        {
+            get { return _currentStatus.TaskId; }
+        }
+
+        public string ContextId
+        {
+            get { return _currentStatus.ContextId; }
+        }
+
+        public void Initialize()
+        {
+            _currentStatus.SetRunning();
+        }
+
+        /// <summary>
+        /// Run the task
+        /// </summary>
+        public void Start()
+        {
+            try
+            {
+                LOGGER.Log(Level.Info, "Call Task");
+                if (_currentStatus.IsNotRunning())
+                {
+                    var e = new InvalidOperationException("TaskRuntime not in Running state, instead it is in state " + _currentStatus.State);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                byte[] result;
+                byte[] taskMemento = _memento.IsPresent() ? _memento.Value : null;
+                System.Threading.Tasks.Task<byte[]> runTask = new System.Threading.Tasks.Task<byte[]>(() => RunTask(taskMemento));
+                try
+                {
+                    runTask.Start();
+                    runTask.Wait();
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(e, Level.Error, "Exception thrown during task running.", LOGGER);
+                }
+                result = runTask.Result;
+
+                LOGGER.Log(Level.Info, "Task Call Finished");
+                if (_task != null)
+                {
+                    _task.Dispose();
+                }
+                _currentStatus.SetResult(result);
+                if (result != null && result.Length > 0)
+                {
+                    LOGGER.Log(Level.Info, "Task running result:\r\n" + System.Text.Encoding.Default.GetString(result));
+                }
+            }
+            catch (Exception e)
+            {
+                if (_task != null)
+                {
+                    _task.Dispose();
+                }
+                LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Task failed caused by exception [{0}]", e));
+                _currentStatus.SetException(e);
+            }
+        }
+
+        public TaskState GetTaskState()
+        {
+            return _currentStatus.State;
+        }
+
+        /// <summary>
+        /// Called by heartbeat manager
+        /// </summary>
+        /// <returns>  current TaskStatusProto </returns>
+        public TaskStatusProto GetStatusProto()
+        {
+            return _currentStatus.ToProto();
+        }
+
+        public bool HasEnded()
+        {
+            return _currentStatus.HasEnded();
+        }
+
+        /// <summary>
+        /// get ID of the task.
+        /// </summary>
+        /// <returns>ID of the task.</returns>
+        public string GetActicityId()
+        {
+            return _currentStatus.TaskId;
+        }
+
+        public void Close(byte[] message)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Trying to close Task {0}", TaskId));
+            if (_currentStatus.IsNotRunning())
+            {
+                LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Trying to close an task that is in {0} state. Ignored.", _currentStatus.State));
+            }
+            else
+            {
+                try
+                {
+                    OnNext(new CloseEventImpl(message));
+                    _currentStatus.SetCloseRequested();
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Error during Close.", LOGGER);
+
+                    _currentStatus.SetException(
+                        new TaskClientCodeException(TaskId, ContextId, "Error during Close().", e));
+                }
+            }
+        }
+
+        public void Suspend(byte[] message)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Trying to suspend Task {0}", TaskId));
+            
+            if (_currentStatus.IsNotRunning())
+            {
+                LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Trying to supend an task that is in {0} state. Ignored.", _currentStatus.State));
+            }
+            else
+            {
+                try
+                {
+                    OnNext(new SuspendEventImpl(message));
+                    _currentStatus.SetSuspendRequested();
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Error during Suspend.", LOGGER);
+                    _currentStatus.SetException(
+                        new TaskClientCodeException(TaskId, ContextId, "Error during Suspend().", e));
+                }
+            }
+        }
+
+        public void Deliver(byte[] message)
+        {
+            if (_currentStatus.IsNotRunning())
+            {
+                LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Trying to send a message to an task that is in {0} state. Ignored.", _currentStatus.State));
+            }
+            else
+            {
+                try
+                {
+                    OnNext(new DriverMessageImpl(message));
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Error during message delivery.", LOGGER);
+                    _currentStatus.SetException(
+                        new TaskClientCodeException(TaskId, ContextId, "Error during message delivery.", e));
+                }
+            }
+        }
+
+        public void OnNext(ICloseEvent value)
+        {
+            LOGGER.Log(Level.Info, "TaskRuntime::OnNext(ICloseEvent value)");
+            // TODO: send a heartbeat
+        }
+
+        void IObserver<ICloseEvent>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<IDriverMessage>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<IDriverMessage>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ISuspendEvent>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ISuspendEvent>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ICloseEvent>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(ISuspendEvent value)
+        {
+            LOGGER.Log(Level.Info, "TaskRuntime::OnNext(ISuspendEvent value)");
+            // TODO: send a heartbeat
+        }
+
+        public void OnNext(IDriverMessage value)
+        {
+            IDriverMessageHandler messageHandler = null;
+            LOGGER.Log(Level.Info, "TaskRuntime::OnNext(IDriverMessage value)");
+            try
+            {
+                messageHandler = _injector.GetInstance<IDriverMessageHandler>();
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(e, Level.Error, "Received Driver message, but unable to inject handler for driver message ", LOGGER);
+            }
+            if (messageHandler != null)
+            {
+                try
+                {
+                    messageHandler.Handle(value);
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, "Exception throw when handling driver message: " + e, LOGGER);
+                    _currentStatus.RecordExecptionWithoutHeartbeat(e);
+                }
+            }
+        }
+
+        private byte[] RunTask(byte[] memento)
+        {
+            return _task.Call(memento);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStartImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStartImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStartImpl.cs
new file mode 100644
index 0000000..c4047b8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStartImpl.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+
+namespace Org.Apache.Reef.Common
+{
+    public class TaskStartImpl : ITaskStart
+    {        
+        //INJECT
+        public TaskStartImpl(string id)
+        {
+            Id = id;
+        }
+
+        public string Id { get; set; } 
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskState.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskState.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskState.cs
new file mode 100644
index 0000000..9e3bcb4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskState.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common
+{
+    public enum TaskState
+    {
+        Init = 0,
+        
+        Running = 1,
+
+        CloseRequested = 2,
+
+        SuspendRequested = 3,
+
+        Suspended = 4,
+
+        Failed = 5,
+
+        Done = 6,
+
+        Killed = 7
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStatus.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStatus.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStatus.cs
new file mode 100644
index 0000000..639a7d0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStatus.cs
@@ -0,0 +1,330 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common
+{
+    public class TaskStatus
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TaskStatus));
+        private readonly TaskLifeCycle _taskLifeCycle;
+        private readonly HeartBeatManager _heartBeatManager;
+        private readonly Optional<ISet<ITaskMessageSource>> _evaluatorMessageSources;
+
+        private string _taskId;
+        private string _contextId;
+        private Optional<Exception> _lastException = Optional<Exception>.Empty();
+        private Optional<byte[]> _result = Optional<byte[]>.Empty();
+        private TaskState _state;
+
+        public TaskStatus(HeartBeatManager heartBeatManager, string contextId, string taskId, Optional<ISet<ITaskMessageSource>> evaluatorMessageSources)
+        {
+            _contextId = contextId;
+            _taskId = taskId;
+            _heartBeatManager = heartBeatManager;
+            _taskLifeCycle = new TaskLifeCycle();
+            _evaluatorMessageSources = evaluatorMessageSources;
+            State = TaskState.Init;
+        }
+
+        public TaskState State
+        {
+            get
+            {
+                return _state;
+            }
+
+            set
+            {
+                if (IsLegalStateTransition(_state, value))
+                {
+                    _state = value;
+                }
+                else
+                {
+                    string message = string.Format(CultureInfo.InvariantCulture, "Illegal state transition from [{0}] to [{1}]", _state, value);
+                    LOGGER.Log(Level.Error, message);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException(message), LOGGER);
+                }
+            }
+        }
+
+        public string TaskId
+        {
+            get { return _taskId; }
+        }
+
+        public string ContextId
+        {
+            get { return _contextId; }
+        }
+
+        public void SetException(Exception e)
+        {
+            RecordExecptionWithoutHeartbeat(e);
+            Heartbeat();
+            _lastException = Optional<Exception>.Empty();
+        }
+
+        public void SetResult(byte[] result)
+        {
+            _result = Optional<byte[]>.OfNullable(result);
+            if (State == TaskState.Running)
+            {
+                State = TaskState.Done;
+            }
+            else if (State == TaskState.SuspendRequested)
+            {
+                State = TaskState.Suspended;
+            }
+            else if (State == TaskState.CloseRequested)
+            {
+                State = TaskState.Done;
+            }
+            _taskLifeCycle.Stop();
+            Heartbeat();
+        }
+
+        public void SetRunning()
+        {
+            LOGGER.Log(Level.Verbose, "TaskStatus::SetRunning");
+            if (_state == TaskState.Init)
+            {
+                try
+                {
+                    _taskLifeCycle.Start();
+                    // Need to send an INIT heartbeat to the driver prompting it to create an RunningTask event. 
+                    LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Sending task INIT heartbeat"));
+                    Heartbeat();
+                    State = TaskState.Running;
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Cannot set task status to running.", LOGGER);
+                    SetException(e);
+                }
+            }
+        }
+
+        public void SetCloseRequested()
+        {
+            State = TaskState.CloseRequested;
+        }
+
+        public void SetSuspendRequested()
+        {
+            State = TaskState.SuspendRequested;
+        }
+
+        public void SetKilled()
+        {
+            State = TaskState.Killed;
+            Heartbeat();
+        }
+
+        public bool IsNotRunning()
+        {
+            return _state != TaskState.Running;
+        }
+
+        public bool HasEnded()
+        {
+            switch (_state)
+            {
+                case TaskState.Done:
+                case TaskState.Suspended:
+                case TaskState.Failed:
+                case TaskState.Killed:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        public TaskStatusProto ToProto()
+        {
+            Check();
+            TaskStatusProto taskStatusProto = new TaskStatusProto()
+            {
+                context_id = _contextId,
+                task_id = _taskId,
+                state = GetProtoState(),
+            };
+            if (_result.IsPresent())
+            {
+                taskStatusProto.result = ByteUtilities.CopyBytesFrom(_result.Value);
+            }
+            else if (_lastException.IsPresent())
+            {
+                //final Encoder<Throwable> codec = new ObjectSerializableCodec<>();
+                //final byte[] error = codec.encode(_lastException.get());
+                byte[] error = ByteUtilities.StringToByteArrays(_lastException.Value.ToString());
+                taskStatusProto.result = ByteUtilities.CopyBytesFrom(error);
+            }
+            else if (_state == TaskState.Running)
+            {
+                foreach (TaskMessage message in GetMessages())
+                {
+                    TaskStatusProto.TaskMessageProto taskMessageProto = new TaskStatusProto.TaskMessageProto()
+                    {
+                        source_id = message.MessageSourceId,
+                        message = ByteUtilities.CopyBytesFrom(message.Message),
+                    };
+                    taskStatusProto.task_message.Add(taskMessageProto);
+                }
+            }
+            return taskStatusProto;
+        }
+
+        internal void RecordExecptionWithoutHeartbeat(Exception e)
+        {
+            if (!_lastException.IsPresent())
+            {
+                _lastException = Optional<Exception>.Of(e);
+            }
+            State = TaskState.Failed;
+            _taskLifeCycle.Stop();
+        }
+
+        private static bool IsLegalStateTransition(TaskState? from, TaskState to)
+        {
+            if (from == null)
+            {
+                return to == TaskState.Init;
+            }
+            switch (from)
+            {
+                case TaskState.Init:
+                    switch (to)
+                    {
+                        case TaskState.Init:
+                        case TaskState.Running:
+                        case TaskState.Failed:
+                        case TaskState.Killed:
+                        case TaskState.Done:
+                            return true;
+                        default:
+                            return false;
+                    }
+                case TaskState.Running:
+                    switch (to)
+                    {
+                        case TaskState.CloseRequested:
+                        case TaskState.SuspendRequested:
+                        case TaskState.Failed:
+                        case TaskState.Killed:
+                        case TaskState.Done:
+                            return true;
+                        default:
+                            return false;
+                    }
+                case TaskState.CloseRequested:
+                    switch (to)
+                    {
+                        case TaskState.Failed:
+                        case TaskState.Killed:
+                        case TaskState.Done:
+                            return true;
+                        default:
+                            return false;
+                    }
+                case TaskState.SuspendRequested:
+                    switch (to)
+                    {
+                        case TaskState.Failed:
+                        case TaskState.Killed:
+                        case TaskState.Suspended:
+                            return true;
+                        default:
+                            return false;
+                    }
+
+                case TaskState.Failed:
+                case TaskState.Done:
+                case TaskState.Killed:           
+                default:
+                    return true;
+            }
+        }
+
+        private void Check()
+        {
+            if (_result.IsPresent() && _lastException.IsPresent())
+            {
+                LOGGER.Log(Level.Warning, "Both task result and exception are present, the expcetion will take over. Thrown away result:" + ByteUtilities.ByteArrarysToString(_result.Value));
+                State = TaskState.Failed;
+                _result = Optional<byte[]>.Empty();
+            }
+        }
+
+        private void Heartbeat()
+        {
+            _heartBeatManager.OnNext(ToProto());
+        }
+
+        private State GetProtoState()
+        {
+            switch (_state)
+            {
+                case TaskState.Init:
+                    return ProtoBuf.ReefServiceProto.State.INIT;
+                case TaskState.CloseRequested:
+                case TaskState.SuspendRequested:
+                case TaskState.Running:
+                    return ProtoBuf.ReefServiceProto.State.RUNNING;
+                case TaskState.Done:
+                    return ProtoBuf.ReefServiceProto.State.DONE;
+                case TaskState.Suspended:
+                    return ProtoBuf.ReefServiceProto.State.SUSPEND;
+                case TaskState.Failed:
+                    return ProtoBuf.ReefServiceProto.State.FAILED;
+                case TaskState.Killed:
+                    return ProtoBuf.ReefServiceProto.State.KILLED;
+                default:
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException("Unknown state: " + _state), LOGGER);
+                    break;
+            }
+            return ProtoBuf.ReefServiceProto.State.FAILED; //this line should not be reached as default case will throw exception
+        }
+
+        private ICollection<TaskMessage> GetMessages()
+        {
+            List<TaskMessage> result = new List<TaskMessage>();
+            if (_evaluatorMessageSources.IsPresent())
+            {
+                foreach (ITaskMessageSource source in _evaluatorMessageSources.Value)
+                {
+                    Optional<TaskMessage> taskMessageOptional = source.Message;
+                    if (taskMessageOptional.IsPresent())
+                    {
+                        result.Add(taskMessageOptional.Value);
+                    }
+                }
+            }
+            return result;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStopImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStopImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStopImpl.cs
new file mode 100644
index 0000000..2c7e75e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/task/TaskStopImpl.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Tasks.Events;
+
+namespace Org.Apache.Reef.Common
+{
+    public class TaskStopImpl : ITaskStop
+    {
+        //INJECT
+        public TaskStopImpl(string id)
+        {
+            Id = id;
+        }
+
+        public string Id { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/EvaluatorConfigurations.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/EvaluatorConfigurations.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/EvaluatorConfigurations.cs
new file mode 100644
index 0000000..3154541
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/EvaluatorConfigurations.cs
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using System;
+using System.IO;
+using System.Linq;
+
+namespace Org.Apache.Reef.Common
+{
+    public class EvaluatorConfigurations
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorConfigurations));
+
+        private AvroConfiguration _avroConfiguration;
+
+        private string _configFile;
+
+        private string _applicationId;
+
+        private string _evaluatorId;
+
+        private string _taskConfiguration;
+
+        private string _rootContextConfiguration;
+
+        private string _rootServiceConfiguration;
+
+        public EvaluatorConfigurations(string configFile)
+        {
+            using (LOGGER.LogFunction("EvaluatorConfigurations::EvaluatorConfigurations"))
+            {
+                if (string.IsNullOrWhiteSpace(configFile))
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("configFile"), LOGGER);
+                }
+                if (!File.Exists(configFile))
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new FileNotFoundException("cannot find file " + configFile), LOGGER);
+                }
+                _configFile = configFile;
+                AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+                _avroConfiguration = serializer.AvroDeseriaizeFromFile(_configFile);
+            }
+        }
+
+        public string TaskConfiguration
+        {
+            get
+            {
+                _taskConfiguration = _taskConfiguration ?? GetSettingValue(Reef.Evaluator.Constants.TaskConfiguration);
+                return _taskConfiguration;
+            }
+        }
+
+        public string EvaluatorId
+        {
+            get
+            {
+                _evaluatorId = _evaluatorId ?? GetSettingValue(Reef.Evaluator.Constants.EvaluatorIdentifier);
+                return _evaluatorId;
+            }
+        }
+
+        public string ApplicationId
+        {
+            get
+            {
+                _applicationId = _applicationId ?? GetSettingValue(Reef.Evaluator.Constants.ApplicationIdentifier);
+                return _applicationId;
+            }
+        }
+
+        public string RootContextConfiguration
+        {
+            get
+            {
+                _rootContextConfiguration = _rootContextConfiguration ?? GetSettingValue(Reef.Evaluator.Constants.RootContextConfiguration);
+                return _rootContextConfiguration;
+            }
+        }
+
+        public string RootServiceConfiguration
+        {
+            get
+            {
+                _rootServiceConfiguration = _rootServiceConfiguration ?? GetSettingValue(Reef.Evaluator.Constants.RootServiceConfiguration);
+                return _rootServiceConfiguration;
+            }
+        }
+
+        private string GetSettingValue(string settingKey)
+        {
+            ConfigurationEntry configurationEntry =
+                _avroConfiguration.Bindings.SingleOrDefault(b => b.key.EndsWith(settingKey, StringComparison.OrdinalIgnoreCase));
+            if (configurationEntry == null)
+            {
+                return string.Empty;
+            }
+
+            return configurationEntry.value;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/RemoteManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/RemoteManager.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/RemoteManager.cs
new file mode 100644
index 0000000..4e68186
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/utils/RemoteManager.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common
+{
+    public class RemoteManager
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/services/IService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/services/IService.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/services/IService.cs
new file mode 100644
index 0000000..cbcebf8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/services/IService.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Services
+{
+    public interface IService
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServiceConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServiceConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServiceConfiguration.cs
new file mode 100644
index 0000000..c51ef40
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServiceConfiguration.cs
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "static field, typical usage in configurations")]
+
+namespace Org.Apache.Reef.Services
+{
+    /// <summary>
+    /// Configuration module for services. The configuration created here can be passed alongside a ContextConfiguration
+    /// to form a context. Different from bindings made in the ContextConfiguration, those made here will be passed along
+    /// to child context.
+    /// </summary>
+    public class ServiceConfiguration : ConfigurationModuleBuilder
+    {
+        /// <summary>
+        /// A set of services to instantiate. All classes given here will be instantiated in the context, and their references
+        /// will be made available to child context and tasks.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalParameter<IService> Services = new OptionalParameter<IService>();
+
+        public ServiceConfiguration()
+            : base()
+        {
+        }
+
+        public ServiceConfiguration(string config)
+        {
+            TangConfig = new AvroConfigurationSerializer().FromString(config);
+        }
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new ServiceConfiguration()
+                    .BindSetEntry(GenericType<ServicesSet>.Class, Services)
+                    .Build();
+            }
+        }
+
+        public IConfiguration TangConfig { get; private set; }
+    }
+
+    public class InjectedServices
+    {
+        [Inject]
+        public InjectedServices([Parameter(typeof(ServicesSet))] ISet<IService> services)
+        {
+            Services = services;
+        }
+
+        public ISet<IService> Services { get; set; }
+    }
+
+    [NamedParameter("Set of services", "servicesSet", "")]
+    class ServicesSet : Name<ISet<IService>>
+    {      
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServicesConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServicesConfigurationOptions.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServicesConfigurationOptions.cs
new file mode 100644
index 0000000..30a38de
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/services/ServicesConfigurationOptions.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Services
+{
+    public class ServicesConfigurationOptions
+    {
+        [NamedParameter("Services", "services", "services")]
+        public class Services : Name<string>
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IDriverMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IDriverMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IDriverMessageHandler.cs
new file mode 100644
index 0000000..a0111b8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IDriverMessageHandler.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Defaults;
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tasks
+{
+    //[DefaultImplementation(typeof(DefaultTaskMessageSource))]
+    public interface IDriverMessageHandler
+    {
+        void Handle(IDriverMessage message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IRunningTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IRunningTask.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IRunningTask.cs
new file mode 100644
index 0000000..92a6887
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/IRunningTask.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Common.Task
+{
+    /// <summary>
+    /// Represents a running Task
+    /// </summary>
+    public interface IRunningTask : IIdentifiable, IDisposable
+    {
+        /// <summary>
+        /// Sends the message to the running task.
+        /// </summary>
+        /// <param name="message"></param>
+        void OnNext(byte[] message);
+
+        /// <summary>
+        ///  Signal the task to suspend.
+        /// </summary>
+        /// <param name="message">a message that is sent to the Task.</param>
+        void Suspend(byte[] message);
+
+        /// <summary>
+        /// Sends the message to the running task.
+        /// </summary>
+        void Suspend();
+
+        /// <summary>
+        /// Signal the task to shut down.
+        /// </summary>
+        /// <param name="message">a message that is sent to the Task.</param>
+        void Dispose(byte[] message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITask.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITask.cs
new file mode 100644
index 0000000..3655a4b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITask.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public interface ITask : IDisposable
+    {
+        byte[] Call(byte[] memento);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITaskMessageSource.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITaskMessageSource.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITaskMessageSource.cs
new file mode 100644
index 0000000..589a445
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/ITaskMessageSource.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Defaults;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tasks
+{
+    [DefaultImplementation(typeof(DefaultTaskMessageSource))]
+    public interface ITaskMessageSource
+    {
+        Optional<TaskMessage> Message { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfiguration.cs
new file mode 100644
index 0000000..6fb386b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfiguration.cs
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "static readonly field, typical usage in configurations")]
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class TaskConfiguration : ConfigurationModuleBuilder
+    {
+        // this is a hack for getting the task identifier for now
+        public const string TaskIdentifier = "TaskConfigurationOptions+Identifier";
+
+        /// <summary>
+        ///  The identifier of the task.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredParameter<string> Identifier = new RequiredParameter<string>();
+
+        /// <summary>
+        /// The task to instantiate.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredImpl<ITask> Task = new RequiredImpl<ITask>();
+
+        /// <summary>
+        /// for task suspension. Defaults to task failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ISuspendEvent>> OnSuspend = new OptionalImpl<IObserver<ISuspendEvent>>();
+
+        /// <summary>
+        /// for messages from the driver. Defaults to task failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IDriverMessageHandler> OnMessage = new OptionalImpl<IDriverMessageHandler>();
+
+        /// <summary>
+        /// for closure requests from the driver. Defaults to task failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ICloseEvent>> OnClose = new OptionalImpl<IObserver<ICloseEvent>>();
+
+        /// <summary>
+        /// Message source invoked upon each evaluator heartbeat.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<ITaskMessageSource> OnSendMessage = new OptionalImpl<ITaskMessageSource>();
+
+        /// <summary>
+        /// to receive TaskStart after the Task.call() method was called.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ITaskStart>> OnTaskStart = new OptionalImpl<IObserver<ITaskStart>>();
+
+        /// <summary>
+        /// to receive TaskStop after the Task.call() method returned.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ITaskStop>> OnTaskStop = new OptionalImpl<IObserver<ITaskStop>>();
+
+        /// <summary>
+        /// The memento to be passed to Task.call().
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalParameter<string> Memento = new OptionalParameter<string>();
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TaskConfiguration));
+
+        public TaskConfiguration()
+            : base()
+        {
+        }
+
+        public TaskConfiguration(string configString)
+        {
+            TangConfig = new AvroConfigurationSerializer().FromString(configString);
+            AvroConfiguration avroConfiguration = AvroConfiguration.GetAvroConfigurationFromEmbeddedString(configString);
+            foreach (ConfigurationEntry config in avroConfiguration.Bindings)
+            {
+                if (config.key.Contains(TaskIdentifier))
+                {
+                    TaskId = config.value;
+                }
+            }
+            if (string.IsNullOrWhiteSpace(TaskId))
+            {
+                string msg = "Required parameter TaskId not provided.";
+                LOGGER.Log(Level.Error, msg);
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException(msg), LOGGER);
+            }
+        }
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new TaskConfiguration()
+                    .BindImplementation(GenericType<ITask>.Class, Task)
+                    .BindImplementation(GenericType<ITaskMessageSource>.Class, OnSendMessage)
+                    .BindImplementation(GenericType<IDriverMessageHandler>.Class, OnMessage)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.Identifier>.Class, Identifier)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.Memento>.Class, Memento)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.CloseHandler>.Class, OnClose)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.SuspendHandler>.Class, OnSuspend)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.StartHandlers>.Class, OnTaskStart)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.StopHandlers>.Class, OnTaskStop)
+                    .Build();
+            }
+        }
+
+        public string TaskId { get;  private set; }
+
+        public IList<KeyValuePair<string, string>> Configurations { get; private set; }
+
+        public IConfiguration TangConfig { get; private set; }
+
+        public override string ToString()
+        {
+            return string.Format(CultureInfo.InvariantCulture, "TaskConfiguration - configurations: {0}", TangConfig.ToString());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfigurationOptions.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfigurationOptions.cs
new file mode 100644
index 0000000..888faf0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskConfigurationOptions.cs
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class TaskConfigurationOptions
+    {
+        [NamedParameter("The Identifier of the Task", "taskid", "Task")]
+        public class Identifier : Name<string>
+        {
+        }
+
+        [NamedParameter(documentation: "The memento to be used for the Task")]
+        public class Memento : Name<string>
+        {
+        }
+
+        [NamedParameter("TaskMessageSource", "messagesource", null)]
+        public class TaskMessageSources : Name<ISet<ITaskMessageSource>>
+        {
+        }
+
+        [NamedParameter(documentation: "The set of event handlers for the TaskStart event.")]
+        public class StartHandlers : Name<ISet<IObserver<ITaskStart>>>
+        {
+        }
+
+        [NamedParameter(documentation: "The set of event handlers for the TaskStop event.")]
+        public class StopHandlers : Name<ISet<IObserver<ITaskStop>>>
+        {
+        }
+
+        [NamedParameter(documentation: "The event handler that receives the close event.")]
+        public class CloseHandler : Name<IObserver<ICloseEvent>>
+        {
+        }
+
+        [NamedParameter(documentation: "The event handler that receives the suspend event.")]
+        public class SuspendHandler : Name<IObserver<ISuspendEvent>>
+        {
+        }
+
+        [NamedParameter(documentation: "The event handler that receives messages from the driver.")]
+        public class MessageHandler : Name<IObserver<IDriverMessage>>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskMessage.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskMessage.cs
new file mode 100644
index 0000000..20defce
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/TaskMessage.cs
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class TaskMessage : IMessage
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TaskMessage));
+        private readonly string _messageSourcId;
+        private readonly byte[] _bytes;
+
+        private TaskMessage(string messageSourceId, byte[] bytes)
+        {
+            _messageSourcId = messageSourceId;
+            _bytes = bytes;
+        }
+
+        public string MessageSourceId
+        {
+            get { return _messageSourcId; }
+        }
+
+        public byte[] Message
+        {
+            get { return _bytes; }
+            set { }
+        }
+
+        /// <summary>
+        ///  From byte[] message to a TaskMessage
+        /// </summary>
+        /// <param name="messageSourceId">messageSourceId The message's sourceID. This will be accessible in the Driver for routing</param>
+        /// <param name="message">The actual content of the message, serialized into a byte[]</param>
+        /// <returns>a new TaskMessage with the given content</returns>
+        public static TaskMessage From(string messageSourceId, byte[] message)
+        {
+            if (string.IsNullOrEmpty(messageSourceId))
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("messageSourceId"), LOGGER);
+            }
+            if (message == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("bytes"), LOGGER);
+            }
+            return new TaskMessage(messageSourceId, message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultDriverMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultDriverMessageHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultDriverMessageHandler.cs
new file mode 100644
index 0000000..f77e18d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultDriverMessageHandler.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Tasks.Defaults
+{
+    public class DefaultDriverMessageHandler : IDriverMessageHandler
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverMessageHandler));
+
+        [Inject]
+        public DefaultDriverMessageHandler()
+        {
+        }
+
+        public void Handle(IDriverMessage message)
+        {
+            Exceptions.Throw(new InvalidOperationException("No DriverMessage handler bound. Message received" + message), LOGGER);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultTaskMessageSource.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultTaskMessageSource.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultTaskMessageSource.cs
new file mode 100644
index 0000000..97b52db
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/defaults/DefaultTaskMessageSource.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Tasks.Defaults
+{
+    public class DefaultTaskMessageSource : ITaskMessageSource
+    {
+        [Inject]
+        public DefaultTaskMessageSource()
+        {
+        }
+
+        public Optional<TaskMessage> Message
+        {
+            get
+            {
+                TaskMessage defaultTaskMessage = TaskMessage.From(
+                    "defaultSourceId", 
+                    ByteUtilities.StringToByteArrays("default message generated at " + DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+                return Optional<TaskMessage>.Of(defaultTaskMessage);
+            }
+
+            set
+            {
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ICloseEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ICloseEvent.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ICloseEvent.cs
new file mode 100644
index 0000000..3ff9ccf
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ICloseEvent.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Tasks.Events
+{
+    public interface ICloseEvent
+    {
+        Optional<byte[]> Value { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/IDriverMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/IDriverMessage.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/IDriverMessage.cs
new file mode 100644
index 0000000..9ac120d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/IDriverMessage.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Tasks.Events
+{
+    public interface IDriverMessage
+    {
+        Optional<byte[]> Message { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ISuspendEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ISuspendEvent.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ISuspendEvent.cs
new file mode 100644
index 0000000..218a28f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ISuspendEvent.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tasks.Events
+{
+    public interface ISuspendEvent
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStart.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStart.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStart.cs
new file mode 100644
index 0000000..bcde0b3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStart.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tasks.Events
+{
+    public interface ITaskStart
+    {
+        string Id { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStop.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStop.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStop.cs
new file mode 100644
index 0000000..5e8ebc8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/tasks/events/ITaskStop.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tasks.Events
+{
+    public interface ITaskStop
+    {
+        string Id { get; }
+    }
+}


[07/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Driver/DriverTestStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Driver/DriverTestStartHandler.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Driver/DriverTestStartHandler.cs
new file mode 100644
index 0000000..4ab94dd
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Driver/DriverTestStartHandler.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time;
+
+namespace Org.Apache.Reef.Test
+{
+    public class DriverTestStartHandler : IStartHandler
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DriverTestStartHandler));
+
+        private IClock _clock;
+        private HttpServerPort _httpServerPort;
+
+        [Inject]
+        public DriverTestStartHandler(IClock clock, HttpServerPort httpServerPort)
+        {
+            _clock = clock;
+            _httpServerPort = httpServerPort;
+            Identifier = "DriverTestStartHandler";
+            LOGGER.Log(Level.Info, "Http Server port number: " + httpServerPort.PortNumber);
+        }
+
+        public string Identifier { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Driver/TestDriver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Driver/TestDriver.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Driver/TestDriver.cs
new file mode 100644
index 0000000..8f7b36a
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Driver/TestDriver.cs
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class TestDriver : ReefFunctionalTest
+    {
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            CleanUp();
+        }
+
+        [TestCleanup]
+        public void TestCleanup()
+        {
+            CleanUp();
+        }
+
+        /// <summary>
+        /// This is to test DriverTestStartHandler. No evaluator and tasks are involked.
+        /// </summary>
+        [TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Test DriverTestStartHandler. No evaluator and tasks are involked")]
+        [DeploymentItem(@".")]
+        [Timeout(180 * 1000)]
+        public void TestDriverStart()
+        {
+            IConfiguration driverConfig = DriverBridgeConfiguration.ConfigurationModule
+             .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<DriverTestStartHandler>.Class)
+             .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class)
+             .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString())
+             .Build();
+
+            HashSet<string> appDlls = new HashSet<string>();
+            appDlls.Add(typeof(DriverTestStartHandler).Assembly.GetName().Name);
+
+            TestRun(appDlls, driverConfig);
+
+            ValidateSuccessForLocalRuntime(0);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageDriver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageDriver.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageDriver.cs
new file mode 100644
index 0000000..c86c7ae
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageDriver.cs
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Net;
+using System.Text;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations.Configuration;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Test
+{
+    public class MessageDriver : IStartHandler, IObserver<IAllocatedEvaluator>, IObserver<IEvaluatorRequestor>, IObserver<ITaskMessage>, IObserver<IRunningTask>
+    {
+        public const int NumerOfEvaluator = 1;
+
+        public const string Message = "MESSAGE::DRIVER";
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MessageDriver));
+
+        [Inject]
+        public MessageDriver()
+        {
+            CreateClassHierarchy();
+            Identifier = "TaskMessagingStartHandler";
+        }
+
+        public string Identifier { get; set; }
+
+        public void OnNext(IAllocatedEvaluator eval)
+        {
+            string taskId = "Task_" + eval.Id;
+
+            IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule
+                .Set(ContextConfiguration.Identifier, taskId)
+                .Build();
+
+            IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
+                .Set(TaskConfiguration.Identifier, taskId)
+                .Set(TaskConfiguration.Task, GenericType<MessageTask>.Class)
+                .Set(TaskConfiguration.OnMessage, GenericType<MessageTask.MessagingDriverMessageHandler>.Class)
+                .Set(TaskConfiguration.OnSendMessage, GenericType<MessageTask>.Class)
+                .Build();
+
+            eval.SubmitContextAndTask(contextConfiguration, taskConfiguration);
+        }
+
+        public void OnNext(IEvaluatorRequestor evalutorRequestor)
+        {
+            EvaluatorRequest request = new EvaluatorRequest(NumerOfEvaluator, 512, 2, "WonderlandRack", "TaskMessagingEvaluator");
+            evalutorRequestor.Submit(request);
+        }
+
+        public void OnNext(ITaskMessage taskMessage)
+        {
+            string msgReceived = ByteUtilities.ByteArrarysToString(taskMessage.Message);
+
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "CLR TaskMessagingTaskMessageHandler received following message from Task: {0}, Message: {1}.", taskMessage.TaskId, msgReceived));
+
+            if (!msgReceived.StartsWith(MessageTask.MessageSend, true, CultureInfo.CurrentCulture))
+            {
+                Exceptions.Throw(new Exception("Unexpected message: " + msgReceived), "Unexpected task message received: " + msgReceived, LOGGER);
+            }
+        }
+
+        public void OnNext(IRunningTask runningTask)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "TaskMessegingRunningTaskHandler: {0} is to send message {1}.", runningTask.Id, Message));
+            runningTask.Send(ByteUtilities.StringToByteArrays(Message));
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        private void CreateClassHierarchy()
+        {
+            HashSet<string> clrDlls = new HashSet<string>();
+            clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+            clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+            clrDlls.Add(typeof(MessageTask).Assembly.GetName().Name);
+
+            ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageTask.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageTask.cs
new file mode 100644
index 0000000..164724f
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/MessageTask.cs
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Threading;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Test
+{
+    public class MessageTask : ITask, ITaskMessageSource
+    {
+        public const string MessageSend = "MESSAGE:TASK";
+
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MessageTask));
+
+        [Inject]
+        public MessageTask()
+        {
+        }
+
+        public HelloService Service { get; set; }
+
+        public Optional<TaskMessage> Message
+        {
+            get
+            {
+                TaskMessage defaultTaskMessage = TaskMessage.From(
+                    "messagingSourceId",
+                    ByteUtilities.StringToByteArrays(MessageSend + " generated at " + DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+                return Optional<TaskMessage>.Of(defaultTaskMessage);
+            }
+
+            set
+            {
+            }
+        }
+
+        public byte[] Call(byte[] memento)
+        {
+            Console.WriteLine("Hello, CLR TaskMsg!");
+            Thread.Sleep(5 * 1000);
+            return null;
+        }
+
+        public void Dispose()
+        {
+            LOGGER.Log(Level.Info, "TaskMsg disposed.");
+        }
+
+        private void DriverMessage(string message)
+        {
+            LOGGER.Log(Level.Info, "Receieved DriverMessage in TaskMsg: " + message);
+            if (!message.Equals(MessageDriver.Message))
+            {
+                Exceptions.Throw(new Exception("Unexpected driver message: " + message), "Unexpected driver message received: " + message, LOGGER);
+            }
+        }
+
+        public class MessagingDriverMessageHandler : IDriverMessageHandler
+        {
+            private MessageTask _parentTask;
+
+            [Inject]
+            public MessagingDriverMessageHandler(MessageTask task)
+            {
+                _parentTask = task;
+            }
+
+            public void Handle(IDriverMessage value)
+            {
+                string message = string.Empty;
+                LOGGER.Log(Level.Verbose, "Receieved a message from driver, handling it with MessagingDriverMessageHandler");
+                if (value.Message.IsPresent())
+                {
+                    message = ByteUtilities.ByteArrarysToString(value.Message.Value);
+                }
+                _parentTask.DriverMessage(message);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/TestTaskMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/TestTaskMessage.cs b/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/TestTaskMessage.cs
new file mode 100644
index 0000000..89c6fc3
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/Messaging/TestTaskMessage.cs
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Defaults;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class TestTaskMessage : ReefFunctionalTest
+    {
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            CleanUp();
+            Init();
+        }
+
+        [TestCleanup]
+        public void TestCleanup()
+        {
+            CleanUp();
+        }
+
+        /// <summary>
+        /// This test is to test both task message and driver message. The messages are sent 
+        /// from one side and received in the corresponding handlers and verified in the test 
+        /// </summary>
+        [TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Test task message and driver message")]
+        [DeploymentItem(@".")]
+        [Timeout(180 * 1000)]
+        public void TestSendTaskMessage()
+        {
+            IConfiguration driverConfig = DriverBridgeConfiguration.ConfigurationModule
+             .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<MessageDriver>.Class)
+             .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<MessageDriver>.Class)
+             .Set(DriverBridgeConfiguration.OnTaskMessage, GenericType<MessageDriver>.Class)
+             .Set(DriverBridgeConfiguration.OnTaskRunning, GenericType<MessageDriver>.Class)
+             .Set(DriverBridgeConfiguration.OnEvaluatorRequested, GenericType<MessageDriver>.Class)
+             .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class)
+             .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString())
+             .Build();
+
+            HashSet<string> appDlls = new HashSet<string>();
+            appDlls.Add(typeof(MessageDriver).Assembly.GetName().Name);
+            appDlls.Add(typeof(MessageTask).Assembly.GetName().Name);
+
+            TestRun(appDlls, driverConfig);
+            ValidateSuccessForLocalRuntime(MessageDriver.NumerOfEvaluator);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Functional.Tests/ReefFunctionalTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Functional.Tests/ReefFunctionalTest.cs b/lang/cs/Tests/ReefTests/Functional.Tests/ReefFunctionalTest.cs
new file mode 100644
index 0000000..0dd2b46
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Functional.Tests/ReefFunctionalTest.cs
@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Timers;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Blob;
+using Timer = System.Timers.Timer;
+
+namespace Org.Apache.Reef.Test
+{
+    public class ReefFunctionalTest
+    {
+        protected const string _stdout = "driver.stdout";
+        protected const string _stderr = "driver.stderr";
+        protected const string _cmdFile = "run.cmd";
+        protected const string _binFolder = "bin";
+        // TODO: we will need a proper way to hide this when we are OSS'ed
+        protected const string _blobStorageConnectionString =
+            @"DefaultEndpointsProtocol=https;AccountName=reeftestlog;AccountKey=cuUmPRF9DiG56bciNc37O/SfHAoh1jFfJW6AsXAtWLPnjlOzXJGWgXhkyDFOGEHIMscqDU41ElUKnjcsJjWD9w==";
+
+        private bool _testSuccess = false;
+        private bool _onLocalRuntime = false;
+        private string _className = Constants.BridgeLaunchClass;
+        private string _clrFolder = ".";
+        private string _reefJar = Path.Combine(_binFolder, Constants.BridgeJarFileName);
+        private string _runCommand = Path.Combine(_binFolder, _cmdFile);
+
+        // TODO: once things stablize, we would like to toggle this to be false and only enable when needed for debugging test failures.
+        private bool _enableRealtimeLogUpload = true; 
+
+        protected string TestId { get; set; }
+
+        protected Timer TestTimer { get; set; }
+
+        protected Task TimerTask { get; set; }
+
+        protected bool TestSuccess 
+        {
+            get { return _testSuccess; }
+            set { _testSuccess = value; }
+        }
+
+        protected bool IsOnLocalRuntiime
+        {
+            get { return _onLocalRuntime; }
+            set { _onLocalRuntime = value; }
+        }
+
+        public void Init()
+        {
+            TestId = Guid.NewGuid().ToString("N").Substring(0, 8);
+            Console.WriteLine("Running test " + TestId + ". If failed AND log uploaded is enabled, log can be find in " + Path.Combine(DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), TestId));
+            if (_enableRealtimeLogUpload)
+            {
+                TimerTask = new Task(() =>
+                {
+                    TestTimer = new Timer()
+                    {
+                        Interval = 1000,
+                        Enabled = true,
+                        AutoReset = true
+                    };
+                    TestTimer.Elapsed += PeriodicUploadLog;
+                    TestTimer.Start();
+                });
+                TimerTask.Start(); 
+            }
+            
+            ValidationUtilities.ValidateEnvVariable("JAVA_HOME");
+
+            if (!Directory.Exists(_binFolder))
+            {
+                throw new InvalidOperationException(_binFolder + " not found in current directory, cannot init test");
+            }
+        }
+
+        protected void TestRun(HashSet<string> appDlls, IConfiguration driverBridgeConfig, bool runOnYarn = false, JavaLoggingSetting javaLogSettings = JavaLoggingSetting.INFO)
+        {
+            ClrClientHelper.Run(appDlls, driverBridgeConfig, new DriverSubmissionSettings() { RunOnYarn = runOnYarn, JavaLogLevel = javaLogSettings }, _reefJar, _runCommand, _clrFolder, _className);
+        }
+
+        protected void CleanUp()
+        {
+            Console.WriteLine("Cleaning up test.");
+
+            if (TimerTask != null)
+            {
+                TestTimer.Stop();
+                TimerTask.Dispose();
+                TimerTask = null;
+            }
+            
+            // Wait for file upload task to complete
+            Thread.Sleep(500);
+
+            string dir = Path.Combine(Directory.GetCurrentDirectory(), "REEF_LOCAL_RUNTIME");
+            try
+            {
+                if (Directory.Exists(dir))
+                {
+                    Directory.Delete(dir, true);
+                }
+            }
+            catch (IOException)
+            {
+                // do not fail if clean up is unsuccessful
+            }   
+        }
+
+        protected void ValidateSuccessForLocalRuntime(int numberOfEvaluatorsToClose)
+        {
+            const string successIndication = "EXIT: ActiveContextClr2Java::Close";
+            const string failedTaskIndication = "Java_com_microsoft_reef_javabridge_NativeInterop_ClrSystemFailedTaskHandlerOnNext";
+            const string failedEvaluatorIndication = "Java_com_microsoft_reef_javabridge_NativeInterop_ClrSystemFailedEvaluatorHandlerOnNext";
+            string[] lines = File.ReadAllLines(GetLogFile(_stdout));
+            string[] successIndicators = lines.Where(s => s.Contains(successIndication)).ToArray();
+            string[] failedTaskIndicators = lines.Where(s => s.Contains(failedTaskIndication)).ToArray();
+            string[] failedIndicators = lines.Where(s => s.Contains(failedEvaluatorIndication)).ToArray();
+            Assert.IsTrue(successIndicators.Count() == numberOfEvaluatorsToClose);
+            Assert.IsFalse(failedTaskIndicators.Any());
+            Assert.IsFalse(failedIndicators.Any());
+        }
+
+        protected void PeriodicUploadLog(object source, ElapsedEventArgs e)
+        {
+            try
+            {
+                UploadDriverLog();
+            }
+            catch (Exception)
+            {
+                // log not available yet, ignore it
+            }
+        }
+
+        protected string GetLogFile(string logFileName)
+        {
+            string driverContainerDirectory = Directory.GetDirectories(Path.Combine(Directory.GetCurrentDirectory(), "REEF_LOCAL_RUNTIME"), "driver", SearchOption.AllDirectories).SingleOrDefault();
+            if (string.IsNullOrWhiteSpace(driverContainerDirectory))
+            {
+                throw new InvalidOperationException("Cannot find driver container directory");
+            }
+            string logFile = Path.Combine(driverContainerDirectory, logFileName);
+            if (!File.Exists(logFile))
+            {
+                throw new InvalidOperationException("Driver stdout file not found");
+            }
+            return logFile;
+        }
+
+        private void UploadDriverLog()
+        {
+            string driverStdout = GetLogFile(_stdout);
+            string driverStderr = GetLogFile(_stderr);
+            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(_blobStorageConnectionString);
+            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
+            CloudBlobContainer container = blobClient.GetContainerReference(DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));   
+            container.CreateIfNotExists();
+
+            CloudBlockBlob blob = container.GetBlockBlobReference(Path.Combine(TestId, "driverStdOut"));
+            FileStream fs = new FileStream(driverStdout, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+            blob.UploadFromStream(fs);
+            fs.Close();
+
+            blob = container.GetBlockBlobReference(Path.Combine(TestId, "driverStdErr"));
+            fs = new FileStream(driverStderr, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+            blob.UploadFromStream(fs);
+            fs.Close();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/IO.Tests/BlockingCollectionExtensionTests.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/IO.Tests/BlockingCollectionExtensionTests.cs b/lang/cs/Tests/ReefTests/IO.Tests/BlockingCollectionExtensionTests.cs
new file mode 100644
index 0000000..3ccd3e9
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/IO.Tests/BlockingCollectionExtensionTests.cs
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Utilities;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Test.IO.Tests
+{
+    [TestClass]
+    public class BlockingCollectionExtensionTests
+    {
+        [TestMethod]
+        public void TestCollectionContainsElement()
+        {
+            string item = "abc";
+            BlockingCollection<string> collection = new BlockingCollection<string>();
+            collection.Add(item);
+
+            Assert.AreEqual(item, collection.Take(item));
+
+            // Check that item is no longer in collection
+            Assert.AreEqual(0, collection.Count);
+        }
+
+        [TestMethod]
+        public void TestCollectionContainsElement2()
+        {
+            string item = "abc";
+            BlockingCollection<string> collection = new BlockingCollection<string>();
+            collection.Add("cat");
+            collection.Add(item);
+            collection.Add("dog");
+
+            Assert.AreEqual(item, collection.Take(item));
+
+            // Remove remaining items, check that item is not there
+            Assert.AreNotEqual(item, collection.Take());
+            Assert.AreNotEqual(item, collection.Take());
+            Assert.AreEqual(0, collection.Count);
+        }
+
+        [TestMethod]
+        [ExpectedException(typeof(InvalidOperationException))]
+        public void TestCollectionDoesNotContainsElement()
+        {
+            string item1 = "abc";
+            string item2 = "def";
+
+            BlockingCollection<string> collection = new BlockingCollection<string>();
+            collection.Add(item2);
+
+            // Should throw InvalidOperationException since item1 is not in collection
+            collection.Take(item1);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/IO.Tests/NameServerTests.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/IO.Tests/NameServerTests.cs b/lang/cs/Tests/ReefTests/IO.Tests/NameServerTests.cs
new file mode 100644
index 0000000..ee118da
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/IO.Tests/NameServerTests.cs
@@ -0,0 +1,274 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.Test
+{
+    [TestClass]
+    public class NameServerTests
+    {
+        [TestMethod]
+        public void TestNameServerNoRequests()
+        {
+           using (var server = new NameServer(0))
+           {
+           }
+        }
+
+        [TestMethod]
+        public void TestNameServerNoRequestsTwoClients()
+        {
+           using (var server = new NameServer(0))
+           {
+               var nameClient = new NameClient(server.LocalEndpoint);
+               var nameClient2 = new NameClient(server.LocalEndpoint);
+               nameClient2.Register("1", new IPEndPoint(IPAddress.Any, 8080));
+               nameClient.Lookup("1");
+           }
+        }
+
+        [TestMethod]
+        public void TestNameServerNoRequestsTwoClients2()
+        {
+           using (var server = new NameServer(0))
+           {
+               var nameClient = new NameClient(server.LocalEndpoint);
+               var nameClient2 = new NameClient(server.LocalEndpoint);
+               nameClient2.Register("1", new IPEndPoint(IPAddress.Any, 8080));
+               nameClient.Lookup("1");
+           }
+        }
+
+        [TestMethod]
+        public void TestNameServerMultipleRequestsTwoClients()
+        {
+           using (var server = new NameServer(0))
+           {
+               var nameClient = new NameClient(server.LocalEndpoint);
+               var nameClient2 = new NameClient(server.LocalEndpoint);
+               nameClient.Register("1", new IPEndPoint(IPAddress.Any, 8080));
+               nameClient2.Lookup("1");
+           }
+        }
+
+        [TestMethod]
+        public void TestRegister()
+        {
+            using (INameServer server = BuildNameServer())
+            {
+                using (INameClient client = BuildNameClient(server.LocalEndpoint))
+                {
+                    IPEndPoint endpoint1 = new IPEndPoint(IPAddress.Parse("100.0.0.1"), 100);
+                    IPEndPoint endpoint2 = new IPEndPoint(IPAddress.Parse("100.0.0.2"), 200);
+                    IPEndPoint endpoint3 = new IPEndPoint(IPAddress.Parse("100.0.0.3"), 300);
+
+                    // Check that no endpoints have been registered
+                    Assert.IsNull(client.Lookup("a"));
+                    Assert.IsNull(client.Lookup("b"));
+                    Assert.IsNull(client.Lookup("c"));
+                
+                    // Register endpoints
+                    client.Register("a", endpoint1);
+                    client.Register("b", endpoint2);
+                    client.Register("c", endpoint3);
+
+                    // Check that they can be looked up correctly
+                    Assert.AreEqual(endpoint1, client.Lookup("a"));
+                    Assert.AreEqual(endpoint2, client.Lookup("b"));
+                    Assert.AreEqual(endpoint3, client.Lookup("c"));
+                }
+            }
+        }
+
+        [TestMethod]
+        public void TestUnregister()
+        {
+            using (INameServer server = BuildNameServer())
+            {
+                using (INameClient client = BuildNameClient(server.LocalEndpoint))
+                {
+                    IPEndPoint endpoint1 = new IPEndPoint(IPAddress.Parse("100.0.0.1"), 100);
+                
+                    // Register endpoint
+                    client.Register("a", endpoint1);
+
+                    // Check that it can be looked up correctly
+                    Assert.AreEqual(endpoint1, client.Lookup("a"));
+
+                    // Unregister endpoints
+                    client.Unregister("a");
+                    Thread.Sleep(1000);
+
+                    // Make sure they were unregistered correctly
+                    Assert.IsNull(client.Lookup("a"));
+                }
+            }
+        }
+
+        [TestMethod]
+        public void TestLookup()
+        {
+            using (INameServer server = BuildNameServer())
+            {
+                using (INameClient client = BuildNameClient(server.LocalEndpoint))
+                {
+                    IPEndPoint endpoint1 = new IPEndPoint(IPAddress.Parse("100.0.0.1"), 100);
+                    IPEndPoint endpoint2 = new IPEndPoint(IPAddress.Parse("100.0.0.2"), 200);
+                
+                    // Register endpoint1
+                    client.Register("a", endpoint1);
+                    Assert.AreEqual(endpoint1, client.Lookup("a"));
+
+                    // Reregister identifer a
+                    client.Register("a", endpoint2);
+                    Assert.AreEqual(endpoint2, client.Lookup("a"));
+                }
+            }
+        }
+
+        [TestMethod]
+        public void TestLookupList()
+        {
+            using (INameServer server = BuildNameServer())
+            {
+                using (INameClient client = BuildNameClient(server.LocalEndpoint))
+                {
+                    IPEndPoint endpoint1 = new IPEndPoint(IPAddress.Parse("100.0.0.1"), 100);
+                    IPEndPoint endpoint2 = new IPEndPoint(IPAddress.Parse("100.0.0.2"), 200);
+                    IPEndPoint endpoint3 = new IPEndPoint(IPAddress.Parse("100.0.0.3"), 300);
+                
+                    // Register endpoints
+                    client.Register("a", endpoint1);
+                    client.Register("b", endpoint2);
+                    client.Register("c", endpoint3);
+
+                    // Look up both at the same time
+                    List<string> ids = new List<string> { "a", "b", "c", "d" };
+                    List<NameAssignment> assignments = client.Lookup(ids);
+
+                    // Check that a, b, and c are registered
+                    Assert.AreEqual("a", assignments[0].Identifier);
+                    Assert.AreEqual(endpoint1, assignments[0].Endpoint);
+                    Assert.AreEqual("b", assignments[1].Identifier);
+                    Assert.AreEqual(endpoint2, assignments[1].Endpoint);
+                    Assert.AreEqual("c", assignments[2].Identifier);
+                    Assert.AreEqual(endpoint3, assignments[2].Endpoint);
+
+                    // Check that d is not registered
+                    Assert.AreEqual(3, assignments.Count);
+                }
+            }
+        }
+
+        [TestMethod]
+        public void TestNameClientRestart()
+        {
+            int oldPort = 6666;
+            int newPort = 6662;
+            INameServer server = new NameServer(oldPort);
+
+            using (INameClient client = BuildNameClient(server.LocalEndpoint))
+            {
+                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("100.0.0.1"), 100);
+            
+                client.Register("a", endpoint);
+                Assert.AreEqual(endpoint, client.Lookup("a"));
+
+                server.Dispose();
+
+                server = new NameServer(newPort);
+                client.Restart(server.LocalEndpoint);
+
+                client.Register("b", endpoint);
+                Assert.AreEqual(endpoint, client.Lookup("b"));
+
+                server.Dispose();
+            }
+        }
+
+        [TestMethod]
+        public void TestConstructorInjection()
+        {
+            int port = 6666;
+            using (INameServer server = new NameServer(port))
+            {
+                IConfiguration nameClientConfiguration = NamingConfiguration.ConfigurationModule
+                    .Set(NamingConfiguration.NameServerAddress, server.LocalEndpoint.Address.ToString())
+                    .Set(NamingConfiguration.NameServerPort, port + string.Empty)
+                    .Build();
+
+                ConstructorInjection c = TangFactory.GetTang()
+                    .NewInjector(nameClientConfiguration)
+                    .GetInstance<ConstructorInjection>();
+
+                Assert.IsNotNull(c);
+            }
+        }
+
+        private INameServer BuildNameServer()
+        {
+            var builder = TangFactory.GetTang()
+                                     .NewConfigurationBuilder()
+                                     .BindNamedParameter<NamingConfigurationOptions.NameServerPort, int>(
+                                         GenericType<NamingConfigurationOptions.NameServerPort>.Class, "0");
+
+            return TangFactory.GetTang().NewInjector(builder.Build()).GetInstance<INameServer>();
+        }
+
+        private INameClient BuildNameClient(IPEndPoint remoteEndpoint)
+        {
+            string nameServerAddr = remoteEndpoint.Address.ToString();
+            int nameServerPort = remoteEndpoint.Port;
+            IConfiguration nameClientConfiguration = NamingConfiguration.ConfigurationModule
+                .Set(NamingConfiguration.NameServerAddress, nameServerAddr)
+                .Set(NamingConfiguration.NameServerPort, nameServerPort + string.Empty)
+                .Build();
+
+            return TangFactory.GetTang().NewInjector(nameClientConfiguration).GetInstance<NameClient>();
+        }
+
+        private class ConstructorInjection
+        {
+            [Inject]
+            public ConstructorInjection(NameClient client)
+            {
+                if (client == null)
+                {
+                    throw new ArgumentNullException("client");
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/IO.Tests/NetworkServiceTests.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/IO.Tests/NetworkServiceTests.cs b/lang/cs/Tests/ReefTests/IO.Tests/NetworkServiceTests.cs
new file mode 100644
index 0000000..46dce1b
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/IO.Tests/NetworkServiceTests.cs
@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.IO.Network.NetworkService;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.Util;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Test.IO.Tests
+{
+    [TestClass]
+    public class NetworkServiceTests
+    {
+        [TestMethod]
+        public void TestNetworkServiceOneWayCommunication()
+        {
+            int networkServicePort1 = NetworkUtils.GenerateRandomPort(6000, 7000);
+            int networkServicePort2 = NetworkUtils.GenerateRandomPort(7001, 8000);
+
+            BlockingCollection<string> queue = new BlockingCollection<string>();
+
+            using (INameServer nameServer = new NameServer(0))
+            {
+                IPEndPoint endpoint = nameServer.LocalEndpoint;
+                int nameServerPort = endpoint.Port;
+                string nameServerAddr = endpoint.Address.ToString();
+                using (INetworkService<string> networkService1 = BuildNetworkService(networkServicePort1, nameServerPort, nameServerAddr, null))
+                using (INetworkService<string> networkService2 = BuildNetworkService(networkServicePort2, nameServerPort, nameServerAddr, new MessageHandler(queue)))
+                {
+                    IIdentifier id1 = new StringIdentifier("service1");
+                    IIdentifier id2 = new StringIdentifier("service2");
+                    networkService1.Register(id1);
+                    networkService2.Register(id2);
+
+                    using (IConnection<string> connection = networkService1.NewConnection(id2))
+                    {
+                        connection.Open();
+                        connection.Write("abc");
+                        connection.Write("def");
+                        connection.Write("ghi");
+
+                        Assert.AreEqual("abc", queue.Take());
+                        Assert.AreEqual("def", queue.Take());
+                        Assert.AreEqual("ghi", queue.Take());
+                    }
+                }
+            }
+        }
+
+        [TestMethod]
+        public void TestNetworkServiceTwoWayCommunication()
+        {
+            int networkServicePort1 = NetworkUtils.GenerateRandomPort(6000, 7000);
+            int networkServicePort2 = NetworkUtils.GenerateRandomPort(7001, 8000);
+
+            BlockingCollection<string> queue1 = new BlockingCollection<string>();
+            BlockingCollection<string> queue2 = new BlockingCollection<string>();
+
+            using (INameServer nameServer = new NameServer(0))
+            {
+                IPEndPoint endpoint = nameServer.LocalEndpoint;
+                int nameServerPort = endpoint.Port;
+                string nameServerAddr = endpoint.Address.ToString();
+                using (INetworkService<string> networkService1 = BuildNetworkService(networkServicePort1, nameServerPort, nameServerAddr, new MessageHandler(queue1)))
+                using (INetworkService<string> networkService2 = BuildNetworkService(networkServicePort2, nameServerPort, nameServerAddr, new MessageHandler(queue2)))
+                {
+                    IIdentifier id1 = new StringIdentifier("service1");
+                    IIdentifier id2 = new StringIdentifier("service2");
+                    networkService1.Register(id1);
+                    networkService2.Register(id2);
+
+                    using (IConnection<string> connection1 = networkService1.NewConnection(id2))
+                    using (IConnection<string> connection2 = networkService2.NewConnection(id1))
+                    {
+                        connection1.Open();
+                        connection1.Write("abc");
+                        connection1.Write("def");
+                        connection1.Write("ghi");
+
+                        connection2.Open();
+                        connection2.Write("jkl");
+                        connection2.Write("mno");
+
+                        Assert.AreEqual("abc", queue2.Take());
+                        Assert.AreEqual("def", queue2.Take());
+                        Assert.AreEqual("ghi", queue2.Take());
+
+                        Assert.AreEqual("jkl", queue1.Take());
+                        Assert.AreEqual("mno", queue1.Take());
+                    }
+                }
+            }
+        }
+
+        private INetworkService<string> BuildNetworkService(
+            int networkServicePort,
+            int nameServicePort,
+            string nameServiceAddr,
+            IObserver<NsMessage<string>> handler)
+        {
+            // Test injection
+            if (handler == null)
+            {
+                var networkServiceConf = TangFactory.GetTang().NewConfigurationBuilder()
+                    .BindNamedParameter<NetworkServiceOptions.NetworkServicePort, int>(
+                        GenericType<NetworkServiceOptions.NetworkServicePort>.Class,
+                        networkServicePort.ToString(CultureInfo.CurrentCulture))
+                    .BindNamedParameter<NamingConfigurationOptions.NameServerPort, int>(
+                        GenericType<NamingConfigurationOptions.NameServerPort>.Class,
+                        nameServicePort.ToString(CultureInfo.CurrentCulture))
+                    .BindNamedParameter<NamingConfigurationOptions.NameServerAddress, string>(
+                        GenericType<NamingConfigurationOptions.NameServerAddress>.Class,
+                        nameServiceAddr)
+                    .BindImplementation(GenericType<ICodec<string>>.Class, GenericType<StringCodec>.Class)
+                    .BindImplementation(GenericType<IObserver<NsMessage<string>>>.Class, GenericType<NetworkMessageHandler>.Class)
+                    .Build();
+
+                return TangFactory.GetTang().NewInjector(networkServiceConf).GetInstance<NetworkService<string>>();
+            }
+
+            return new NetworkService<string>(networkServicePort, nameServiceAddr, nameServicePort, 
+                handler, new StringIdentifierFactory(), new StringCodec());
+        }
+
+        private class MessageHandler : IObserver<NsMessage<string>>
+        {
+            private BlockingCollection<string> _queue;
+
+            public MessageHandler(BlockingCollection<string> queue)
+            {
+                _queue = queue;
+            }
+
+            public void OnNext(NsMessage<string> value)
+            {
+                _queue.Add(value.Data.First());
+            }
+
+            public void OnError(Exception error)
+            {
+                throw new NotImplementedException();
+            }
+
+            public void OnCompleted()
+            {
+                throw new NotImplementedException();
+            }
+        }
+
+        private class NetworkMessageHandler : IObserver<NsMessage<string>>
+        {
+            [Inject]
+            public NetworkMessageHandler()
+            {
+            }
+
+            public void OnNext(NsMessage<string> value)
+            {
+            }
+
+            public void OnError(Exception error)
+            {
+            }
+
+            public void OnCompleted()
+            {
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Properties/AssemblyInfo.cs b/lang/cs/Tests/ReefTests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9d92b89
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ReefTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ReefTests")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("19ebceb4-3b1f-466b-9127-aa14e636d723")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/ReefTests.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/ReefTests.csproj b/lang/cs/Tests/ReefTests/ReefTests.csproj
new file mode 100644
index 0000000..221dd0b
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/ReefTests.csproj
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{988F90CF-A48D-4938-A4D2-FA3B758FB5A7}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Test</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Test</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\bin\Debug\Org.Apache.Reef.Test\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\bin\Release\Microsoft.Reef.Tests\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Data.Edm, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\Microsoft.Data.Edm.5.6.3\lib\net40\Microsoft.Data.Edm.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Data.OData, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\Microsoft.Data.OData.5.6.3\lib\net40\Microsoft.Data.OData.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Data.Services.Client, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\Microsoft.Data.Services.Client.5.6.3\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.WindowsAzure.Configuration">
+      <HintPath>..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.WindowsAzure.Storage">
+      <HintPath>..\..\packages\WindowsAzure.Storage.4.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Reactive.Core">
+      <HintPath>..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Reactive.Interfaces">
+      <HintPath>..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Spatial, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\System.Spatial.5.6.3\lib\net40\System.Spatial.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Evaluator.Tests\EvaluatorConfigurationsTests.cs" />
+    <Compile Include="Evaluator.Tests\EvaluatorTests.cs" />
+    <Compile Include="Functional.Tests\Bridge\TestBridgeClient.cs" />
+    <Compile Include="Functional.Tests\Bridge\TestHelloBridgeHandlers.cs" />
+    <Compile Include="Functional.Tests\Bridge\TestSimpleEventHandlers.cs" />
+    <Compile Include="Functional.Tests\Driver\DriverTestStartHandler.cs" />
+    <Compile Include="Functional.Tests\Driver\TestDriver.cs" />
+    <Compile Include="Functional.Tests\Messaging\MessageDriver.cs" />
+    <Compile Include="Functional.Tests\Messaging\MessageTask.cs" />
+    <Compile Include="Functional.Tests\Messaging\TestTaskMessage.cs" />
+    <Compile Include="Functional.Tests\ReefFunctionalTest.cs" />
+    <Compile Include="IO.Tests\BlockingCollectionExtensionTests.cs" />
+    <Compile Include="IO.Tests\NameServerTests.cs" />
+    <Compile Include="IO.Tests\NetworkServiceTests.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Utility.Test\TestDriverConfigGenerator.cs" />
+    <Compile Include="Utility.Test\TestExceptions.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="bin\run.cmd">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Include="ConfigFiles\evaluator.conf">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Source\REEF\reef-applications\CLRBridgeClient\CLRBridgeClient.csproj">
+      <Project>{5094c35b-4fdb-4322-ac05-45d684501cbf}</Project>
+      <Name>CLRBridgeClient</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-applications\Evaluator\Evaluator.csproj">
+      <Project>{1b983182-9c30-464c-948d-f87eb93a8240}</Project>
+      <Name>Evaluator</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-examples\HelloCLRBridge\HelloCLRBridge.csproj">
+      <Project>{a78dd8e8-31d0-4506-8738-daa9da86d55b}</Project>
+      <Name>HelloCLRBridge</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-io\NetWork\NetWork.csproj">
+      <Project>{883ce800-6a6a-4e0a-b7fe-c054f4f2c1dc}</Project>
+      <Name>NetWork</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\REEF\reef-tasks\Tasks\Tasks.csproj">
+      <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+      <Name>Tasks</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\TANG\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Source\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="bin\reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="bin\Debug\" />
+    <Folder Include="bin\Release\" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Utility.Test/TestDriverConfigGenerator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Utility.Test/TestDriverConfigGenerator.cs b/lang/cs/Tests/ReefTests/Utility.Test/TestDriverConfigGenerator.cs
new file mode 100644
index 0000000..214188a
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Utility.Test/TestDriverConfigGenerator.cs
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Driver;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test.Utility.Test
+{
+    [TestClass]
+    public class TestDriverConfigGenerator
+    {
+        [TestMethod]
+        public void TestGeneratingFullDriverConfigFile()
+        {
+            DriverConfigurationSettings driverSubmissionSettings = new DriverConfigurationSettings()
+            {
+                DriverMemory = 1024,
+                DriverIdentifier = "juliaDriverId",
+                SubmissionDirectory = "reefClrBridgeTmp/job_" + Guid.NewGuid().ToString("N").Substring(0, 8),
+                IncludingHttpServer = true,
+                IncludingNameServer = true,
+                //ClrFolder = "C:\\Reef\\ReefApache\\incubator-reef\\reef-bridge-project\\reef-bridge\\dotnetHello",
+                ClrFolder = ".",
+                JarFileFolder = ".\\bin\\"
+            };
+
+            DriverConfigGenerator.DriverConfigurationBuilder(driverSubmissionSettings);
+        }
+
+        [TestMethod]
+        public void TestGeneratingDriverConfigFileWithoutHttp()
+        {
+            DriverConfigurationSettings driverSubmissionSettings = new DriverConfigurationSettings()
+            {
+                DriverMemory = 1024,
+                DriverIdentifier = "juliaDriverId",
+                SubmissionDirectory = "reefClrBridgeTmp/job_" + Guid.NewGuid().ToString("N").Substring(0, 8),
+                IncludingHttpServer = false,
+                IncludingNameServer = true,
+//                ClrFolder = "C:\\Reef\\ReefApache\\incubator-reef\\reef-bridge-project\\reef-bridge\\dotnetHello",
+                ClrFolder = ".",
+                JarFileFolder = ".\\bin\\"
+            };
+
+            DriverConfigGenerator.DriverConfigurationBuilder(driverSubmissionSettings);
+        }
+
+        [TestMethod]
+        public void TestGeneratingDriverConfigFileWithoutNameServer()
+        {
+            DriverConfigurationSettings driverSubmissionSettings = new DriverConfigurationSettings()
+            {
+                DriverMemory = 1024,
+                DriverIdentifier = "juliaDriverId",
+                SubmissionDirectory = "reefClrBridgeTmp/job_" + Guid.NewGuid().ToString("N").Substring(0, 8),
+                IncludingHttpServer = true,
+                IncludingNameServer = false,
+                //ClrFolder = "C:\\Reef\\ReefApache\\incubator-reef\\reef-bridge-project\\reef-bridge\\dotnetHello",
+                ClrFolder = ".",
+                JarFileFolder = ".\\bin\\"
+            };
+
+            DriverConfigGenerator.DriverConfigurationBuilder(driverSubmissionSettings);
+        }
+
+        [TestMethod]
+        public void TestGeneratingDriverConfigFileDriverOnly()
+        {
+            DriverConfigurationSettings driverSubmissionSettings = new DriverConfigurationSettings()
+            {
+                DriverMemory = 1024,
+                DriverIdentifier = "juliaDriverId",
+                SubmissionDirectory = "reefClrBridgeTmp/job_" + Guid.NewGuid().ToString("N").Substring(0, 8),
+                IncludingHttpServer = false,
+                IncludingNameServer = false,
+                //ClrFolder = "C:\\Reef\\ReefApache\\incubator-reef\\reef-bridge-project\\reef-bridge\\dotnetHello",
+                ClrFolder = ".",
+                JarFileFolder = ".\\bin\\"
+            };
+
+            DriverConfigGenerator.DriverConfigurationBuilder(driverSubmissionSettings);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/Utility.Test/TestExceptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/Utility.Test/TestExceptions.cs b/lang/cs/Tests/ReefTests/Utility.Test/TestExceptions.cs
new file mode 100644
index 0000000..16bde92
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/Utility.Test/TestExceptions.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Test.Utility.Test
+{
+    [TestClass]
+    public class TestExceptions
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(TestExceptions));
+
+        [TestMethod]
+        public void TestThrowCaught()
+        {
+            string msg = null;
+            try
+            {
+                Exceptions.Throw(new ApplicationException("test"), LOGGER);
+                msg = "not supposed to reach here";
+                Assert.Fail(msg);
+            }
+            catch (ApplicationException e)
+            {
+                Exceptions.Caught(e, Level.Info, LOGGER);
+            }
+            Assert.IsNull(msg);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/bin/reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/bin/reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar b/lang/cs/Tests/ReefTests/bin/reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar
new file mode 100644
index 0000000..e43d8bf
Binary files /dev/null and b/lang/cs/Tests/ReefTests/bin/reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar differ

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/bin/run.cmd
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/bin/run.cmd b/lang/cs/Tests/ReefTests/bin/run.cmd
new file mode 100644
index 0000000..ddff8a7
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/bin/run.cmd
@@ -0,0 +1,45 @@
+@REM
+@REM Copyright (C) 2013 Microsoft Corporation
+@REM
+@REM Licensed under the Apache License, Version 2.0 (the "License");
+@REM you may not use this file except in compliance with the License.
+@REM You may obtain a copy of the License at
+@REM
+@REM         http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+::
+:: Copyright (C) 2013 Microsoft Corporation
+::
+:: 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.
+::
+
+
+:: RUNTIME
+set SHADED_JAR=bin\reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar
+
+set LOGGING_CONFIG=-Djava.util.logging.config.class=org.apache.reef.util.logging.Config
+
+set CLASSPATH=%HADOOP_HOME%\share\hadoop\hdfs\lib\*;%HADOOP_HOME%\share\hadoop\hdfs\*;%HADOOP_HOME%\share\hadoop\common\*;%HADOOP_HOME%\share\hadoop\common\lib\*;%HADOOP_HOME%\share\hadoop\mapreduce\lib\*;%HADOOP_HOME%\share\hadoop\mapreduce\*;%HADOOP_HOME%\share\hadoop\yarn\*;%HADOOP_HOME%\share\hadoop\yarn\lib\*
+
+set CMD=%JAVA_HOME%\bin\java.exe -cp %HADOOP_HOME%\etc\hadoop;%SHADED_JAR%;%CLASSPATH% %*
+::%LOGGING_CONFIG%
+echo %CMD%
+%CMD%

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/ReefTests/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/ReefTests/packages.config b/lang/cs/Tests/ReefTests/packages.config
new file mode 100644
index 0000000..ef4860c
--- /dev/null
+++ b/lang/cs/Tests/ReefTests/packages.config
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Data.Edm" version="5.6.3" targetFramework="net45" />
+  <package id="Microsoft.Data.OData" version="5.6.3" targetFramework="net45" />
+  <package id="Microsoft.Data.Services.Client" version="5.6.3" targetFramework="net45" />
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+  <package id="Rx-Core" version="2.2.5" targetFramework="net45" />
+  <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
+  <package id="System.Spatial" version="5.6.3" targetFramework="net45" />
+  <package id="WindowsAzure.Storage" version="4.3.0" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ClassHierarchy/TestAnonymousType.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ClassHierarchy/TestAnonymousType.cs b/lang/cs/Tests/TangTests/ClassHierarchy/TestAnonymousType.cs
new file mode 100644
index 0000000..262ea7a
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ClassHierarchy/TestAnonymousType.cs
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Org.Apache.Reef.Tang.Examples;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ClassHierarchy
+{
+    [TestClass]
+    public class TestAnonymousType
+    {
+        const string ClassHierarchyBinFileName = "example.bin";
+
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            TangImpl.Reset();
+        }
+
+        [TestMethod]
+        public void TestAnonymousTypeWithDictionary()
+        {
+            List<string> appDlls = new List<string>();
+            appDlls.Add(typeof(AnonymousType).Assembly.GetName().Name);
+            var c = TangFactory.GetTang().GetClassHierarchy(appDlls.ToArray());
+            c.GetNode(typeof(AnonymousType).AssemblyQualifiedName);
+
+            IConfiguration conf = TangFactory.GetTang().NewConfigurationBuilder(c).Build();
+            IInjector injector = TangFactory.GetTang().NewInjector(conf);
+            var obj = injector.GetInstance<AnonymousType>();
+            Assert.IsNotNull(obj);
+
+            var cd = Directory.GetCurrentDirectory();
+            Console.WriteLine(cd);
+
+            ProtocolBufferClassHierarchy.Serialize(ClassHierarchyBinFileName, c);
+            IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize(ClassHierarchyBinFileName);
+            ch.GetNode(typeof(AnonymousType).AssemblyQualifiedName);
+        }
+    }
+}


[24/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..14567ae
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ReefDriver")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ReefDriver")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("81ea2648-b341-4852-93b0-806da615c6b8")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj b/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj
new file mode 100644
index 0000000..bc41253
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{A6BAA2A7-F52F-4329-884E-1BCF711D6805}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Driver</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Driver</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Driver\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Driver\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="bridge\BridgeLogger.cs" />
+    <Compile Include="bridge\clr2java\IActiveContextClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IAllocatedEvaluaotrClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IClosedContextClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IClr2Java.cs" />
+    <Compile Include="bridge\clr2java\ICompletedEvaluatorClr2Java.cs" />
+    <Compile Include="bridge\clr2java\ICompletedTaskClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IContextMessageClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IEvaluatorRequestorClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IFailedContextClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IFailedEvaluatorClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IFailedTaskClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IHttpServerBridgeClr2Java.cs" />
+    <Compile Include="bridge\clr2java\IRunningTaskClr2Java.cs" />
+    <Compile Include="bridge\clr2java\ISuspendedTaskClr2Java.cs" />
+    <Compile Include="bridge\clr2java\ITaskMessageClr2Java.cs" />
+    <Compile Include="bridge\ClrClientHelper.cs" />
+    <Compile Include="bridge\ClrHandlerHelper.cs" />
+    <Compile Include="bridge\ClrSystemHandler.cs" />
+    <Compile Include="bridge\ClrSystemHandlerWrapper.cs" />
+    <Compile Include="bridge\DriverBridge.cs" />
+    <Compile Include="bridge\DriverBridgeConfiguration.cs" />
+    <Compile Include="bridge\DriverBridgeConfigurationOptions.cs" />
+    <Compile Include="bridge\events\ActiveContext.cs" />
+    <Compile Include="bridge\events\AllocatedEvaluator.cs" />
+    <Compile Include="bridge\events\ClosedContext.cs" />
+    <Compile Include="bridge\events\CompletedEvaluator.cs" />
+    <Compile Include="bridge\events\CompletedTask.cs" />
+    <Compile Include="bridge\events\ContextMessage.cs" />
+    <Compile Include="bridge\events\EvaluatorRequstor.cs" />
+    <Compile Include="bridge\events\FailedContext.cs" />
+    <Compile Include="bridge\events\FailedEvaluator.cs" />
+    <Compile Include="bridge\events\FailedTask.cs" />
+    <Compile Include="bridge\events\RunningTask.cs" />
+    <Compile Include="bridge\events\SuspendedTask.cs" />
+    <Compile Include="bridge\events\TaskMessage.cs" />
+    <Compile Include="bridge\HttpMessage.cs" />
+    <Compile Include="bridge\HttpServerHandler.cs" />
+    <Compile Include="bridge\HttpServerPort.cs" />
+    <Compile Include="bridge\IHttpHandler.cs" />
+    <Compile Include="bridge\IHttpMessage.cs" />
+    <Compile Include="bridge\ReefHttpRequest.cs" />
+    <Compile Include="bridge\ReefHttpResponse.cs" />
+    <Compile Include="ClientManager.cs" />
+    <Compile Include="Constants.cs" />
+    <Compile Include="context\ContextConfiguration.cs" />
+    <Compile Include="context\ContextConfigurationOptions.cs" />
+    <Compile Include="context\defaults\DefaultContextMessageSource.cs" />
+    <Compile Include="context\defaults\DefaultContextStartHandler.cs" />
+    <Compile Include="context\defaults\DefaultContextStopHandler.cs" />
+    <Compile Include="context\EvaluatorContext.cs" />
+    <Compile Include="context\IActiveContext.cs" />
+    <Compile Include="context\IClosedContext.cs" />
+    <Compile Include="context\IContext.cs" />
+    <Compile Include="context\IFailedContext.cs" />
+    <Compile Include="contract\IBridgeContract.cs" />
+    <Compile Include="defaults\DefaultClientCloseHandler.cs" />
+    <Compile Include="defaults\DefaultClientCloseWithMessageHandler.cs" />
+    <Compile Include="defaults\DefaultClientMessageHandler.cs" />
+    <Compile Include="defaults\DefaultContextActiveHandler.cs" />
+    <Compile Include="defaults\DefaultContextClosureHandler.cs" />
+    <Compile Include="defaults\DefaultContextFailureHandler.cs" />
+    <Compile Include="defaults\DefaultContextMessageHandler.cs" />
+    <Compile Include="defaults\DefaultCustomTraceListener.cs" />
+    <Compile Include="defaults\DefaultDriverRestartContextActiveHandler.cs" />
+    <Compile Include="defaults\DefaultDriverRestartHandler.cs" />
+    <Compile Include="defaults\DefaultDriverRestartTaskRunningHandler.cs" />
+    <Compile Include="defaults\DefaultEvaluatorAllocationHandler.cs" />
+    <Compile Include="defaults\DefaultEvaluatorCompletionHandler.cs" />
+    <Compile Include="defaults\DefaultEvaluatorFailureHandler.cs" />
+    <Compile Include="defaults\DefaultEvaluatorRequestorHandler.cs" />
+    <Compile Include="defaults\DefaultHttpHandler.cs" />
+    <Compile Include="defaults\DefaultTaskCompletionHandler.cs" />
+    <Compile Include="defaults\DefaultTaskFailureHandler.cs" />
+    <Compile Include="defaults\DefaultTaskMessageHandler.cs" />
+    <Compile Include="defaults\DefaultTaskRunningHandler.cs" />
+    <Compile Include="defaults\DefaultTaskSuspensionHandler.cs" />
+    <Compile Include="DriverConfigGenerator.cs" />
+    <Compile Include="DriverConfigurationSettings.cs" />
+    <Compile Include="DriverManager.cs" />
+    <Compile Include="DriverRuntimeConfiguration.cs" />
+    <Compile Include="DriverRuntimeConfigurationOptions.cs" />
+    <Compile Include="DriverSubmissionSettings.cs" />
+    <Compile Include="EvaluatorManager.cs" />
+    <Compile Include="evaluator\EvaluatorDescriptorImpl.cs" />
+    <Compile Include="evaluator\EvaluatorRequest.cs" />
+    <Compile Include="evaluator\EvaluatorRequestBuilder.cs" />
+    <Compile Include="evaluator\IAllocatedEvaluator.cs" />
+    <Compile Include="evaluator\ICompletedEvaluator.cs" />
+    <Compile Include="evaluator\IEvaluatorDescriptor.cs" />
+    <Compile Include="evaluator\IEvaluatorRequest .cs" />
+    <Compile Include="evaluator\IEvaluatorRequestor.cs" />
+    <Compile Include="evaluator\IFailedEvaluator.cs" />
+    <Compile Include="FailedJob.cs" />
+    <Compile Include="IDriver.cs" />
+    <Compile Include="IStartHandler.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="task\ICompletedTask.cs" />
+    <Compile Include="task\IFailedTask.cs" />
+    <Compile Include="task\IRunningTask.cs" />
+    <Compile Include="task\ISuspendedTask.cs" />
+    <Compile Include="task\ITaskMessage.cs" />
+    <Compile Include="task\RunningTaskImpl.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs
new file mode 100644
index 0000000..671b82e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    /// <summary>
+    /// A wrapper around the general Logger class used specifically for 
+    /// logging in CPP bridge code. 
+    /// This is enabled when trace leve is above Level.Info (included)
+    /// </summary>
+    public class BridgeLogger
+    {
+        private Logger _logger;
+
+        public BridgeLogger(string name)
+        {
+            _logger = Logger.GetLogger(name);
+        }
+
+        public static BridgeLogger GetLogger(string className)
+        {
+            return new BridgeLogger(className);
+        }
+
+        public void Log(string message)
+        {
+            _logger.Log(Level.Info, message);
+        }
+
+        public void LogStart(string message)
+        {
+            _logger.Log(Level.Start, message);
+        }
+
+        public void LogStop(string message)
+        {
+            _logger.Log(Level.Stop, message);
+        }
+
+        public void LogError(string message, Exception e)
+        {
+            _logger.Log(Level.Error, message, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs
new file mode 100644
index 0000000..56341d6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Driver.bridge
+{
+    public class ClrClientHelper
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClrClientHelper));
+
+        public static void Run(HashSet<string> appDlls, IConfiguration driverBridgeConfig, DriverSubmissionSettings driverSubmissionSettings, string reefJar = Constants.BridgeJarFileName, string runCommand = "run.cmd", string clrFolder = ".", string className = Constants.BridgeLaunchClass)
+        {
+            using (LOGGER.LogFunction("ClrHandlerHelper::Run"))
+            {
+                if (driverSubmissionSettings.Submit)
+                {
+                    ClrHandlerHelper.CopyDllsToAppDirectory(appDlls);
+                    UpdateJarFileWithAssemblies(reefJar);
+                }
+
+                using (LOGGER.LogScope("ClrHandlerHelper::serialize driverBridgeConfig to clrRuntimeConfigFile"))
+                {
+                    string clrRuntimeConfigFile = Path.Combine(clrFolder, Constants.DriverBridgeConfiguration);
+                    new AvroConfigurationSerializer().ToFile(driverBridgeConfig, clrRuntimeConfigFile);
+                    LOGGER.Log(Level.Info, "CLR driver bridge configurations written to " + clrRuntimeConfigFile);
+                }
+
+                ProcessStartInfo startInfo = new ProcessStartInfo();
+                if (driverSubmissionSettings.RunOnYarn)
+                {
+                    startInfo.FileName = runCommand;
+                    startInfo.Arguments = className + " " + clrFolder +
+                                          driverSubmissionSettings.ToComamndLineArguments();
+                }
+                else
+                {
+                    startInfo.FileName = GetJavaBinary();
+                    string loggingPrefix = string.Empty;
+                    if (driverSubmissionSettings.JavaLogLevel == JavaLoggingSetting.VERBOSE_TO_CLR)
+                    {
+                        loggingPrefix = Constants.JavaToCLRLoggingConfig + " ";
+                    }
+                    else if (driverSubmissionSettings.JavaLogLevel == JavaLoggingSetting.VERBOSE)
+                    {
+                        loggingPrefix = Constants.JavaVerboseLoggingConfig + " ";
+                    }
+                    startInfo.Arguments = loggingPrefix + @"-classpath " + reefJar + " " + Constants.BridgeLaunchClass +
+                                          " " + clrFolder + " " + driverSubmissionSettings.ToComamndLineArguments();
+                }
+                startInfo.RedirectStandardOutput = true;
+                startInfo.UseShellExecute = false;
+                startInfo.CreateNoWindow = false;
+                LOGGER.Log(Level.Info, "Executing\r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
+                using (Process process = Process.Start(startInfo))
+                {
+                    process.WaitForExit();
+                }
+            }
+        }
+
+        public static void UpdateJarFileWithAssemblies(string reefJar)
+        {
+            using (LOGGER.LogFunction("ClrHandlerHelper::UpdateJarFileWithAssemblies"))
+            {
+                string assembliesList = ClrHandlerHelper.GetAssembliesListForReefDriverApp();
+                if (!File.Exists(reefJar))
+                {
+                    throw new InvalidOperationException("cannot find reef jar file: " + reefJar);
+                }
+                ProcessStartInfo startInfo = new ProcessStartInfo()
+                    {
+                        FileName = GetJarBinary(),
+                        Arguments = @"uf " + reefJar + " " + assembliesList,
+                        RedirectStandardOutput = true,
+                        RedirectStandardError = true,
+                        UseShellExecute = false,
+                        CreateNoWindow = true
+                    };
+
+                LOGGER.Log(Level.Info, "updating jar file with \r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
+                using (Process process = Process.Start(startInfo))
+                {
+                    StreamReader outReader = process.StandardOutput;
+                    StreamReader errorReader = process.StandardError;
+                    string output = outReader.ReadToEnd();
+                    string error = errorReader.ReadToEnd();
+                    process.WaitForExit();
+                    if (process.ExitCode != 0)
+                    {
+                        throw new InvalidOperationException("Failed to update jar file with stdout :" + output +
+                                                            "and stderr:" + error);
+                    }
+                }
+                LOGGER.Log(Level.Info, "jar file updated.");
+            }
+        }
+
+        public static void ExtractConfigfileFromJar(string reefJar, IList<string> configFiles, string dropFolder)
+        {
+                var configFileNames = string.Join(" ", configFiles.ToArray());
+                ProcessStartInfo startInfo = new ProcessStartInfo()
+                {
+                    FileName = GetJarBinary(),
+                    Arguments = @"xf " + reefJar + " " + configFileNames,
+                    RedirectStandardOutput = true,
+                    RedirectStandardError = true,
+                    UseShellExecute = false,
+                    CreateNoWindow = true
+                };
+
+                LOGGER.Log(Level.Info, "extracting files from jar file with \r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
+                using (Process process = Process.Start(startInfo))
+                {
+                    StreamReader outReader = process.StandardOutput;
+                    StreamReader errorReader = process.StandardError;
+                    string output = outReader.ReadToEnd();
+                    string error = errorReader.ReadToEnd();
+                    process.WaitForExit();
+                    if (process.ExitCode != 0)
+                    {
+                        throw new InvalidOperationException("Failed to extract files from jar file with stdout :" + output +
+                                                            "and stderr:" + error);
+                    }
+                }
+                LOGGER.Log(Level.Info, "files are extracted.");
+        }
+        
+        private static string GetJarBinary()
+        {
+            string javaHome = Environment.GetEnvironmentVariable("JAVA_HOME");
+            if (string.IsNullOrWhiteSpace(javaHome))
+            {
+                LOGGER.Log(Level.Info, "JAVA_HOME not set. Please set JAVA_HOME environment variable first. Exiting...");
+                Environment.Exit(1);
+            }
+            return Path.Combine(javaHome, "bin", "jar.exe");
+        }
+
+        private static string GetJavaBinary()
+        {
+            string javaHome = Environment.GetEnvironmentVariable("JAVA_HOME");
+            if (string.IsNullOrWhiteSpace(javaHome))
+            {
+                LOGGER.Log(Level.Info, "JAVA_HOME not set. Please set JAVA_HOME environment variable first. Exiting...");
+                Environment.Exit(1);
+            }
+            return Path.Combine(javaHome, "bin", "java.exe");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs
new file mode 100644
index 0000000..78d3e0a
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class ClrHandlerHelper
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClrHandlerHelper));
+
+        public static string[] ReefAssemblies
+        {
+            get
+            {
+                return new[] { "Microsoft.Hadoop.Avro.dll", "Org.Apache.Reef.Driver.dll", "Org.Apache.Reef.Common.dll", "Org.Apache.Reef.Utilities.dll", "Org.Apache.Reef.IO.Network.dll", "Org.Apache.Reef.Tang.dll", "Org.Apache.Reef.Wake.dll", "Newtonsoft.Json.dll", "protobuf-net.dll" };
+            }
+        }
+
+        internal static int MemoryGranularity { get; set; }
+
+        public static ulong CreateHandler(object handler)
+        {
+            GCHandle gc = GCHandle.Alloc(handler);
+            IntPtr intPtr = GCHandle.ToIntPtr(gc);
+            ulong ul = (ulong)intPtr.ToInt64();
+            return ul;
+        }
+
+        public static void FreeHandle(ulong handle)
+        {
+            GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+            gc.Free();
+        }
+
+        public static void SetMemoryGranuality(int granularity)
+        {
+            if (granularity <= 0)
+            {
+                var e = new ArgumentException("granularity must be a positive value, provided: " + granularity);
+                Exceptions.Throw(e, LOGGER);
+            }
+            MemoryGranularity = granularity;
+        }
+
+        public static ulong CreateNullHandler()
+        {
+            return Constants.NullHandler;
+        }
+
+        public static ISet<string> GetCommandLineArguments()
+        {
+            using (LOGGER.LogFunction("ClrHandlerHelper::GetCommandLineArguments"))
+            {
+                string bridgeConfiguration = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global",
+                                                          Constants.DriverBridgeConfiguration);
+
+                if (!File.Exists(bridgeConfiguration))
+                {
+                    string error = "Configuraiton file not found: " + bridgeConfiguration;
+                    LOGGER.Log(Level.Error, error);
+                    Exceptions.Throw(new InvalidOperationException(error), LOGGER);
+                }
+                CommandLineArguments arguments;
+                IInjector injector;
+                try
+                {
+                    IConfiguration driverBridgeConfiguration =
+                        new AvroConfigurationSerializer().FromFile(bridgeConfiguration);
+                    injector = TangFactory.GetTang().NewInjector(driverBridgeConfiguration);
+                    arguments = injector.GetInstance<CommandLineArguments>();
+                }
+                catch (InjectionException e)
+                {
+                    string error = "Cannot inject command line arguments from driver bridge configuration. ";
+                    Exceptions.Caught(e, Level.Error, error, LOGGER);
+                    // return empty string set
+                    return new HashSet<string>();
+                }
+                return arguments.Arguments;
+            }
+        }
+
+        public static void SupplyAdditionalClassPath(params string[] classPaths)
+        {
+            string path = Path.Combine(Directory.GetCurrentDirectory(), Constants.GlobalUserSuppliedJavaLibraries);
+            File.Delete(path);
+            File.WriteAllText(path, string.Join(",", classPaths));
+        }
+
+        public static void GenerateClassHierarchy(HashSet<string> clrDlls)
+        {
+            using (LOGGER.LogFunction("ClrHandlerHelper::GenerateClassHierarchy"))
+            {
+                IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(clrDlls.ToArray());
+                ProtocolBufferClassHierarchy.Serialize(Constants.ClassHierarachyBin, ns);
+
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Class hierarchy written to [{0}].", Path.Combine(Directory.GetCurrentDirectory(), Constants.ClassHierarachyBin)));
+            }
+        }
+
+        public static string GetAssembliesListForReefDriverApp()
+        {
+            using (LOGGER.LogFunction("ClrHandlerHelper::GetAssembliesListForReefDriverApp"))
+            {
+                string executionDirectory = Directory.GetCurrentDirectory();
+                IList<string> assemblies =
+                    Directory.GetFiles(Path.Combine(executionDirectory, Constants.DriverAppDirectory), "*.dll")
+                             .Select(f => string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Constants.DriverAppDirectory + @"\" + Path.GetFileName(f))).ToList();
+
+                foreach (string reefAssembly in ReefAssemblies)
+                {
+                    if (!File.Exists(reefAssembly))
+                    {
+                        var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Assembly [{0}] needed for REEF driver not found in {1}", reefAssembly, executionDirectory));
+                        Exceptions.Throw(e, LOGGER);
+                    }
+                    File.Copy(reefAssembly, Path.Combine(executionDirectory, Constants.DriverAppDirectory, reefAssembly), overwrite: true);
+                    assemblies.Add(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Constants.DriverAppDirectory + @"\" + reefAssembly));
+                }
+                return string.Join(" ", assemblies);
+            }
+        }
+
+        public static void CopyDllsToAppDirectory(HashSet<string> dlls)
+        {
+            using (LOGGER.LogFunction("ClrHandlerHelper::CopyDllsToAppDirectory"))
+            {
+                string executionDirectory = Directory.GetCurrentDirectory();
+                Directory.CreateDirectory(Path.Combine(executionDirectory, Constants.DriverAppDirectory));
+                foreach (string dll in dlls)
+                {
+                    string dllFile = dll;
+                    if (!dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
+                    {
+                        dllFile += ".dll";
+                    }
+                    if (!File.Exists(dllFile))
+                    {
+                        var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Assembly [{0}] for REEF application not found in {1}", dllFile, executionDirectory));
+                        Exceptions.Throw(e, LOGGER);
+                    }
+                    File.Copy(dllFile, Path.Combine(executionDirectory, Constants.DriverAppDirectory, dllFile), overwrite: true);
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs
new file mode 100644
index 0000000..88fb410
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class ClrSystemHandler<T> : IObserver<T>, IObservable<T>
+    {
+        List<IObserver<T>> userHandlers = new List<IObserver<T>>();
+
+        public void OnNext(T value)
+        {
+            foreach (var observer in userHandlers)
+            {
+                observer.OnNext(value);
+            }
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public IDisposable Subscribe(IObserver<T> observer)
+        {
+            userHandlers.Add(observer);
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs
new file mode 100644
index 0000000..bcd4be4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs
@@ -0,0 +1,273 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using System.IO;
+using System.Runtime.InteropServices;
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Wake.Time;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class ClrSystemHandlerWrapper
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClrSystemHandlerWrapper));
+
+        private static DriverBridge _driverBridge;
+
+        public static void Call_ClrSystemAllocatedEvaluatorHandler_OnNext(ulong handle, IAllocatedEvaluaotrClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemAllocatedEvaluatorHandler_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IAllocatedEvaluator> obj = (ClrSystemHandler<IAllocatedEvaluator>)gc.Target;
+                obj.OnNext(new AllocatedEvaluator(clr2Java)); 
+            }       
+        }
+
+        public static void Call_ClrSystemActiveContextHandler_OnNext(ulong handle, IActiveContextClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemActiveContextHandler_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IActiveContext> obj = (ClrSystemHandler<IActiveContext>)gc.Target;
+                obj.OnNext(new ActiveContext(clr2Java));
+            }            
+        }
+
+        public static void Call_ClrSystemDriverRestartActiveContextHandler_OnNext(ulong handle, IActiveContextClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartActiveContextHandler_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IActiveContext> obj = (ClrSystemHandler<IActiveContext>)gc.Target;
+                obj.OnNext(new ActiveContext(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemEvaluatorRequestor_OnNext(ulong handle, IEvaluatorRequestorClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemEvaluatorRequestor_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IEvaluatorRequestor> obj = (ClrSystemHandler<IEvaluatorRequestor>)gc.Target;
+                obj.OnNext(new EvaluatorRequestor(clr2Java));
+            }   
+        }
+
+        public static void Call_ClrSystemTaskMessage_OnNext(ulong handle, ITaskMessageClr2Java clr2Java, byte[] message)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemTaskMessage_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<ITaskMessage> obj = (ClrSystemHandler<ITaskMessage>)gc.Target;
+                obj.OnNext(new TaskMessage(clr2Java, message));
+            }   
+        }
+
+        public static void Call_ClrSystemFailedTask_OnNext(ulong handle, IFailedTaskClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemFailedTask_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IFailedTask> obj = (ClrSystemHandler<IFailedTask>)gc.Target;
+                obj.OnNext(new FailedTask(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemRunningTask_OnNext(ulong handle, IRunningTaskClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemRunningTask_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IRunningTask> obj = (ClrSystemHandler<IRunningTask>)gc.Target;
+                obj.OnNext(new RunningTask(clr2Java));
+            }        
+        }
+
+        public static void Call_ClrSystemDriverRestartRunningTask_OnNext(ulong handle, IRunningTaskClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartRunningTask_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IRunningTask> obj = (ClrSystemHandler<IRunningTask>)gc.Target;
+                obj.OnNext(new RunningTask(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemFailedEvaluator_OnNext(ulong handle, IFailedEvaluatorClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemFailedEvaluator_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IFailedEvaluator> obj = (ClrSystemHandler<IFailedEvaluator>)gc.Target;
+                obj.OnNext(new FailedEvaluator(clr2Java));
+            }     
+        }
+
+        public static void Call_ClrSystemCompletedTask_OnNext(ulong handle, ICompletedTaskClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemCompletedTask_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<ICompletedTask> obj = (ClrSystemHandler<ICompletedTask>)gc.Target;
+                obj.OnNext(new CompletedTask(clr2Java));
+            }         
+        }
+
+        public static void Call_ClrSystemSuspendedTask_OnNext(ulong handle, ISuspendedTaskClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemSuspendedTask_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<ISuspendedTask> obj = (ClrSystemHandler<ISuspendedTask>)gc.Target;
+                obj.OnNext(new SuspendedTask(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemCompletedEvaluator_OnNext(ulong handle, ICompletedEvaluatorClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemCompletedEvaluator_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<ICompletedEvaluator> obj = (ClrSystemHandler<ICompletedEvaluator>)gc.Target;
+                obj.OnNext(new CompletedEvaluator(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemHttpServer_OnNext(ulong handle, IHttpServerBridgeClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemHttpServer_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IHttpMessage> obj = (ClrSystemHandler<IHttpMessage>)gc.Target;
+                obj.OnNext(new HttpMessage(clr2Java));
+            }      
+        }
+
+        public static void Call_ClrSystemClosedContext_OnNext(ulong handle, IClosedContextClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemClosedContext_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IClosedContext> obj = (ClrSystemHandler<IClosedContext>)gc.Target;
+                obj.OnNext(new ClosedContext(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemFailedContext_OnNext(ulong handle, IFailedContextClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemFailedContext_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IFailedContext> obj = (ClrSystemHandler<IFailedContext>)gc.Target;
+                obj.OnNext(new FailedContext(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemContextMessage_OnNext(ulong handle, IContextMessageClr2Java clr2Java)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemContextMessage_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<IContextMessage> obj = (ClrSystemHandler<IContextMessage>)gc.Target;
+                obj.OnNext(new ContextMessage(clr2Java));
+            }
+        }
+
+        public static void Call_ClrSystemDriverRestart_OnNext(ulong handle)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestart_OnNext"))
+            {
+                GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
+                ClrSystemHandler<StartTime> obj = (ClrSystemHandler<StartTime>)gc.Target;
+                obj.OnNext(new StartTime(DateTime.Now.Ticks));
+            }
+        }
+
+        //Deprecate, remove after both Java and C# code gets checked in
+        public static ulong[] Call_ClrSystemStartHandler_OnStart(DateTime startTime)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemStartHandler_OnStart"))
+            {
+                LOGGER.Log(Level.Info, "*** Start time is " + startTime);
+                return GetHandlers(null);
+            }
+        }
+
+        public static ulong[] Call_ClrSystemStartHandler_OnStart(DateTime startTime, string httpServerPort)
+        {
+            using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemStartHandler_OnStart"))
+            {
+                LOGGER.Log(Level.Info, "*** Start time is " + startTime);
+                LOGGER.Log(Level.Info, "*** httpServerPort: " + httpServerPort);
+                return GetHandlers(httpServerPort);
+            }   
+        }
+
+        private static ulong[] GetHandlers(string httpServerPortNumber)
+        {
+            IStartHandler startHandler;
+            IInjector injector = null;
+            string errorMessage;
+            string bridgeConfiguration = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global", Constants.DriverBridgeConfiguration);
+            if (!File.Exists(bridgeConfiguration))
+            {
+                errorMessage = "Cannot find CLR Driver bridge configuration file " + bridgeConfiguration;
+                Exceptions.Throw(new InvalidOperationException(errorMessage), LOGGER);
+            }
+            try
+            {
+                IConfiguration driverBridgeConfiguration = new AvroConfigurationSerializer().FromFile(bridgeConfiguration);
+                injector = TangFactory.GetTang().NewInjector(driverBridgeConfiguration);
+            }
+            catch (Exception e)
+            {
+                errorMessage = "Failed to get injector from driver bridge configuration.";
+                Exceptions.CaughtAndThrow(new InvalidOperationException(errorMessage, e), Level.Error, errorMessage, LOGGER);
+            }
+
+            try
+            {
+                HttpServerPort port = injector.GetInstance<HttpServerPort>();
+                port.PortNumber = httpServerPortNumber == null ? 0 : int.Parse(httpServerPortNumber, CultureInfo.InvariantCulture);
+
+                startHandler = injector.GetInstance<IStartHandler>();
+                LOGGER.Log(Level.Info, "Start handler set to be " + startHandler.Identifier);
+                _driverBridge = injector.GetInstance<DriverBridge>();
+            }
+            catch (Exception e)
+            {
+                Exceptions.CaughtAndThrow(e, Level.Error, "Cannot get instance.", LOGGER);
+            }
+
+            return _driverBridge.Subscribe();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridge.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridge.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridge.cs
new file mode 100644
index 0000000..05f33b3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridge.cs
@@ -0,0 +1,321 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+
+using Org.Apache.Reef.Wake.Time;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class DriverBridge
+    {
+        private static Logger _logger;
+        
+        private static ClrSystemHandler<IAllocatedEvaluator> _allocatedEvaluatorSubscriber;
+
+        private static ClrSystemHandler<IEvaluatorRequestor> _evaluatorRequestorSubscriber;
+
+        private static ClrSystemHandler<ITaskMessage> _taskMessageSubscriber;
+
+        private static ClrSystemHandler<IActiveContext> _activeContextSubscriber;
+
+        private static ClrSystemHandler<IActiveContext> _driverRestartActiveContextSubscriber;
+
+        private static ClrSystemHandler<IFailedTask> _failedTaskSubscriber;
+
+        private static ClrSystemHandler<IRunningTask> _runningTaskSubscriber;
+
+        private static ClrSystemHandler<IRunningTask> _driverRestartRunningTaskSubscriber;
+
+        private static ClrSystemHandler<ISuspendedTask> _suspendedTaskSubscriber;
+
+        private static ClrSystemHandler<IFailedEvaluator> _failedEvaluatorSubscriber;
+
+        private static ClrSystemHandler<ICompletedEvaluator> _completedEvaluatorSubscriber;
+
+        private static ClrSystemHandler<IHttpMessage> _httpServerEventSubscriber;
+
+        private static ClrSystemHandler<ICompletedTask> _completedTaskSubscriber;
+
+        private static ClrSystemHandler<IClosedContext> _closedContextSubscriber;
+
+        private static ClrSystemHandler<IFailedContext> _failedContextSubscriber;
+
+        private static ClrSystemHandler<IContextMessage> _contextMessageSubscriber;
+
+        private static ClrSystemHandler<StartTime> _driverRestartSubscriber;
+
+        private IObserver<StartTime> _driverRestartHandler; 
+
+        private ISet<IObserver<IEvaluatorRequestor>> _evaluatorRequestHandlers;
+
+        private ISet<IObserver<IAllocatedEvaluator>> _allocatedEvaluatorHandlers;
+
+        private ISet<IObserver<IActiveContext>> _activeContextHandlers;
+
+        private ISet<IObserver<IActiveContext>> _driverRestartActiveContextHandlers;
+
+        private ISet<IObserver<ITaskMessage>> _taskMessageHandlers;
+
+        private ISet<IObserver<IFailedTask>> _failedTaskHandlers;
+
+        private ISet<IObserver<ISuspendedTask>> _suspendedTaskHandlers;
+
+        private ISet<IObserver<IRunningTask>> _runningTaskHandlers;
+
+        private ISet<IObserver<IRunningTask>> _driverRestartRunningTaskHandlers;
+
+        private ISet<IObserver<IFailedEvaluator>> _failedEvaluatorHandlers;
+
+        private ISet<IObserver<ICompletedEvaluator>> _completedEvaluatorHandlers;
+
+        private ISet<IObserver<IClosedContext>> _closedContextHandlers;
+
+        private ISet<IObserver<IFailedContext>> _failedContextHandlers;
+
+        private ISet<IObserver<IContextMessage>> _contextMessageHandlers;
+
+        private ISet<IObserver<ICompletedTask>> _completedTaskHandlers;
+
+        private HttpServerHandler _httpServerHandler;
+
+        [Inject]
+        public DriverBridge(
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.DriverRestartHandler))] IObserver<StartTime> driverRestartHandler,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.EvaluatorRequestHandlers))] ISet<IObserver<IEvaluatorRequestor>> evaluatorRequestHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.AllocatedEvaluatorHandlers))] ISet<IObserver<IAllocatedEvaluator>> allocatedEvaluatorHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.ActiveContextHandlers))] ISet<IObserver<IActiveContext>> activeContextHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.TaskMessageHandlers))] ISet<IObserver<ITaskMessage>> taskMessageHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.FailedTaskHandlers))] ISet<IObserver<IFailedTask>> failedTaskHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.FailedEvaluatorHandlers))] ISet<IObserver<IFailedEvaluator>> failedEvaluatorHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.CompletedEvaluatorHandlers))] ISet<IObserver<ICompletedEvaluator>> completedEvaluatorHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.RunningTaskHandlers))] ISet<IObserver<IRunningTask>> runningTaskHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.CompletedTaskHandlers))] ISet<IObserver<ICompletedTask>> completedTaskHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.SuspendedTaskHandlers))] ISet<IObserver<ISuspendedTask>> suspendedTaskHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.ClosedContextHandlers))] ISet<IObserver<IClosedContext>> closedContextHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.FailedContextHandlers))] ISet<IObserver<IFailedContext>> failedContextHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.ContextMessageHandlers))] ISet<IObserver<IContextMessage>> contextMessageHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.DriverRestartActiveContextHandlers))] ISet<IObserver<IActiveContext>> driverRestartActiveContextHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.DriverRestartRunningTaskHandlers))] ISet<IObserver<IRunningTask>> driverRestartRunningTaskHandlers,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.TraceListenersSet))] ISet<TraceListener> traceListeners,
+            [Parameter(Value = typeof(DriverBridgeConfigurationOptions.TraceLevel))] string traceLevel,
+            HttpServerHandler httpServerHandler)
+        {
+            foreach (TraceListener listener in traceListeners)
+            {
+                Logger.AddTraceListner(listener);
+            }
+            _logger = Logger.GetLogger(typeof(DriverBridge));
+            _logger.Log(Level.Info, "Constructing DriverBridge");
+
+            Level level;
+            if (!Enum.TryParse(traceLevel.ToString(CultureInfo.InvariantCulture), out level))
+            {
+                _logger.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Invalid trace level {0} provided, will by default use verbose level", traceLevel));
+            }
+            else
+            {
+                Logger.SetCustomLevel(level);
+            }
+            
+            _evaluatorRequestHandlers = evaluatorRequestHandlers;
+            _allocatedEvaluatorHandlers = allocatedEvaluatorHandlers;
+            _activeContextHandlers = activeContextHandlers;
+            _taskMessageHandlers = taskMessageHandlers;
+            _failedEvaluatorHandlers = failedEvaluatorHandlers;
+            _failedTaskHandlers = failedTaskHandlers;
+            _completedTaskHandlers = completedTaskHandlers;
+            _runningTaskHandlers = runningTaskHandlers;
+            _suspendedTaskHandlers = suspendedTaskHandlers;
+            _completedEvaluatorHandlers = completedEvaluatorHandlers;
+            _closedContextHandlers = closedContextHandlers;
+            _failedContextHandlers = failedContextHandlers;
+            _contextMessageHandlers = contextMessageHandlers;
+            _driverRestartHandler = driverRestartHandler;
+            _driverRestartActiveContextHandlers = driverRestartActiveContextHandlers;
+            _driverRestartRunningTaskHandlers = driverRestartRunningTaskHandlers;
+            _httpServerHandler = httpServerHandler;
+
+            _evaluatorRequestorSubscriber = new ClrSystemHandler<IEvaluatorRequestor>();
+            _allocatedEvaluatorSubscriber = new ClrSystemHandler<IAllocatedEvaluator>();
+            _completedEvaluatorSubscriber = new ClrSystemHandler<ICompletedEvaluator>();
+            _taskMessageSubscriber = new ClrSystemHandler<ITaskMessage>();
+            _activeContextSubscriber = new ClrSystemHandler<IActiveContext>();
+            _failedTaskSubscriber = new ClrSystemHandler<IFailedTask>();
+            _failedEvaluatorSubscriber = new ClrSystemHandler<IFailedEvaluator>();
+            _httpServerEventSubscriber = new ClrSystemHandler<IHttpMessage>();
+            _completedTaskSubscriber = new ClrSystemHandler<ICompletedTask>();
+            _runningTaskSubscriber = new ClrSystemHandler<IRunningTask>();
+            _suspendedTaskSubscriber = new ClrSystemHandler<ISuspendedTask>();
+            _closedContextSubscriber = new ClrSystemHandler<IClosedContext>();
+            _failedContextSubscriber = new ClrSystemHandler<IFailedContext>();
+            _contextMessageSubscriber = new ClrSystemHandler<IContextMessage>();
+            _driverRestartSubscriber = new ClrSystemHandler<StartTime>();
+            _driverRestartActiveContextSubscriber = new ClrSystemHandler<IActiveContext>();
+            _driverRestartRunningTaskSubscriber = new ClrSystemHandler<IRunningTask>();
+        }
+
+        public ulong[] Subscribe()
+        {
+            ulong[] handlers = Enumerable.Repeat(Constants.NullHandler, Constants.HandlersNumber).ToArray();
+
+            // subscribe to StartTime event for driver restart         
+            _driverRestartSubscriber.Subscribe(_driverRestartHandler);
+            _logger.Log(Level.Info, "subscribed to Driver restart handler: " + _driverRestartHandler);
+            handlers[Constants.Handlers[Constants.DriverRestartHandler]] = ClrHandlerHelper.CreateHandler(_driverRestartSubscriber);
+
+            // subscribe to Evaluator Requestor          
+            foreach (var handler in _evaluatorRequestHandlers)
+            {
+                _evaluatorRequestorSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IEvaluatorRequestor handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.EvaluatorRequestorHandler]] = ClrHandlerHelper.CreateHandler(_evaluatorRequestorSubscriber);
+
+            // subscribe to Allocated Evaluator
+            foreach (var handler in _allocatedEvaluatorHandlers)
+            {
+                _allocatedEvaluatorSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IAllocatedEvaluator handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.AllocatedEvaluatorHandler]] = ClrHandlerHelper.CreateHandler(_allocatedEvaluatorSubscriber);
+
+            // subscribe to TaskMessage
+            foreach (var handler in _taskMessageHandlers)
+            {
+                _taskMessageSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to ITaskMessage handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.TaskMessageHandler]] = ClrHandlerHelper.CreateHandler(_taskMessageSubscriber);
+
+            // subscribe to Active Context
+            foreach (var handler in _activeContextHandlers)
+            {
+                _activeContextSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IActiveContext handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.ActiveContextHandler]] = ClrHandlerHelper.CreateHandler(_activeContextSubscriber);
+
+            // subscribe to Failed Task
+            foreach (var handler in _failedTaskHandlers)
+            {
+                _failedTaskSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IFailedTask handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.FailedTaskHandler]] = ClrHandlerHelper.CreateHandler(_failedTaskSubscriber);
+
+            // subscribe to Running Task
+            foreach (var handler in _runningTaskHandlers)
+            {
+                _runningTaskSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IRunningask handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.RunningTaskHandler]] = ClrHandlerHelper.CreateHandler(_runningTaskSubscriber);
+
+            // subscribe to Completed Task
+            foreach (var handler in _completedTaskHandlers)
+            {
+                _completedTaskSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to ICompletedTask handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.CompletedTaskHandler]] = ClrHandlerHelper.CreateHandler(_completedTaskSubscriber);
+
+            // subscribe to Suspended Task
+            foreach (var handler in _suspendedTaskHandlers)
+            {
+                _suspendedTaskSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to ISuspendedTask handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.SuspendedTaskHandler]] = ClrHandlerHelper.CreateHandler(_suspendedTaskSubscriber);
+
+            // subscribe to Failed Evaluator
+            foreach (var handler in _failedEvaluatorHandlers)
+            {
+                _failedEvaluatorSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IFailedEvaluator handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.FailedEvaluatorHandler]] = ClrHandlerHelper.CreateHandler(_failedEvaluatorSubscriber);
+
+            // subscribe to Completed Evaluator
+            foreach (var handler in _completedEvaluatorHandlers)
+            {
+                _completedEvaluatorSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to ICompletedEvaluator handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.CompletedEvaluatorHandler]] = ClrHandlerHelper.CreateHandler(_completedEvaluatorSubscriber);
+
+            // subscribe to Closed Context
+            foreach (var handler in _closedContextHandlers)
+            {
+                _closedContextSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IClosedContext handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.ClosedContextHandler]] = ClrHandlerHelper.CreateHandler(_closedContextSubscriber);
+
+            // subscribe to Failed Context
+            foreach (var handler in _failedContextHandlers)
+            {
+                _failedContextSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IFailedContext handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.FailedContextHandler]] = ClrHandlerHelper.CreateHandler(_failedContextSubscriber);
+
+            // subscribe to Context Message
+            foreach (var handler in _contextMessageHandlers)
+            {
+                _contextMessageSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to IContextMesage handler: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.ContextMessageHandler]] = ClrHandlerHelper.CreateHandler(_contextMessageSubscriber);
+
+            // subscribe to Active Context received during driver restart
+            foreach (var handler in _driverRestartActiveContextHandlers)
+            {
+                _driverRestartActiveContextSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to handler for IActiveContext received during driver restart: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.DriverRestartActiveContextHandler]] = ClrHandlerHelper.CreateHandler(_driverRestartActiveContextSubscriber);
+
+            // subscribe to Running Task received during driver restart
+            foreach (var handler in _driverRestartRunningTaskHandlers)
+            {
+                _driverRestartRunningTaskSubscriber.Subscribe(handler);
+                _logger.Log(Level.Info, "subscribed to handler for IRunningTask received during driver restart: " + handler);
+            }
+            handlers[Constants.Handlers[Constants.DriverRestartRunningTaskHandler]] = ClrHandlerHelper.CreateHandler(_driverRestartRunningTaskSubscriber);
+
+            // subscribe to Http message
+            _httpServerEventSubscriber.Subscribe(_httpServerHandler);
+            _logger.Log(Level.Info, "subscribed to IHttpMessage handler  :" + _httpServerHandler);
+            handlers[Constants.Handlers[Constants.HttpServerHandler]] = ClrHandlerHelper.CreateHandler(_httpServerEventSubscriber);
+
+            return handlers;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfiguration.cs
new file mode 100644
index 0000000..cf74529
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/DriverBridgeConfiguration.cs
@@ -0,0 +1,273 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Wake.Time;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "static field, typical usage in configurations")]
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    public class DriverBridgeConfiguration : ConfigurationModuleBuilder
+    {
+        /// <summary>
+        ///  The event handler invoked right after the driver boots up. 
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredImpl<IStartHandler> OnDriverStarted = new RequiredImpl<IStartHandler>();
+
+        /// <summary>
+        ///  The event handler invoked when driver restarts
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<StartTime>> OnDriverRestarted = new OptionalImpl<IObserver<StartTime>>();
+
+        /// <summary>
+        /// The event handler for requesting evaluator
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IEvaluatorRequestor>> OnEvaluatorRequested = new OptionalImpl<IObserver<IEvaluatorRequestor>>();
+
+        /// <summary>
+        /// Event handler for allocated evaluators. Defaults to returning the evaluator if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IAllocatedEvaluator>> OnEvaluatorAllocated = new OptionalImpl<IObserver<IAllocatedEvaluator>>();
+
+        /// <summary>
+        /// Event handler for completed evaluators. Defaults to logging if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ICompletedEvaluator>> OnEvaluatorCompleted = new OptionalImpl<IObserver<ICompletedEvaluator>>();
+
+        /// <summary>
+        /// Event handler for failed evaluators. Defaults to job failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IFailedEvaluator>> OnEvaluatorFailed = new OptionalImpl<IObserver<IFailedEvaluator>>();
+
+        /// <summary>
+        /// Event handler for failed evaluators. Defaults to job failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IHttpHandler> OnHttpEvent = new OptionalImpl<IHttpHandler>();
+
+        /// <summary>
+        /// Event handler for task messages. Defaults to logging if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ITaskMessage>> OnTaskMessage = new OptionalImpl<IObserver<ITaskMessage>>();
+
+        /// <summary>
+        /// Event handler for completed tasks. Defaults to closing the context the task ran on if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]        
+        public static readonly OptionalImpl<IObserver<ICompletedTask>> OnTaskCompleted = new OptionalImpl<IObserver<ICompletedTask>>();
+
+        /// <summary>
+        /// Event handler for failed tasks. Defaults to job failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IFailedTask>> OnTaskFailed = new OptionalImpl<IObserver<IFailedTask>>();
+
+        ///// <summary>
+        ///// Event handler for running tasks. Defaults to logging if not bound.
+        ///// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IRunningTask>> OnTaskRunning = new OptionalImpl<IObserver<IRunningTask>>();
+
+        ///// <summary>
+        ///// Event handler for running task received during driver restart. Defaults to logging if not bound.
+        ///// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IRunningTask>> OnDriverRestartTaskRunning = new OptionalImpl<IObserver<IRunningTask>>();
+
+        /// <summary>
+        /// Event handler for suspended tasks. Defaults to job failure if not bound. Rationale: many jobs don't support
+        /// task suspension. Hence, this parameter should be optional. The only sane default is to crash the job, then.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<ISuspendedTask>> OnTaskSuspended = new OptionalImpl<IObserver<ISuspendedTask>>();
+
+        /// <summary>
+        /// Event handler for active context. Defaults to closing the context if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IActiveContext>> OnContextActive = new OptionalImpl<IObserver<IActiveContext>>();
+
+        /// <summary>
+        /// Event handler for active context received during driver restart. Defaults to closing the context if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IActiveContext>> OnDirverRestartContextActive = new OptionalImpl<IObserver<IActiveContext>>();
+
+        /// <summary>
+        /// Event handler for closed context. Defaults to logging if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IClosedContext>> OnContextClosed = new OptionalImpl<IObserver<IClosedContext>>();
+
+        /// <summary>
+        ///  Event handler for closed context. Defaults to job failure if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IFailedContext>> OnContextFailed = new OptionalImpl<IObserver<IFailedContext>>();
+
+        /// <summary>
+        ///  Event handler for context messages. Defaults to logging if not bound.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IObserver<IContextMessage>> OnContextMessage = new OptionalImpl<IObserver<IContextMessage>>();
+
+        /// <summary>
+        /// Additional set of string arguments that can be pssed to handlers through client
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalParameter<string> CommandLineArguments = new OptionalParameter<string>();
+
+        /// <summary>
+        /// The trace level of the TraceListner
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalParameter<string> CustomTraceLevel = new OptionalParameter<string>();
+
+        /// <summary>
+        /// Additional set of trace listners provided by client
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalParameter<TraceListener> CustomTraceListeners = new OptionalParameter<TraceListener>();
+
+        /// <summary>
+        ///  The implemenation for (attempting to) re-establish connection to driver
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly OptionalImpl<IDriverConnection> OnDriverReconnect = new OptionalImpl<IDriverConnection>();
+
+        // This is currently not needed in Bridge/Driver model
+        ///// <summary>
+        ///// The event handler invoked right before the driver shuts down. Defaults to ignore.
+        ///// </summary>
+        //public static readonly OptionalImpl<IObserver<StopTime>> OnDriverStop = new OptionalImpl<IObserver<StopTime>>();
+
+        // Client handlers only needed when client interactions are expeceted. Not enabled for now.
+        ///// <summary>
+        ///// Event handler for client messages. Defaults to logging if not bound.
+        ///// </summary>
+        //public static readonly OptionalImpl<IObserver<byte[]>> OnClientMessage = new OptionalImpl<IObserver<byte[]>>();
+
+        // Client handlers only needed when client interactions are expeceted. Not enabled for now.
+        ///// <summary>
+        ///// Event handler for close messages sent by the client. Defaults to job failure if not bound.
+        ///// Note: in java the type is void, but IObserver does not take void as a type
+        ///// </summary>
+        //public static readonly OptionalImpl<IObserver<byte[]>> OnClientClosed = new OptionalImpl<IObserver<byte[]>>();
+
+        // Client handlers only needed when client interactions are expeceted. Not enabled for now.
+        ///// <summary>
+        ///// Event handler for close messages sent by the client. Defaults to job failure if not bound.
+        ///// </summary>
+        //public static readonly OptionalImpl<IObserver<byte[]>> OnClientClosedMessage = new OptionalImpl<IObserver<byte[]>>();
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new DriverBridgeConfiguration()
+                .BindImplementation(GenericType<IStartHandler>.Class, OnDriverStarted)
+                .BindNamedParameter(GenericType<DriverBridgeConfigurationOptions.DriverRestartHandler>.Class, OnDriverRestarted)
+                .BindImplementation(GenericType<IDriverConnection>.Class, OnDriverReconnect)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.EvaluatorRequestHandlers>.Class, OnEvaluatorRequested)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.AllocatedEvaluatorHandlers>.Class, OnEvaluatorAllocated)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ActiveContextHandlers>.Class, OnContextActive)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.TaskMessageHandlers>.Class, OnTaskMessage)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.FailedTaskHandlers>.Class, OnTaskFailed)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.RunningTaskHandlers>.Class, OnTaskRunning)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.SuspendedTaskHandlers>.Class, OnTaskSuspended)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.FailedEvaluatorHandlers>.Class, OnEvaluatorFailed)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.CompletedEvaluatorHandlers>.Class, OnEvaluatorCompleted)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.CompletedTaskHandlers>.Class, OnTaskCompleted)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ClosedContextHandlers>.Class, OnContextClosed)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.FailedContextHandlers>.Class, OnContextFailed)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ContextMessageHandlers>.Class, OnContextMessage)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ArgumentSets>.Class, CommandLineArguments)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.HttpEventHandlers>.Class, OnHttpEvent)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.TraceListenersSet>.Class, CustomTraceListeners)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartActiveContextHandlers>.Class, OnDirverRestartContextActive)
+                .BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartRunningTaskHandlers>.Class, OnDriverRestartTaskRunning)
+                .BindNamedParameter(GenericType<DriverBridgeConfigurationOptions.TraceLevel>.Class, CustomTraceLevel)
+                .Build();
+            }
+        }
+    }
+
+    public class CommandLineArguments
+    {
+        [Inject]
+        public CommandLineArguments([Parameter(typeof(DriverBridgeConfigurationOptions.ArgumentSets))] ISet<string> arguments)
+        {
+            Arguments = arguments;
+        }
+
+        public ISet<string> Arguments { get; set; }
+    }
+
+    public class CustomTraceListeners
+    {
+        [Inject]
+        public CustomTraceListeners([Parameter(typeof(DriverBridgeConfigurationOptions.TraceListenersSet))] ISet<TraceListener> listeners)
+        {
+            Listeners = listeners;
+        }
+
+        public ISet<TraceListener> Listeners { get; set; }
+    }
+
+    public class CustomTraceLevel
+    {
+        [Inject]
+        public CustomTraceLevel([Parameter(typeof(DriverBridgeConfigurationOptions.TraceLevel))] string traceLevel)
+        {
+            Level level = Level.Verbose;
+            if (Enum.TryParse(traceLevel.ToString(CultureInfo.InvariantCulture), out level))
+            {
+                Logger.SetCustomLevel(level);
+            }
+            else
+            {
+                Console.WriteLine("Cannot parse trace level" + traceLevel);
+            }
+            TraceLevel = level;
+        }
+
+        public Level TraceLevel { get; set; }
+    }
+}


[03/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestSetInjection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestSetInjection.cs b/lang/cs/Tests/TangTests/Injection/TestSetInjection.cs
new file mode 100644
index 0000000..82a9cf5
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestSetInjection.cs
@@ -0,0 +1,739 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    public interface INumber : IComparable
+    {
+    }
+
+    public interface ITimeshift
+    {
+        string LinkId { get; }
+
+        TimeSpan TimeshiftSpan { get; }
+    }
+
+    [TestClass]
+    public class TestSetInjection
+    {
+        [TestMethod]
+        public void TestStringInjectDefault()
+        {
+            Box b = (Box)TangFactory.GetTang().NewInjector().GetInstance(typeof(Box));
+
+            ISet<string> actual = b.Numbers;
+
+            ISet<string> expected = new HashSet<string>();
+            expected.Add("one");
+            expected.Add("two");
+            expected.Add("three");
+
+            Assert.IsTrue(actual.Contains("one"));
+            Assert.IsTrue(actual.Contains("two"));
+            Assert.IsTrue(actual.Contains("three"));
+            //Assert.AreEqual(expected, actual);
+        }
+
+        [TestMethod]
+        public void TestObjectInjectDefault()
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            i.BindVolatileInstance(GenericType<Integer>.Class, new Integer(42));
+            i.BindVolatileInstance(GenericType<Float>.Class, new Float(42.0001f));
+            ISet<INumber> actual = ((Pool)i.GetInstance(typeof(Pool))).Numbers;
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new Integer(42));
+            expected.Add(new Float(42.0001f));
+
+            Assert.IsTrue(actual.Contains(new Integer(42)));
+            Assert.IsTrue(actual.Contains(new Float(42.0001f)));
+            //Assert.AreEqual(expected, actual);
+        }
+
+        [TestMethod]
+        public void testStringInjectBound()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "four");
+            cb.BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "five");
+            cb.BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "six");
+
+            Box b = (Box)TangFactory.GetTang().NewInjector(cb.Build()).GetInstance(typeof(Box));
+            ISet<string> actual = b.Numbers;
+            ISet<string> expected = new HashSet<string>();
+            expected.Add("four");
+            expected.Add("five");
+            expected.Add("six");
+
+            Assert.IsTrue(actual.Contains("four"));
+            Assert.IsTrue(actual.Contains("five"));
+            Assert.IsTrue(actual.Contains("six"));
+        }
+
+        [TestMethod]
+        public void TestObjectInjectBound()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindSetEntry<SetOfClasses, Integer, INumber>(GenericType<SetOfClasses>.Class, GenericType<Integer>.Class);
+            cb.BindSetEntry<SetOfClasses, Float, INumber>(GenericType<SetOfClasses>.Class, GenericType<Float>.Class);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<Integer>.Class, new Integer(4));
+            i.BindVolatileInstance(GenericType<Float>.Class, new Float(42.0001f));
+
+            ISet<INumber> actual = i.GetInstance<Pool>().Numbers;
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new Integer(4));
+            expected.Add(new Float(42.0001f));
+            Assert.IsTrue(Utilities.Utilities.Equals<INumber>(actual, expected));
+        }
+
+        [TestMethod]
+        public void TestSetOfClassBound()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindSetEntry<SetOfClasses, Integer1, INumber>(GenericType<SetOfClasses>.Class, GenericType<Integer1>.Class)  //bind an impl to the interface of the set
+              .BindNamedParameter<Integer1.NamedInt, int>(GenericType<Integer1.NamedInt>.Class, "4"); //bind parameter for the impl
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<INumber> actual = i.GetInstance<Pool>().Numbers;
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new Integer1(4));
+
+            Assert.IsTrue(Utilities.Utilities.Equals<INumber>(actual, expected));
+        }
+
+        [TestMethod]
+        public void TestSetOfClassWithDefault()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<INumber> actual = i.GetInstance<Pool1>().Numbers;
+            Assert.IsNotNull(actual);
+        }
+
+        [TestMethod]
+        public void TestSetOfTimeshift()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+
+            cb.BindSetEntry<SetOfTimeshifts, Timeshift, ITimeshift>(GenericType<SetOfTimeshifts>.Class, GenericType<Timeshift>.Class)
+            .BindNamedParameter<Timeshift.TimeshiftLinkId, string>(GenericType<Timeshift.TimeshiftLinkId>.Class, "123")
+            .BindNamedParameter<Timeshift.TimeshiftInTicks, long>(GenericType<Timeshift.TimeshiftInTicks>.Class, "10");
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<ITimeshift> actual = i.GetInstance<SetofTimeShiftClass>().Timeshifts;
+            Assert.IsTrue(actual.Count == 1);
+        }
+
+        [TestMethod]
+        public void TestSetOfTimeshiftMultipleInstances()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+
+            //when adding another Timeshift into the set for named parameter SetOfTimeshifts, it ends up the same entry. 
+            cb.BindSetEntry<SetOfTimeshifts, Timeshift, ITimeshift>(GenericType<SetOfTimeshifts>.Class, GenericType<Timeshift>.Class);
+            cb.BindSetEntry<SetOfTimeshifts, Timeshift, ITimeshift>(GenericType<SetOfTimeshifts>.Class, GenericType<Timeshift>.Class);
+            cb.BindNamedParameter<Timeshift.TimeshiftLinkId, string>(GenericType<Timeshift.TimeshiftLinkId>.Class, "123")
+            .BindNamedParameter<Timeshift.TimeshiftInTicks, long>(GenericType<Timeshift.TimeshiftInTicks>.Class, "10");
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<ITimeshift> actual = i.GetInstance<SetofTimeShiftClass>().Timeshifts;
+            Assert.IsTrue(actual.Count == 1);
+        }
+
+        [TestMethod]
+        public void TestSetOfTimeshiftMultipleSubClasses()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+
+            //Adding implementations from different subclasses
+            cb.BindSetEntry<SetOfTimeshifts, Timeshift, ITimeshift>(GenericType<SetOfTimeshifts>.Class, GenericType<Timeshift>.Class);
+            cb.BindSetEntry<SetOfTimeshifts, Timeshift1, ITimeshift>(GenericType<SetOfTimeshifts>.Class, GenericType<Timeshift1>.Class);
+
+            cb.BindNamedParameter<Timeshift.TimeshiftLinkId, string>(GenericType<Timeshift.TimeshiftLinkId>.Class, "123")
+            .BindNamedParameter<Timeshift.TimeshiftInTicks, long>(GenericType<Timeshift.TimeshiftInTicks>.Class, "10");
+
+            cb.BindNamedParameter<Timeshift1.TimeshiftLinkId, string>(GenericType<Timeshift1.TimeshiftLinkId>.Class, "456")
+            .BindNamedParameter<Timeshift1.TimeshiftInTicks, long>(GenericType<Timeshift1.TimeshiftInTicks>.Class, "20"); 
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<ITimeshift> actual = i.GetInstance<SetofTimeShiftClass>().Timeshifts;
+            Assert.IsTrue(actual.Count == 2);
+        }
+
+        [TestMethod]
+        public void TestSetOfTimeshiftWithDefault()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<ITimeshift> actual = i.GetInstance<SetofTimeShiftClass>().Timeshifts;
+            Assert.IsTrue(actual.Count == 1);
+        }
+
+        [TestMethod]
+        public void TestSetOfTimeshiftWithEmptySet()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<ITimeshift> actual = i.GetInstance<SetofTimeShiftClassWithoutDefault>().Timeshifts;
+            Assert.IsTrue(actual.Count == 0);
+        }        
+
+        [TestMethod]
+        public void TestObjectInjectRoundTrip()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindSetEntry<SetOfClasses, Integer, INumber>(GenericType<SetOfClasses>.Class, GenericType<Integer>.Class);
+            cb.BindSetEntry<SetOfClasses, Float, INumber>(GenericType<SetOfClasses>.Class, GenericType<Float>.Class);
+
+            AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+            IConfiguration c2 = serializer.FromString(serializer.ToString(cb.Build()));
+
+            IInjector i = TangFactory.GetTang().NewInjector(c2);
+            i.BindVolatileInstance(GenericType<Integer>.Class, new Integer(4));
+            i.BindVolatileInstance(GenericType<Float>.Class, new Float(42.0001f));
+
+            ISet<INumber> actual = i.GetInstance<Pool>().Numbers;
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new Integer(4));
+            expected.Add(new Float(42.0001f));
+            Assert.IsTrue(Utilities.Utilities.Equals<INumber>(actual, expected));
+        }
+
+        [TestMethod]
+        public void TestStringInjectRoundTrip()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "four");
+            cb.BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "five");
+            cb.BindSetEntry<SetOfNumbers, string>(GenericType<SetOfNumbers>.Class, "six");
+
+            string s = ConfigurationFile.ToConfigurationString(cb.Build());
+            ICsConfigurationBuilder cb2 = TangFactory.GetTang().NewConfigurationBuilder();
+            ConfigurationFile.AddConfigurationFromString(cb2, s);
+
+            ISet<string> actual =
+                ((Box)TangFactory.GetTang().NewInjector(cb2.Build()).GetInstance(typeof(Box))).Numbers;
+
+            Assert.IsTrue(actual.Contains("four"));
+            Assert.IsTrue(actual.Contains("five"));
+            Assert.IsTrue(actual.Contains("six"));
+        }
+
+        [TestMethod]
+        public void TestDefaultAsClass()
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            i.BindVolatileInstance(GenericType<Integer>.Class, new Integer(1));
+            i.BindVolatileInstance(GenericType<Float>.Class, new Float(2f));
+            ISet<INumber> actual =
+                (ISet<INumber>)
+                i.GetNamedInstance<SetOfClassesDefaultClass, ISet<INumber>>(GenericType<SetOfClassesDefaultClass>.Class);
+
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new Integer(1));
+            Assert.AreEqual(expected.Count, actual.Count);
+            Assert.IsTrue(actual.Contains(new Integer(1)));
+        }
+
+        [TestMethod]
+        public void TestInjectionExtension()
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            i.BindVolatileInstance<Integer>(new Integer(1));
+            i.BindVolatileInstance<Float>(new Float(2f));
+            ISet<INumber> actual =
+                (ISet<INumber>)
+                i.GetNamedInstance<SetOfClassesDefaultClass, ISet<INumber>>();
+
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new Integer(1));
+            Assert.AreEqual(expected.Count, actual.Count);
+            Assert.IsTrue(actual.Contains(new Integer(1)));
+        }
+
+        [NamedParameter(DefaultValues = new string[] { "one", "two", "three" })]
+        public class SetOfNumbers : Name<ISet<string>>
+        {
+        }
+
+        public class Box
+        {
+            [Inject]
+            public Box([Parameter(typeof(SetOfNumbers))] ISet<string> numbers)
+            {
+                this.Numbers = numbers;
+            }
+
+            public ISet<string> Numbers { get; set; }
+        }
+
+        [NamedParameter(DefaultClasses = new Type[] { typeof(Integer), typeof(Float) })]
+        public class SetOfClasses : Name<ISet<INumber>>
+        {
+        }
+
+        public class Pool
+        {
+            [Inject]
+            private Pool([Parameter(typeof(SetOfClasses))] ISet<INumber> numbers)
+            {
+                this.Numbers = numbers;
+            }
+
+            public ISet<INumber> Numbers { get; set; }
+        }
+
+        [NamedParameter(DefaultClass = typeof(Integer))]
+        public class SetOfClassesDefaultClass : Name<ISet<INumber>>
+        {
+        }
+
+        public class Integer : INumber
+        {
+            private int val;
+          
+            public Integer(int v)
+            {
+                val = v;
+            }
+
+            public int CompareTo(object obj)
+            {
+                if (!(obj is Integer))
+                {
+                    return -1;
+                }
+                if (this.val == ((Integer)obj).val)
+                {
+                    return 0;
+                }
+
+                if (this.val < ((Integer)obj).val)
+                {
+                    return -1;
+                }
+
+                return 1;
+            }
+
+            public override bool Equals(object obj)
+            {
+                if (!(obj is Integer))
+                {
+                    return false;
+                }
+
+                if (this.val == ((Integer)obj).val)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+
+            public override int GetHashCode()
+            {
+                return val.GetHashCode();
+            }
+        }
+
+        public class Float : INumber
+        {
+            private float val;
+
+            [Inject]
+            public Float(float v)
+            {
+                val = v;
+            }
+
+            public int CompareTo(object obj)
+            {
+                if (!(obj is Float))
+                {
+                    return -1;
+                }
+
+                if (val == ((Float)obj).val)
+                {
+                    return 0;
+                }
+
+                if (val < ((Float)obj).val)
+                {
+                    return -1;
+                }
+
+                return 1;
+            }
+
+            public override bool Equals(object obj)
+            {
+                if (!(obj is Float))
+                {
+                    return false;
+                }
+
+                if (this.val == ((Float)obj).val)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+
+            public override int GetHashCode()
+            {
+                return val.GetHashCode();
+            }
+        }
+        
+        public class Integer1 : INumber
+        {
+            private int val;
+
+            [Inject]
+            public Integer1([Parameter(typeof(NamedInt))] int v)
+            {
+                val = v;
+            }
+
+            public int CompareTo(object obj)
+            {
+                if (!(obj is Integer1))
+                {
+                    return -1;
+                }
+                if (this.val == ((Integer1)obj).val)
+                {
+                    return 0;
+                }
+
+                if (this.val < ((Integer1)obj).val)
+                {
+                    return -1;
+                }
+
+                return 1;
+            }
+
+            public override bool Equals(object obj)
+            {
+                if (!(obj is Integer1))
+                {
+                    return false;
+                }
+
+                if (this.val == ((Integer1)obj).val)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+
+            public override int GetHashCode()
+            {
+                return val.GetHashCode();
+            }
+
+            [NamedParameter]
+            public class NamedInt : Name<int>
+            {
+            }
+        }
+
+        public class Integer2 : INumber
+        {
+            private int val;
+
+            [Inject]
+            public Integer2()
+            {
+                val = 0;
+            }
+
+            public int CompareTo(object obj)
+            {
+                if (!(obj is Integer2))
+                {
+                    return -1;
+                }
+                if (this.val == ((Integer2)obj).val)
+                {
+                    return 0;
+                }
+
+                if (this.val < ((Integer2)obj).val)
+                {
+                    return -1;
+                }
+
+                return 1;
+            }
+
+            public override bool Equals(object obj)
+            {
+                if (!(obj is Integer2))
+                {
+                    return false;
+                }
+
+                if (this.val == ((Integer2)obj).val)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+
+            public override int GetHashCode()
+            {
+                return val.GetHashCode();
+            }
+        }
+
+        public class Integer3 : INumber
+        {
+            private int val;
+
+            [Inject]
+            public Integer3([Parameter(typeof(NamedInt))] int v)
+            {
+                val = v;
+            }
+
+            public int CompareTo(object obj)
+            {
+                if (!(obj is Integer))
+                {
+                    return -1;
+                }
+                if (this.val == ((Integer3)obj).val)
+                {
+                    return 0;
+                }
+
+                if (this.val < ((Integer3)obj).val)
+                {
+                    return -1;
+                }
+
+                return 1;
+            }
+
+            public override bool Equals(object obj)
+            {
+                if (!(obj is Integer3))
+                {
+                    return false;
+                }
+
+                if (this.val == ((Integer3)obj).val)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+
+            public override int GetHashCode()
+            {
+                return val.GetHashCode();
+            }
+
+            [NamedParameter]
+            public class NamedInt : Name<int>
+            {
+            }
+        }
+
+        public class Float1 : INumber
+        {
+            private float val;
+
+            [Inject]
+            public Float1([Parameter(typeof(NamedFloat))] float v)
+            {
+                val = v;
+            }
+
+            public int CompareTo(object obj)
+            {
+                if (!(obj is Float))
+                {
+                    return -1;
+                }
+
+                if (val == ((Float1)obj).val)
+                {
+                    return 0;
+                }
+
+                if (val < ((Float1)obj).val)
+                {
+                    return -1;
+                }
+
+                return 1;
+            }
+
+            public override bool Equals(object obj)
+            {
+                if (!(obj is Float1))
+                {
+                    return false;
+                }
+
+                if (this.val == ((Float1)obj).val)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+
+            public override int GetHashCode()
+            {
+                return val.GetHashCode();
+            }
+
+            [NamedParameter]
+            public class NamedFloat : Name<float>
+            {
+            }
+        }
+
+        public class Pool1
+        {
+            [Inject]
+            private Pool1([Parameter(typeof(SetOfClasseWithDefault))] ISet<INumber> numbers)
+            {
+                this.Numbers = numbers;
+            }
+
+            public ISet<INumber> Numbers { get; set; }
+        }
+
+        [NamedParameter(DefaultClass = typeof(Integer2))]
+        public class SetOfClasseWithDefault : Name<ISet<INumber>>
+        {
+        }
+    }
+
+    public class Timeshift : ITimeshift
+    {
+        [Inject]
+        public Timeshift([Parameter(typeof(TimeshiftLinkId))] string linkId, [Parameter(typeof(TimeshiftInTicks))] long timeshiftInTicks)
+        {
+            this.LinkId = linkId;
+            this.TimeshiftSpan = TimeSpan.FromTicks(timeshiftInTicks);
+        }
+
+        public string LinkId { get; private set; }
+
+        public TimeSpan TimeshiftSpan { get; private set; }
+
+        [NamedParameter("TimeshiftLinkId", "TimeshiftLinkId", "myid")]
+        public class TimeshiftLinkId : Name<string>
+        {
+        }
+
+        [NamedParameter("TimeshiftInTicks", "TimeshiftInTicks", "10")]
+        public class TimeshiftInTicks : Name<long>
+        {
+        }
+    }
+
+    public class Timeshift1 : ITimeshift
+    {
+        [Inject]
+        public Timeshift1([Parameter(typeof(TimeshiftLinkId))] string linkId, [Parameter(typeof(TimeshiftInTicks))] long timeshiftInTicks)
+        {
+            this.LinkId = linkId;
+            this.TimeshiftSpan = TimeSpan.FromTicks(timeshiftInTicks);
+        }
+
+        public string LinkId { get; private set; }
+
+        public TimeSpan TimeshiftSpan { get; private set; }
+
+        [NamedParameter("TimeshiftLinkId1", "TimeshiftLinkId1", "myid")]
+        public class TimeshiftLinkId : Name<string>
+        {
+        }
+
+        [NamedParameter("TimeshiftInTicks1", "TimeshiftInTicks1", "10")]
+        public class TimeshiftInTicks : Name<long>
+        {
+        }
+    }
+
+    [NamedParameter(DefaultClass = typeof(Timeshift))]
+    public class SetOfTimeshifts : Name<ISet<ITimeshift>>
+    {
+    }
+
+    public class SetofTimeShiftClass
+    {
+        [Inject]
+        public SetofTimeShiftClass([Parameter(typeof(SetOfTimeshifts))] ISet<ITimeshift> timeshifts)
+        {
+            this.Timeshifts = timeshifts;
+        }
+    
+        public ISet<ITimeshift> Timeshifts { get; set; }
+    }
+    [NamedParameter]
+    public class SetOfTimeshiftsWithoutDefaultClass : Name<ISet<ITimeshift>>
+    {
+    }
+
+    public class SetofTimeShiftClassWithoutDefault
+    {
+        [Inject]
+        public SetofTimeShiftClassWithoutDefault([Parameter(typeof(SetOfTimeshiftsWithoutDefaultClass))] ISet<ITimeshift> timeshifts)
+        {
+            this.Timeshifts = timeshifts;
+        }
+
+        public ISet<ITimeshift> Timeshifts { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Properties/AssemblyInfo.cs b/lang/cs/Tests/TangTests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..02a072f
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Org.Apache.Reef.Tang.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Org.Apache.Reef.Tang.Tests")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("fd47238d-600b-42cd-b62d-0724171a2bc4")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/HttpHandlerConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/HttpHandlerConfiguration.cs b/lang/cs/Tests/TangTests/ScenarioTest/HttpHandlerConfiguration.cs
new file mode 100644
index 0000000..41d6c91
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/HttpHandlerConfiguration.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    public class HttpHandlerConfiguration : ConfigurationModuleBuilder
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Not Applicable")]
+        public static readonly OptionalParameter<IHttpHandler> P = new OptionalParameter<IHttpHandler>();
+
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Not Applicable")]
+        public static readonly ConfigurationModule CONF = new HttpHandlerConfiguration().Merge(HttpRuntimeConfiguration.CONF)
+        .BindSetEntry<HttpEventHanlders, IHttpHandler>(GenericType<HttpEventHanlders>.Class, HttpHandlerConfiguration.P)
+        .Build();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeConfiguration.cs b/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeConfiguration.cs
new file mode 100644
index 0000000..7d91b6c
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeConfiguration.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    public class HttpRuntimeConfiguration : ConfigurationModuleBuilder
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Not Applicable")]
+        public static readonly ConfigurationModule CONF = new HttpRuntimeConfiguration()
+            .BindSetEntry<RuntimeStartHandler, HttpRunTimeStartHandler, IObserver<RuntimeStart>>(
+                GenericType<RuntimeStartHandler>.Class, GenericType<HttpRunTimeStartHandler>.Class)
+            .BindSetEntry<RuntimeStopHandler, HttpRunTimeStopHandler, IObserver<RuntimeStop>>(
+                GenericType<RuntimeStopHandler>.Class, GenericType<HttpRunTimeStopHandler>.Class)
+            .Build();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStartHandler.cs b/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStartHandler.cs
new file mode 100644
index 0000000..38acda6
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStartHandler.cs
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    public class HttpRunTimeStartHandler : IObserver<RuntimeStart>
+    {
+        [Inject]
+        public HttpRunTimeStartHandler(HttpServer httpServer)
+        {
+            Server = httpServer;
+        }
+
+        public HttpServer Server { get; set; }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(RuntimeStart value)
+        {
+            Server.StartServer();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStopHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStopHandler.cs b/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStopHandler.cs
new file mode 100644
index 0000000..7b687e6
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/HttpRuntimeStopHandler.cs
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    public class HttpRunTimeStopHandler : IObserver<RuntimeStop>
+    {
+        [Inject]
+        public HttpRunTimeStopHandler(HttpServer httpServer)
+        {
+            Server = httpServer;
+        }
+
+        public HttpServer Server { get; set; }
+        
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(RuntimeStop value)
+        {
+            Server.StopServer();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/HttpServer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/HttpServer.cs b/lang/cs/Tests/TangTests/ScenarioTest/HttpServer.cs
new file mode 100644
index 0000000..beea575
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/HttpServer.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    public class HttpServer
+    {
+        private Server _server;
+
+        [Inject]
+        public HttpServer(JettyHandler jettyHandler)
+        {
+            JettyHandler = jettyHandler;
+            _server = new Server(8080);
+            _server.SetHandler(jettyHandler);
+        }
+
+        public JettyHandler JettyHandler { get; set; }
+
+        public void StartServer()
+        {
+            _server.Start();
+            _server.Join();
+        }
+
+        public void StopServer()
+        {
+            _server.Stop();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/IHttpHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/IHttpHandler.cs b/lang/cs/Tests/TangTests/ScenarioTest/IHttpHandler.cs
new file mode 100644
index 0000000..031c29c
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/IHttpHandler.cs
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    public interface IHttpHandler
+    {
+        string GetUriSpecification();
+
+        void OnHttpRequest(HttpRequest request, Httpresponse response);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/JettyHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/JettyHandler.cs b/lang/cs/Tests/TangTests/ScenarioTest/JettyHandler.cs
new file mode 100644
index 0000000..b027e91
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/JettyHandler.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    [NamedParameter()]
+    public class HttpEventHanlders : Name<ISet<IHttpHandler>>
+    {
+    }
+
+    public class JettyHandler //: AbstractHandler
+    {
+        [Inject]
+        public JettyHandler([Parameter(typeof(HttpEventHanlders))] ISet<IHttpHandler> httpeventHanlders)
+        {
+            HttpeventHanlders = httpeventHanlders;
+        }
+
+        public ISet<IHttpHandler> HttpeventHanlders { get; set; }
+
+        public void handle()
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/TestDefaultConstructor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/TestDefaultConstructor.cs b/lang/cs/Tests/TangTests/ScenarioTest/TestDefaultConstructor.cs
new file mode 100644
index 0000000..fd09bbc
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/TestDefaultConstructor.cs
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    [TestClass]
+    public class TestDefaultConstructor
+    {
+        [TestMethod]
+        public void TestDefaultCOnstructorWithoutBinding()
+        {
+            var r = (A)TangFactory.GetTang().NewInjector().GetInstance(typeof(A));
+            System.Diagnostics.Debug.WriteLine(r.Instance);
+        }
+    }
+
+    class A
+    {
+        [Inject]
+        public A()
+        {
+            Instance = "default";
+        }
+        [Inject]
+        public A(B b)
+        {
+            Instance = "non default";
+        }
+    
+        public string Instance { get; set; }
+    }
+
+    class B
+    {
+        [Inject]
+        public B()
+        {
+            Instance = "default";
+        }
+        [Inject]
+        public B(C c)
+        {
+            Instance = "non default";
+        }
+
+        public string Instance { get; set; }
+    }
+
+    class C
+    {
+        [Inject]
+        public C()
+        {
+            Instance = "default";
+        }
+    
+        public string Instance { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/TestHttpService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/TestHttpService.cs b/lang/cs/Tests/TangTests/ScenarioTest/TestHttpService.cs
new file mode 100644
index 0000000..8d1e9d7
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/TestHttpService.cs
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    [TestClass]
+    public class TestHttpService
+    {
+        [TestMethod]
+        public void HttpEventHanldersTest()
+        {
+            ConfigurationModule module =
+                new ConfigurationModuleBuilder()
+                .BindSetEntry<HttpEventHanlders, HttpServerReefEventHandler, IHttpHandler>(GenericType<HttpEventHanlders>.Class, GenericType<HttpServerReefEventHandler>.Class)
+                .BindSetEntry<HttpEventHanlders, HttpServerNrtEventHandler, IHttpHandler>(GenericType<HttpEventHanlders>.Class, GenericType<HttpServerNrtEventHandler>.Class)
+                .Build();
+
+           IConfiguration c = module.Build();
+           var service = TangFactory.GetTang().NewInjector(c).GetInstance<HttpServer>();
+           Assert.IsNotNull(service);
+
+           var j = TangFactory.GetTang().NewInjector(c).GetInstance<HttpRunTimeStartHandler>();
+           Assert.IsNotNull(j);
+        }
+
+        [TestMethod]
+        public void RuntimeStartHandlerTest()
+        {
+            ConfigurationModule module =
+                new ConfigurationModuleBuilder()
+                    .BindSetEntry<RuntimeStartHandler, HttpRunTimeStartHandler, IObserver<RuntimeStart>>(
+                        GenericType<RuntimeStartHandler>.Class, GenericType<HttpRunTimeStartHandler>.Class)
+                    .Build();
+            IConfiguration clockConfiguraiton = module.Build();
+
+            RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
+            var rh = clock.ClockRuntimeStartHandler.Get();
+            Assert.AreEqual(rh.Count, 1);
+            foreach (var e in rh)
+            {
+                Assert.IsTrue(e is HttpRunTimeStartHandler);
+                HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e;
+                var s = r.Server;
+                Assert.AreEqual(s.JettyHandler.HttpeventHanlders.Count, 0); // no handlers are bound
+            }
+        }
+
+        [TestMethod]
+        public void RuntimeStartStopHandlerTest()
+        {
+            IConfiguration clockConfiguraiton = HttpRuntimeConfiguration.CONF.Build();
+            RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
+            var starts = clock.ClockRuntimeStartHandler.Get();
+            var stops = clock.ClockRuntimeStopHandler.Get();
+
+            HttpRunTimeStartHandler start = null;
+            HttpRunTimeStopHandler stop = null;
+
+            Assert.AreEqual(starts.Count, 1);
+            foreach (var e in starts)
+            {
+                Assert.IsTrue(e is HttpRunTimeStartHandler);
+                start = (HttpRunTimeStartHandler)e;
+            }
+
+            Assert.AreEqual(stops.Count, 1);
+            foreach (var e in stops)
+            {
+                Assert.IsTrue(e is HttpRunTimeStopHandler);
+                stop = (HttpRunTimeStopHandler)e;
+            }
+
+            Assert.AreEqual(start.Server, stop.Server);
+            Assert.AreEqual(start.Server.JettyHandler.HttpeventHanlders, stop.Server.JettyHandler.HttpeventHanlders);
+            Assert.AreSame(start.Server, stop.Server); 
+        }
+
+        [TestMethod]
+        public void RuntimeStartHandlerMergeTest()
+        {
+            IConfiguration clockConfiguraiton = HttpHandlerConfiguration.CONF
+                .Set(HttpHandlerConfiguration.P,
+                     GenericType<HttpServerReefEventHandler>.Class)
+                .Set(HttpHandlerConfiguration.P,
+                     GenericType<HttpServerNrtEventHandler>.Class)
+                .Build();
+                                       
+            RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
+
+            var rh = clock.ClockRuntimeStartHandler.Get();
+            Assert.AreEqual(rh.Count, 1);
+            foreach (var e in rh)
+            {
+                Assert.IsTrue(e is HttpRunTimeStartHandler);
+                HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e;
+                var s = r.Server;
+                foreach (IHttpHandler h in s.JettyHandler.HttpeventHanlders)
+                {
+                    System.Diagnostics.Debug.WriteLine(h.GetUriSpecification());
+                }
+            }
+        }
+    }
+
+    public class HttpRequest
+    {        
+    }
+
+    public class Httpresponse
+    {        
+    }
+
+    public class HttpServerReefEventHandler : IHttpHandler
+    {
+        [Inject]
+        public HttpServerReefEventHandler()
+        {
+        }
+
+        public string GetUriSpecification()
+        {
+            return "/Reef";
+        }
+
+        public void OnHttpRequest(HttpRequest request, Httpresponse response)
+        {
+            //handle the event
+        }
+    }
+
+    public class HttpServerNrtEventHandler : IHttpHandler
+    {
+        [Inject]
+        public HttpServerNrtEventHandler()
+        {            
+        }
+
+        public string GetUriSpecification()
+        {
+            return "/NRT";
+        }
+
+        public void OnHttpRequest(HttpRequest request, Httpresponse response)
+        {
+        }
+    }
+
+    public class Server
+    {
+        public Server(int port)
+        {          
+        }
+
+        public void Start()
+        {           
+        }
+
+        public void Stop()
+        {
+        }
+
+        public void Join()
+        {
+        }
+
+        public void SetHandler(JettyHandler handler)
+        {           
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/TestRuntimeClock.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/TestRuntimeClock.cs b/lang/cs/Tests/TangTests/ScenarioTest/TestRuntimeClock.cs
new file mode 100644
index 0000000..c5ce694
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/TestRuntimeClock.cs
@@ -0,0 +1,253 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    [DefaultImplementation(typeof(RealTimer))]
+    public interface ITimer
+    {
+        int GetCurrent();
+
+        int GetDuration(int time);
+
+        bool IsReady(int time);
+    }
+
+    [DefaultImplementation(typeof(RuntimeClock))]
+    public interface IClock
+    {
+        DateTime CurrentTime();
+    }
+
+    public interface IEventHandler<T>
+    {
+        void OnNext(T value);
+    }
+
+    [TestClass]
+    public class TestSenarios
+    {
+        [TestMethod]
+        public void TestRuntimeClock()
+        {
+            var r = (RuntimeClock)TangFactory.GetTang().NewInjector().GetInstance(typeof(RuntimeClock));
+            Assert.IsNotNull(r);
+            r.CurrentTime();
+        }
+
+        [TestMethod]
+        public void TestEvaluatorRuntime()
+        {
+            ConfigurationModule module =
+                new ConfigurationModuleBuilder()
+                .BindSetEntry<RuntimeStartHandler, EvaluatorRuntime, IObserver<RuntimeStart>>(GenericType<RuntimeStartHandler>.Class, GenericType<EvaluatorRuntime>.Class)
+                .Build();
+            IConfiguration clockConfiguraiton = module.Build();
+
+            RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
+            var r = clock.ClockRuntimeStartHandler.Get();
+            Assert.AreEqual(r.Count, 1);
+            foreach (var e in r)
+            {
+                Assert.IsTrue(e is EvaluatorRuntime);
+            }
+        }
+    }
+
+    public class RuntimeClock : IClock
+    {      
+        [Inject]
+        public RuntimeClock(ITimer timer,
+                            [Parameter(typeof(StartHandler))] IInjectionFuture<ISet<IEventHandler<StartTime>>> startHandler,
+                            [Parameter(typeof(RuntimeStartHandler))] IInjectionFuture<ISet<IObserver<RuntimeStart>>> runtimeStartHandler,
+                            [Parameter(typeof(RuntimeStopHandler))] IInjectionFuture<ISet<IObserver<RuntimeStop>>> runtimeStopHandler)
+        {
+            this.ClockStartHandler = startHandler;
+            this.ClockRuntimeStartHandler = runtimeStartHandler;
+            this.ClockRuntimeStopHandler = runtimeStopHandler;
+        }
+
+        public IInjectionFuture<ISet<IObserver<RuntimeStart>>> ClockRuntimeStartHandler { get; set; }
+
+        public IInjectionFuture<ISet<IObserver<RuntimeStop>>> ClockRuntimeStopHandler { get; set; }
+
+        public IInjectionFuture<ISet<IEventHandler<StartTime>>> ClockStartHandler { get; set; }
+
+        public DateTime CurrentTime()
+        {
+            return DateTime.Now;
+        }
+    }
+
+    [NamedParameter(DefaultClass = typeof(MissingStartHandlerHandler),
+        Documentation = "Will be called upon the start event")]
+    public class StartHandler : Name<ISet<IEventHandler<StartTime>>>
+    {
+    }
+
+    /// <summary>
+    /// Bind this to an event handler to statically subscribe to the RuntimeStart Event
+    /// </summary>
+    [NamedParameter(Documentation = "Will be called upon the runtime start event",
+        DefaultClass = typeof(LoggingEventHandler<RuntimeStart>))]
+    public class RuntimeStartHandler : Name<ISet<IObserver<RuntimeStart>>>
+    {
+    }
+
+    [NamedParameter(documentation: "Will be called upon the runtime start event",
+    defaultClass: typeof(LoggingEventHandler<RuntimeStop>))]
+    public class RuntimeStopHandler : Name<ISet<IObserver<RuntimeStop>>>
+    {
+    }
+
+    public class StartTime : Time
+    {
+        public StartTime(long timestamp) : base(timestamp)
+        {
+        }
+    }
+
+    public class RuntimeStart : Time
+    {
+        public RuntimeStart(long timeStamp)
+            : base(timeStamp)
+        {
+        }
+    }
+
+    public class RuntimeStop : Time
+    {
+        public RuntimeStop(long timeStamp)
+            : base(timeStamp)
+        {
+        }
+    }
+
+    public class EvaluatorRuntime : IObserver<RuntimeStart>
+    {
+        [Inject]
+        public EvaluatorRuntime()
+        {            
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnNext(RuntimeStart value)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public class LoggingEventHandler<T> : IObserver<T>
+    {
+        [Inject]
+        public LoggingEventHandler()
+        {
+        }
+
+        /// <summary>Logs the event</summary>
+        /// <param name="value">an event</param>
+        public void OnNext(T value)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public abstract class Time : IComparable<Time>
+    {
+        private long timestamp;
+
+        public Time(long timestamp)
+        {
+            this.timestamp = timestamp;
+        }
+
+        public long GetTimeStamp()
+        {
+            return this.timestamp;
+        }
+
+        public int CompareTo(Time other)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public class MissingStartHandlerHandler : IEventHandler<StartTime> 
+    {
+      [Inject]
+      public MissingStartHandlerHandler() 
+      {
+      }
+
+      public void OnNext(StartTime value) 
+      {
+      }
+    }
+
+    public class RealTimer : ITimer 
+    {
+        [Inject]
+        public RealTimer() 
+        {
+        }
+
+        public int GetCurrent() 
+        {
+            return DateTime.Now.Millisecond;
+        }
+
+        public int GetDuration(int time) 
+        {
+            return time - GetCurrent();
+        }
+
+        public bool IsReady(int time) 
+        {
+            return GetDuration(time) <= 0;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/TestTrackingURIProvider.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/TestTrackingURIProvider.cs b/lang/cs/Tests/TangTests/ScenarioTest/TestTrackingURIProvider.cs
new file mode 100644
index 0000000..f97e9db
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/TestTrackingURIProvider.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    [TestClass]
+    public class TestTrackingURIProvider
+    {
+        [TestMethod]
+        public void TrackingIdThroughNamedParameterTest()
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            string trackingId = System.Environment.MachineName + ":8080";
+            cba.BindNamedParameter<TrackingId, string>(GenericType<TrackingId>.Class, trackingId);
+            string id = (string)TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(TrackingId));
+            Assert.AreEqual(id, trackingId);
+        }
+
+        [TestMethod]
+        public void DefaultTrackingIdThroughInterfaceTest()
+        {
+            string trackingId = System.Environment.MachineName + ":8080";
+            var id = TangFactory.GetTang().NewInjector().GetInstance<ITrackingURIProvider>();
+            Assert.AreEqual(id.GetURI(), trackingId);
+        }
+
+        [TestMethod]
+        public void TrackingIdThroughInterfaceTest()
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            cba.BindNamedParameter<PortNumber, string>(GenericType<PortNumber>.Class, "8080");
+            string trackingId = System.Environment.MachineName + ":8080";
+            var id = TangFactory.GetTang().NewInjector().GetInstance<ITrackingURIProvider>();
+            Assert.AreEqual(id.GetURI(), trackingId);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/TrackingURIProvider.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/TrackingURIProvider.cs b/lang/cs/Tests/TangTests/ScenarioTest/TrackingURIProvider.cs
new file mode 100644
index 0000000..d9200db
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/TrackingURIProvider.cs
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    [DefaultImplementation(typeof(DefaultTrackingURIProvider))]
+    public interface ITrackingURIProvider
+    {
+        string GetURI();
+    }
+
+    [NamedParameter(DefaultValue = " ")]
+    public class TrackingId : Name<string>
+    {        
+    }
+
+    [NamedParameter(DefaultValue = "8080")]
+    public class PortNumber : Name<string>
+    {        
+    }
+
+    public class DefaultTrackingURIProvider : ITrackingURIProvider
+    {
+        private string port;
+
+        [Inject]
+        public DefaultTrackingURIProvider([Parameter(typeof(PortNumber))] string port)
+        {
+            this.port = port;
+        }
+
+        public string GetURI()
+        {
+            try
+            {
+                return System.Environment.MachineName + ":" + port;
+            }
+            catch (Exception)
+            {
+                return null;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/ScenarioTest/TrackingYRIProvider.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/ScenarioTest/TrackingYRIProvider.cs b/lang/cs/Tests/TangTests/ScenarioTest/TrackingYRIProvider.cs
new file mode 100644
index 0000000..47d408b
--- /dev/null
+++ b/lang/cs/Tests/TangTests/ScenarioTest/TrackingYRIProvider.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Test.ScenarioTest
+{
+    class TrackingYRIProvider
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/AnInterface.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/AnInterface.cs b/lang/cs/Tests/TangTests/SmokeTest/AnInterface.cs
new file mode 100644
index 0000000..86f45cb
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/AnInterface.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    [DefaultImplementation(typeof(AnInterfaceImplementation))]
+    public interface IAnInterface
+    {
+        void AMethod();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/AnInterfaceImplementation.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/AnInterfaceImplementation.cs b/lang/cs/Tests/TangTests/SmokeTest/AnInterfaceImplementation.cs
new file mode 100644
index 0000000..317cce1
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/AnInterfaceImplementation.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class AnInterfaceImplementation : IAnInterface
+    {
+        private readonly int aMagicNumber;
+
+        [Inject]
+        AnInterfaceImplementation() 
+        {
+            this.aMagicNumber = 42;
+        }
+
+        public void AMethod() 
+        {
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null)
+            {
+                return false;
+            }
+
+            AnInterfaceImplementation that = (AnInterfaceImplementation)o;
+
+            if (aMagicNumber != that.aMagicNumber)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            return aMagicNumber;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/CyclicDependency.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/CyclicDependency.cs b/lang/cs/Tests/TangTests/SmokeTest/CyclicDependency.cs
new file mode 100644
index 0000000..fb3e4dd
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/CyclicDependency.cs
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class CyclicDependency
+    {
+        private readonly CyclicDependencyClassOne one;
+        private readonly CyclicDependencyClassTwo two;
+
+        [Inject]
+        CyclicDependency(CyclicDependencyClassOne one, CyclicDependencyClassTwo two) 
+        {
+            this.one = one;
+            this.two = two;
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null)
+            {
+                return false;
+            }
+
+            CyclicDependency that = (CyclicDependency)o;
+
+            if (!one.Equals(that.one))
+            {
+                return false;
+            }
+
+            if (!two.Equals(that.two))
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            int result = one.GetHashCode();
+            result = (31 * result) + two.GetHashCode();
+            return result;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassOne.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassOne.cs b/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassOne.cs
new file mode 100644
index 0000000..bbc5d4d
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassOne.cs
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class CyclicDependencyClassOne
+    {
+        private readonly CyclicDependencyClassTwo other;
+
+        [Inject]
+        CyclicDependencyClassOne(CyclicDependencyClassTwo other) 
+        {
+            this.other = other;
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null)
+            {
+                return false;
+            }
+
+            CyclicDependencyClassOne that = (CyclicDependencyClassOne)o;
+
+            if (!other.Equals(that.other))
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            return other.GetHashCode();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassTwo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassTwo.cs b/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassTwo.cs
new file mode 100644
index 0000000..ea79c78
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/CyclicDependencyClassTwo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class CyclicDependencyClassTwo
+    {
+        private readonly IInjectionFuture<CyclicDependencyClassOne> other;
+
+        [Inject]
+        CyclicDependencyClassTwo(IInjectionFuture<CyclicDependencyClassOne> other) 
+        {
+            this.other = other;
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            return other.GetHashCode();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/Handler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/Handler.cs b/lang/cs/Tests/TangTests/SmokeTest/Handler.cs
new file mode 100644
index 0000000..8cf1bfb
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/Handler.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public interface IHandler<T> 
+    {
+        void Process(T value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/InjectableClass.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/InjectableClass.cs b/lang/cs/Tests/TangTests/SmokeTest/InjectableClass.cs
new file mode 100644
index 0000000..05291c1
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/InjectableClass.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class InjectableClass 
+    {
+        private readonly int magicNumber = -42;
+
+        [Inject]
+        InjectableClass() 
+        {
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null)
+            {
+                return false;
+            }
+
+            InjectableClass that = (InjectableClass)o;
+
+            if (magicNumber != that.magicNumber)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            return magicNumber;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/ListOfBaseTypes.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/ListOfBaseTypes.cs b/lang/cs/Tests/TangTests/SmokeTest/ListOfBaseTypes.cs
new file mode 100644
index 0000000..278a543
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/ListOfBaseTypes.cs
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class ListOfBaseTypes
+    {
+        private readonly IList<int> integers;
+        private readonly IList<double> doubles;
+        private readonly IList<string> strings;
+        private readonly IList<int> moreIntegers;
+
+        [Inject]
+        private ListOfBaseTypes([Parameter(typeof(ListOfBaseTypes.Integers))] IList<int> integers,
+                               [Parameter(typeof(ListOfBaseTypes.Doubles))] IList<double> doubles,
+                               [Parameter(typeof(ListOfBaseTypes.Strings))] IList<string> strings,
+                               [Parameter(typeof(ListOfBaseTypes.MoreIntegers))] IList<int> moreIntegers)
+        {
+            this.integers = integers;
+            this.doubles = doubles;
+            this.strings = strings;
+            this.moreIntegers = moreIntegers;
+        }
+
+        public override bool Equals(object o)
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null || !(o is ListOfBaseTypes))
+            {
+                return false;
+            }
+
+            ListOfBaseTypes that = (ListOfBaseTypes)o;
+
+            if (!Utilities.Utilities.Equals(doubles, that.doubles))
+            {
+                return false;
+            }
+
+            if (!Utilities.Utilities.Equals(integers, that.integers))
+            {
+                return false;
+            }
+
+            if (!Utilities.Utilities.Equals(strings, that.strings))
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            int result = integers.GetHashCode();
+            result = (31 * result) + doubles.GetHashCode();
+            result = (31 * result) + strings.GetHashCode();
+            return result;
+        }
+
+        [NamedParameter]
+        public class Integers : Name<IList<int>>
+        {
+        }
+
+        [NamedParameter(DefaultValues = new string[] { "1", "2", "3" })]
+        public class MoreIntegers : Name<IList<int>>
+        {
+        }
+
+        [NamedParameter]
+        public class Doubles : Name<IList<double>>
+        {
+        }
+
+        [NamedParameter]
+        public class Strings : Name<IList<string>>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/ObjectTreeTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/ObjectTreeTest.cs b/lang/cs/Tests/TangTests/SmokeTest/ObjectTreeTest.cs
new file mode 100644
index 0000000..801a61b
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/ObjectTreeTest.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    [TestClass]
+    public class ObjectTreeTest
+    {
+        public static IConfiguration GetConfiguration()
+        {
+            return TestConfigurationModuleBuilder.CONF
+                .Set(TestConfigurationModuleBuilder.OPTIONALSTRING, TestConfigurationModuleBuilder.OptionaStringValue)
+                .Set(TestConfigurationModuleBuilder.REQUIREDSTRING, TestConfigurationModuleBuilder.RequiredStringValue)
+                .Build();
+        }
+
+        [TestMethod]
+        public void TestInstantiation() 
+        {
+            IRootInterface root = TangFactory.GetTang().NewInjector(GetConfiguration()).GetInstance<IRootInterface>();
+            Assert.IsTrue(root.IsValid(), "Object instantiation left us in an inconsistent state.");
+        }
+
+        [TestMethod]
+        public void TestTwoInstantiations() 
+        {
+            IRootInterface firstRoot = TangFactory.GetTang().NewInjector(GetConfiguration()).GetInstance<IRootInterface>();
+            IRootInterface secondRoot = TangFactory.GetTang().NewInjector(GetConfiguration()).GetInstance<IRootInterface>();
+
+            Assert.AreNotSame(firstRoot, secondRoot, "Two instantiations of the object tree should not be the same");
+            Assert.AreEqual(firstRoot, secondRoot, "Two instantiations of the object tree should be equal");
+        }
+    }
+}


[30/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.cs b/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.cs
new file mode 100644
index 0000000..0489154
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.cs
@@ -0,0 +1,260 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.Evaluator.Context;
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+
+namespace Org.Apache.Reef.Evaluator
+{
+    public class Evaluator
+    {
+        private static Logger _logger;
+
+        private static int _heartbeatPeriodInMs = Constants.DefaultEvaluatorHeartbeatPeriodInMs;
+
+        private static int _heartbeatMaxRetry = Constants.DefaultEvaluatorHeartbeatMaxRetry;
+
+        private static IInjector _injector;
+
+        private static EvaluatorConfigurations _evaluatorConfig;
+
+        public static void Main(string[] args)
+        {
+            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.", DateTime.Now));
+            Stopwatch timer = new Stopwatch();
+            InitInjector();
+            SetCustomTraceListners();
+            timer.Stop();
+            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed));
+
+            RuntimeClock clock;
+
+            using (_logger.LogScope("Evaluator::Main"))
+            {
+                string debugEnabledString = Environment.GetEnvironmentVariable("Org.Apache.Reef.EvaluatorDebug");
+                if (!string.IsNullOrWhiteSpace(debugEnabledString) &&
+                    debugEnabledString.Equals("enabled", StringComparison.OrdinalIgnoreCase))
+                {
+                    while (true)
+                    {
+                        if (Debugger.IsAttached)
+                        {
+                            break;
+                        }
+                        else
+                        {
+                            _logger.Log(Level.Info, "Evaluator in debug mode, waiting for debugger to be attached...");
+                            Thread.Sleep(2000);
+                        }
+                    }
+                }
+
+                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
+
+                string heartbeatPeriodFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatPeriodInMs"];
+
+                int heartbeatPeriod = 0;
+
+                if (!string.IsNullOrWhiteSpace(heartbeatPeriodFromConfig) &&
+                    int.TryParse(heartbeatPeriodFromConfig, out heartbeatPeriod))
+                {
+                    _heartbeatPeriodInMs = heartbeatPeriod;
+                }
+                _logger.Log(Level.Verbose,
+                            "Evaluator heartbeat period set to be " + _heartbeatPeriodInMs + " milliSeconds.");
+
+                int maxHeartbeatRetry = 0;
+                string heartbeatMaxRetryFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatRetryMaxTimes"];
+
+                if (!string.IsNullOrWhiteSpace(heartbeatMaxRetryFromConfig) &&
+                    int.TryParse(heartbeatMaxRetryFromConfig, out maxHeartbeatRetry))
+                {
+                    _heartbeatMaxRetry = maxHeartbeatRetry;
+                }
+                _logger.Log(Level.Verbose, "Evaluator heatrbeat max retry set to be " + _heartbeatMaxRetry + " times.");
+
+                if (args.Count() < 2)
+                {
+                    var e = new InvalidOperationException("must supply at least the rId and evaluator config file");
+                    Exceptions.Throw(e, _logger);
+                }
+
+                // remote driver Id
+                string rId = args[0];
+
+                // evaluator configuraiton file
+                string evaluatorConfigurationPath = args[1];
+
+                ICodec<REEFMessage> reefMessageCodec = new REEFMessageCodec();
+
+                _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath);
+
+                string rootContextConfigString = _evaluatorConfig.RootContextConfiguration;
+                if (string.IsNullOrWhiteSpace(rootContextConfigString))
+                {
+                    Exceptions.Throw(new ArgumentException("empty or null rootContextConfigString"), _logger);
+                }
+                ContextConfiguration rootContextConfiguration = new ContextConfiguration(rootContextConfigString);
+
+                string taskConfig = _evaluatorConfig.TaskConfiguration;
+                Optional<TaskConfiguration> rootTaskConfig = string.IsNullOrEmpty(taskConfig)
+                                        ? Optional<TaskConfiguration>.Empty()
+                                        : Optional<TaskConfiguration>.Of(
+                                            new TaskConfiguration(taskConfig));
+                string rootServiceConfigString = _evaluatorConfig.RootServiceConfiguration;
+                Optional<ServiceConfiguration> rootServiceConfig = string.IsNullOrEmpty(rootServiceConfigString)
+                                        ? Optional<ServiceConfiguration>.Empty()
+                                        : Optional<ServiceConfiguration>.Of(
+                                            new ServiceConfiguration(
+                                                rootServiceConfigString));
+ 
+                // remoteManager used as client-only in evaluator
+                IRemoteManager<REEFMessage> remoteManager = new DefaultRemoteManager<REEFMessage>(reefMessageCodec);
+                IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId));
+
+                ConfigurationModule module = new ConfigurationModuleBuilder().Build();
+                IConfiguration clockConfiguraiton = module.Build();
+
+                clock =
+                    TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
+                    _logger.Log(Level.Info, "Application Id: " + _evaluatorConfig.ApplicationId);
+
+                EvaluatorSettings evaluatorSettings = new EvaluatorSettings(
+                    _evaluatorConfig.ApplicationId,
+                    _evaluatorConfig.EvaluatorId,
+                    _heartbeatPeriodInMs,
+                    _heartbeatMaxRetry,
+                    rootContextConfiguration,
+                    clock,
+                    remoteManager,
+                    _injector);
+
+                HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId);
+                ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig);
+                EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager);
+
+                // TODO: repalce with injectionFuture
+                heartBeatManager._evaluatorRuntime = evaluatorRuntime;
+                heartBeatManager._contextManager = contextManager;
+
+                SetRuntimeHanlders(evaluatorRuntime, clock);
+            }
+
+            Task evaluatorTask = Task.Run(new Action(clock.Run));
+            evaluatorTask.Wait();            
+        }
+
+        private static void InitInjector()
+        {
+            string clrRuntimeConfigurationFile = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global",
+                                                                Common.Constants.ClrBridgeRuntimeConfiguration);
+            if (!File.Exists(clrRuntimeConfigurationFile))
+            {
+                var e =
+                    new InvalidOperationException("Cannot find clrRuntimeConfiguration from " +
+                                                    clrRuntimeConfigurationFile);
+                Exceptions.Throw(e, _logger);
+            }
+
+            try
+            {
+                IConfiguration clrBridgeConfiguration =
+                    new AvroConfigurationSerializer().FromFile(clrRuntimeConfigurationFile);
+                _injector = TangFactory.GetTang().NewInjector(clrBridgeConfiguration);
+            }
+            catch (Exception e)
+            {
+                Exceptions.Caught(e, Level.Error, "Cannot obtain injector from clr bridge configuration.", _logger);
+                Exceptions.Throw(
+                    new InvalidOperationException("Cannot obtain injector from clr bridge configuration.", e),
+                    _logger);
+            }
+        }
+
+        private static void SetCustomTraceListners()
+        {
+            ISet<TraceListener> customTraceListeners;
+            CustomTraceListeners listeners = null;
+            try
+            {
+                listeners = _injector.GetInstance<CustomTraceListeners>();
+                customTraceListeners = listeners.Listeners;
+            }
+            catch (Exception e)
+            {
+                Exceptions.Caught(e, Level.Error, _logger);
+                // custom trace listner not set properly, use empty set
+                customTraceListeners = new HashSet<TraceListener>();
+            }
+            foreach (TraceListener listener in customTraceListeners)
+            {
+                Logger.AddTraceListner(listener);
+            }
+            _logger = Logger.GetLogger(typeof(Evaluator));
+            CustomTraceLevel traceLevel = _injector.GetInstance<CustomTraceLevel>();
+            Logger.SetCustomLevel(traceLevel.TraceLevel);
+        }
+
+        private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
+        {
+            Exception ex = default(Exception);
+            ex = (Exception)e.ExceptionObject;
+            _logger.Log(Level.Error, "Unhandled exception caught in Evaluator.", ex);
+            Exceptions.Throw(new InvalidOperationException("Unhandled exception caught in Evaluator.", ex), _logger);
+        }
+
+        // set the handlers for runtimeclock manually
+        // we only need runtimestart and runtimestop handlers now
+        private static void SetRuntimeHanlders(EvaluatorRuntime evaluatorRuntime, RuntimeClock clock)
+        {
+            HashSet<IObserver<RuntimeStart>> runtimeStarts = new HashSet<IObserver<RuntimeStart>>();
+            runtimeStarts.Add(evaluatorRuntime);
+            InjectionFutureImpl<ISet<IObserver<RuntimeStart>>> injectRuntimeStart = new InjectionFutureImpl<ISet<IObserver<RuntimeStart>>>(runtimeStarts);
+            clock.InjectedRuntimeStartHandler = injectRuntimeStart;
+
+            HashSet<IObserver<RuntimeStop>> runtimeStops = new HashSet<IObserver<RuntimeStop>>();
+            runtimeStops.Add(evaluatorRuntime);
+            InjectionFutureImpl<ISet<IObserver<RuntimeStop>>> injectRuntimeStop = new InjectionFutureImpl<ISet<IObserver<RuntimeStop>>>(runtimeStops);
+            clock.InjectedRuntimeStopHandler = injectRuntimeStop;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.csproj b/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.csproj
new file mode 100644
index 0000000..dc9c703
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/Evaluator/Evaluator.csproj
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{1B983182-9C30-464C-948D-F87EB93A8240}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Evaluator</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Evaluator</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Evaluator\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Evaluator\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Evaluator.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/Evaluator/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/Evaluator/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-applications/Evaluator/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..51ff356
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/Evaluator/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Evaluator")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Evaluator")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a64dc535-9b1e-41a4-8303-117f8b28c8c0")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-applications/Evaluator/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-applications/Evaluator/packages.config b/lang/cs/Source/REEF/reef-applications/Evaluator/packages.config
new file mode 100644
index 0000000..81b0ef5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-applications/Evaluator/packages.config
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/ClientJobStatusHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/ClientJobStatusHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/ClientJobStatusHandler.cs
new file mode 100644
index 0000000..508d3b3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/ClientJobStatusHandler.cs
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Client;
+using Org.Apache.Reef.Common.ProtoBuf.ClienRuntimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Time;
+using System;
+
+namespace Org.Apache.Reef.Common
+{
+    public class ClientJobStatusHandler : IJobMessageObserver, IObserver<StartTime>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClientJobStatusHandler));
+
+        private IClock _clock;
+
+        private string _jobId;
+
+        private IObserver<JobStatusProto> _jobStatusHandler;
+
+        private IDisposable _jobControlChannel;
+
+        State _state = State.INIT;
+
+        public ClientJobStatusHandler(
+            IRemoteManager<IRemoteMessage<REEFMessage>> remoteManager,
+            IClock clock,
+            IObserver<JobControlProto> jobControlHandler,
+            string jobId,
+            string clientRID)
+        {
+            _clock = clock;
+            _jobId = jobId;
+            _jobStatusHandler = null;
+            _jobControlChannel = null;
+            //_jobStatusHandler = remoteManager.GetRemoteObserver()
+            //_jobControlChannel = remoteManager.RegisterObserver()
+        }
+
+        public void Dispose(Optional<Exception> e)
+        {
+            try
+            {
+                if (e.IsPresent())
+                {
+                    OnError(e.Value);
+                }
+                else
+                {
+                    JobStatusProto proto = new JobStatusProto();
+                    proto.identifier = _jobId;
+                    proto.state = State.DONE;
+                    Send(proto);
+                }
+            }
+            catch (Exception ex)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Warning, "Error closing ClientJobStatusHandler", LOGGER);
+            }
+
+            try
+            {
+                _jobControlChannel.Dispose();
+            }
+            catch (Exception ex)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Warning, "Error closing jobControlChannel", LOGGER);
+            }
+        }
+
+        public void OnNext(byte[] value)
+        {
+            LOGGER.Log(Level.Info, "Job message from {0}" + _jobId);   
+            SendInit();
+            JobStatusProto proto = new JobStatusProto();
+            proto.identifier = _jobId;
+            proto.state = State.RUNNING;
+            proto.message = value;
+            Send(proto);
+        }
+
+        public void OnNext(StartTime value)
+        {
+            LOGGER.Log(Level.Info, "StartTime:" + value);
+            SendInit();
+        }
+
+        public void OnError(Exception error)
+        {
+            LOGGER.Log(Level.Error, "job excemption", error);
+            JobStatusProto proto = new JobStatusProto();
+            proto.identifier = _jobId;
+            proto.state = State.FAILED;
+            proto.exception = ByteUtilities.StringToByteArrays(error.Message);
+            _clock.Dispose();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        private void Send(JobStatusProto status)
+        {
+            LOGGER.Log(Level.Info, "Sending job status " + status);
+            _jobStatusHandler.OnNext(status);
+        }
+
+        private void SendInit()
+        {
+            if (_state == State.INIT)
+            {
+                JobStatusProto proto = new JobStatusProto();
+                proto.identifier = _jobId;
+                proto.state = State.INIT;
+                Send(proto);
+                _state = State.RUNNING;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/Constants.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/Constants.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/Constants.cs
new file mode 100644
index 0000000..ea9ce76
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/Constants.cs
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common
+{
+    public class Constants
+    {
+        public const string ClrBridgeRuntimeConfiguration = "clrBridge.config";
+
+        // if 8080 port is not used, then query would fail, 
+        // this is only for local runtime testing purpose though, so it should be ok
+        public const string LocalHttpEndpointBaseUri = @"http://localhost:8080/";  
+
+        public const string HDInsightClusterHttpEndpointBaseUri = @"http://headnodehost:9014/proxy/";
+
+        public const string HttpReefUriSpecification = @"Reef/v1/";
+
+        public const string HttpDriverUriTarget = @"Driver/";
+
+        public const string NameServerServiceName = "NameServer";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/EvaluatorHeartBeatSanityChecker.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/EvaluatorHeartBeatSanityChecker.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/EvaluatorHeartBeatSanityChecker.cs
new file mode 100644
index 0000000..38ed6c0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/EvaluatorHeartBeatSanityChecker.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common
+{
+    public class EvaluatorHeartBeatSanityChecker
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorHeartBeatSanityChecker));
+        
+        Dictionary<string, long> _timeStamps = new Dictionary<string, long>();
+
+        public void check(string id, long timeStamp)
+        {
+            lock (this)
+            {
+                if (_timeStamps.ContainsKey(id))
+                {
+                    long oldTimeStamp = _timeStamps[id];
+                    LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "TIMESTAMP CHECKER: id [{0}], old timestamp [{1}], new timestamp [{2}]", id, oldTimeStamp, timeStamp));
+                    if (oldTimeStamp > timeStamp)
+                    {
+                        string msg = string.Format(
+                            CultureInfo.InvariantCulture,
+                            "Received an old heartbeat with timestamp [{0}] while timestamp [{1}] was received earlier",
+                            oldTimeStamp,
+                            timeStamp);
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException(msg), LOGGER);
+                    }
+                }
+                _timeStamps.Add(id, timeStamp);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/FailedRuntime.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/FailedRuntime.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/FailedRuntime.cs
new file mode 100644
index 0000000..c700986
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/FailedRuntime.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Common
+{
+    public class FailedRuntime : AbstractFailure
+    {
+        public FailedRuntime(RuntimeErrorProto error)
+            : base(error.identifier, error.message, null, GetException(error), error.exception)
+        {
+        }
+
+        /// <summary>
+        /// Get the exception from error
+        /// </summary>
+        /// <param name="error"></param>
+        /// <returns>excetpiont from error</returns>
+        private static Exception GetException(RuntimeErrorProto error)
+        {
+            byte[] data = error.exception;
+            if (data != null)
+            {
+                return new InvalidOperationException(ByteUtilities.ByteArrarysToString(error.exception));
+            }
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/IContextAndTaskSubmittable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/IContextAndTaskSubmittable.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/IContextAndTaskSubmittable.cs
new file mode 100644
index 0000000..edf983f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/IContextAndTaskSubmittable.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Common
+{
+    /// <summary>
+    /// Base interface for classes that support the simultaneous submission of both Context and Task configurations.
+    /// </summary>
+    public interface IContextAndTaskSubmittable
+    {
+        /// <summary>
+        /// Submit a Context and an Task.
+        /// The semantics of this call are the same as first submitting the context and then, on the fired ActiveContext event
+        /// to submit the Task. The performance of this will be better, though as it potentially saves some roundtrips on
+        /// the network.
+        /// REEF will not fire an ActiveContext as a result of this. Instead, it will fire a TaskRunning event.
+        /// </summary>
+        /// <param name="contextConfiguration"> the Configuration of the EvaluatorContext. See ContextConfiguration for details.</param>
+        /// <param name="taskConfiguration">the Configuration of the Task. See TaskConfiguration for details.</param>
+        void SubmitContextAndTask(IConfiguration contextConfiguration, IConfiguration taskConfiguration);
+
+        /// <summary>
+        /// Submit a Context with Services and an Task.
+        /// The semantics of this call are the same as first submitting the context and services and then, on the fired
+        /// ActiveContext event to submit the Task. The performance of this will be better, though as it potentially saves
+        /// some roundtrips on the network.
+        /// REEF will not fire an ActiveContext as a result of this. Instead, it will fire a TaskRunning event.
+        /// </summary>
+        /// <param name="contextConfiguration"></param>
+        /// <param name="serviceConfiguration"></param>
+        /// <param name="taskConfiguration"></param>
+        void SubmitContextAndServiceAndTask(
+            IConfiguration contextConfiguration, 
+            IConfiguration serviceConfiguration, 
+            IConfiguration taskConfiguration);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/IContextSubmittable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/IContextSubmittable.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/IContextSubmittable.cs
new file mode 100644
index 0000000..039d2a3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/IContextSubmittable.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Common
+{
+    /// <summary>
+    ///  Base interface for classes that support Context submission.
+    /// </summary>
+    public interface IContextSubmittable
+    {
+        /// <summary>
+        ///  Submit a Context.
+        /// </summary>
+        /// <param name="contextConfiguration">the Configuration of the EvaluatorContext. See ContextConfiguration for details.</param>
+        void SubmitContext(IConfiguration contextConfiguration);
+
+        /// <summary>
+        /// Submit a Context and a Service Configuration.
+        /// </summary>
+        /// <param name="contextConfiguration">the Configuration of the EvaluatorContext. See ContextConfiguration for details.</param>
+        /// <param name="serviceConfiguration">the Configuration for the Services. See ServiceConfiguration for details.</param>
+        void SubmitContextAndService(IConfiguration contextConfiguration, IConfiguration serviceConfiguration);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/IJobMessageObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/IJobMessageObserver.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/IJobMessageObserver.cs
new file mode 100644
index 0000000..a5be5d5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/IJobMessageObserver.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Common.Client
+{
+    /// <summary>
+    ///  The driver uses this interface to communicate with the job client.
+    /// </summary>
+    public interface IJobMessageObserver : IObserver<byte[]>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/ITaskSubmittable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/ITaskSubmittable.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/ITaskSubmittable.cs
new file mode 100644
index 0000000..1cc9312
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/ITaskSubmittable.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Common
+{
+    /// <summary>
+    ///  Base interface for classes that support Task submission.
+    /// </summary>
+    public interface ITaskSubmittable
+    {
+       /// <summary>
+        /// Submits an Task (encoded in the Configuration) for execution.
+       /// </summary>
+        /// <param name="taskConf">the Configuration. See TaskConfiguration for details</param>
+        void SubmitTask(IConfiguration taskConf);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f6c13bd
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ReefCommon")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ReefCommon")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a810ee4a-fe13-4536-9e9c-5275b16e0842")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/ReefCommon.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/ReefCommon.csproj b/lang/cs/Source/REEF/reef-common/ReefCommon/ReefCommon.csproj
new file mode 100644
index 0000000..6dc5b4b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/ReefCommon.csproj
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{545A0582-4105-44CE-B99C-B1379514A630}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Common</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Common</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Common\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Common\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Reactive.Core">
+      <HintPath>..\..\..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Reactive.Interfaces">
+      <HintPath>..\..\..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="api\AbstractFailure.cs" />
+    <Compile Include="api\IAbstractFailure.cs" />
+    <Compile Include="api\IFailure.cs" />
+    <Compile Include="api\IResourceLaunchHandler.cs" />
+    <Compile Include="api\IResourceReleaseHandler.cs" />
+    <Compile Include="api\IResourceRequestHandler.cs" />
+    <Compile Include="avro\AvroDriverInfo.cs" />
+    <Compile Include="avro\AvroHttpRequest.cs" />
+    <Compile Include="avro\AvroHttpSerializer.cs" />
+    <Compile Include="avro\AvroJsonSerializer.cs" />
+    <Compile Include="avro\AvroReefServiceInfo.cs" />
+    <Compile Include="catalog\capabilities\CPU.cs" />
+    <Compile Include="catalog\capabilities\ICapability.cs" />
+    <Compile Include="catalog\capabilities\RAM.cs" />
+    <Compile Include="catalog\INodeDescriptor.cs" />
+    <Compile Include="catalog\IRackDescriptor.cs" />
+    <Compile Include="catalog\IResourceCatalog.cs" />
+    <Compile Include="catalog\NodeDescriptorImpl.cs" />
+    <Compile Include="catalog\RackDescriptorImpl.cs" />
+    <Compile Include="catalog\ResourceCatalogImpl.cs" />
+    <Compile Include="ClientJobStatusHandler.cs" />
+    <Compile Include="Constants.cs" />
+    <Compile Include="context\ContextMessage.cs" />
+    <Compile Include="context\IContextMessage.cs" />
+    <Compile Include="context\IContextMessageHandler.cs" />
+    <Compile Include="context\IContextMessageSource.cs" />
+    <Compile Include="EvaluatorHeartBeatSanityChecker.cs" />
+    <Compile Include="evaluator\DefaultLocalHttpDriverConnection.cs" />
+    <Compile Include="evaluator\DefaultYarnClusterHttpDriverConnection.cs" />
+    <Compile Include="evaluator\DefaultYarnOneBoxHttpDriverConnection.cs" />
+    <Compile Include="evaluator\DriverInformation.cs" />
+    <Compile Include="evaluator\EvaluatorOperationState.cs" />
+    <Compile Include="evaluator\EvaluatorRuntimeState.cs" />
+    <Compile Include="evaluator\EvaluatorType.cs" />
+    <Compile Include="evaluator\IDriverConnection.cs" />
+    <Compile Include="events\IContextStart.cs" />
+    <Compile Include="events\IContextStop.cs" />
+    <Compile Include="exceptions\EvaluatorException.cs" />
+    <Compile Include="exceptions\JobException.cs" />
+    <Compile Include="FailedRuntime.cs" />
+    <Compile Include="IContextAndTaskSubmittable.cs" />
+    <Compile Include="IContextSubmittable.cs" />
+    <Compile Include="IJobMessageObserver.cs" />
+    <Compile Include="io\INameClient.cs" />
+    <Compile Include="io\NameAssignment.cs" />
+    <Compile Include="io\NamingConfiguration.cs" />
+    <Compile Include="io\NamingConfigurationOptions.cs" />
+    <Compile Include="ITaskSubmittable.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="protobuf\cs\ClientRuntime.pb.cs" />
+    <Compile Include="protobuf\cs\codec\EvaluatorHeartbeatProtoCodec.cs" />
+    <Compile Include="protobuf\cs\codec\REEFMessageCodec.cs" />
+    <Compile Include="protobuf\cs\DriverRuntime.pb.cs" />
+    <Compile Include="protobuf\cs\EvaluatorRunTime.pb.cs" />
+    <Compile Include="protobuf\cs\ReefProtocol.pb.cs" />
+    <Compile Include="protobuf\cs\ReefService.pb.cs" />
+    <Compile Include="protobuf\cs\Serializer.cs" />
+    <Compile Include="runtime\evaluator\Constants.cs" />
+    <Compile Include="runtime\evaluator\context\ContextClientCodeException.cs" />
+    <Compile Include="runtime\evaluator\context\ContextConfiguration.cs" />
+    <Compile Include="runtime\evaluator\context\ContextLifeCycle.cs" />
+    <Compile Include="runtime\evaluator\context\ContextManager.cs" />
+    <Compile Include="runtime\evaluator\context\ContextRuntime.cs" />
+    <Compile Include="runtime\evaluator\context\ContextStartImpl.cs" />
+    <Compile Include="runtime\evaluator\context\ContextStopImpl.cs" />
+    <Compile Include="runtime\evaluator\context\RootContextLauncher.cs" />
+    <Compile Include="runtime\evaluator\EvaluatorRuntime.cs" />
+    <Compile Include="runtime\evaluator\EvaluatorSettings.cs" />
+    <Compile Include="runtime\evaluator\HeartBeatManager.cs" />
+    <Compile Include="runtime\evaluator\ReefMessageProtoObserver.cs" />
+    <Compile Include="runtime\evaluator\task\CloseEventImpl.cs" />
+    <Compile Include="runtime\evaluator\task\DriverMessageImpl.cs" />
+    <Compile Include="runtime\evaluator\task\SuspendEventImpl.cs" />
+    <Compile Include="runtime\evaluator\task\TaskClientCodeException.cs" />
+    <Compile Include="runtime\evaluator\task\TaskLifeCycle.cs" />
+    <Compile Include="runtime\evaluator\task\TaskRuntime.cs" />
+    <Compile Include="runtime\evaluator\task\TaskStartImpl.cs" />
+    <Compile Include="runtime\evaluator\task\TaskState.cs" />
+    <Compile Include="runtime\evaluator\task\TaskStatus.cs" />
+    <Compile Include="runtime\evaluator\task\TaskStopImpl.cs" />
+    <Compile Include="runtime\evaluator\utils\EvaluatorConfigurations.cs" />
+    <Compile Include="runtime\evaluator\utils\RemoteManager.cs" />
+    <Compile Include="runtime\MachineStatus.cs" />
+    <Compile Include="services\IService.cs" />
+    <Compile Include="services\ServiceConfiguration.cs" />
+    <Compile Include="services\ServicesConfigurationOptions.cs" />
+    <Compile Include="tasks\defaults\DefaultDriverMessageHandler.cs" />
+    <Compile Include="tasks\defaults\DefaultTaskMessageSource.cs" />
+    <Compile Include="tasks\events\ICloseEvent.cs" />
+    <Compile Include="tasks\events\IDriverMessage.cs" />
+    <Compile Include="tasks\events\ISuspendEvent.cs" />
+    <Compile Include="tasks\events\ITaskStart.cs" />
+    <Compile Include="tasks\events\ITaskStop.cs" />
+    <Compile Include="tasks\IDriverMessageHandler.cs" />
+    <Compile Include="tasks\IRunningTask.cs" />
+    <Compile Include="tasks\ITask.cs" />
+    <Compile Include="tasks\ITaskMessageSource.cs" />
+    <Compile Include="tasks\TaskConfiguration.cs" />
+    <Compile Include="tasks\TaskConfigurationOptions.cs" />
+    <Compile Include="tasks\TaskMessage.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+    <None Include="protobuf\proto\client_runtime.proto" />
+    <None Include="protobuf\proto\driver_runtime.proto" />
+    <None Include="protobuf\proto\evaluator_runtime.proto" />
+    <None Include="protobuf\proto\reef_protocol.proto" />
+    <None Include="protobuf\proto\reef_service_protos.proto" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="protobuf\tools\" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/api/AbstractFailure.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/api/AbstractFailure.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/api/AbstractFailure.cs
new file mode 100644
index 0000000..4b9c1a6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/api/AbstractFailure.cs
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using System;
+using System.Globalization;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Common.Api
+{
+    public abstract class AbstractFailure : IFailure
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(AbstractFailure));
+
+        public AbstractFailure()
+        {
+        }
+
+        /// <summary>
+        /// Most detailed error message constructor that takes all parameters possible.
+        /// </summary>
+        /// <param name="id">Identifier of the entity that produced the error. Cannot be null.</param>
+        /// <param name="message">One-line error message. Cannot be null.</param>
+        /// <param name="description">Long error description. Can be null.</param>
+        /// <param name="cause">Exception that caused the error. Can be null.</param>
+        /// <param name="data">byte array that contains serialized version of the error. Can be null.</param>
+        public AbstractFailure(string id, string message, string description, Exception cause, byte[] data)
+        {
+            if (string.IsNullOrEmpty(id))
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("id"), LOGGER);
+            }
+            if (string.IsNullOrEmpty(message))
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("message"), LOGGER);
+            }
+            Id = id;
+            Message = message;
+            Description = Optional<string>.OfNullable(string.IsNullOrEmpty(description) ? GetStackTrace(cause) : description);
+            Cause = Optional<Exception>.OfNullable(cause);
+            Data = Optional<byte[]>.OfNullable(data);
+        }
+
+        /// <summary>
+        ///  Build error message given the entity ID and the short error message.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="message"></param>
+        public AbstractFailure(string id, string message)
+            : this(id, message, null, null, null)
+        {
+        }
+
+        /// <summary>
+        ///  Build error message given the failed entity ID and  Exception.
+        ///  Populates the message with the Exception.getMessage() result, and stores
+        ///  the exception stack trace in the description.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="cause"></param>
+        public AbstractFailure(string id, Exception cause)
+        {
+            if (string.IsNullOrEmpty(id))
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("id"), LOGGER);
+            }
+            Id = id;
+            Message = cause.Message;
+            Description = Optional<string>.Of(GetStackTrace(cause));
+            Cause = Optional<Exception>.Of(cause);
+            Data = Optional<byte[]>.Empty();
+        }
+
+        /// <summary>
+        /// Build error message given the entity ID plus short and long error message.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="message"></param>
+        /// <param name="description"></param>
+        public AbstractFailure(string id, string message, string description)
+            : this(id, message, description, null, null)
+        {
+        }
+
+        /// <summary>
+        /// Identifier of the entity that produced the error. Cannot be null.
+        /// </summary>
+        public string Id { get; set; }
+
+        public string Message { get; set; }
+
+        public Optional<string> Description { get; set; }
+
+        public Optional<string> Reason { get; set; }
+
+        public Optional<Exception> Cause { get; set; }
+
+        public Optional<byte[]> Data { get; set; }
+
+        public Exception AsError()
+        {
+            return Cause.IsPresent() ? Cause.Value : new InvalidOperationException(ToString());
+        }
+
+        /// <summary>
+        ///  Helper function: produce the string that contains the given exception's stack trace. Returns null if the argument is null.
+        /// </summary>
+        /// <param name="ex"></param>
+        public string GetStackTrace(Exception ex)
+        {
+            if (ex == null)
+            {
+                return null;
+            }
+            else
+            {
+                return ex.StackTrace;
+            }
+        }
+
+        public override string ToString()
+        {
+            return string.Format(CultureInfo.InvariantCulture, "{0} with id={1} failed: {2}", GetType(), Id, Message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/api/IAbstractFailure.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/api/IAbstractFailure.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IAbstractFailure.cs
new file mode 100644
index 0000000..410eacb
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IAbstractFailure.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Api
+{
+    public interface IAbstractFailure : IFailure
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/api/IFailure.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/api/IFailure.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IFailure.cs
new file mode 100644
index 0000000..02382d0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IFailure.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Common.Api
+{
+    /// <summary>
+    /// Common interface for all error messages in REEF.
+    /// Most of its functionality is generic and implemented in the AbstractFailure class.
+    /// </summary>
+    public interface IFailure : IIdentifiable
+    {
+        /// <summary>
+        /// One-line error message. Should never be null.
+        /// </summary>
+        string Message { get; set; }
+
+        /// <summary>
+        ///  Optional long error description.
+        /// </summary>
+        Optional<string> Description { get; set; }
+
+        /// <summary>
+        /// Exception that caused the error, or null.
+        /// </summary>
+        Optional<string> Reason { get; set; }
+
+        /// <summary>
+        /// Optional serialized version of the error message.
+        /// </summary>
+        Optional<byte[]> Data { get; set; }
+
+        /// <summary>
+        /// Return the original Java Exception, or generate a new one if it does not exists.
+        /// ALWAYS returns an exception, never null
+        /// </summary>
+        Exception AsError();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceLaunchHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceLaunchHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceLaunchHandler.cs
new file mode 100644
index 0000000..edea908
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceLaunchHandler.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto;
+using System;
+
+namespace Org.Apache.Reef.Common.Api
+{
+    public interface IResourceLaunchHandler : IObserver<ResourceLaunchProto>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceReleaseHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceReleaseHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceReleaseHandler.cs
new file mode 100644
index 0000000..bcc93ba
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceReleaseHandler.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto;
+using System;
+
+namespace Org.Apache.Reef.Common.Api
+{
+    public interface IResourceReleaseHandler : IObserver<ResourceReleaseProto>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceRequestHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceRequestHandler.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceRequestHandler.cs
new file mode 100644
index 0000000..9eda5c8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/api/IResourceRequestHandler.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto;
+using System;
+
+namespace Org.Apache.Reef.Common.Api
+{
+    public interface IResourceRequestHandler : IObserver<ResourceRequestProto>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroDriverInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroDriverInfo.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroDriverInfo.cs
new file mode 100644
index 0000000..7a54f4f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroDriverInfo.cs
@@ -0,0 +1,65 @@
+//<auto-generated />
+namespace Org.Apache.Reef.Common.Avro
+{
+    using System.Collections.Generic;
+    using System.Runtime.Serialization;
+
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.webserver.AvroDriverInfo.
+    /// </summary>
+    [DataContract(Namespace = "org.apache.reef.webserver")]
+    [KnownType(typeof(List<Org.Apache.Reef.Common.Avro.AvroReefServiceInfo>))]
+    public partial class AvroDriverInfo
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.webserver.AvroDriverInfo"",""fields"":[{""name"":""remoteId"",""type"":""string""},{""name"":""startTime"",""type"":""string""},{""name"":""services"",""type"":{""type"":""array"",""items"":{""type"":""record"",""name"":""org.apache.reef.webserver.AvroReefServiceInfo"",""fields"":[{""name"":""serviceName"",""type"":""string""},{""name"":""serviceInfo"",""type"":""string""}]}}}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the remoteId field.
+        /// </summary>
+        [DataMember]
+        public string remoteId { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the startTime field.
+        /// </summary>
+        [DataMember]
+        public string startTime { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the services field.
+        /// </summary>
+        [DataMember]
+        public IList<Org.Apache.Reef.Common.Avro.AvroReefServiceInfo> services { get; set; }
+                
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AvroDriverInfo"/> class.
+        /// </summary>
+        public AvroDriverInfo()
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AvroDriverInfo"/> class.
+        /// </summary>
+        /// <param name="remoteId">The remoteId.</param>
+        /// <param name="startTime">The startTime.</param>
+        /// <param name="services">The services.</param>
+        public AvroDriverInfo(string remoteId, string startTime, IList<Org.Apache.Reef.Common.Avro.AvroReefServiceInfo> services)
+        {
+            this.remoteId = remoteId;
+            this.startTime = startTime;
+            this.services = services;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpRequest.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpRequest.cs
new file mode 100644
index 0000000..1e22569
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpRequest.cs
@@ -0,0 +1,79 @@
+//<auto-generated />
+namespace Org.Apache.Reef.Common.Avro
+{
+    using System.Runtime.Serialization;
+
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.webserver.AvroHttpRequest.
+    /// </summary>
+    [DataContract(Namespace = "org.apache.reef.webserver")]
+    public partial class AvroHttpRequest
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.webserver.AvroHttpRequest"",""fields"":[{""name"":""requestUrl"",""type"":""string""},{""name"":""pathInfo"",""type"":""string""},{""name"":""queryString"",""type"":""string""},{""name"":""httpMethod"",""type"":""string""},{""name"":""inputStream"",""type"":""bytes""}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the requestUrl field.
+        /// </summary>
+        [DataMember]
+        public string RequestUrl { get; set; }
+
+        /// <summary>
+        /// Gets or sets the pathInfo field.
+        /// </summary>
+        [DataMember]
+        public string PathInfo { get; set; }
+
+        /// <summary>
+        /// Gets or sets the queryString field.
+        /// </summary>
+        [DataMember]
+        public string QueryString { get; set; }
+
+        /// <summary>
+        /// Gets or sets the httpMethod field.
+        /// </summary>
+        [DataMember]
+        public string HttpMethod { get; set; }
+
+        /// <summary>
+        /// Gets or sets the inputStream field.
+        /// </summary>
+        [DataMember]
+        public byte[] InputStream { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AvroHttpRequest"/> class.
+        /// </summary>
+        public AvroHttpRequest()
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AvroHttpRequest"/> class.
+        /// </summary>
+        /// <param name="requestUrl">The requestUrl.</param>
+        /// <param name="pathInfo">The pathInfo.</param>
+        /// <param name="queryString">The queryString.</param>
+        /// <param name="httpMethod">The httpMethod.</param>
+        /// <param name="inputStream">The inputStream.</param>
+        public AvroHttpRequest(string requestUrl, string pathInfo, string queryString, string httpMethod, byte[] inputStream)
+        {
+            RequestUrl = requestUrl;
+            PathInfo = pathInfo;
+            QueryString = queryString;
+            HttpMethod = httpMethod;
+            InputStream = inputStream;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpSerializer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpSerializer.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpSerializer.cs
new file mode 100644
index 0000000..886658f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroHttpSerializer.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Microsoft.Hadoop.Avro;
+using System.IO;
+
+namespace Org.Apache.Reef.Common.Avro
+{
+    public class AvroHttpSerializer
+    {
+        public static AvroHttpRequest FromBytes(byte[] serializedBytes)
+        {
+            var serializer = AvroSerializer.Create<AvroHttpRequest>();
+            using (var stream = new MemoryStream(serializedBytes))
+            {
+                return serializer.Deserialize(stream);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroJsonSerializer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroJsonSerializer.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroJsonSerializer.cs
new file mode 100644
index 0000000..9158a16
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroJsonSerializer.cs
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+using Newtonsoft.Json;
+
+namespace Org.Apache.Reef.Common.Avro
+{
+    /// <summary>
+    /// Wrapper class for serialize/deserialize Avro json. This avoids having to reference Avro dll in every project 
+    /// </summary>
+    /// <typeparam name="T"> the deserialized type</typeparam>
+    public class AvroJsonSerializer<T>
+    {
+        public static T FromString(string str)
+        {
+            return JsonConvert.DeserializeObject<T>(str);
+        }
+
+        public static string ToString(T obj)
+        {
+            return JsonConvert.SerializeObject(obj);
+        }
+
+        public static T FromBytes(byte[] bytes)
+        {
+            return FromString(ByteUtilities.ByteArrarysToString(bytes));
+        }
+
+        public static byte[] ToBytes(T obj)
+        {
+            return ByteUtilities.StringToByteArrays(JsonConvert.SerializeObject(obj));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroReefServiceInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroReefServiceInfo.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroReefServiceInfo.cs
new file mode 100644
index 0000000..671b067
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/avro/AvroReefServiceInfo.cs
@@ -0,0 +1,55 @@
+//<auto-generated />
+namespace Org.Apache.Reef.Common.Avro
+{
+    using System.Runtime.Serialization;
+
+    /// <summary>
+    /// Used to serialize and deserialize Avro record org.apache.reef.webserver.AvroReefServiceInfo.
+    /// </summary>
+    [DataContract(Namespace = "org.apache.reef.webserver")]
+    public partial class AvroReefServiceInfo
+    {
+        private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.webserver.AvroReefServiceInfo"",""fields"":[{""name"":""serviceName"",""type"":""string""},{""name"":""serviceInfo"",""type"":""string""}]}";
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        public static string Schema
+        {
+            get
+            {
+                return JsonSchema;
+            }
+        }
+      
+        /// <summary>
+        /// Gets or sets the serviceName field.
+        /// </summary>
+        [DataMember]
+        public string serviceName { get; set; }
+              
+        /// <summary>
+        /// Gets or sets the serviceInfo field.
+        /// </summary>
+        [DataMember]
+        public string serviceInfo { get; set; }
+                
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AvroReefServiceInfo"/> class.
+        /// </summary>
+        public AvroReefServiceInfo()
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AvroReefServiceInfo"/> class.
+        /// </summary>
+        /// <param name="serviceName">The serviceName.</param>
+        /// <param name="serviceInfo">The serviceInfo.</param>
+        public AvroReefServiceInfo(string serviceName, string serviceInfo)
+        {
+            this.serviceName = serviceName;
+            this.serviceInfo = serviceInfo;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/INodeDescriptor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/INodeDescriptor.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/INodeDescriptor.cs
new file mode 100644
index 0000000..672a0cd
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/INodeDescriptor.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Net;
+
+using Org.Apache.Reef.Common.Capabilities;
+
+namespace Org.Apache.Reef.Common.Catalog
+{
+    public interface INodeDescriptor
+    {
+        IPEndPoint InetSocketAddress { get; set; }
+
+        string HostName { get; set; }
+
+        CPU Cpu { get; set; }
+
+        RAM Ram { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IRackDescriptor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IRackDescriptor.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IRackDescriptor.cs
new file mode 100644
index 0000000..ce576c4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/catalog/IRackDescriptor.cs
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Common.Catalog
+{
+    public interface IRackDescriptor : IResourceCatalog
+    {
+    }
+}


[19/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterResponse.cs
new file mode 100644
index 0000000..9a3775d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterResponse.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.IO.Network.Naming.Events
+{
+    /// <summary>
+    /// Response event for unregistering of an IPEndpoint with the Name Service
+    /// </summary>
+    internal class NamingUnregisterResponse : NamingEvent
+    {
+        public NamingUnregisterResponse(NamingUnregisterRequest request)
+        {
+            Request = request;
+        }
+
+        public NamingUnregisterRequest Request { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/INameServer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/INameServer.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/INameServer.cs
new file mode 100644
index 0000000..fc8e891
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/INameServer.cs
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.IO.Network.Naming
+{
+    /// <summary>
+    /// Service that manages names and IPEndpoints for well known hosts.
+    /// Can register, unregister, and look up IPAddresses using a string identifier.
+    /// </summary>
+    [DefaultImplementation(typeof(NameServer))]
+    public interface INameServer : IDisposable
+    {
+        /// <summary>
+        /// Listening endpoint for the NameServer
+        /// </summary>
+        IPEndPoint LocalEndpoint { get; }
+
+        /// <summary>
+        /// Looks up the IPEndpoints for each string identifier
+        /// </summary>
+        /// <param name="ids">The IDs to look up</param>
+        /// <returns>A list of Name assignments representing the identifier
+        /// that was searched for and the mapped IPEndpoint</returns>
+        List<NameAssignment> Lookup(List<string> ids);
+
+        /// <summary>
+        /// Gets all of the registered identifier/endpoint pairs.
+        /// </summary>
+        /// <returns>A list of all of the registered identifiers and their
+        /// mapped IPEndpoints</returns>
+        List<NameAssignment> GetAll();
+
+        /// <summary>
+        /// Registers the string identifier with the given IPEndpoint
+        /// </summary>
+        /// <param name="id">The string ident</param>
+        /// <param name="endpoint">The mapped endpoint</param>
+        void Register(string id, IPEndPoint endpoint);
+
+        /// <summary>
+        /// Unregister the given identifier with the NameServer
+        /// </summary>
+        /// <param name="id">The identifier to unregister</param>
+        void Unregister(string id);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/NameClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/NameClient.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/NameClient.cs
new file mode 100644
index 0000000..b100edb
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/NameClient.cs
@@ -0,0 +1,279 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Codec;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.RX;
+using Org.Apache.Reef.Wake.RX.Impl;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Reactive;
+
+namespace Org.Apache.Reef.IO.Network.Naming
+{
+    /// <summary>
+    /// Client for the Reef name service. 
+    /// Used to register, unregister, and lookup IP Addresses of known hosts.
+    /// </summary>
+    public class NameClient : INameClient
+    {
+        private static Logger _logger = Logger.GetLogger(typeof(NameClient));
+
+        private BlockingCollection<NamingLookupResponse> _lookupResponseQueue;
+        private BlockingCollection<NamingGetAllResponse> _getAllResponseQueue;
+        private BlockingCollection<NamingRegisterResponse> _registerResponseQueue;
+        private BlockingCollection<NamingUnregisterResponse> _unregisterResponseQueue;
+
+        private TransportClient<NamingEvent> _client;
+
+        private NameLookupClient _lookupClient;
+        private NameRegisterClient _registerClient;
+
+        private bool _disposed;
+
+        /// <summary>
+        /// Constructs a NameClient to register, lookup, and unregister IPEndpoints
+        /// with the NameServer.
+        /// </summary>
+        /// <param name="remoteAddress">The ip address of the NameServer</param>
+        /// <param name="remotePort">The port of the NameServer</param>
+        [Inject]
+        public NameClient(
+            [Parameter(typeof(NamingConfigurationOptions.NameServerAddress))] string remoteAddress, 
+            [Parameter(typeof(NamingConfigurationOptions.NameServerPort))] int remotePort)
+        {
+            IPEndPoint remoteEndpoint = new IPEndPoint(IPAddress.Parse(remoteAddress), remotePort);
+            Initialize(remoteEndpoint);
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Constructs a NameClient to register, lookup, and unregister IPEndpoints
+        /// with the NameServer.
+        /// </summary>
+        /// <param name="remoteEndpoint">The endpoint of the NameServer</param>
+        public NameClient(IPEndPoint remoteEndpoint) 
+        {
+            Initialize(remoteEndpoint);
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Synchronously registers the identifier with the NameService.  
+        /// Overwrites the previous mapping if the identifier has already 
+        /// been registered.
+        /// </summary>
+        /// <param name="id">The key used to map the remote endpoint</param>
+        /// <param name="endpoint">The endpoint to map</param>
+        public void Register(string id, IPEndPoint endpoint)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+            if (endpoint == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("endpoint"), _logger);
+            }
+
+            _logger.Log(Level.Info, "Registering id: " + id + ", and endpoint: " + endpoint);
+            _registerClient.Register(id, endpoint);
+        }
+
+        /// <summary>
+        /// Synchronously unregisters the remote identifier with the NameService
+        /// </summary>
+        /// <param name="id">The identifier to unregister</param>
+        public void Unregister(string id)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+
+            _logger.Log(Level.Info, "Unregistering id: " + id);
+            _registerClient.Unregister(id);
+        }
+
+        /// <summary>
+        /// Synchronously looks up the IPEndpoint for the registered identifier.
+        /// </summary>
+        /// <param name="id">The identifier to look up</param>
+        /// <returns>The mapped IPEndpoint for the identifier, or null if
+        /// the identifier has not been registered with the NameService</returns>
+        public IPEndPoint Lookup(string id)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+
+            List<NameAssignment> assignments = Lookup(new List<string> { id });
+            if (assignments != null && assignments.Count > 0)
+            {
+                return assignments.First().Endpoint;
+            }
+
+            return null;
+        }
+
+        /// <summary>
+        /// Synchronously looks up the IPEndpoint for each of the registered identifiers in the list.
+        /// </summary>
+        /// <param name="ids">The list of identifiers to look up</param>
+        /// <returns>The list of NameAssignments representing a pair of identifer
+        /// and mapped IPEndpoint for that identifier.  If any of the requested identifiers
+        /// are not registered with the NameService, their corresponding NameAssignment
+        /// IPEndpoint value will be null.</returns>
+        public List<NameAssignment> Lookup(List<string> ids)
+        {
+            if (ids == null || ids.Count == 0)
+            {
+                Exceptions.Throw(new ArgumentNullException("ids cannot be null or empty"), _logger);
+            }
+
+            _logger.Log(Level.Verbose, "Looking up ids");
+            List<NameAssignment> assignments = _lookupClient.Lookup(ids);
+            if (assignments != null)
+            {
+                return assignments;
+            }
+            Exceptions.Throw(new WakeRuntimeException("NameClient failed to look up ids."), _logger);
+            return null;  //above line will throw exception. So null will never be returned.
+        }
+
+        /// <summary>
+        /// Restart the name client in case of failure.
+        /// </summary>
+        /// <param name="serverEndpoint">The new server endpoint to connect to</param>
+        public void Restart(IPEndPoint serverEndpoint)
+        {
+            _client.Dispose();
+            Initialize(serverEndpoint);
+        }
+
+        /// <summary>
+        /// Releases resources used by NameClient
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+            {
+                return;
+            }
+            if (disposing)
+            {
+                _client.Dispose();
+            }
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Create a new transport client connected to the NameServer at the given remote endpoint.
+        /// </summary>
+        /// <param name="serverEndpoint">The NameServer endpoint to connect to.</param>
+        private void Initialize(IPEndPoint serverEndpoint)
+        {
+            _lookupResponseQueue = new BlockingCollection<NamingLookupResponse>();
+            _getAllResponseQueue = new BlockingCollection<NamingGetAllResponse>();
+            _registerResponseQueue = new BlockingCollection<NamingRegisterResponse>();
+            _unregisterResponseQueue = new BlockingCollection<NamingUnregisterResponse>();
+
+            IObserver<TransportEvent<NamingEvent>> clientHandler = CreateClientHandler();
+            ICodec<NamingEvent> codec = CreateClientCodec();
+            _client = new TransportClient<NamingEvent>(serverEndpoint, codec, clientHandler);
+
+            _lookupClient = new NameLookupClient(_client, _lookupResponseQueue, _getAllResponseQueue);
+            _registerClient = new NameRegisterClient(_client, _registerResponseQueue, _unregisterResponseQueue);
+        }
+
+        /// <summary>
+        /// Create handler to handle async responses from the NameServer.
+        /// </summary>
+        /// <returns>The client handler to manage responses from the NameServer</returns>
+        private IObserver<TransportEvent<NamingEvent>> CreateClientHandler()
+        {
+            PubSubSubject<NamingEvent> subject = new PubSubSubject<NamingEvent>();
+            subject.Subscribe(Observer.Create<NamingLookupResponse>(msg => HandleResponse(_lookupResponseQueue, msg)));
+            subject.Subscribe(Observer.Create<NamingGetAllResponse>(msg => HandleResponse(_getAllResponseQueue, msg)));
+            subject.Subscribe(Observer.Create<NamingRegisterResponse>(msg => HandleResponse(_registerResponseQueue, msg)));
+            subject.Subscribe(Observer.Create<NamingUnregisterResponse>(msg => HandleResponse(_unregisterResponseQueue, msg)));
+            return new ClientObserver(subject);
+        }
+
+        /// <summary>
+        /// Create the codec used to serialize/deserialize NamingEvent messages
+        /// </summary>
+        /// <returns>The serialization codec</returns>
+        private ICodec<NamingEvent> CreateClientCodec()
+        {
+            MultiCodec<NamingEvent> codec = new MultiCodec<NamingEvent>();
+            codec.Register(new NamingLookupRequestCodec(), "org.apache.reef.io.network.naming.serialization.NamingLookupRequest");
+            codec.Register(new NamingLookupResponseCodec(), "org.apache.reef.io.network.naming.serialization.NamingLookupResponse");
+            NamingRegisterRequestCodec requestCodec = new NamingRegisterRequestCodec();
+            codec.Register(requestCodec, "org.apache.reef.io.network.naming.serialization.NamingRegisterRequest");
+            codec.Register(new NamingRegisterResponseCodec(requestCodec), "org.apache.reef.io.network.naming.serialization.NamingRegisterResponse");
+            codec.Register(new NamingUnregisterRequestCodec(), "org.apache.reef.io.network.naming.serialization.NamingUnregisterRequest");
+            return codec;
+        }
+
+        private void HandleResponse<T>(BlockingCollection<T> queue, T message)
+        {
+            queue.Add(message);
+        }
+
+        /// <summary>
+        /// Helper class used to handle response events from the NameServer.
+        /// Delegates the event to the appropriate response queue depending on
+        /// its event type.
+        /// </summary>
+        private class ClientObserver : AbstractObserver<TransportEvent<NamingEvent>>
+        {
+            private IObserver<NamingEvent> _handler;
+
+            public ClientObserver(IObserver<NamingEvent> handler)
+            {
+                _handler = handler;
+            }
+
+            public override void OnNext(TransportEvent<NamingEvent> value)
+            {
+                NamingEvent message = value.Data;
+                message.Link = value.Link;
+                _handler.OnNext(message);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/NameLookupClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/NameLookupClient.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/NameLookupClient.cs
new file mode 100644
index 0000000..9443704
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/NameLookupClient.cs
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Threading;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.Remote.Impl;
+
+namespace Org.Apache.Reef.IO.Network.Naming
+{
+    /// <summary>
+    /// Helper class to send lookup events to the name server
+    /// </summary>
+    internal class NameLookupClient
+    {
+        private TransportClient<NamingEvent> _client;
+        private BlockingCollection<NamingLookupResponse> _lookupResponseQueue;
+        private BlockingCollection<NamingGetAllResponse> _getAllResponseQueue;
+
+        /// <summary>
+        /// Constructs a new NameLookupClient.
+        /// </summary>
+        /// <param name="client">The transport client used to connect to the NameServer</param>
+        /// <param name="lookupQueue">The queue used to signal that a response
+        /// has been received from the NameServer</param>
+        /// <param name="getAllQueue">The queue used to signal that a GetAllResponse 
+        /// has been received from the NameServer</param>
+        public NameLookupClient(TransportClient<NamingEvent> client,
+                                BlockingCollection<NamingLookupResponse> lookupQueue,
+                                BlockingCollection<NamingGetAllResponse> getAllQueue)
+        {
+            _client = client;
+            _lookupResponseQueue = lookupQueue;
+            _getAllResponseQueue = getAllQueue;
+        }
+
+        /// <summary>
+        /// Look up the IPEndPoint that has been registered with the NameServer using
+        /// the given identifier as the key.
+        /// </summary>
+        /// <param name="id">The id for the IPEndPoint</param>
+        /// <param name="token">The cancellation token used for timeout</param>
+        /// <returns>The registered IPEndpoint, or null if the identifer has not 
+        /// been registered with the NameServer or if the operation times out.</returns>
+        public IPEndPoint Lookup(string id, CancellationToken token)
+        {
+            List<string> ids = new List<string> { id };
+            List<NameAssignment> assignment = Lookup(ids);
+            return (assignment == null || assignment.Count == 0) ? null : assignment.First().Endpoint;
+        }
+
+        /// <summary>
+        /// Look up IPEndPoints that have been registered with the NameService
+        /// </summary>
+        /// <param name="ids">The list of ids to look up</param>
+        /// <returns>A list of NameAssignments representing the mapped identifier/IPEndpoint
+        /// pairs</returns>
+        public List<NameAssignment> Lookup(List<string> ids)
+        {
+            _client.Send(new NamingLookupRequest(ids));
+            NamingLookupResponse response = _lookupResponseQueue.Take();
+            return response.NameAssignments;
+        }
+
+        /// <summary>
+        /// Synchronously gets all of the identifier/IPEndpoint pairs registered with the NameService.
+        /// </summary>
+        /// <returns>A list of NameAssignments representing the mapped identifier/IPEndpoint
+        /// pairs</returns>
+        public List<NameAssignment> GetAll()
+        {
+            _client.Send(new NamingGetAllRequest());
+            NamingGetAllResponse response = _getAllResponseQueue.Take();
+            return response.Assignments;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/NameRegisterClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/NameRegisterClient.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/NameRegisterClient.cs
new file mode 100644
index 0000000..4dbf8f4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/NameRegisterClient.cs
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Concurrent;
+using System.Net;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.Remote.Impl;
+
+namespace Org.Apache.Reef.IO.Network.Naming
+{
+    /// <summary>
+    /// Helper class to send register and unregister events to the NameServer.
+    /// </summary>
+    internal class NameRegisterClient
+    {
+        private TransportClient<NamingEvent> _client;
+        private BlockingCollection<NamingRegisterResponse> _registerResponseQueue;
+        private BlockingCollection<NamingUnregisterResponse> _unregisterResponseQueue;
+
+        public NameRegisterClient(TransportClient<NamingEvent> client,
+                                  BlockingCollection<NamingRegisterResponse> registerQueue,
+                                  BlockingCollection<NamingUnregisterResponse> unregisterQueue)
+        {
+            _client = client;
+            _registerResponseQueue = registerQueue;
+            _unregisterResponseQueue = unregisterQueue;
+        }
+
+        /// <summary>
+        /// Synchronously register the id and endpoint with the NameServer.
+        /// </summary>
+        /// <param name="id">The identifier</param>
+        /// <param name="endpoint">The endpoint</param>
+        public void Register(string id, IPEndPoint endpoint)
+        {
+            NameAssignment assignment = new NameAssignment(id, endpoint);
+            _client.Send(new NamingRegisterRequest(assignment));
+            _registerResponseQueue.Take();
+        }
+
+        /// <summary>
+        /// Synchronously unregisters the identifier with the NameServer.
+        /// </summary>
+        /// <param name="id">The identifer to unregister</param>
+        public void Unregister(string id)
+        {
+            _client.Send(new NamingUnregisterRequest(id));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/NameServer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/NameServer.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/NameServer.cs
new file mode 100644
index 0000000..6d79d34
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/NameServer.cs
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Codec;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.IO.Network.Naming.Observers;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.RX;
+using Org.Apache.Reef.Wake.RX.Impl;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+
+namespace Org.Apache.Reef.IO.Network.Naming
+{
+    /// <summary>
+    /// Service that manages names and IPEndpoints for well known hosts.
+    /// Can register, unregister, and look up IPAddresses using a string identifier.
+    /// </summary>
+    public class NameServer : INameServer
+    {
+        private static Logger _logger = Logger.GetLogger(typeof(NameServer));
+
+        private TransportServer<NamingEvent> _server;
+        private Dictionary<string, IPEndPoint> _idToAddrMap;
+
+        /// <summary>
+        /// Create a new NameServer to run on the specified port.
+        /// </summary>
+        /// <param name="port">The port to listen for incoming connections on.</param>
+        [Inject]
+        public NameServer([Parameter(typeof(NamingConfigurationOptions.NameServerPort))] int port)
+        {
+            IObserver<TransportEvent<NamingEvent>> handler = CreateServerHandler();
+            _idToAddrMap = new Dictionary<string, IPEndPoint>();
+            ICodec<NamingEvent> codec = CreateServerCodec();
+
+            // Start transport server, get listening IP endpoint
+            _logger.Log(Level.Info, "Starting naming server");
+            _server = new TransportServer<NamingEvent>(port, handler, codec);
+            _server.Run();
+            LocalEndpoint = _server.LocalEndpoint;
+        }
+
+        public IPEndPoint LocalEndpoint { get; private set; }
+
+        /// <summary>
+        /// Looks up the IPEndpoints for each string identifier
+        /// </summary>
+        /// <param name="ids">The IDs to look up</param>
+        /// <returns>A list of Name assignments representing the identifier
+        /// that was searched for and the mapped IPEndpoint</returns>
+        public List<NameAssignment> Lookup(List<string> ids)
+        {
+            if (ids == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("ids"), _logger);
+            }
+
+            return ids.Where(id => _idToAddrMap.ContainsKey(id))
+                      .Select(id => new NameAssignment(id, _idToAddrMap[id]))
+                      .ToList();
+        }
+
+        /// <summary>
+        /// Gets all of the registered identifier/endpoint pairs.
+        /// </summary>
+        /// <returns>A list of all of the registered identifiers and their
+        /// mapped IPEndpoints</returns>
+        public List<NameAssignment> GetAll()
+        {
+            return _idToAddrMap.Select(pair => new NameAssignment(pair.Key, pair.Value)).ToList();
+        }
+
+        /// <summary>
+        /// Registers the string identifier with the given IPEndpoint
+        /// </summary>
+        /// <param name="id">The string ident</param>
+        /// <param name="endpoint">The mapped endpoint</param>
+        public void Register(string id, IPEndPoint endpoint)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+            if (endpoint == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("endpoint"), _logger);
+            }
+
+            _logger.Log(Level.Info, "Registering id: " + id + ", and endpoint: " + endpoint);
+            _idToAddrMap[id] = endpoint;
+        }
+
+        /// <summary>
+        /// Unregister the given identifier with the NameServer
+        /// </summary>
+        /// <param name="id">The identifier to unregister</param>
+        public void Unregister(string id)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+
+            _logger.Log(Level.Info, "Unregistering id: " + id);
+            _idToAddrMap.Remove(id);
+        }
+
+        /// <summary>
+        /// Stops the NameServer
+        /// </summary>
+        public void Dispose()
+        {
+            _server.Dispose();
+        }
+
+        /// <summary>
+        /// Create the handler to manage incoming NamingEvent types
+        /// </summary>
+        /// <returns>The server handler</returns>
+        private IObserver<TransportEvent<NamingEvent>> CreateServerHandler()
+        {
+            PubSubSubject<NamingEvent> subject = new PubSubSubject<NamingEvent>();
+            subject.Subscribe(new NamingLookupRequestObserver(this));
+            subject.Subscribe(new NamingGetAllRequestObserver(this));
+            subject.Subscribe(new NamingRegisterRequestObserver(this));
+            subject.Subscribe(new NamingUnregisterRequestObserver(this));
+            return new ServerHandler(subject);
+        }
+
+        /// <summary>
+        /// Create the codec used to serialize/deserialize NamingEvent messages
+        /// </summary>
+        /// <returns>The serialization codec</returns>
+        private ICodec<NamingEvent> CreateServerCodec()
+        {
+            MultiCodec<NamingEvent> codec = new MultiCodec<NamingEvent>();
+            codec.Register(new NamingLookupRequestCodec(), "org.apache.reef.io.network.naming.serialization.NamingLookupRequest");
+            codec.Register(new NamingLookupResponseCodec(), "org.apache.reef.io.network.naming.serialization.NamingLookupResponse");
+            NamingRegisterRequestCodec requestCodec = new NamingRegisterRequestCodec();
+            codec.Register(requestCodec, "org.apache.reef.io.network.naming.serialization.NamingRegisterRequest");
+            codec.Register(new NamingRegisterResponseCodec(requestCodec), "org.apache.reef.io.network.naming.serialization.NamingRegisterResponse");
+            codec.Register(new NamingUnregisterRequestCodec(), "org.apache.reef.io.network.naming.serialization.NamingUnregisterRequest");
+            return codec;
+        }
+
+        [NamedParameter("Port for the NameServer to listen on")]
+        public class Port : Name<int>
+        {
+        }
+
+        /// <summary>
+        /// Class used to handle incoming NamingEvent messages.
+        /// Delegates the event to the prescribed handler depending on its type
+        /// </summary>
+        private class ServerHandler : AbstractObserver<TransportEvent<NamingEvent>>
+        {
+            private IObserver<NamingEvent> _handler; 
+
+            public ServerHandler(IObserver<NamingEvent> handler)
+            {
+                _handler = handler;
+            }
+
+            public override void OnNext(TransportEvent<NamingEvent> value)
+            {
+                NamingEvent message = value.Data;
+                message.Link = value.Link;
+                _handler.OnNext(message);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfiguration.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfiguration.cs
new file mode 100644
index 0000000..95ab878
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfiguration.cs
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Naming
+{
+    public class NamingConfiguration : ConfigurationModuleBuilder
+    {
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredParameter<string> NameServerAddress = new RequiredParameter<string>();
+
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")]
+        public static readonly RequiredParameter<int> NameServerPort = new RequiredParameter<int>();
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new NamingConfiguration()
+                    .BindNamedParameter(GenericType<NamingConfigurationOptions.NameServerAddress>.Class, NameServerAddress)
+                    .BindNamedParameter(GenericType<NamingConfigurationOptions.NameServerPort>.Class, NameServerPort)
+                    .Build();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfigurationOptions.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfigurationOptions.cs
new file mode 100644
index 0000000..e010f11
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/NamingConfigurationOptions.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Naming
+{
+    public class NamingConfigurationOptions
+    {
+        [NamedParameter("IP address of NameServer")]
+        public class NameServerAddress : Name<string>
+        {
+        }
+
+        [NamedParameter("Port of NameServer")]
+        public class NameServerPort : Name<int>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingGetAllRequestObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingGetAllRequestObserver.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingGetAllRequestObserver.cs
new file mode 100644
index 0000000..e32ede7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingGetAllRequestObserver.cs
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.RX;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Observers
+{
+    /// <summary>
+    /// Handler for NameService for events of type NamingGetAllRequest. 
+    /// Gets all of the identifiers and their mapped IPEndpoints registered 
+    /// with the NameServer.
+    /// </summary>
+    internal class NamingGetAllRequestObserver : AbstractObserver<NamingGetAllRequest>
+    {
+        private NameServer _server;
+
+        public NamingGetAllRequestObserver(NameServer server)
+        {
+            _server = server;
+        }
+
+        public override void OnNext(NamingGetAllRequest value)
+        {
+            List<NameAssignment> assignments = _server.GetAll();
+            value.Link.Write(new NamingGetAllResponse(assignments));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingLookupRequestObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingLookupRequestObserver.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingLookupRequestObserver.cs
new file mode 100644
index 0000000..07cabc0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingLookupRequestObserver.cs
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.RX;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Observers
+{
+    /// <summary>
+    /// Handler for looking up IPEndpoints registered with the NameServer
+    /// </summary>
+    internal class NamingLookupRequestObserver : AbstractObserver<NamingLookupRequest>
+    {
+        private NameServer _server;
+
+        public NamingLookupRequestObserver(NameServer server)
+        {
+            _server = server;
+        }
+
+        /// <summary>
+        /// Look up the IPEndpoints for the given identifiers and write them
+        /// back to the NameClient
+        /// </summary>
+        /// <param name="value">The lookup request event</param>
+        public override void OnNext(NamingLookupRequest value)
+        {
+            List<NameAssignment> assignments = _server.Lookup(value.Identifiers);
+            value.Link.Write(new NamingLookupResponse(assignments));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingRegisterRequestObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingRegisterRequestObserver.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingRegisterRequestObserver.cs
new file mode 100644
index 0000000..ccce0b3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingRegisterRequestObserver.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.RX;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Observers
+{
+    /// <summary>
+    /// Handler for registering an identifier and endpoint with the Name Service
+    /// </summary>
+    internal class NamingRegisterRequestObserver : AbstractObserver<NamingRegisterRequest>
+    {
+        private NameServer _server;
+
+        public NamingRegisterRequestObserver(NameServer server)
+        {
+            _server = server;
+        }
+
+        /// <summary>
+        /// Register the identifier and IPEndpoint with the NameServer and send 
+        /// the response back to the NameClient
+        /// </summary>
+        /// <param name="value">The register request event</param>
+        public override void OnNext(NamingRegisterRequest value)
+        {
+            NameAssignment assignment = value.NameAssignment;
+            _server.Register(assignment.Identifier, assignment.Endpoint);
+
+            value.Link.Write(new NamingRegisterResponse(value));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingUnregisterRequestObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingUnregisterRequestObserver.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingUnregisterRequestObserver.cs
new file mode 100644
index 0000000..c034269
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Observers/NamingUnregisterRequestObserver.cs
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.RX;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Observers
+{
+    /// <summary>
+    /// Handler for unregistering an identifier with the NameServer
+    /// </summary>
+    internal class NamingUnregisterRequestObserver : AbstractObserver<NamingUnregisterRequest>
+    {
+        private NameServer _server;
+
+        public NamingUnregisterRequestObserver(NameServer server)
+        {
+            _server = server;
+        }
+
+        /// <summary>
+        /// Unregister the identifer with the NameServer.  
+        /// </summary>
+        /// <param name="value">The unregister request event</param>
+        public override void OnNext(NamingUnregisterRequest value)
+        {
+            // Don't send a response
+            _server.Unregister(value.Identifier); 
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Network.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Network.csproj b/lang/cs/Source/REEF/reef-io/Network/Network.csproj
new file mode 100644
index 0000000..6ab99d8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Network.csproj
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{883CE800-6A6A-4E0A-B7FE-C054F4F2C1DC}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.IO.Network</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.IO.Network</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.IO.Network\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.IO.Network\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="protobuf-net">
+      <HintPath>..\..\..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Reactive.Core">
+      <HintPath>..\..\..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Reactive.Interfaces">
+      <HintPath>..\..\..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Naming\Codec\NamingLookupRequestCodec.cs" />
+    <Compile Include="Naming\Codec\NamingLookupResponseCodec.cs" />
+    <Compile Include="Naming\Codec\NamingRegisterRequestCodec.cs" />
+    <Compile Include="Naming\Codec\NamingRegisterResponseCodec.cs" />
+    <Compile Include="Naming\Codec\NamingUnregisterRequestCodec.cs" />
+    <Compile Include="Naming\Contracts\AvroNamingAssignment.cs" />
+    <Compile Include="Naming\Contracts\AvroNamingLookupRequest.cs" />
+    <Compile Include="Naming\Contracts\AvroNamingLookupResponse.cs" />
+    <Compile Include="Naming\Contracts\AvroNamingRegisterRequest.cs" />
+    <Compile Include="Naming\Contracts\AvroNamingUnRegisterRequest.cs" />
+    <Compile Include="Naming\Events\NamingEvent.cs" />
+    <Compile Include="Naming\Events\NamingGetAllRequest.cs" />
+    <Compile Include="Naming\Events\NamingGetAllResponse.cs" />
+    <Compile Include="Naming\Events\NamingLookupRequest.cs" />
+    <Compile Include="Naming\Events\NamingLookupResponse.cs" />
+    <Compile Include="Naming\Events\NamingRegisterRequest.cs" />
+    <Compile Include="Naming\Events\NamingRegisterResponse.cs" />
+    <Compile Include="Naming\Events\NamingUnregisterRequest.cs" />
+    <Compile Include="Naming\Events\NamingUnregisterResponse.cs" />
+    <Compile Include="Naming\INameServer.cs" />
+    <Compile Include="Naming\NameClient.cs" />
+    <Compile Include="Naming\NameLookupClient.cs" />
+    <Compile Include="Naming\NameRegisterClient.cs" />
+    <Compile Include="Naming\NameServer.cs" />
+    <Compile Include="Naming\NamingConfiguration.cs" />
+    <Compile Include="Naming\NamingConfigurationOptions.cs" />
+    <Compile Include="Naming\Observers\NamingGetAllRequestObserver.cs" />
+    <Compile Include="Naming\Observers\NamingLookupRequestObserver.cs" />
+    <Compile Include="Naming\Observers\NamingRegisterRequestObserver.cs" />
+    <Compile Include="Naming\Observers\NamingUnregisterRequestObserver.cs" />
+    <Compile Include="NetworkService\Codec\ControlMessageCodec.cs" />
+    <Compile Include="NetworkService\Codec\NsMessageCodec.cs" />
+    <Compile Include="NetworkService\Codec\NsMessageProto.cs" />
+    <Compile Include="NetworkService\ControlMessage.cs" />
+    <Compile Include="NetworkService\IConnection.cs" />
+    <Compile Include="NetworkService\INetworkService.cs" />
+    <Compile Include="NetworkService\NetworkService.cs" />
+    <Compile Include="NetworkService\NetworkServiceConfiguration.cs" />
+    <Compile Include="NetworkService\NetworkServiceOptions.cs" />
+    <Compile Include="NetworkService\NsConnection.cs" />
+    <Compile Include="NetworkService\NsMessage.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Utilities\BlockingCollectionExtensions.cs" />
+    <Compile Include="Utilities\Utils.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/ControlMessageCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/ControlMessageCodec.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/ControlMessageCodec.cs
new file mode 100644
index 0000000..bfdb708
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/ControlMessageCodec.cs
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService.Codec
+{
+    public class ControlMessageCodec : ICodec<ControlMessage>
+    {
+        [Inject]
+        public ControlMessageCodec()
+        {
+        }
+
+        public byte[] Encode(ControlMessage message)
+        {
+            return BitConverter.GetBytes((int) message);
+        }
+
+        public ControlMessage Decode(byte[] data)
+        {
+            return (ControlMessage) BitConverter.ToInt32(data, 0);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageCodec.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageCodec.cs
new file mode 100644
index 0000000..c2f3f0f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageCodec.cs
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Remote;
+using ProtoBuf;
+using System;
+using System.IO;
+using System.Linq;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService.Codec
+{
+    /// <summary>
+    /// Codec to serialize NsMessages for NetworkService.
+    /// </summary>
+    /// <typeparam name="T">The message type</typeparam>
+    public class NsMessageCodec<T> : ICodec<NsMessage<T>>
+    {
+        private ICodec<T> _codec;
+        private IIdentifierFactory _idFactory;
+
+        /// <summary>
+        /// Create new NsMessageCodec.
+        /// </summary>
+        /// <param name="codec">The codec used to serialize message data</param>
+        /// <param name="idFactory">Used to create identifier from string.</param>
+        public NsMessageCodec(ICodec<T> codec, IIdentifierFactory idFactory)
+        {
+            _codec = codec;
+            _idFactory = idFactory;
+        }
+
+        /// <summary>
+        /// Serialize the NsMessage.
+        /// </summary>
+        /// <param name="obj">The object to serialize</param>
+        /// <returns>The serialized object in byte array form</returns>
+        public byte[] Encode(NsMessage<T> obj)
+        {
+            NsMessageProto proto = NsMessageProto.Create(obj, _codec);
+            using (var stream = new MemoryStream())
+            {
+                Serializer.Serialize(stream, proto);
+                return stream.ToArray();
+            }
+        }
+
+        /// <summary>
+        /// Deserialize the byte array into NsMessage.
+        /// </summary>
+        /// <param name="data">The serialized byte array</param>
+        /// <returns>The deserialized NsMessage</returns>
+        public NsMessage<T> Decode(byte[] data)
+        {
+            using (var stream = new MemoryStream(data))
+            {
+                NsMessageProto proto = Serializer.Deserialize<NsMessageProto>(stream);
+
+                IIdentifier sourceId = _idFactory.Create(proto.SourceId);
+                IIdentifier destId = _idFactory.Create(proto.DestId);
+                NsMessage<T> message = new NsMessage<T>(sourceId, destId);
+
+                var messages = proto.Data.Select(byteArr => _codec.Decode(byteArr));
+                message.Data.AddRange(messages);
+                return message;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageProto.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageProto.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageProto.cs
new file mode 100644
index 0000000..fd03026
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/Codec/NsMessageProto.cs
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Wake.Remote;
+using ProtoBuf;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService.Codec
+{
+    [ProtoContract]
+    public class NsMessageProto
+    {
+        public NsMessageProto()
+        {
+            Data = new List<byte[]>(); 
+        }
+
+        [ProtoMember(1)]
+        public string SourceId { get; set; }
+
+        [ProtoMember(2)]
+        public string DestId { get; set; }
+
+        [ProtoMember(3)]
+        public List<byte[]> Data { get; set; } 
+
+        public static NsMessageProto Create<T>(NsMessage<T> message, ICodec<T> codec)
+        {
+            NsMessageProto proto = new NsMessageProto();
+
+            proto.SourceId = message.SourceId.ToString();
+            proto.DestId = message.DestId.ToString();
+
+            foreach (T item in message.Data)
+            {
+                proto.Data.Add(codec.Encode(item));
+            }
+
+            return proto;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/ControlMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/ControlMessage.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/ControlMessage.cs
new file mode 100644
index 0000000..bd05d56
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/ControlMessage.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.IO.Network.NetworkService
+{
+    public enum ControlMessage
+    {
+        /// <summary>
+        /// default state
+        /// </summary>
+        UNDEFINED = 0,
+
+        /// <summary>
+        /// expecting data to be sent/received
+        /// </summary>
+        RECEIVE = 1,
+
+        /// <summary>
+        /// stop group communications
+        /// </summary>
+        STOP = 2,
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/IConnection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/IConnection.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/IConnection.cs
new file mode 100644
index 0000000..8a09934
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/IConnection.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    /// <summary>
+    /// Represents a connection between two endpoints named by identifiers
+    /// </summary>
+    public interface IConnection<T> : IDisposable
+    {
+        /// <summary>
+        /// Opens the connection
+        /// </summary>
+        void Open();
+
+        /// <summary>
+        /// Writes the object to the connection
+        /// </summary>
+        /// <param name="obj">The message to send</param>
+        void Write(T obj);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/INetworkService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/INetworkService.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/INetworkService.cs
new file mode 100644
index 0000000..bdd0ac9
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/INetworkService.cs
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    /// <summary>
+    /// Network service used for Reef Task communication.
+    /// </summary>
+    /// <typeparam name="T">The message type</typeparam>
+    public interface INetworkService<T> : IService, IDisposable
+    {
+        /// <summary>
+        /// Name client for registering ids
+        /// </summary>
+        INameClient NamingClient { get; }
+
+        /// <summary>
+        /// Open a new connection to the remote host registered to
+        /// the name service with the given identifier
+        /// </summary>
+        /// <param name="destinationId">The identifier of the remote host</param>
+        /// <returns>The IConnection used for communication</returns>
+        IConnection<T> NewConnection(IIdentifier destinationId);
+
+        /// <summary>
+        /// Register the identifier for the NetworkService with the NameService.
+        /// </summary>
+        /// <param name="id">The identifier to register</param>
+        void Register(IIdentifier id);
+
+        /// <summary>
+        /// Unregister the identifier for the NetworkService with the NameService.
+        /// </summary>
+        void Unregister();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkService.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkService.cs
new file mode 100644
index 0000000..89e4151
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkService.cs
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Reactive;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.IO.Network.NetworkService.Codec;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    /// <summary>
+    /// Network service used for Reef Task communication.
+    /// </summary>
+    /// <typeparam name="T">The message type</typeparam>
+    public class NetworkService<T> : INetworkService<T>
+    {
+        private Logger LOGGER = Logger.GetLogger(typeof(NetworkService<>));
+
+        private IRemoteManager<NsMessage<T>> _remoteManager;
+        private IObserver<NsMessage<T>> _messageHandler; 
+        private ICodec<NsMessage<T>> _codec; 
+        private IIdentifier _localIdentifier;
+        private IDisposable _messageHandlerDisposable;
+        private Dictionary<IIdentifier, IConnection<T>> _connectionMap;  
+
+        /// <summary>
+        /// Create a new NetworkFactory.
+        /// </summary>
+        /// <param name="nsPort">The port that the NetworkService will listen on</param>
+        /// <param name="nameServerAddr">The address of the NameServer</param>
+        /// <param name="nameServerPort">The port of the NameServer</param>
+        /// <param name="messageHandler">The observer to handle incoming messages</param>
+        /// <param name="idFactory">The factory used to create IIdentifiers</param>
+        /// <param name="codec">The codec used for serialization</param>
+        [Inject]
+        public NetworkService(
+            [Parameter(typeof(NetworkServiceOptions.NetworkServicePort))] int nsPort,
+            [Parameter(typeof(NamingConfigurationOptions.NameServerAddress))] string nameServerAddr,
+            [Parameter(typeof(NamingConfigurationOptions.NameServerPort))] int nameServerPort,
+            IObserver<NsMessage<T>> messageHandler,
+            IIdentifierFactory idFactory,
+            ICodec<T> codec)
+        {
+            _codec = new NsMessageCodec<T>(codec, idFactory);
+
+            IPAddress localAddress = NetworkUtils.LocalIPAddress;
+            _remoteManager = new DefaultRemoteManager<NsMessage<T>>(localAddress, nsPort, _codec);
+            _messageHandler = messageHandler;
+
+            NamingClient = new NameClient(nameServerAddr, nameServerPort);
+            _connectionMap = new Dictionary<IIdentifier, IConnection<T>>();
+
+            LOGGER.Log(Level.Info, "Started network service");
+        }
+
+        /// <summary>
+        /// Name client for registering ids
+        /// </summary>
+        public INameClient NamingClient { get; private set; }
+
+        /// <summary>
+        /// Open a new connection to the remote host registered to
+        /// the name service with the given identifier
+        /// </summary>
+        /// <param name="destinationId">The identifier of the remote host</param>
+        /// <returns>The IConnection used for communication</returns>
+        public IConnection<T> NewConnection(IIdentifier destinationId)
+        {
+            if (_localIdentifier == null)
+            {
+                throw new IllegalStateException("Cannot open connection without first registering an ID");
+            }
+
+            IConnection<T> connection;
+            if (_connectionMap.TryGetValue(destinationId, out connection))
+            {
+                return connection;
+            }
+
+            connection = new NsConnection<T>(_localIdentifier, destinationId, 
+                NamingClient, _remoteManager, _connectionMap);
+
+            _connectionMap[destinationId] = connection;
+            return connection;
+        }
+
+        /// <summary>
+        /// Register the identifier for the NetworkService with the NameService.
+        /// </summary>
+        /// <param name="id">The identifier to register</param>
+        public void Register(IIdentifier id)
+        {
+            LOGGER.Log(Level.Info, "Registering id {0} with network service.", id);
+
+            _localIdentifier = id;
+            NamingClient.Register(id.ToString(), _remoteManager.LocalEndpoint);
+
+            // Create and register incoming message handler
+            var anyEndpoint = new IPEndPoint(IPAddress.Any, 0);
+            _messageHandlerDisposable = _remoteManager.RegisterObserver(anyEndpoint, _messageHandler);
+        }
+
+        /// <summary>
+        /// Unregister the identifier for the NetworkService with the NameService.
+        /// </summary>
+        public void Unregister()
+        {
+            if (_localIdentifier == null)
+            {
+                throw new IllegalStateException("Cannot unregister a non existant identifier");
+            }
+
+            NamingClient.Unregister(_localIdentifier.ToString());
+            _localIdentifier = null;
+            _messageHandlerDisposable.Dispose();
+        }
+
+        /// <summary>
+        /// Dispose of the NetworkService's resources
+        /// </summary>
+        public void Dispose()
+        {
+            NamingClient.Dispose();
+            _remoteManager.Dispose();
+
+            LOGGER.Log(Level.Info, "Disposed of network service");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceConfiguration.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceConfiguration.cs
new file mode 100644
index 0000000..54da9cb
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceConfiguration.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    public class NetworkServiceConfiguration : ConfigurationModuleBuilder
+    {
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] 
+        public static readonly RequiredParameter<int> NetworkServicePort = new RequiredParameter<int>();
+
+        [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] 
+        public static readonly RequiredImpl<ICodecFactory> NetworkServiceCodecFactory = new RequiredImpl<ICodecFactory>();
+
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new NetworkServiceConfiguration()
+                    .BindNamedParameter(GenericType<NetworkServiceOptions.NetworkServicePort>.Class, NetworkServicePort)
+                    .BindNamedParameter(GenericType<NamingConfigurationOptions.NameServerPort>.Class,
+                                        NamingConfiguration.NameServerPort)
+                    .BindNamedParameter(GenericType<NamingConfigurationOptions.NameServerAddress>.Class,
+                                        NamingConfiguration.NameServerAddress)
+                    .BindImplementation(GenericType<ICodecFactory>.Class, NetworkServiceCodecFactory)
+                    .Build();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceOptions.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceOptions.cs
new file mode 100644
index 0000000..e41e590
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NetworkServiceOptions.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    public class NetworkServiceOptions
+    {
+        [NamedParameter("Port of NetworkService", "NsPort", "0")]
+        public class NetworkServicePort : Name<int>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsConnection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsConnection.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsConnection.cs
new file mode 100644
index 0000000..1752e82
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsConnection.cs
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.Remoting;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    /// <summary>
+    /// Represents a connection between two hosts using the NetworkService.
+    /// </summary>
+    public class NsConnection<T> : IConnection<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(NsConnection<T>));
+
+        private IIdentifier _sourceId;
+        private IIdentifier _destId;
+        private INameClient _nameClient;
+        private IRemoteManager<NsMessage<T>> _remoteManager; 
+        private Dictionary<IIdentifier, IConnection<T>> _connectionMap;
+        private IObserver<NsMessage<T>> _remoteSender;
+
+        /// <summary>
+        /// Creates a new NsConnection between two hosts.
+        /// </summary>
+        /// <param name="sourceId">The identifier of the sender</param>
+        /// <param name="destId">The identifier of the receiver</param>
+        /// <param name="nameClient">The NameClient used for naming lookup</param>
+        /// <param name="remoteManager">The remote manager used for network communication</param>
+        /// <param name="connectionMap">A cache of opened connections.  Will remove itself from
+        /// the cache when the NsConnection is disposed.</param>
+        public NsConnection(
+            IIdentifier sourceId, 
+            IIdentifier destId, 
+            INameClient nameClient,
+            IRemoteManager<NsMessage<T>> remoteManager,
+            Dictionary<IIdentifier, IConnection<T>> connectionMap)
+        {
+            _sourceId = sourceId;
+            _destId = destId;
+            _nameClient = nameClient;
+            _remoteManager = remoteManager;
+            _connectionMap = connectionMap;
+        }
+
+        /// <summary>
+        /// Opens the connection to the remote host.
+        /// </summary>
+        public void Open()
+        {
+            string destStr = _destId.ToString();
+            LOGGER.Log(Level.Verbose, "Network service opening connection to {0}...", destStr);
+
+            IPEndPoint destAddr = _nameClient.Lookup(_destId.ToString());
+            if (destAddr == null)
+            {
+                throw new RemotingException("Cannot register Identifier with NameService");
+            }
+
+            try
+            {
+                _remoteSender = _remoteManager.GetRemoteObserver(destAddr);
+                LOGGER.Log(Level.Verbose, "Network service completed connection to {0}.", destStr);
+            }
+            catch (SocketException)
+            {
+                LOGGER.Log(Level.Error, "Network Service cannot open connection to " + destAddr);
+                throw;
+            }
+            catch (ObjectDisposedException)
+            {
+                LOGGER.Log(Level.Error, "Network Service cannot open connection to " + destAddr);
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// Writes the object to the remote host.
+        /// </summary>
+        /// <param name="message">The message to send</param>
+        public void Write(T message)
+        {
+            if (_remoteSender == null)
+            {
+                throw new IllegalStateException("NsConnection has not been opened yet."); 
+            }
+
+            try
+            {
+                _remoteSender.OnNext(new NsMessage<T>(_sourceId, _destId, message));
+            }
+            catch (IOException)
+            {
+                LOGGER.Log(Level.Error, "Network Service cannot write message to {0}", _destId);
+                throw;
+            }
+            catch (ObjectDisposedException)
+            {
+                LOGGER.Log(Level.Error, "Network Service cannot write message to {0}", _destId);
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// Closes the connection
+        /// </summary>
+        public void Dispose()
+        {
+            _connectionMap.Remove(_destId);
+        }
+    }
+}


[25/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/ClientManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/ClientManager.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/ClientManager.cs
new file mode 100644
index 0000000..3cd3e15
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/ClientManager.cs
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.ClienRuntimeProto;
+using System;
+
+// TODO
+namespace Org.Apache.Reef.Driver
+{
+    public class ClientManager : IObserver<JobControlProto>
+    {
+        public void OnNext(JobControlProto value)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/Constants.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/Constants.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/Constants.cs
new file mode 100644
index 0000000..4e8e68c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/Constants.cs
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class Constants
+    {
+        public const ulong NullHandler = 0;
+
+        public const string ClassHierarachyBin = "clrClassHierarchy.bin";
+
+        public const string GlobalUserSuppliedJavaLibraries = "userSuppliedGlobalLibraries.txt";
+
+        public const int DefaultMemoryGranularity = 1024;
+
+        public const int HandlersNumber = 17;
+
+        public const string EvaluatorRequestorHandler = "EvaluatorRequestor";
+
+        public const string AllocatedEvaluatorHandler = "AllocatedEvaluator";
+
+        public const string CompletedEvaluatorHandler = "CompletedEvaluator";
+
+        public const string ActiveContextHandler = "ActiveContext";
+
+        public const string ClosedContextHandler = "ClosedContext";
+
+        public const string FailedContextHandler = "FailedContext";
+
+        public const string ContextMessageHandler = "ContextMessage";
+
+        public const string TaskMessageHandler = "TaskMessage";
+
+        public const string FailedTaskHandler = "FailedTask";
+
+        public const string RunningTaskHandler = "RunningTask";
+
+        public const string FailedEvaluatorHandler = "FailedEvaluator";
+
+        public const string CompletedTaskHandler = "CompletedTask";
+
+        public const string SuspendedTaskHandler = "SuspendedTask";
+
+        public const string HttpServerHandler = "HttpServerHandler";
+
+        public const string DriverRestartHandler = "DriverRestart";
+
+        public const string DriverRestartActiveContextHandler = "DriverRestartActiveContext";
+
+        public const string DriverRestartRunningTaskHandler = "DriverRestartRunningTask";
+
+        public const string DriverBridgeConfiguration = Common.Constants.ClrBridgeRuntimeConfiguration;
+
+        public const string DriverAppDirectory = "ReefDriverAppDlls";
+
+        public const string BridgeJarFileName = "reef-bridge-0.11.0-incubating-SNAPSHOT-shaded.jar";
+
+        public const string BridgeLaunchClass = "org.apache.reef.javabridge.generic.Launch";
+
+        public const string BridgeLaunchHeadlessClass = "org.apache.reef.javabridge.generic.LaunchHeadless";
+
+        public const string DirectLauncherClass = "org.apache.reef.runtime.common.Launcher";
+
+        public const string JavaToCLRLoggingConfig = "-Djava.util.logging.config.class=org.apache.reef.util.logging.CLRLoggingConfig";
+
+        public const string JavaVerboseLoggingConfig = "-Djava.util.logging.config.class=org.apache.reef.util.logging.Config";
+
+        public static Dictionary<string, int> Handlers
+        {
+            get
+            {
+                return
+                    new Dictionary<string, int>()
+                    {
+                        { EvaluatorRequestorHandler, 0 },
+                        { AllocatedEvaluatorHandler, 1 },
+                        { ActiveContextHandler, 2 },
+                        { TaskMessageHandler, 3 },
+                        { FailedTaskHandler, 4 },
+                        { FailedEvaluatorHandler, 5 },
+                        { HttpServerHandler, 6 },
+                        { CompletedTaskHandler, 7 },
+                        { RunningTaskHandler, 8 },
+                        { SuspendedTaskHandler, 9 },
+                        { CompletedEvaluatorHandler, 10 },
+                        { ClosedContextHandler, 11 },
+                        { FailedContextHandler, 12 },
+                        { ContextMessageHandler, 13 },
+                        { DriverRestartHandler, 14 },
+                        { DriverRestartActiveContextHandler, 15 },
+                        { DriverRestartRunningTaskHandler, 16 },
+                    };
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigGenerator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigGenerator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigGenerator.cs
new file mode 100644
index 0000000..46c56c5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigGenerator.cs
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations.Configuration;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Protobuf;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class DriverConfigGenerator
+    {
+        public const string DriverConfigFile = "driver.config";
+        public const string JobDriverConfigFile = "jobDriver.config";
+        public const string DriverChFile = "driverClassHierarchy.bin";
+        public const string HttpServerConfigFile = "httpServer.config";
+        public const string NameServerConfigFile = "nameServer.config";
+        public const string UserSuppliedGlobalLibraries = "userSuppliedGlobalLibraries.txt";
+
+        private static readonly Logger Log = Logger.GetLogger(typeof(DriverConfigGenerator));
+
+        public static void DriverConfigurationBuilder(DriverConfigurationSettings driverConfigurationSettings)
+        {
+            ExtractConfigFromJar(driverConfigurationSettings.JarFileFolder);
+
+            if (!File.Exists(DriverChFile))
+            {
+                Log.Log(Level.Warning, string.Format(CultureInfo.CurrentCulture, "There is no file {0} extracted from the jar file at {1}.", DriverChFile, driverConfigurationSettings.JarFileFolder));
+                return;
+            }
+
+            if (!File.Exists(HttpServerConfigFile))
+            {
+                Log.Log(Level.Warning, string.Format(CultureInfo.CurrentCulture, "There is no file {0} extracted from the jar file at {1}.", HttpServerConfigFile, driverConfigurationSettings.JarFileFolder));
+                return;
+            }
+
+            if (!File.Exists(JobDriverConfigFile))
+            {
+                Log.Log(Level.Warning, string.Format(CultureInfo.CurrentCulture, "There is no file {0} extracted from the jar file at {1}.", JobDriverConfigFile, driverConfigurationSettings.JarFileFolder));
+                return;
+            }
+
+            if (!File.Exists(NameServerConfigFile))
+            {
+                Log.Log(Level.Warning, string.Format(CultureInfo.CurrentCulture, "There is no file {0} extracted from the jar file at {1}.", NameServerConfigFile, driverConfigurationSettings.JarFileFolder));
+                return;
+            }
+
+            AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+
+            IClassHierarchy drvierClassHierarchy = ProtocolBufferClassHierarchy.DeSerialize(DriverChFile);
+
+            AvroConfiguration jobDriverAvroconfiguration = serializer.AvroDeseriaizeFromFile(JobDriverConfigFile);
+            IConfiguration jobDriverConfiguration = serializer.FromAvro(jobDriverAvroconfiguration, drvierClassHierarchy);
+
+            AvroConfiguration httpAvroconfiguration = serializer.AvroDeseriaizeFromFile(HttpServerConfigFile);
+            IConfiguration httpConfiguration = serializer.FromAvro(httpAvroconfiguration, drvierClassHierarchy);
+
+            AvroConfiguration nameAvroconfiguration = serializer.AvroDeseriaizeFromFile(NameServerConfigFile);
+            IConfiguration nameConfiguration = serializer.FromAvro(nameAvroconfiguration, drvierClassHierarchy);
+
+            IConfiguration merged;
+
+            if (driverConfigurationSettings.IncludingHttpServer && driverConfigurationSettings.IncludingNameServer)
+            {
+                merged = Configurations.MergeDeserializedConfs(jobDriverConfiguration, httpConfiguration, nameConfiguration);
+            } 
+            else if (driverConfigurationSettings.IncludingHttpServer)
+            {
+                merged = Configurations.MergeDeserializedConfs(jobDriverConfiguration, httpConfiguration);                
+            }
+            else if (driverConfigurationSettings.IncludingNameServer)
+            {
+                merged = Configurations.MergeDeserializedConfs(jobDriverConfiguration, nameConfiguration);
+            }
+            else
+            {
+                merged = jobDriverConfiguration;
+            }
+
+            var b = merged.newBuilder();
+
+            b.BindSetEntry("org.apache.reef.driver.parameters.DriverIdentifier", driverConfigurationSettings.DriverIdentifier);
+            b.Bind("org.apache.reef.driver.parameters.DriverMemory", driverConfigurationSettings.DriverMemory.ToString(CultureInfo.CurrentCulture));
+            b.Bind("org.apache.reef.driver.parameters.DriverJobSubmissionDirectory", driverConfigurationSettings.SubmissionDirectory);
+
+            //add for all the globallibaries
+            if (File.Exists(UserSuppliedGlobalLibraries))
+            {
+                var globalLibString = File.ReadAllText(UserSuppliedGlobalLibraries);
+                if (!string.IsNullOrEmpty(globalLibString))
+                {
+                    foreach (string fname in globalLibString.Split(','))
+                    {
+                        b.BindSetEntry("org.apache.reef.driver.parameters.JobGlobalLibraries", fname);
+                    }
+                }
+            }
+
+            foreach (string f in Directory.GetFiles(driverConfigurationSettings.ClrFolder))
+            {
+                b.BindSetEntry("org.apache.reef.driver.parameters.JobGlobalFiles", f);
+            }
+
+            IConfiguration c = b.Build();
+
+            serializer.ToFile(c, DriverConfigFile);
+
+            Log.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "driver.config is written to: {0} {1}.", Directory.GetCurrentDirectory(), DriverConfigFile));
+
+            //additional file for easy to read
+            using (StreamWriter outfile = new StreamWriter(DriverConfigFile + ".txt"))
+            {
+                outfile.Write(serializer.ToString(c));
+            }
+        }
+
+        private static void ExtractConfigFromJar(string jarfileFolder)
+        {
+            string jarfile = jarfileFolder + Constants.BridgeJarFileName;
+            List<string> files = new List<string>();
+            files.Add(DriverConfigGenerator.HttpServerConfigFile);
+            files.Add(DriverConfigGenerator.JobDriverConfigFile);
+            files.Add(DriverConfigGenerator.NameServerConfigFile);
+            files.Add(DriverConfigGenerator.DriverChFile);
+            ClrClientHelper.ExtractConfigfileFromJar(jarfile, files, ".");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigurationSettings.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigurationSettings.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigurationSettings.cs
new file mode 100644
index 0000000..463e983
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverConfigurationSettings.cs
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class DriverConfigurationSettings
+    {
+        // default to "ReefDevClrBridge"
+        private string _driverIdentifier = "ReefDevClrBridge";
+
+        // default to _defaultSubmissionDirectory if not provided
+        private string _submissionDirectory = "reefTmp/job_" + DateTime.Now.Millisecond;
+
+        // deault to 512MB if no value is provided
+        private int _driverMemory = 512;
+
+        // folder path that constains clr dlls used by reef
+        private string _clrFolder = ".";
+
+        // folder that contains jar File provided Byte REEF
+        private string _jarFileFolder = ".";
+
+        // default to true if no value is specified
+        private bool _includeHttpServer = true;
+
+        // default to true if no value is specified
+        private bool _includeNameServer = true;
+
+        /// <summary>
+        /// Memory allocated for driver, default to 512 MB
+        /// </summary>
+        public int DriverMemory
+        {
+            get
+            {
+                return _driverMemory;
+            }
+
+            set
+            {
+                if (value < 0)
+                {
+                    throw new ArgumentException("driver memory cannot be negatvie value.");
+                }
+                _driverMemory = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether including name server in the config file.
+        /// </summary>
+        /// <value>
+        ///   <c>true</c> if [including name server]; otherwise, <c>false</c>.
+        /// </value>
+        public bool IncludingNameServer
+        {
+            get { return _includeNameServer; }
+            set { _includeNameServer = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether including HTTP server in the config file.
+        /// </summary>
+        /// <value>
+        ///   <c>true</c> if [including HTTP server]; otherwise, <c>false</c>.
+        /// </value>
+        public bool IncludingHttpServer
+        {
+            get { return _includeHttpServer; }
+            set { _includeHttpServer = value; }
+        } 
+
+        /// <summary>
+        /// Driver Identifier, default to "ReefDevClrBridge" 
+        /// </summary>
+        public string DriverIdentifier
+        {
+            get { return _driverIdentifier; }
+            set { _driverIdentifier = value; }
+        }
+
+        /// <summary>
+        /// Driver job submission directory in (H)DFS where jar file shall be uploaded, default to a tmp directory with GUID name
+        /// If set by CLR user, the user must guarantee the uniquness of the directory across multiple jobs
+        /// </summary>
+        public string SubmissionDirectory
+        {
+            get { return _submissionDirectory; }
+            set { _submissionDirectory = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets the CLR folder.
+        /// </summary>
+        /// <value>
+        /// The CLR folder.
+        /// </value>
+        public string ClrFolder
+        {
+            get { return this._clrFolder; }
+            set { _clrFolder = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets the jar file folder.
+        /// </summary>
+        /// <value>
+        /// The jar file folder.
+        /// </value>
+        public string JarFileFolder
+        {
+            get { return this._jarFileFolder; }
+            set { _jarFileFolder = value; }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/DriverManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/DriverManager.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverManager.cs
new file mode 100644
index 0000000..b0efc2a
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverManager.cs
@@ -0,0 +1,540 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Common.Exceptions;
+using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Time;
+using Org.Apache.Reef.Wake.Time.Runtime.Event;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class DriverManager : 
+        IEvaluatorRequestor, 
+        IObserver<RuntimeStatusProto>, 
+        IObserver<ResourceStatusProto>,
+        IObserver<ResourceAllocationProto>,
+        IObserver<NodeDescriptorProto>,
+        IObserver<RuntimeStart>,
+        IObserver<RuntimeStop>,
+        IObserver<IdleClock>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DriverManager));
+        
+        private IInjector _injector;
+
+        private IInjectionFuture<IClock> _clockFuture; 
+
+        private ResourceCatalogImpl _resourceCatalog;
+
+        private IInjectionFuture<IResourceRequestHandler> _futureResourceRequestHandler;
+        
+        private Dictionary<string, EvaluatorManager> _evaluators = new Dictionary<string, EvaluatorManager>();
+
+        private EvaluatorHeartBeatSanityChecker _sanityChecker = new EvaluatorHeartBeatSanityChecker();
+
+        private ClientJobStatusHandler _clientJobStatusHandler;
+
+        private IDisposable _heartbeatConnectionChannel;
+
+        private IDisposable _errorChannel;
+
+        private IObserver<RuntimeErrorProto> _runtimeErrorHandler;
+
+        public DriverManager(
+            IInjector injector,
+            ResourceCatalogImpl resourceCatalog,
+            IRemoteManager<REEFMessage> remoteManager,
+            IInjectionFuture<IClock> clockFuture,
+            IInjectionFuture<IResourceRequestHandler> futureResourceRequestHandler,
+            ClientJobStatusHandler clientJobStatusHandler,
+            string clientRId)
+        {
+            _injector = injector;
+            _clockFuture = clockFuture;
+            _resourceCatalog = resourceCatalog;
+            _futureResourceRequestHandler = futureResourceRequestHandler;
+            _clientJobStatusHandler = clientJobStatusHandler;
+
+            _heartbeatConnectionChannel = null;
+            _errorChannel = null;
+            _runtimeErrorHandler = null;
+            LOGGER.Log(Level.Info, "DriverManager instantiated");
+        }
+
+        public IResourceCatalog ResourceCatalog
+        {
+            get
+            {
+                return _resourceCatalog;
+            }
+
+            set
+            {
+            }
+        }
+
+        private RuntimeStatusProto _runtimeStatusProto
+        {
+            get
+            {
+                RuntimeStatusProto proto = new RuntimeStatusProto();
+                proto.state = State.INIT;
+                proto.name = "REEF";
+                proto.outstanding_container_requests = 0;
+                return proto;
+            }
+
+            set
+            {
+                _runtimeStatusProto = value;
+            }
+        }
+
+        public void Submit(IEvaluatorRequest request)
+        {
+            LOGGER.Log(Level.Info, "Got an EvaluatorRequest");
+            ResourceRequestProto proto = new ResourceRequestProto();
+            //TODO: request.size deprecated should use megabytes instead
+            //switch (request.Size)
+            //{
+            //        case EvaluatorRequest.EvaluatorSize.SMALL:
+            //        proto.resource_size = SIZE.SMALL;
+            //        break;
+            //        case EvaluatorRequest.EvaluatorSize.MEDIUM:
+            //        proto.resource_size = SIZE.MEDIUM;
+            //        break;
+            //        case EvaluatorRequest.EvaluatorSize.LARGE:
+            //        proto.resource_size = SIZE.LARGE;
+            //        break;
+            //        case EvaluatorRequest.EvaluatorSize.XLARGE:
+            //        proto.resource_size = SIZE.XLARGE;
+            //        break;
+            //    default:
+            //        throw new InvalidOperationException("invalid request size" + request.Size);
+            //}
+            proto.resource_count = request.Number;
+            if (request.MemoryMegaBytes > 0)
+            {
+                proto.memory_size = request.MemoryMegaBytes;
+            }
+
+            //final ResourceCatalog.Descriptor descriptor = req.getDescriptor();
+            //if (descriptor != null) {
+            //  if (descriptor instanceof RackDescriptor) {
+            //    request.addRackName(descriptor.getName());
+            //  } else if (descriptor instanceof NodeDescriptor) {
+            //    request.addNodeName(descriptor.getName());
+            //  }
+            //}
+
+            //_futureResourceRequestHandler.Get().OnNext(proto);
+        }
+
+        public void Release(EvaluatorManager evaluatorManager)
+        {
+            lock (this)
+            {
+                string evaluatorManagerId = evaluatorManager.Id;
+                if (_evaluators.ContainsKey(evaluatorManagerId))
+                {
+                    _evaluators.Remove(evaluatorManagerId);
+                }
+                else
+                {
+                    var e = new InvalidOperationException("Trying to remove an unknown evaluator manager with id " + evaluatorManagerId);
+                    Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        /// <summary>
+        /// This handles runtime error occurs on the evaluator
+        /// </summary>
+        /// <param name="runtimeErrorProto"></param>
+        public void Handle(RuntimeErrorProto runtimeErrorProto)
+        {
+            FailedRuntime error = new FailedRuntime(runtimeErrorProto);
+            LOGGER.Log(Level.Warning, "Runtime error:" + error);
+
+            EvaluatorException evaluatorException = error.Cause != null
+                ? new EvaluatorException(error.Id, error.Cause.Value)
+                : new EvaluatorException(error.Id, "Runtime error");
+            EvaluatorManager evaluatorManager = null;
+            lock (_evaluators)
+            {
+                if (_evaluators.ContainsKey(error.Id))
+                {
+                    evaluatorManager = _evaluators[error.Id];
+                }
+                else
+                {
+                    LOGGER.Log(Level.Warning, "Unknown evaluator runtime error: " + error.Cause);
+                }
+            }
+            if (null != evaluatorManager)
+            {
+                evaluatorManager.Handle(evaluatorException);
+            }
+        }
+
+        /// <summary>
+        /// A RuntimeStatusProto comes from the ResourceManager layer indicating its current status
+        /// </summary>
+        /// <param name="runtimeStatusProto"></param>
+        public void OnNext(RuntimeStatusProto runtimeStatusProto)
+        {
+            Handle(runtimeStatusProto);
+        }
+
+        /// <summary>
+        /// A ResourceStatusProto message comes from the ResourceManager layer to indicate what it thinks
+        /// about the current state of a given resource. Ideally, we should think the same thing.
+        /// </summary>
+        /// <param name="resourceStatusProto"></param>
+        public void OnNext(ResourceStatusProto resourceStatusProto)
+        {
+            Handle(resourceStatusProto);
+        }
+
+        /// <summary>
+        /// A ResourceAllocationProto indicates a resource allocation given by the ResourceManager layer.
+        /// </summary>
+        /// <param name="resourceAllocationProto"></param>
+        public void OnNext(ResourceAllocationProto resourceAllocationProto)
+        {
+            Handle(resourceAllocationProto);
+        }
+
+        /// <summary>
+        ///  A NodeDescriptorProto defines a new node in the cluster. We should add this to the resource catalog
+        /// so that clients can make resource requests against it.
+        /// </summary>
+        /// <param name="nodeDescriptorProto"></param>
+        public void OnNext(NodeDescriptorProto nodeDescriptorProto)
+        {
+            _resourceCatalog.Handle(nodeDescriptorProto);
+        }
+
+        /// <summary>
+        /// This EventHandler is subscribed to the StartTime event of the Clock statically. It therefore provides the entrance
+        /// point to REEF.
+        /// </summary>
+        /// <param name="runtimeStart"></param>
+        public void OnNext(RuntimeStart runtimeStart)
+        {
+            LOGGER.Log(Level.Info, "RuntimeStart: " + runtimeStart);
+            _runtimeStatusProto = new RuntimeStatusProto();
+            _runtimeStatusProto.state = State.RUNNING;
+            _runtimeStatusProto.name = "REEF";
+            _runtimeStatusProto.outstanding_container_requests = 0;
+        }
+
+        /// <summary>
+        /// Handles RuntimeStop
+        /// </summary>
+        /// <param name="runtimeStop"></param>
+        public void OnNext(RuntimeStop runtimeStop)
+        {
+            LOGGER.Log(Level.Info, "RuntimeStop: " + runtimeStop);
+            if (runtimeStop.Exception != null)
+            {
+                string exceptionMessage = runtimeStop.Exception.Message;
+                LOGGER.Log(Level.Warning, "Sending runtime error:" + exceptionMessage);
+                RuntimeErrorProto runtimeErrorProto = new RuntimeErrorProto();
+                runtimeErrorProto.message = exceptionMessage;
+                runtimeErrorProto.exception = ByteUtilities.StringToByteArrays(exceptionMessage);
+                runtimeErrorProto.name = "REEF";
+                _runtimeErrorHandler.OnNext(runtimeErrorProto);
+
+                LOGGER.Log(Level.Warning, "DONE Sending runtime error: " + exceptionMessage);
+            }
+
+            lock (_evaluators)
+            {
+                foreach (EvaluatorManager evaluatorManager in _evaluators.Values)
+                {
+                    LOGGER.Log(Level.Warning, "Unclean shutdown of evaluator: " + evaluatorManager.Id);
+                    evaluatorManager.Dispose();
+                }
+            }
+
+            try
+            {
+                _heartbeatConnectionChannel.Dispose();
+                _errorChannel.Dispose();
+                Optional<Exception> e = runtimeStop.Exception != null ?
+                    Optional<Exception>.Of(runtimeStop.Exception) : Optional<Exception>.Empty();
+                _clientJobStatusHandler.Dispose(e);
+
+                LOGGER.Log(Level.Info, "driver manager closed");
+            }
+            catch (Exception e)
+            {
+                Exceptions.Caught(e, Level.Error, "Error disposing Driver manager", LOGGER);
+                Exceptions.Throw(new InvalidOperationException("Cannot dispose driver manager"), LOGGER);
+            }
+        }
+
+        public void OnNext(IdleClock value)
+        {
+            string message = string.Format(
+                CultureInfo.InvariantCulture,
+                "IdleClock: [{0}], RuntimeState [{1}], Outstanding container requests [{2}], Container allocation count[{3}]",
+                value + Environment.NewLine,
+                _runtimeStatusProto.state + Environment.NewLine,
+                _runtimeStatusProto.outstanding_container_requests + Environment.NewLine,
+                _runtimeStatusProto.container_allocation.Count);
+            LOGGER.Log(Level.Info, message);
+
+            lock (_evaluators)
+            {
+                if (_runtimeStatusProto.state == State.RUNNING
+                    && _runtimeStatusProto.outstanding_container_requests == 0
+                    && _runtimeStatusProto.container_allocation.Count == 0)
+                {
+                    LOGGER.Log(Level.Info, "Idle runtime shutdown");
+                    _clockFuture.Get().Dispose();
+                }
+            }
+        }
+
+        void IObserver<IdleClock>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<IdleClock>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStop>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStop>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStart>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStart>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<NodeDescriptorProto>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<NodeDescriptorProto>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ResourceAllocationProto>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ResourceAllocationProto>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ResourceStatusProto>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<ResourceStatusProto>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStatusProto>.OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        void IObserver<RuntimeStatusProto>.OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        /// <summary>
+        /// Something went wrong at the runtime layer (either driver or evaluator). This
+        /// method simply forwards the RuntimeErrorProto to the client via the RuntimeErrorHandler.
+        /// </summary>
+        /// <param name="runtimeErrorProto"></param>
+        private void Fail(RuntimeErrorProto runtimeErrorProto)
+        {
+            _runtimeErrorHandler.OnNext(runtimeErrorProto);
+            _clockFuture.Get().Dispose();
+        }
+
+        /// <summary>
+        ///  Helper method to create a new EvaluatorManager instance
+        /// </summary>
+        /// <param name="id">identifier of the Evaluator</param>
+        /// <param name="descriptor"> NodeDescriptor on which the Evaluator executes.</param>
+        /// <returns>new EvaluatorManager instance.</returns>
+        private EvaluatorManager GetNewEvaluatorManagerInstance(string id, EvaluatorDescriptorImpl descriptor)
+        {
+            LOGGER.Log(Level.Info, "Creating Evaluator Manager: " + id);
+            //TODO bindVolatieParameter
+            return (EvaluatorManager)_injector.GetInstance(typeof(EvaluatorManager));
+        }
+
+        /// <summary>
+        ///  Receives and routes heartbeats from Evaluators.
+        /// </summary>
+        /// <param name="evaluatorHearBeatProto"></param>
+        private void Handle(IRemoteMessage<EvaluatorHeartbeatProto> evaluatorHearBeatProto)
+        {
+            EvaluatorHeartbeatProto heartbeat = evaluatorHearBeatProto.Message;
+            EvaluatorStatusProto status = heartbeat.evaluator_status;
+            string evaluatorId = status.evaluator_id;
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Heartbeat from Evaluator {0} with state {1} timestamp {2}", evaluatorId, status.state, heartbeat.timestamp));
+            _sanityChecker.check(evaluatorId, heartbeat.timestamp);
+
+            lock (_evaluators)
+            {
+                if (_evaluators.ContainsKey(evaluatorId))
+                {
+                    EvaluatorManager evaluatorManager = _evaluators[evaluatorId];
+                    evaluatorManager.Handle(evaluatorHearBeatProto);
+                }
+                else
+                {
+                    string msg = "Contact from unkonwn evaluator with id: " + evaluatorId;
+                    if (heartbeat.evaluator_status != null)
+                    {
+                        msg += " with state" + status.state;
+                    }
+                    LOGGER.Log(Level.Error, msg);
+                    Exceptions.Throw(new InvalidOperationException(msg), LOGGER);
+                }
+            }            
+        }
+
+        /// <summary>
+        /// This resource status message comes from the ResourceManager layer; telling me what it thinks
+        /// about the state of the resource executing an Evaluator; This method simply passes the message
+        /// off to the referenced EvaluatorManager
+        /// </summary>
+        /// <param name="resourceStatusProto"></param>
+        private void Handle(ResourceStatusProto resourceStatusProto)
+        {
+            lock (_evaluators)
+            {
+                if (_evaluators.ContainsKey(resourceStatusProto.identifier))
+                {
+                    EvaluatorManager evaluatorManager = _evaluators[resourceStatusProto.identifier];
+                    evaluatorManager.Handle(resourceStatusProto);
+                }
+                else
+                {
+                    var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unknown resource status from evaluator {0} with state {1}", resourceStatusProto.identifier, resourceStatusProto.state));
+                    Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        /// <summary>
+        ///  This method handles resource allocations by creating a new EvaluatorManager instance.
+        /// </summary>
+        /// <param name="resourceAllocationProto"></param>
+        private void Handle(ResourceAllocationProto resourceAllocationProto)
+        {
+            lock (_evaluators)
+            {
+                try
+                {
+                    INodeDescriptor nodeDescriptor = _resourceCatalog.GetNode(resourceAllocationProto.node_id);
+                    if (nodeDescriptor == null)
+                    {
+                        Exceptions.Throw(new InvalidOperationException("Unknown resurce: " + resourceAllocationProto.node_id), LOGGER);
+                    }
+                    EvaluatorDescriptorImpl evaluatorDescriptor = new EvaluatorDescriptorImpl(nodeDescriptor, EvaluatorType.UNDECIDED, resourceAllocationProto.resource_memory, resourceAllocationProto.virtual_cores);
+                    LOGGER.Log(Level.Info, "Resource allocation: new evaluator id: " + resourceAllocationProto.identifier);
+                    EvaluatorManager evaluatorManager = GetNewEvaluatorManagerInstance(resourceAllocationProto.identifier, evaluatorDescriptor);
+                    _evaluators.Add(resourceAllocationProto.identifier, evaluatorManager);
+                }
+                catch (Exception e)
+                {
+                    Exceptions.Caught(e, Level.Error, LOGGER);
+                    Exceptions.Throw(new InvalidOperationException("Error handling resourceAllocationProto."), LOGGER);
+                }
+            }
+        }
+
+        private void Handle(RuntimeStatusProto runtimeStatusProto)
+        {
+            State runtimeState = runtimeStatusProto.state;
+            LOGGER.Log(Level.Info, "Runtime status: " + runtimeStatusProto.state);
+
+            switch (runtimeState)
+            {
+                case State.FAILED:
+                    Fail(runtimeStatusProto.error);
+                    break;
+                case State.DONE:
+                    _clockFuture.Get().Dispose();
+                    break;
+                case State.RUNNING:
+                    lock (_evaluators)
+                    {
+                        _runtimeStatusProto = runtimeStatusProto;
+                        if (_clockFuture.Get().IsIdle()
+                            && runtimeStatusProto.outstanding_container_requests == 0
+                            && runtimeStatusProto.container_allocation.Count == 0)
+                        {
+                            _clockFuture.Get().Dispose();
+                        }
+                    }
+                    break;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfiguration.cs
new file mode 100644
index 0000000..a3dff0e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfiguration.cs
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Client;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class DriverRuntimeConfiguration : ConfigurationModuleBuilder
+    {
+        public static ConfigurationModule ConfigurationModule
+        {
+            get
+            {
+                return new DriverRuntimeConfiguration()
+                // Resource Catalog
+                .BindImplementation(GenericType<IResourceCatalog>.Class, GenericType<ResourceCatalogImpl>.Class)
+
+                // JobMessageObserver
+                //.BindImplementation(GenericType<IEvaluatorRequestor>.Class, GenericType<DriverManager>.Class)
+                .BindImplementation(GenericType<IJobMessageObserver>.Class, GenericType<ClientJobStatusHandler>.Class)
+
+                // JobMessageObserver Wake event handler bindings
+                .BindNamedParameter(GenericType<DriverRuntimeConfigurationOptions.JobMessageHandler>.Class, GenericType<ClientJobStatusHandler>.Class)
+                .BindNamedParameter(GenericType<DriverRuntimeConfigurationOptions.JobExceptionHandler>.Class, GenericType<ClientJobStatusHandler>.Class)
+
+                // Client manager
+                .BindNamedParameter(GenericType<DriverRuntimeConfigurationOptions.JobControlHandler>.Class, GenericType<ClientManager>.Class)
+
+                // Bind the runtime parameters
+                //.BindNamedParameter(GenericType<RuntimeParameters.NodeDescriptorHandler>.Class, GenericType<DriverManager>.Class)
+                //.BindNamedParameter(GenericType<RuntimeParameters.ResourceAllocationHandler>.Class, GenericType<DriverManager>.Class)
+                //.BindNamedParameter(GenericType<RuntimeParameters.ResourceStatusHandler>.Class, GenericType<DriverManager>.Class)
+                //.BindNamedParameter(GenericType<RuntimeParameters.RuntimeStatusHandler>.Class, GenericType<DriverManager>.Class)
+
+                // Bind to the Clock
+                //.BindSetEntry(GenericType<IClock.RuntimeStopHandler>.Class, GenericType<DriverManager>.Class)
+                .Build();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfigurationOptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfigurationOptions.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfigurationOptions.cs
new file mode 100644
index 0000000..5de7856
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverRuntimeConfigurationOptions.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Driver
+{
+    public class DriverRuntimeConfigurationOptions
+    {
+        [NamedParameter(documentation: "Job message handler (see ClientJobStatusHandler)")]
+        public class JobMessageHandler : Name<ClientJobStatusHandler>
+        {
+        }
+
+        [NamedParameter(documentation: "Job exception handler (see ClientJobStatusHandler)")]
+        public class JobExceptionHandler : Name<ClientJobStatusHandler>
+        {
+        }
+
+        [NamedParameter(documentation: "Called when a job control message is received by the client.")]
+        public class JobControlHandler : Name<ClientManager>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/DriverSubmissionSettings.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/DriverSubmissionSettings.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverSubmissionSettings.cs
new file mode 100644
index 0000000..3bdaf6b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/DriverSubmissionSettings.cs
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Driver
+{
+    // TODO: merge with EvaluatorConfigurations class
+    public class DriverSubmissionSettings
+    {
+        // default to "ReefDevClrBridge"
+        private string _driverIdentifier;
+
+        // default to _defaultSubmissionDirectory is not provided
+        private string _submissionDirectory;
+
+        // deault to 512MB if no value is provided
+        private int _driverMemory = 0;
+
+        // default value, client wait till driver exit
+        private int _clientWaitTime = -1;
+
+        // default to submit to driver with driver config
+        private bool _submit = true;
+
+        // default to always update jar before submission
+        private bool _updateJar = true;
+
+        // default to run on local
+        private bool _runOnYarn;
+
+        // default to set to info logging
+        private JavaLoggingSetting _javaLogLevel = JavaLoggingSetting.INFO;
+
+        /// <summary>
+        /// Whether to update jar file with needed dlls before submission
+        /// User can choose to reduce startup time by skipping the update, if jar file already contains all necessary dll
+        /// Note this settig is .NET only, it does not propagate to java side.
+        /// </summary>
+        public bool UpdateJarBeforeSubmission 
+        {
+            get { return _updateJar; }
+            set { _updateJar = value; }
+        }
+
+        /// <summary>
+        /// Determine the vebosity of Java driver's log.
+        /// Note this parameter is used when launching java process only, it does not propagate to java side.
+        /// </summary>
+        public JavaLoggingSetting JavaLogLevel
+        {
+            get { return _javaLogLevel; }
+            set { _javaLogLevel = value; }
+        }
+
+        /// <summary>
+        /// Memory allocated for driver, default to 512 MB
+        /// </summary>
+        public int DriverMemory
+        {
+            get
+            {
+                return _driverMemory;
+            }
+
+            set
+            {
+                if (value < 0)
+                {
+                    throw new ArgumentException("driver memory cannot be negatvie value.");
+                }
+                _driverMemory = value;
+            }
+        }
+
+        /// <summary>
+        /// Driver Identifier, default to "ReefDevClrBridge" 
+        /// </summary>
+        public string DriverIdentifier
+        {
+            get
+            {
+                return _driverIdentifier;
+            }
+
+            set
+            {
+                _driverIdentifier = value;
+            }
+        }
+
+        /// <summary>
+        /// Whether to submit driver with config after driver configuration is construted, default to True
+        /// </summary>
+        public bool Submit
+        {
+            get
+            {
+                return _submit;
+            }
+
+            set
+            {
+                _submit = value;
+            }
+        }
+
+        /// <summary>
+        /// How long client would wait for Driver, default to wait till  driver is done
+        /// </summary>
+        public int ClientWaitTime
+        {
+            get
+            {
+                return _clientWaitTime;
+            }
+
+            set
+            {
+                _clientWaitTime = value;
+            }
+        }
+
+        /// <summary>
+        /// Driver job submission directory in (H)DFS where jar file shall be uploaded, default to a tmp directory with GUID name
+        /// If set by CLR user, the user must guarantee the uniquness of the directory across multiple jobs
+        /// </summary>
+        public string SubmissionDirectory
+        {
+            get
+            {
+                return _submissionDirectory;
+            }
+
+            set
+            {
+                _submissionDirectory = value;
+            }
+        }
+
+        /// <summary>
+        /// Whether to Run on YARN runtime, default to false
+        /// </summary>
+        public bool RunOnYarn
+        {
+            get
+            {
+                return _runOnYarn;
+            }
+
+            set
+            {
+                _runOnYarn = value;
+            }
+        }
+
+        public string ToComamndLineArguments()
+        {
+            return
+                (RunOnYarn ? " -local false" : string.Empty) +
+                (!Submit ? " -submit false" : string.Empty) +
+                (DriverMemory > 0 ? " -driver_memory " + DriverMemory : string.Empty) +
+                (!string.IsNullOrWhiteSpace(DriverIdentifier) ? " -drive_id " + DriverIdentifier : string.Empty) +
+                (ClientWaitTime > 0 ? " -wait_time " + ClientWaitTime : string.Empty) +
+                (!string.IsNullOrWhiteSpace(SubmissionDirectory) ? " -submission_directory " + SubmissionDirectory : string.Empty);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs
new file mode 100644
index 0000000..5dc1ce7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs
@@ -0,0 +1,655 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Common.Exceptions;
+using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Time;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+
+using TaskMessage = Org.Apache.Reef.Tasks.TaskMessage;
+
+namespace Org.Apache.Reef.Driver
+{
+    /// <summary>
+    /// Manages a single Evaluator instance including all lifecycle instances:
+    /// (AllocatedEvaluator, CompletedEvaluator, FailedEvaluator).
+    /// A (periodic) heartbeat channel is established EvaluatorRuntime -> EvaluatorManager.
+    /// The EvaluatorRuntime will (periodically) send (status) messages to the EvaluatorManager using this heartbeat channel.
+    /// A (push-based) EventHandler channel is established EvaluatorManager -> EvaluatorRuntime.
+    /// The EvaluatorManager uses this to forward Driver messages, launch Tasks, and initiate
+    /// control information (e.g., shutdown, suspend).* Manages a single Evaluator instance including all lifecycle instances:
+    /// (AllocatedEvaluator, CompletedEvaluator, FailedEvaluator).
+    /// A (periodic) heartbeat channel is established EvaluatorRuntime -> EvaluatorManager.
+    /// The EvaluatorRuntime will (periodically) send (status) messages to the EvaluatorManager using this heartbeat channel.
+    /// A (push-based) EventHandler channel is established EvaluatorManager -> EvaluatorRuntime.
+    /// The EvaluatorManager uses this to forward Driver messages, launch Tasks, and initiate control information (e.g., shutdown, suspend).
+    /// </summary>
+    public class EvaluatorManager : IDisposable, IIdentifiable
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorManager));
+        
+        private STATE _state = STATE.ALLOCATED;
+
+        private IClock _clock;
+
+        // TODO
+        //  private final RemoteManager remoteManager;
+        private DriverManager _driverManager;
+
+        private IResourceReleaseHandler _resourceReleaseHandler;
+
+        private IResourceLaunchHandler _resourceLaunchHandler;
+
+        private EvaluatorDescriptorImpl _evaluatorDescriptor;
+
+        private string _evaluatorId;
+
+        private IList<EvaluatorContext> _activeContexts = new List<EvaluatorContext>();
+
+        private HashSet<string> _activeContextIds = new HashSet<string>();
+
+        private IRunningTask _runningTask = null;
+
+        private IObserver<EvaluatorControlProto> _evaluatorControlHandler = null;
+
+        private bool _isResourceReleased = false;
+
+        //TODO
+        //private final DispatchingEStage dispatcher;
+        private EvaluatorType _type = EvaluatorType.CLR;
+
+        public EvaluatorManager(
+            IClock clock,
+            //RemoteManager remoteManager,
+            DriverManager driverManager,
+            IResourceReleaseHandler resourceReleaseHandler,
+            IResourceLaunchHandler resourceLaunchHandler,
+            //REEFErrorHandler errorHandler,
+            string evaluatorId,
+            EvaluatorDescriptorImpl evaluatorDescriptor,
+            ISet<IObservable<IActiveContext>> activeContextEventHandler,
+            ISet<IObservable<IClosedContext>> closedContextEventHandlers,
+            ISet<IObservable<FailedContext>> failedContextEventHandlers,
+            ISet<IObservable<ContextMessage>> contextMessageHandlers,
+            ISet<IObservable<IRunningTask>> runningTaskEventHandlers,
+            ISet<IObservable<ICompletedTask>> completedTaskEventHandlers,
+            ISet<IObservable<ISuspendedTask>> suspendedTaskEventHandlers,
+            ISet<IObservable<TaskMessage>> taskMessageEventHandlers,
+            ISet<IObservable<FailedTask>> taskExceptionEventHandlers,
+            ISet<IObservable<IAllocatedEvaluator>> allocatedEvaluatorEventHandlers,
+            ISet<IObservable<IFailedEvaluator>> failedEvaluatorHandlers,
+            ISet<IObservable<ICompletedEvaluator>> completedEvaluatorHandlers)
+        {
+            _clock = clock;
+            //_remoteManager = remoteManager;
+            _driverManager = driverManager;
+            _resourceReleaseHandler = resourceReleaseHandler;
+            _resourceLaunchHandler = resourceLaunchHandler;
+            _evaluatorId = evaluatorId;
+            _evaluatorDescriptor = evaluatorDescriptor;
+
+            //this.dispatcher = new DispatchingEStage(errorHandler, 16); // 16 threads
+
+            //this.dispatcher.register(ActiveContext.class, activeContextEventHandlers);
+            //this.dispatcher.register(ClosedContext.class, closedContextEventHandlers);
+            //this.dispatcher.register(FailedContext.class, failedContextEventHandlers);
+            //this.dispatcher.register(ContextMessage.class, contextMessageHandlers);
+
+            //this.dispatcher.register(RunningTask.class, runningTaskEventHandlers);
+            //this.dispatcher.register(CompletedTask.class, completedTaskEventHandlers);
+            //this.dispatcher.register(SuspendedTask.class, suspendedTaskEventHandlers);
+            //this.dispatcher.register(TaskMessage.class, taskMessageEventHandlers);
+            //this.dispatcher.register(FailedTask.class, taskExceptionEventHandlers);
+
+            //this.dispatcher.register(FailedEvaluator.class, failedEvaluatorHandlers);
+            //this.dispatcher.register(CompletedEvaluator.class, completedEvaluatorHandlers);
+            //this.dispatcher.register(AllocatedEvaluator.class, allocatedEvaluatorEventHandlers);
+
+            //this.dispatcher.onNext(AllocatedEvaluator.class,
+            //    new AllocatedEvaluatorImpl(this, remoteManager.getMyIdentifier()));
+        }
+
+        /// <summary>
+        /// Various states that the EvaluatorManager could be in. The EvaluatorManager is created when a resource has been allocated by the ResourceManager.
+        /// </summary>
+        public enum STATE
+        {
+            ALLOCATED,  // initial state
+            SUBMITTED,  // client called AllocatedEvaluator.submitTask() and we're waiting for first contact
+            RUNNING,    // first contact received, all communication channels established, Evaluator sent to client.
+            DONE,       // clean shutdown
+            FAILED,     // some failure occurred.
+            KILLED      // unclean shutdown
+        }
+
+        public IEvaluatorDescriptor EvaluatorDescriptor
+        {
+            get
+            {
+                return _evaluatorDescriptor;
+            }
+        }
+
+        public INodeDescriptor NodeDescriptor
+        {
+            get
+            {
+                return EvaluatorDescriptor.NodeDescriptor;
+            }
+        }
+
+        public IRunningTask RunningTask
+        {
+            get
+            {
+                lock (_evaluatorDescriptor)
+                {
+                    return _runningTask;
+                }
+            }
+        }
+
+        public string Id
+        {
+            get
+            {
+                return _evaluatorId;
+            }
+
+            set
+            {
+            }
+        }
+
+        public EvaluatorType Type
+        {
+            get
+            {
+                return _type;
+            }
+
+            set
+            {
+                _type = value;
+                _evaluatorDescriptor.EvaluatorType = value;
+            }
+        }
+
+        public void Dispose()
+        {
+            lock (_evaluatorDescriptor)
+            {
+                if (_state == STATE.RUNNING)
+                {
+                    LOGGER.Log(Level.Warning, "Dirty shutdown of running evaluator :" + Id);
+                    try
+                    {
+                        // Killing the evaluator means that it doesn't need to send a confirmation; it just dies.
+                        EvaluatorControlProto proto = new EvaluatorControlProto();
+                        proto.timestamp = DateTime.Now.Ticks;
+                        proto.identifier = Id;
+                        proto.kill_evaluator = new KillEvaluatorProto();
+                        Handle(proto);
+                    }
+                    finally
+                    {
+                        _state = STATE.KILLED;
+                    }
+                }
+            }
+
+            if (!_isResourceReleased)
+            {
+                try
+                {
+                    // We need to wait awhile before returning the container to the RM in order to
+                    // give the EvaluatorRuntime (and Launcher) time to cleanly exit. 
+
+                    // this.clock.scheduleAlarm(100, new EventHandler<Alarm>() {
+                    //@Override
+                    //public void onNext(final Alarm alarm) {
+                    //  EvaluatorManager.this.resourceReleaseHandler.onNext(
+                    //      DriverRuntimeProtocol.ResourceReleaseProto.newBuilder()
+                    //          .setIdentifier(EvaluatorManager.this.evaluatorId).build());
+                }
+                catch (Exception e)
+                {
+                    Exceptions.Caught(e, Level.Warning, "Force resource release because the client closed the clock.", LOGGER);
+                    ResourceReleaseProto proto = new ResourceReleaseProto();
+                    proto.identifier = _evaluatorId;
+                    _resourceReleaseHandler.OnNext(proto);
+                }
+                finally
+                {
+                    _isResourceReleased = true;
+                    _driverManager.Release(this);
+                }
+            }
+        }
+
+        /// <summary>
+        /// EvaluatorException will trigger is FailedEvaluator and state transition to FAILED
+        /// </summary>
+        /// <param name="exception"></param>
+        public void Handle(EvaluatorException exception)
+        {
+            lock (_evaluatorDescriptor)
+            {
+                if (_state >= STATE.DONE)
+                {
+                    return;
+                } 
+                LOGGER.Log(Level.Warning, "Failed Evaluator: " + Id + exception.Message);
+                try
+                {
+                    IList<FailedContext> failedContexts = new List<FailedContext>();
+                    IList<EvaluatorContext> activeContexts = new List<EvaluatorContext>(_activeContexts);
+                    activeContexts = activeContexts.Reverse().ToList();
+                    foreach (EvaluatorContext context in activeContexts)
+                    {
+                        Optional<IActiveContext> parentContext = context.ParentId.IsPresent()
+                            ? Optional<IActiveContext>.Of(GetEvaluatorContext(context.ParentId.Value))
+                            : Optional<IActiveContext>.Empty();
+                        failedContexts.Add(context.GetFailedContext(parentContext, exception));
+                    }
+
+                    //Optional<FailedTask> failedTask = _runningTask != null ? 
+                    //    Optional<FailedTask>.Of(new FailedTask(_runningTask.Id, exception)) : Optional<FailedTask>.Empty();
+                    //LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + failedTask.ToString());
+                    //this.dispatcher.onNext(FailedEvaluator.class, new FailedEvaluatorImpl(
+                    //exception, failedContextList, failedTaskOptional, this.evaluatorId));
+                }
+                catch (Exception e)
+                {
+                    Exceptions.CaughtAndThrow(e, Level.Error, "Exception while handling FailedEvaluator.", LOGGER);
+                }
+                finally
+                {
+                    _state = STATE.FAILED; 
+                    Dispose();
+                }
+            }
+        }
+
+        public void Handle(IRemoteMessage<EvaluatorHeartbeatProto> evaluatorHearBeatProtoMessage)
+        {
+            lock (_evaluatorDescriptor)
+            {
+                EvaluatorHeartbeatProto heartbeatProto = evaluatorHearBeatProtoMessage.Message;
+                if (heartbeatProto.evaluator_status != null)
+                {
+                    EvaluatorStatusProto status = heartbeatProto.evaluator_status;
+                    if (status.error != null)
+                    {
+                        Handle(new EvaluatorException(Id, ByteUtilities.ByteArrarysToString(status.error)));
+                        return;
+                    }
+                    else if (_state == STATE.SUBMITTED)
+                    {
+                        string evaluatorRId = evaluatorHearBeatProtoMessage.Identifier.ToString();
+                        LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorRId);
+                        // TODO
+                        // _evaluatorControlHandler = _remoteManager.getHandler(evaluatorRID, EvaluatorRuntimeProtocol.EvaluatorControlProto.class);
+                        _state = STATE.RUNNING;
+                        LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} is running", _evaluatorId));
+                    }
+                }
+
+                LOGGER.Log(Level.Info, "Evaluator heartbeat: " + heartbeatProto);
+
+                EvaluatorStatusProto evaluatorStatusProto = heartbeatProto.evaluator_status;
+                foreach (ContextStatusProto contextStatusProto in heartbeatProto.context_status)
+                {
+                    Handle(contextStatusProto, heartbeatProto.task_status != null);
+                }
+
+                if (heartbeatProto.task_status != null)
+                {
+                    Handle(heartbeatProto.task_status);
+                }
+
+                if (evaluatorStatusProto.state == State.FAILED)
+                {
+                    _state = STATE.FAILED;
+                    EvaluatorException e = evaluatorStatusProto.error != null ?
+                        new EvaluatorException(_evaluatorId, ByteUtilities.ByteArrarysToString(evaluatorStatusProto.error)) :
+                        new EvaluatorException(_evaluatorId, "unknown cause");
+                    LOGGER.Log(Level.Warning, "Failed evaluator: " + Id + e.Message);
+                    Handle(e);
+                }
+                else if (evaluatorStatusProto.state == State.DONE)
+                {
+                    LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} done", Id));
+                    _state = STATE.DONE;
+
+                  // TODO
+                  // dispatcher.onNext(CompletedEvaluator.class, new CompletedEvaluator() {
+                  //@Override
+                  //public String getId() {
+                  //  return EvaluatorManager.this.evaluatorId;
+                    Dispose();
+                }
+            }
+            LOGGER.Log(Level.Info, "DONE with evaluator heartbeat");
+        }
+
+        public void Handle(ResourceLaunchProto resourceLaunchProto)
+        {
+            lock (_evaluatorDescriptor)
+            {
+                if (_state == STATE.ALLOCATED)
+                {
+                    _state = STATE.SUBMITTED;
+                    _resourceLaunchHandler.OnNext(resourceLaunchProto);
+                }
+                else
+                {
+                    var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Evaluator manager expected {0} state, but instead is in state {1}", STATE.ALLOCATED, _state));
+                    Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Packages the TaskControlProto in an EvaluatorControlProto and forward it to the EvaluatorRuntime
+        /// </summary>
+        /// <param name="contextControlProto"></param>
+        public void Handle(ContextControlProto contextControlProto)
+        {
+            lock (_evaluatorDescriptor)
+            {
+                LOGGER.Log(Level.Info, "Task control message from " + _evaluatorId);
+                EvaluatorControlProto evaluatorControlProto = new EvaluatorControlProto();
+                evaluatorControlProto.timestamp = DateTime.Now.Ticks;
+                evaluatorControlProto.identifier = Id;
+                evaluatorControlProto.context_control = contextControlProto;
+
+                Handle(evaluatorControlProto);
+            }
+        }
+
+        /// <summary>
+        /// Forward the EvaluatorControlProto to the EvaluatorRuntime
+        /// </summary>
+        /// <param name="proto"></param>
+        public void Handle(EvaluatorControlProto proto)
+        {
+            lock (_evaluatorDescriptor)
+            {
+                if (_state == STATE.RUNNING)
+                {
+                    _evaluatorControlHandler.OnNext(proto);
+                }
+                else
+                {
+                    var e = new InvalidOperationException(
+                        string.Format(
+                        CultureInfo.InvariantCulture, 
+                        "Evaluator manager expects to be in {0} state, but instead is in state {1}", 
+                        STATE.RUNNING, 
+                        _state));
+                    Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Resource status information from the (actual) resource manager.
+        /// </summary>
+        /// <param name="resourceStatusProto"></param>
+        public void Handle(ResourceStatusProto resourceStatusProto)
+        {
+            lock (_evaluatorDescriptor)
+            {
+                State resourceState = resourceStatusProto.state;
+                LOGGER.Log(Level.Info, "Resource manager state update: " + resourceState);
+
+                if (resourceState == State.DONE || resourceState == State.FAILED)
+                {
+                    if (_state < STATE.DONE)
+                    {
+                        // something is wrong, I think I'm alive but the resource manager runtime says I'm dead
+                        StringBuilder stringBuilder = new StringBuilder();
+                        stringBuilder.Append(
+                            string.Format(
+                                CultureInfo.InvariantCulture,
+                                "The resource manager informed me that Evaluator {0} is in state {1} but I think I am in {2} state",
+                                _evaluatorId,
+                                resourceState,
+                                _state));
+                        if (resourceStatusProto.diagnostics != null)
+                        {
+                            stringBuilder.Append("Cause: " + resourceStatusProto.diagnostics);
+                        }
+                        if (_runningTask != null)
+                        {
+                            stringBuilder.Append(
+                                string.Format(
+                                    CultureInfo.InvariantCulture,
+                                    "Taskruntime {0} did not complete before this evaluator died.",
+                                    _runningTask.Id));
+                        }
+
+                        // RM is telling me its DONE/FAILED - assuming it has already released the resources
+                        _isResourceReleased = true;
+                        //Handle(new EvaluatorException(_evaluatorId, stringBuilder.ToString(), _runningTask));
+                        _state = STATE.KILLED;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Handle a context status update
+        /// </summary>
+        /// <param name="contextStatusProto"></param>
+        /// <param name="notifyClientOnNewActiveContext"></param>
+        private void Handle(ContextStatusProto contextStatusProto, bool notifyClientOnNewActiveContext)
+        {
+            string contextId = contextStatusProto.context_id;
+            Optional<string> parentId = contextStatusProto.parent_id != null ?
+                Optional<string>.Of(contextStatusProto.parent_id) : Optional<string>.Empty();
+            if (ContextStatusProto.State.READY == contextStatusProto.context_state)
+            {
+                if (!_activeContextIds.Contains(contextId))
+                {
+                    EvaluatorContext evaluatorContext = new EvaluatorContext(this, contextId, parentId);
+                    AddEvaluatorContext(evaluatorContext);
+                    if (notifyClientOnNewActiveContext)
+                    {
+                        LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorContext.ToString());
+                        //TODO
+                        //dispatcher.onNext(ActiveContext.class, context);
+                    }
+                }
+                foreach (ContextStatusProto.ContextMessageProto contextMessageProto in contextStatusProto.context_message)
+                {
+                    byte[] message = contextMessageProto.message;
+                    string sourceId = contextMessageProto.source_id;
+                    LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + sourceId + message);
+                    //        this.dispatcher.onNext(ContextMessage.class,
+                    //new ContextMessageImpl(theMessage, contextID, sourceID));
+                }
+            }
+            else
+            {
+                if (!_activeContextIds.Contains(contextId))
+                {
+                    if (ContextStatusProto.State.FAIL == contextStatusProto.context_state)
+                    {
+                        AddEvaluatorContext(new EvaluatorContext(this, contextId, parentId));
+                    }
+                    else
+                    {
+                        var e = new InvalidOperationException("unknown context signaling state " + contextStatusProto.context_state);
+                        Exceptions.Throw(e, LOGGER);
+                    }
+                }
+            }
+
+            EvaluatorContext context = GetEvaluatorContext(contextId);
+            EvaluatorContext parentContext = context.ParentId.IsPresent() ?
+                GetEvaluatorContext(context.ParentId.Value) : null;
+            RemoveEvaluatorContext(context);
+
+            if (ContextStatusProto.State.FAIL == contextStatusProto.context_state)
+            {
+                // TODO
+                Exception reason = new InvalidOperationException(ByteUtilities.ByteArrarysToString(contextStatusProto.error));
+                Optional<IActiveContext> optionalParentContext = (null == parentContext) ?
+                    Optional<IActiveContext>.Empty() : Optional<IActiveContext>.Of(parentContext);
+                LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + reason.ToString() + optionalParentContext);
+                // TODO
+                //this.dispatcher.onNext(FailedContext.class,
+                //context.getFailedContext(optionalParentContext, reason));
+            }
+            else if (ContextStatusProto.State.DONE == contextStatusProto.context_state)
+            {
+                if (null != parentContext)
+                {
+                    // TODO
+                    //this.dispatcher.onNext(ClosedContext.class, context.getClosedContext(parentContext));
+                }
+                else
+                {
+                    LOGGER.Log(Level.Info, "Root context closed. Evaluator closed will trigger final shutdown.");
+                }
+            }
+            else
+            {
+                var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unknown context state {0} for context {1}", contextStatusProto.context_state, contextId));
+                Exceptions.Throw(e, LOGGER);
+            }
+        }
+
+        /// <summary>
+        /// Handle task status messages.
+        /// </summary>
+        /// <param name="taskStatusProto"></param>
+        private void Handle(TaskStatusProto taskStatusProto)
+        {
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received task {0} status {1}", taskStatusProto.task_id, taskStatusProto.state));
+            string taskId = taskStatusProto.task_id;
+            string contextId = taskStatusProto.context_id;
+            State taskState = taskStatusProto.state;
+
+            if (taskState == State.INIT)
+            {
+                EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId);
+                _runningTask = new RunningTaskImpl(this, taskId, evaluatorContext);
+                // this.dispatcher.onNext(RunningTask.class, this.runningTask);
+            }
+            else if (taskState == State.SUSPEND)
+            {
+                EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId);
+                _runningTask = null;
+                byte[] message = taskStatusProto.result != null ? taskStatusProto.result : null;
+                LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorContext + message.ToString());
+                //this.dispatcher.onNext(SuspendedTask.class, new SuspendedTaskImpl(evaluatorContext, message, taskId));
+            }
+            else if (taskState == State.DONE)
+            {
+                EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId);
+                _runningTask = null;
+                byte[] message = taskStatusProto.result != null ? taskStatusProto.result : null;
+                LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorContext + message.ToString());
+                //this.dispatcher.onNext(CompletedTask.class, new CompletedTaskImpl(evaluatorContext, message, taskId));
+            }
+            else if (taskState == State.FAILED)
+            {
+                _runningTask = null;
+                //EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId);
+                //FailedTask failedTask = taskStatusProto.result != null ?
+                //    new FailedTask(taskId, ByteUtilities.ByteArrarysToString(taskStatusProto.result), Optional<IActiveContext>.Of(evaluatorContext)) :
+                //    new FailedTask(taskId, "Failed task: " + taskState, Optional<IActiveContext>.Of(evaluatorContext));
+                //LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + failedTask.ToString());
+                //this.dispatcher.onNext(FailedTask.class, taskException);
+            }
+            else if (taskStatusProto.task_message.Count > 0)
+            {
+                if (_runningTask != null)
+                {
+                    var e = new InvalidOperationException("runningTask must be null when there are multiple task messages");
+                    Exceptions.Throw(e, LOGGER);
+                }
+                foreach (TaskStatusProto.TaskMessageProto taskMessageProto in taskStatusProto.task_message)
+                {
+                    LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + taskMessageProto.ToString());
+                    //        this.dispatcher.onNext(TaskMessage.class,
+                    //new TaskMessageImpl(taskMessageProto.getMessage().toByteArray(),
+                    //    taskId, contextId, taskMessageProto.getSourceId()));
+                }
+            }
+        }
+
+        private EvaluatorContext GetEvaluatorContext(string id)
+        {
+            foreach (EvaluatorContext context in _activeContexts)
+            {
+                if (context.Id.Equals(id))
+                {
+                    return context;
+                }
+                var e = new InvalidOperationException("Unknown evaluator context with id " + id);
+                Exceptions.Throw(e, LOGGER);
+            }
+            return null;
+        }
+
+        private void AddEvaluatorContext(EvaluatorContext context)
+        {
+            _activeContexts.Add(context);
+            _activeContextIds.Add(context.Id);
+        }
+
+        private void RemoveEvaluatorContext(EvaluatorContext context)
+        {
+            _activeContexts.Remove(context);
+            _activeContextIds.Remove(context.Id);
+        }
+
+        [NamedParameter(documentation: "The Evaluator Identifier.")]
+        public class EvaluatorIdentifier : Name<string>
+        {
+        }
+
+        [NamedParameter(documentation: "The Evaluator Host.")]
+        public class EvaluatorDescriptorName : Name<EvaluatorDescriptorImpl>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs
new file mode 100644
index 0000000..b0cde11
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Driver
+{
+    /// <summary>
+    /// An error message that REEF Client receives when there is a user error in REEF job.
+    /// </summary>
+    public class FailedJob : AbstractFailure
+    {
+        /// <summary>
+        /// Create an error message given the entity ID and Java Exception. All accessor methods are provided by the base class.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="cause"></param>
+        public FailedJob(string id, Exception cause)
+            : base(id, cause)
+        {
+        }
+
+        public new string Id { get; set; }
+
+        public new string Message { get; set; }
+
+        public new Optional<string> Description { get; set; }
+
+        public new Optional<Exception> Cause { get; set; }
+
+        public new Optional<byte[]> Data { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs
new file mode 100644
index 0000000..b0a37dc
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver
+{
+    /// <summary>
+    /// empty driver interface to facilitate referencing driver dll
+    /// </summary>
+    public interface IDriver
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs
new file mode 100644
index 0000000..64ea1f4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver
+{
+    public interface IStartHandler
+    {
+        string Identifier { get; set; }
+    }
+}
\ No newline at end of file


[21/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskRunningHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskRunningHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskRunningHandler.cs
new file mode 100644
index 0000000..0811967
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskRunningHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    ///  Default event handler for TaskRuntime: Logging it.
+    /// </summary>
+    public class DefaultTaskRunningHandler : IObserver<IRunningTask>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultTaskRunningHandler));
+        
+        [Inject]
+        public DefaultTaskRunningHandler()
+        {
+        }
+
+        public void OnNext(IRunningTask runningTask)
+        {
+            LOGGER.Log(Level.Info, "Received TaskRuntime: " + runningTask.Id);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskSuspensionHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskSuspensionHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskSuspensionHandler.cs
new file mode 100644
index 0000000..328b745
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/defaults/DefaultTaskSuspensionHandler.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Driver.Defaults
+{
+    /// <summary>
+    /// Default event handler used for SuspendedTask: It crashes the driver.
+    /// </summary>
+    public class DefaultTaskSuspensionHandler : IObserver<ISuspendedTask>
+    {
+        [Inject]
+        public DefaultTaskSuspensionHandler()
+        {
+        }
+
+        public void OnNext(ISuspendedTask value)
+        {
+            Exceptions.Throw(new InvalidOperationException("No handler bound for SuspendedTask: " + value.Id), Logger.GetLogger(typeof(DefaultTaskSuspensionHandler)));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorDescriptorImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorDescriptorImpl.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorDescriptorImpl.cs
new file mode 100644
index 0000000..a43337e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorDescriptorImpl.cs
@@ -0,0 +1,218 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    public class EvaluatorDescriptorImpl : IEvaluatorDescriptor
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorDescriptorImpl));
+        
+        private INodeDescriptor _nodeDescriptor;
+
+        private EvaluatorType _type;
+
+        private int _megaBytes;
+
+        private int _virtualCore;
+
+        private string _rack = "default_rack";
+
+        public EvaluatorDescriptorImpl(string serializedString)
+        {
+            FromString(serializedString);
+        }
+
+        public EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core)
+        {
+            _nodeDescriptor = nodeDescriptor;
+            _type = type;
+            _megaBytes = megaBytes;
+            _virtualCore = core;
+        }
+
+        public INodeDescriptor NodeDescriptor 
+        {
+            get
+            {
+                return _nodeDescriptor;
+            }
+
+            set
+            {
+            }
+        }
+
+        public EvaluatorType EvaluatorType
+        {
+            get
+            {
+                return _type;
+            }
+
+            set
+            {
+            }
+        }
+
+        public int Memory
+        {
+            get
+            {
+                return _megaBytes;
+            }
+
+            set
+            {
+            }
+        }
+
+        public int VirtualCore
+        {
+            get
+            {
+                return _virtualCore;
+            }
+
+            set
+            {
+            }
+        }
+
+        public string Rack
+        {
+            get
+            {
+                return _rack;
+            }
+
+            set
+            {
+            }
+        }
+
+        public void FromString(string str)
+        {
+            Dictionary<string, string> settings = new Dictionary<string, string>();
+            string[] components = str.Split(',');
+            foreach (string component in components)
+            {
+                string[] pair = component.Trim().Split('=');
+                if (pair == null || pair.Length != 2)
+                {
+                    var e = new ArgumentException("invalid component to be used as key-value pair:", component);
+                    Exceptions.Throw(e, LOGGER);
+                }
+                settings.Add(pair[0], pair[1]);
+            }
+            string ipAddress;
+            if (!settings.TryGetValue("IP", out ipAddress))
+            {
+                Exceptions.Throw(new ArgumentException("cannot find IP entry"), LOGGER); 
+            }
+            ipAddress = ipAddress.Split('/').Last();
+            string port;
+            if (!settings.TryGetValue("Port", out port))
+            {
+                Exceptions.Throw(new ArgumentException("cannot find Port entry"), LOGGER); 
+            }
+            int portNumber = 0;
+            int.TryParse(port, out portNumber);
+            string hostName;
+            if (!settings.TryGetValue("HostName", out hostName))
+            {
+                Exceptions.Throw(new ArgumentException("cannot find HostName entry"), LOGGER); 
+            }
+            string memory;
+            if (!settings.TryGetValue("Memory", out memory))
+            {
+                Exceptions.Throw(new ArgumentException("cannot find Memory entry"), LOGGER);
+            }
+            int memoryInMegaBytes = 0;
+            int.TryParse(memory, out memoryInMegaBytes);
+
+            string core;
+            if (!settings.TryGetValue("Core", out core))
+            {
+                Exceptions.Throw(new ArgumentException("cannot find Core entry"), LOGGER);
+            }
+            int vCore = 0;
+            int.TryParse(core, out vCore);
+
+            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress), portNumber);
+
+            _nodeDescriptor = new NodeDescriptorImpl();
+            _nodeDescriptor.InetSocketAddress = ipEndPoint;
+            _nodeDescriptor.HostName = hostName;        
+            _type = EvaluatorType.CLR;
+            _megaBytes = memoryInMegaBytes;
+            _virtualCore = vCore;
+        }
+
+        public void SetType(EvaluatorType type)
+        {
+            lock (this)
+            {
+                if (_type != EvaluatorType.UNDECIDED)
+                {
+                    var e = new InvalidOperationException("Cannot change a set evaluator type: " + _type);
+                    Exceptions.Throw(e, LOGGER);
+                }
+                _type = type;
+            }
+        }
+
+        public override bool Equals(object obj)
+        {
+            EvaluatorDescriptorImpl other = obj as EvaluatorDescriptorImpl;
+            if (other == null)
+            {
+                return false;
+            }
+
+            return EquivalentMemory(other);
+            // we don't care about rack now;
+            // && string.Equals(_rack, other.Rack, StringComparison.OrdinalIgnoreCase);
+        }
+
+        public override int GetHashCode()
+        {
+            return base.GetHashCode();
+        }
+
+        private bool EquivalentMemory(EvaluatorDescriptorImpl other)
+        {
+            int granularity = ClrHandlerHelper.MemoryGranularity == 0
+                                  ? Constants.DefaultMemoryGranularity
+                                  : ClrHandlerHelper.MemoryGranularity;
+            int m1 = (Memory - 1) / granularity;
+            int m2 = (other.Memory - 1 ) / granularity;
+            return (m1 == m2);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequest.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequest.cs
new file mode 100644
index 0000000..fda7d5b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequest.cs
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Driver.Evaluator;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.Reef.Driver.Bridge
+{
+    [DataContract]
+    public class EvaluatorRequest : IEvaluatorRequest
+    {
+        public EvaluatorRequest() 
+            : this(0, 0, 1, string.Empty, Guid.NewGuid().ToString("N"))
+        {
+        }
+
+        public EvaluatorRequest(int number, int megaBytes) 
+            : this(number, megaBytes, 1, string.Empty, Guid.NewGuid().ToString("N"))
+        {
+        }
+
+        public EvaluatorRequest(int number, int megaBytes, int core)
+            : this(number, megaBytes, core, string.Empty, Guid.NewGuid().ToString("N"))
+        {
+        }
+
+        public EvaluatorRequest(int number, int megaBytes, string rack)
+            : this(number, megaBytes, 1, rack, Guid.NewGuid().ToString("N"))
+        {
+        }
+
+        public EvaluatorRequest(int number, int megaBytes, int core, string rack)
+            : this(number, megaBytes, core, rack, Guid.NewGuid().ToString("N"))
+        {
+        }
+
+        public EvaluatorRequest(int number, int megaBytes, int core, string rack, string evaluatorBatchId)
+        {
+            Number = number;
+            MemoryMegaBytes = megaBytes;
+            VirtualCore = core;
+            Rack = rack;
+            EvaluatorBatchId = evaluatorBatchId;
+        }
+
+        public EvaluatorRequest(int number, int megaBytes, int core, List<ICapability> capabilitieses, IResourceCatalog catalog)
+        {
+            Number = number;
+            MemoryMegaBytes = megaBytes;
+            Capabilities = capabilitieses;
+            VirtualCore = core;
+            Catalog = catalog;
+            EvaluatorBatchId = Guid.NewGuid().ToString("N");
+        }
+
+        [DataMember]
+        public string InstanceId { get; set; }
+
+        [DataMember]
+        public int MemoryMegaBytes { get; set; }
+
+        [DataMember]
+        public int Number { get; set; }
+        
+        [DataMember]
+        public int VirtualCore { get; set; }
+
+        [DataMember]
+        public string Rack { get; set; }
+
+        [DataMember]
+        public string EvaluatorBatchId { get; set; }
+
+        public List<ICapability> Capabilities { get; set; }
+
+        public IResourceCatalog Catalog { get; set; }
+
+        public static EvaluatorRequestBuilder NewBuilder()
+        {
+            return new EvaluatorRequestBuilder();
+        }
+
+        public static EvaluatorRequestBuilder NewBuilder(EvaluatorRequest request)
+        {
+            return new EvaluatorRequestBuilder(request);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequestBuilder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequestBuilder.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequestBuilder.cs
new file mode 100644
index 0000000..475d9af
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/EvaluatorRequestBuilder.cs
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Driver.Bridge;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    public class EvaluatorRequestBuilder
+    {
+        public EvaluatorRequestBuilder(EvaluatorRequest request)
+        {
+            foreach (ICapability capability in request.Capabilities)
+            {
+                Capabilities.Add(capability);
+            }
+            Number = request.Number;
+            Catalog = request.Catalog;
+            MegaBytes = request.MemoryMegaBytes;
+            VirtualCore = request.VirtualCore;
+        }
+
+        internal EvaluatorRequestBuilder()
+        {
+        }
+
+        public int Number { get; set; }
+
+        public List<ICapability> Capabilities { get; set; }
+
+        public IResourceCatalog Catalog { get; set; }
+
+        public int MegaBytes { get; set; }
+
+        public int VirtualCore { get; set; }
+
+        public EvaluatorRequest Build()
+        {
+            return new EvaluatorRequest(Number, MegaBytes, VirtualCore, Capabilities, Catalog);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IAllocatedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IAllocatedEvaluator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IAllocatedEvaluator.cs
new file mode 100644
index 0000000..ce2bf08
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IAllocatedEvaluator.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Utilities;
+using System;
+using System.Net;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    /// <summary>
+    /// Represents an Evaluator that is allocated, but is not running yet.
+    /// </summary>
+    public interface IAllocatedEvaluator : IDisposable, IIdentifiable, IContextSubmittable, IContextAndTaskSubmittable
+    {
+        EvaluatorType Type { get; set; }
+
+        string NameServerInfo { get; set; }
+
+        string EvaluatorBatchId { get; set; }
+
+        IEvaluatorDescriptor GetEvaluatorDescriptor();
+
+        /// <summary>
+        /// Puts the given file into the working directory of the Evaluator.
+        /// </summary>
+        /// <param name="file">the file to be copied</param>
+        void AddFile(string file);
+
+        /// <summary>
+        /// Puts the given file into the working directory of the Evaluator and adds it to its classpath.
+        /// </summary>
+        /// <param name="file">the file to be copied</param>
+        void AddLibrary(string file);
+
+        void AddFileResource(string file);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/ICompletedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/ICompletedEvaluator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/ICompletedEvaluator.cs
new file mode 100644
index 0000000..5c5fb62
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/ICompletedEvaluator.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    /// <summary>
+    /// Represents an Evaluator that has completed
+    /// </summary>
+    public interface ICompletedEvaluator : IIdentifiable
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorDescriptor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorDescriptor.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorDescriptor.cs
new file mode 100644
index 0000000..29e822f
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorDescriptor.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Catalog;
+using Org.Apache.Reef.Common.Evaluator;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    /// <summary>
+    ///  Metadata about an Evaluator.
+    /// </summary>
+    public interface IEvaluatorDescriptor
+    {
+        /// <summary>
+        ///  NodeDescriptor of the node where this Evaluator is running.
+        /// </summary>
+        INodeDescriptor NodeDescriptor { get; set; }
+
+        /// <summary>
+        /// type of Evaluator.
+        /// </summary>
+        EvaluatorType EvaluatorType { get; set; }
+
+        /// <summary>
+        /// the amount of memory allocated to this Evaluator.
+        /// </summary>
+        int Memory { get; set; }
+
+        /// <summary>
+        /// the virtual core allocated to this Evaluator.
+        /// </summary>
+        int VirtualCore { get; set; }
+
+        /// <summary>
+        /// rack on which the evaluator was allocated
+        /// </summary>
+        string Rack { get; set; }
+
+        void FromString(string str);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequest .cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequest .cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequest .cs
new file mode 100644
index 0000000..4a9633a
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequest .cs	
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Capabilities;
+using Org.Apache.Reef.Common.Catalog;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    public interface IEvaluatorRequest
+    {
+        int MemoryMegaBytes { get; set; }
+
+        int Number { get;  set; }
+
+        int VirtualCore { get; set; }
+
+        string Rack { get; set; }
+
+        string EvaluatorBatchId { get; set; }
+
+        List<ICapability> Capabilities { get; set; }
+
+        IResourceCatalog Catalog { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequestor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequestor.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequestor.cs
new file mode 100644
index 0000000..e562f96
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IEvaluatorRequestor.cs
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+
+using Org.Apache.Reef.Common.Catalog;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    /// <summary>
+    /// Interface through which Evaluators can be requested.
+    /// </summary>
+    public interface IEvaluatorRequestor
+    {
+        /// <summary>
+        /// Access to the {@link ResourceCatalog} for the cluster this Factory has access to
+        /// </summary>
+        IResourceCatalog ResourceCatalog { get; set; }
+
+        /// <summary>
+        /// Map between user evaluator id and evaluator information
+        /// </summary>
+        //IDictionary<string, IEvaluatorDescriptor> Evaluators { get; }
+
+        /// <summary>
+        /// Submit the request for new evaluator. The response will surface in the AllocatedEvaluator message handler.
+        /// </summary>
+        /// <param name="request"></param>
+        void Submit(IEvaluatorRequest request);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IFailedEvaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IFailedEvaluator.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IFailedEvaluator.cs
new file mode 100644
index 0000000..328d3ca
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/evaluator/IFailedEvaluator.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Exceptions;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Driver.Evaluator
+{
+    /// <summary>
+    /// Represents an Evaluator that became unavailable.
+    /// </summary>
+    public interface IFailedEvaluator : IIdentifiable
+    {
+        EvaluatorException EvaluatorException { get; set; }
+
+        List<FailedContext> FailedContexts { get; set; }
+
+        Optional<IFailedTask> FailedTask { get; set; }
+
+        IEvaluatorRequestor GetEvaluatorRequetor();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/packages.config b/lang/cs/Source/REEF/reef-common/ReefDriver/packages.config
new file mode 100644
index 0000000..933b7e1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/packages.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/task/ICompletedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/task/ICompletedTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/task/ICompletedTask.cs
new file mode 100644
index 0000000..336fd5c
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/task/ICompletedTask.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Task
+{
+    public interface ICompletedTask : IMessage, IIdentifiable
+    {
+         IActiveContext ActiveContext { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/task/IFailedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/task/IFailedTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/task/IFailedTask.cs
new file mode 100644
index 0000000..f85f28d
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/task/IFailedTask.cs
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Api;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver.Task
+{
+    public interface IFailedTask : IAbstractFailure
+    {
+        Optional<IActiveContext> GetActiveContext();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/task/IRunningTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/task/IRunningTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/task/IRunningTask.cs
new file mode 100644
index 0000000..7870777
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/task/IRunningTask.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities;
+using System;
+
+namespace Org.Apache.Reef.Driver.Task
+{
+    /// <summary>
+    /// Represents a running Task
+    /// </summary>
+    public interface IRunningTask : IIdentifiable, IDisposable
+    {
+        /// <summary>
+        /// the context the task is running on.
+        /// </summary>
+        IActiveContext ActiveContext { get; set; }
+
+        /// <summary>
+        /// Sends the message to the running task.
+        /// </summary>
+        /// <param name="message"></param>
+        void OnNext(byte[] message);
+
+        /// <summary>
+        /// Sends the message
+        /// </summary>
+        /// <param name="message"></param>
+        void Send(byte[] message);
+
+        /// <summary>
+        ///  Signal the task to suspend.
+        /// </summary>
+        /// <param name="message">a message that is sent to the Task.</param>
+        void Suspend(byte[] message);
+
+        /// <summary>
+        /// Sends the message to the running task.
+        /// </summary>
+        void Suspend();
+
+        /// <summary>
+        /// Signal the task to shut down.
+        /// </summary>
+        /// <param name="message">a message that is sent to the Task.</param>
+        void Dispose(byte[] message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/task/ISuspendedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/task/ISuspendedTask.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/task/ISuspendedTask.cs
new file mode 100644
index 0000000..c6b769a
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/task/ISuspendedTask.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities;
+
+namespace Org.Apache.Reef.Driver
+{
+    public interface ISuspendedTask : IMessage, IIdentifiable
+    {
+        IActiveContext ActiveContext { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/task/ITaskMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/task/ITaskMessage.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/task/ITaskMessage.cs
new file mode 100644
index 0000000..e6fb7a1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/task/ITaskMessage.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Driver.Task
+{
+    public interface ITaskMessage
+    {
+        byte[] Message { get; set; }
+
+        string TaskId { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefDriver/task/RunningTaskImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/task/RunningTaskImpl.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/task/RunningTaskImpl.cs
new file mode 100644
index 0000000..277e742
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefDriver/task/RunningTaskImpl.cs
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Utilities.Logging;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Driver.Task
+{
+   public class RunningTaskImpl : IRunningTask
+   {
+       private static readonly Logger LOGGER = Logger.GetLogger(typeof(RunningTaskImpl));
+       
+       private string _id;
+
+       private EvaluatorManager _evaluatorManager;
+
+       private EvaluatorContext _evaluatorContext;
+
+       public RunningTaskImpl(EvaluatorManager evaluatorManager, string taskId, EvaluatorContext evaluatorContext)
+       {
+           LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "INIT: TaskRuntime id [{0}] on evaluator id [{1}]", taskId, evaluatorManager.Id));
+           _id = taskId;
+           _evaluatorManager = evaluatorManager;
+           _evaluatorContext = evaluatorContext;
+       }
+
+       public string Id
+       {
+           get
+           {
+               return _id;
+           }
+
+           set
+           {
+           }
+       }
+
+       public IActiveContext ActiveContext
+       {
+           get
+           {
+               return _evaluatorContext;
+           }
+
+           set
+           {
+           }
+       }
+
+       public void Dispose()
+       {
+           LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "DISPOSE: TaskRuntime id [{0}] on evaluator id [{1}]", _id, _evaluatorManager.Id));
+           ContextControlProto contextControlProto = new ContextControlProto();
+           contextControlProto.stop_task = new StopTaskProto();
+           _evaluatorManager.Handle(contextControlProto);
+       }
+
+       public void Dispose(byte[] message)
+       {
+           LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "DISPOSE: TaskRuntime id [{0}] on evaluator id [{1}] with message", _id, _evaluatorManager.Id));
+           ContextControlProto contextControlProto = new ContextControlProto();
+           contextControlProto.stop_task = new StopTaskProto();
+           contextControlProto.task_message = message;
+           _evaluatorManager.Handle(contextControlProto);
+       }
+
+       public void OnNext(byte[] message)
+       {
+           LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "MESSAGE: TaskRuntime id [{0}] on evaluator id [{1}]", _id, _evaluatorManager.Id));
+           ContextControlProto contextControlProto = new ContextControlProto();
+           contextControlProto.task_message = message;
+           _evaluatorManager.Handle(contextControlProto);
+       }
+
+       public void Suspend(byte[] message)
+       {
+           LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "SUSPEND: TaskRuntime id [{0}] on evaluator id [{1}] with message", _id, _evaluatorManager.Id));
+           ContextControlProto contextControlProto = new ContextControlProto();
+           contextControlProto.suspend_task = new SuspendTaskProto();
+           contextControlProto.task_message = message;
+           _evaluatorManager.Handle(contextControlProto);
+       }
+
+       public void Suspend()
+       {
+           LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "SUSPEND: TaskRuntime id [{0}] on evaluator id [{1}]", _id, _evaluatorManager.Id));
+           ContextControlProto contextControlProto = new ContextControlProto();
+           contextControlProto.suspend_task = new SuspendTaskProto();
+           _evaluatorManager.Handle(contextControlProto);
+       }
+
+       public override string ToString()
+       {
+           return "TaskRuntime with taskId = " + _id;
+       }
+
+       public override int GetHashCode()
+       {
+           return _id.GetHashCode();
+       }
+
+       public void Send(byte[] message)
+       {
+           LOGGER.Log(Level.Info, "RunningTaskImpl.Send() is called");
+       }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloCLRBridge.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloCLRBridge.csproj b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloCLRBridge.csproj
new file mode 100644
index 0000000..09c8b0b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloCLRBridge.csproj
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{A78DD8E8-31D0-4506-8738-DAA9DA86D55B}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Examples.HelloCLRBridge</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Examples.HelloCLRBridge</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Examples.HelloCLRBridge\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Examples.HelloCLRBridge\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="handlers\AnotherHelloAllocatedEvaluatorHandler.cs" />
+    <Compile Include="handlers\HelloActiveContextHandler.cs" />
+    <Compile Include="handlers\HelloAllocatedEvaluatorHandler.cs" />
+    <Compile Include="handlers\HelloCompletedEvaluatorHandler.cs" />
+    <Compile Include="handlers\HelloDriverRestartActiveContextHandler.cs" />
+    <Compile Include="handlers\HelloDriverRestartRunningTaskHandler.cs" />
+    <Compile Include="handlers\HelloEvaluatorRequestorHandler.cs" />
+    <Compile Include="handlers\HelloFailedEvaluatorHandler.cs" />
+    <Compile Include="handlers\HelloFailedTaskHandler.cs" />
+    <Compile Include="handlers\HelloHttpHandler.cs" />
+    <Compile Include="handlers\HelloRestartHandler.cs" />
+    <Compile Include="handlers\HelloRunningTaskHandler.cs" />
+    <Compile Include="handlers\HelloSimpleEventHandlers.cs" />
+    <Compile Include="handlers\HelloStartHandler.cs" />
+    <Compile Include="handlers\HelloTaskMessageHandler.cs" />
+    <Compile Include="HelloTraceListener.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefDriver\ReefDriver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>ReefDriver</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-io\NetWork\NetWork.csproj">
+      <Project>{883ce800-6a6a-4e0a-b7fe-c054f4f2c1dc}</Project>
+      <Name>NetWork</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-tasks\Tasks\Tasks.csproj">
+      <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+      <Name>Tasks</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloTraceListener.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloTraceListener.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloTraceListener.cs
new file mode 100644
index 0000000..18bcd7b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/HelloTraceListener.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System.Diagnostics;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    /// <summary>
+    /// This is a sample implemenation on how custom trace listner can be implemented
+    /// </summary>
+    public class HelloTraceListener : TraceListener
+    {
+        private TraceListener _listener;
+
+        [Inject]
+        public HelloTraceListener()
+        {
+            _listener = new ConsoleTraceListener();
+        }
+
+        public override void Write(string message)
+        {
+            _listener.Write("[helloTrace]" + message );
+        }
+
+        public override void WriteLine(string message)
+        {
+            _listener.WriteLine("[helloTrace]" + message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..6c1a298
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HelloCLRBridge")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HelloCLRBridge")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("aedd2853-36a1-4a95-ac5c-1535374fa90c")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/AnotherHelloAllocatedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/AnotherHelloAllocatedEvaluatorHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/AnotherHelloAllocatedEvaluatorHandler.cs
new file mode 100644
index 0000000..5fff7b0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/AnotherHelloAllocatedEvaluatorHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class AnotherHelloAllocatedEvaluatorHandler : IObserver<IAllocatedEvaluator>
+    {
+        [Inject]
+        public AnotherHelloAllocatedEvaluatorHandler()
+        {
+        }
+
+        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
+        {
+            Console.WriteLine("I am just here for the ride.");
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloActiveContextHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloActiveContextHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloActiveContextHandler.cs
new file mode 100644
index 0000000..98cf687
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloActiveContextHandler.cs
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloActiveContextHandler : IObserver<IActiveContext>
+    {
+        [Inject]
+        public HelloActiveContextHandler()
+        {
+        }
+
+        public void OnNext(IActiveContext activeContext)
+        {
+            Console.WriteLine(
+                string.Format(
+                    CultureInfo.InvariantCulture,
+                    "Active context {0} received from evaluator {1}",
+                    activeContext.Id,
+                    activeContext.EvaluatorId));
+
+            IEvaluatorDescriptor evaluatorDescriptor = activeContext.EvaluatorDescriptor;
+            string ipAddress = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Address.ToString();
+            int port = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Port;
+            string hostName = evaluatorDescriptor.NodeDescriptor.HostName;
+
+            Console.WriteLine(
+                string.Format(
+                CultureInfo.InvariantCulture, 
+                "The running evaluator is assigned with {0} MB of memory and is running at ip: {1} and port {2}, with hostname {3}", 
+                evaluatorDescriptor.Memory, 
+                ipAddress, 
+                port, 
+                hostName));
+
+            IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
+                .Set(TaskConfiguration.Identifier, "bridgeCLRHelloTask_" + DateTime.Now.Ticks)
+                .Set(TaskConfiguration.Task, GenericType<HelloTask>.Class)
+                .Set(TaskConfiguration.OnMessage, GenericType<HelloTask.HelloDriverMessageHandler>.Class)
+                .Set(TaskConfiguration.OnSendMessage, GenericType<HelloTaskMessage>.Class)
+                .Build();
+
+            activeContext.SubmitTask(taskConfiguration);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloAllocatedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloAllocatedEvaluatorHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloAllocatedEvaluatorHandler.cs
new file mode 100644
index 0000000..a4e4d46
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloAllocatedEvaluatorHandler.cs
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Implementations.Configuration;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloAllocatedEvaluatorHandler : IObserver<IAllocatedEvaluator>
+    {
+        [Inject]
+        public HelloAllocatedEvaluatorHandler()
+        {
+        }
+
+        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
+        {
+            string control = string.Empty;
+
+            ISet<string> arguments = ClrHandlerHelper.GetCommandLineArguments();
+
+            if (arguments != null && arguments.Any())
+            {
+                foreach (string argument in arguments)
+                {
+                    Console.WriteLine("testing argument: " + argument);
+                }
+
+                control = arguments.Last();
+            }
+
+            IEvaluatorDescriptor descriptor = allocatedEvaluator.GetEvaluatorDescriptor();
+
+            IConfiguration serviceConfiguration = ServiceConfiguration.ConfigurationModule
+                .Set(ServiceConfiguration.Services, GenericType<HelloService>.Class)
+                .Build();
+
+            IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule
+                .Set(ContextConfiguration.Identifier, "bridgeHelloCLRContextId_" + Guid.NewGuid().ToString("N"))
+                .Build();
+
+            IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
+                .Set(TaskConfiguration.Identifier, "bridgeHelloCLRTaskId_" + Guid.NewGuid().ToString("N"))
+                .Set(TaskConfiguration.Task, GenericType<HelloTask>.Class)
+                .Set(TaskConfiguration.OnMessage, GenericType<HelloTask.HelloDriverMessageHandler>.Class)
+                .Set(TaskConfiguration.OnSendMessage, GenericType<HelloTaskMessage>.Class)
+                .Build();
+
+            IConfiguration mergedTaskConfiguration = taskConfiguration;
+
+            if (allocatedEvaluator.NameServerInfo != null)
+            {
+                IPEndPoint nameServerEndpoint = NetUtilities.ParseIpEndpoint(allocatedEvaluator.NameServerInfo);
+
+                IConfiguration nameClientConfiguration = TangFactory.GetTang().NewConfigurationBuilder(
+                    NamingConfiguration.ConfigurationModule
+                                       .Set(NamingConfiguration.NameServerAddress, nameServerEndpoint.Address.ToString())
+                                       .Set(NamingConfiguration.NameServerPort,
+                                            nameServerEndpoint.Port.ToString(CultureInfo.InvariantCulture))
+                                       .Build())
+                                                                    .BindImplementation(GenericType<INameClient>.Class,
+                                                                                        GenericType<NameClient>.Class)
+                                                                    .Build();
+
+                mergedTaskConfiguration = Configurations.Merge(taskConfiguration, nameClientConfiguration);
+            }
+
+            string ipAddress = descriptor.NodeDescriptor.InetSocketAddress.Address.ToString();
+            int port = descriptor.NodeDescriptor.InetSocketAddress.Port;
+            string hostName = descriptor.NodeDescriptor.HostName;
+            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Alloated evaluator {0} with ip {1}:{2}. Hostname is {3}", allocatedEvaluator.Id, ipAddress, port, hostName));
+            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Evaluator is assigned with {0} MB of memory and {1} cores.", descriptor.Memory, descriptor.VirtualCore));
+
+            if (control.Equals("submitContext", StringComparison.OrdinalIgnoreCase))
+            {
+                allocatedEvaluator.SubmitContext(contextConfiguration);
+            }
+            else if (control.Equals("submitContextAndServiceAndTask", StringComparison.OrdinalIgnoreCase))
+            {
+                allocatedEvaluator.SubmitContextAndServiceAndTask(contextConfiguration, serviceConfiguration, mergedTaskConfiguration);
+            }
+            else
+            {
+                // default behavior
+                allocatedEvaluator.SubmitContextAndTask(contextConfiguration, mergedTaskConfiguration);
+            }
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloCompletedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloCompletedEvaluatorHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloCompletedEvaluatorHandler.cs
new file mode 100644
index 0000000..3eeef00
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloCompletedEvaluatorHandler.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.Handlers
+{
+    /// <summary>
+    /// Sample implementaion of RunningTaskHandler
+    /// </summary>
+    public class HelloCompletedEvaluatorHandler : IObserver<ICompletedEvaluator>
+    {
+        [Inject]
+        public HelloCompletedEvaluatorHandler()
+        {
+        }
+
+        public void OnNext(ICompletedEvaluator completedEvaluator)
+        {
+            string messageStr = string.Format(
+                CultureInfo.InvariantCulture,
+                "HelloCompletedEvaluatorHandler: Evaluator [{0}] is done.",
+                completedEvaluator.Id);
+            Console.WriteLine(messageStr);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartActiveContextHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartActiveContextHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartActiveContextHandler.cs
new file mode 100644
index 0000000..f60daf2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartActiveContextHandler.cs
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloDriverRestartActiveContextHandler : IObserver<IActiveContext>
+    {
+        [Inject]
+        public HelloDriverRestartActiveContextHandler()
+        {
+        }
+
+        public void OnNext(IActiveContext activeContext)
+        {
+            Console.WriteLine(
+                string.Format(
+                    CultureInfo.InvariantCulture,
+                    "Active context {0} received after driver restart, from evaluator {1}",
+                    activeContext.Id,
+                    activeContext.EvaluatorId));
+
+            IEvaluatorDescriptor evaluatorDescriptor = activeContext.EvaluatorDescriptor;
+            string ipAddress = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Address.ToString();
+            int port = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Port;
+            string hostName = evaluatorDescriptor.NodeDescriptor.HostName;
+
+            Console.WriteLine(
+                string.Format(
+                CultureInfo.InvariantCulture, 
+                "The running evaluator allocated by previous driver is assigned with {0} MB of memory and is running at ip: {1} and port {2}, with hostname {3}", 
+                evaluatorDescriptor.Memory, 
+                ipAddress, 
+                port, 
+                hostName));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartRunningTaskHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartRunningTaskHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartRunningTaskHandler.cs
new file mode 100644
index 0000000..26f72b8
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloDriverRestartRunningTaskHandler.cs
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.Handlers
+{
+    /// <summary>
+    /// Sample implementaion of RunningTaskHandler
+    /// </summary>
+    public class HelloDriverRestartRunningTaskHandler : IObserver<IRunningTask>
+    {
+        [Inject]
+        public HelloDriverRestartRunningTaskHandler()
+        {
+        }
+
+        public void OnNext(IRunningTask runningTask)
+        {
+            IActiveContext context = runningTask.ActiveContext;
+
+            Console.WriteLine(string.Format(
+                CultureInfo.InvariantCulture,
+                "HelloDriverRestartRunningTaskHandler: Task [{0}] is running after driver restart. Evaluator id: [{1}].",
+                runningTask.Id,
+                context.EvaluatorId));
+
+            runningTask.Send(ByteUtilities.StringToByteArrays(
+                string.Format(
+                CultureInfo.InvariantCulture,
+                "Hello, task {0}! Glad to know that you are still running in Evaluator {1} after driver restart!",
+                runningTask.Id,
+                context.EvaluatorId)));
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloEvaluatorRequestorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloEvaluatorRequestorHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloEvaluatorRequestorHandler.cs
new file mode 100644
index 0000000..08f2308
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloEvaluatorRequestorHandler.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Evaluator;
+using System;
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloEvaluatorRequestorHandler : IObserver<IEvaluatorRequestor>
+    {
+        [Inject]
+        public HelloEvaluatorRequestorHandler()
+        {
+        }
+
+        public void OnNext(IEvaluatorRequestor evalutorRequestor)
+        {
+            int evaluatorsNumber = 1;
+            int memory = 512;
+            int core = 2;
+            string rack = "WonderlandRack";
+            string evaluatorBatchId = "evaluatorThatRequires512MBofMemory";
+            EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, core, rack, evaluatorBatchId);
+
+            evalutorRequestor.Submit(request);
+
+            evaluatorsNumber = 1;
+            memory = 1999;
+            core = 2;
+            rack = "WonderlandRack";
+            evaluatorBatchId = "evaluatorThatRequires1999MBofMemory";
+            request = new EvaluatorRequest(evaluatorsNumber, memory, core, rack, evaluatorBatchId);
+            evalutorRequestor.Submit(request);
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedEvaluatorHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedEvaluatorHandler.cs
new file mode 100644
index 0000000..22732e6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedEvaluatorHandler.cs
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloFailedEvaluatorHandler : IObserver<IFailedEvaluator>
+    {
+        private static int _failureCount = 0;
+
+        private static int _maxTrial = 2;
+
+        [Inject]
+        public HelloFailedEvaluatorHandler()
+        {
+        }
+
+        public void OnNext(IFailedEvaluator failedEvaluator)
+        {
+            Console.WriteLine("Receive a failed evaluator: " + failedEvaluator.Id);
+            if (++_failureCount < _maxTrial)
+            {
+                Console.WriteLine("Requesting another evaluator");
+                EvaluatorRequest newRequest = new EvaluatorRequest(1, 512, "somerack");
+                IEvaluatorRequestor requestor = failedEvaluator.GetEvaluatorRequetor();
+                if (failedEvaluator.GetEvaluatorRequetor() != null)
+                {
+                    requestor.Submit(newRequest);
+                }
+            }
+            else
+            {
+                Console.WriteLine("Exceed max retries number");
+                throw new Exception("Unrecoverable evaluator failure.");
+            }
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedTaskHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedTaskHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedTaskHandler.cs
new file mode 100644
index 0000000..541a419
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloFailedTaskHandler.cs
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+    public class HelloFailedTaskHandler : IObserver<IFailedTask>
+    {
+        [Inject]
+        public HelloFailedTaskHandler()
+        {
+        }
+
+        public void OnNext(IFailedTask failedTask)
+        {
+            string errorMessage = string.Format(
+                CultureInfo.InvariantCulture,
+                "Task [{0}] has failed caused by [{1}], with message [{2}] and description [{3}]. The raw data for failure is [{4}].",
+                failedTask.Id,
+                failedTask.Reason.IsPresent() ? failedTask.Reason.Value : string.Empty,
+                failedTask.Message,
+                failedTask.Description.IsPresent() ? failedTask.Description.Value : string.Empty,
+                failedTask.Data.IsPresent() ? ByteUtilities.ByteArrarysToString(failedTask.Data.Value) : string.Empty);
+
+            Console.WriteLine(errorMessage);
+
+            if (failedTask.GetActiveContext().IsPresent())
+            {
+                Console.WriteLine("Disposing the active context the failed task ran in.");
+
+                // we must do something here: either close the context or resubmit a task to the active context
+                failedTask.GetActiveContext().Value.Dispose();
+            }
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}


[02/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/RootImplementation.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/RootImplementation.cs b/lang/cs/Tests/TangTests/SmokeTest/RootImplementation.cs
new file mode 100644
index 0000000..4e07e43
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/RootImplementation.cs
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class RootImplementation : IRootInterface
+    {
+        private readonly string requiredString;
+        private readonly string optionalString;
+        private readonly IAnInterface anInterface;
+        private readonly int anInt;
+        private readonly double aDouble;
+        private readonly InjectableClass injectableClass;
+        private readonly SetOfImplementations setOfImplementations;
+        private readonly SetOfBaseTypes setOfBaseTypes;
+        //private readonly ListOfBaseTypes listOfBaseTypes;  //TODO: to recover once Avro NuGet support it
+        private readonly CyclicDependency cyclicDependency;
+
+        [Inject]
+        public RootImplementation([Parameter(typeof(TestConfigurationModuleBuilder.RequiredString))] string requiredString,
+                                  [Parameter(typeof(TestConfigurationModuleBuilder.OptionalString))] string optionalString,
+                                  [Parameter(typeof(TestConfigurationModuleBuilder.NamedParameterInteger))] int anInt,
+                                  [Parameter(typeof(TestConfigurationModuleBuilder.NamedParameterDouble))] double aDouble,
+                                  IAnInterface anInterface,
+                                  InjectableClass injectableClass,
+                                  SetOfImplementations setOfImplementations,
+                                  SetOfBaseTypes setOfBaseTypes,
+                                  //ListOfBaseTypes listOfBaseTypes, //TODO: to recover once Avro NuGet support it
+                                  CyclicDependency cyclicDependency) 
+        {
+                                this.requiredString = requiredString;
+                                this.optionalString = optionalString;
+                                this.anInterface = anInterface;
+                                this.anInt = anInt;
+                                this.aDouble = aDouble;
+                                this.injectableClass = injectableClass;
+                                this.setOfImplementations = setOfImplementations;
+                                this.setOfBaseTypes = setOfBaseTypes;
+                                //this.listOfBaseTypes = listOfBaseTypes;  //TODO: to recover once Avro NuGet support it
+                                this.cyclicDependency = cyclicDependency;
+        }
+
+        public bool IsValid()
+        {
+            if (!this.setOfImplementations.isValid())
+            {
+                return false;
+            }
+
+            if (!this.requiredString.Equals(TestConfigurationModuleBuilder.RequiredStringValue))
+            {
+                return false;
+            }
+
+            if (!this.optionalString.Equals(TestConfigurationModuleBuilder.OptionaStringValue))
+            {
+                return false;
+            }
+
+            if (this.anInterface == null)
+            {
+                return false;
+            }
+
+            if (this.aDouble != TestConfigurationModuleBuilder.NamedParameterDoubleValue)
+            {
+                return false;
+            }
+
+            if (this.anInt != TestConfigurationModuleBuilder.NamedParameterIntegerValue)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override bool Equals(object o)
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null)
+            {
+                return false;
+            }
+
+            RootImplementation that = (RootImplementation)o;
+            
+            if (that.aDouble != aDouble)
+            {
+                return false;
+            }
+
+            if (anInt != that.anInt)
+            {
+                return false;
+            }
+
+            if (anInterface != null ? !anInterface.Equals(that.anInterface) : that.anInterface != null)
+            {
+                return false;
+            }
+
+            if (optionalString != null ? !optionalString.Equals(that.optionalString) : that.optionalString != null)
+            {
+                return false;
+            }
+
+            if (requiredString != null ? !requiredString.Equals(that.requiredString) : that.requiredString != null)
+            {
+                return false;
+            }
+
+            if (injectableClass != null ? !injectableClass.Equals(that.injectableClass) : that.injectableClass != null)
+            {
+                return false;
+            }
+
+            if (setOfImplementations != null
+                    ? !setOfImplementations.Equals(that.setOfImplementations)
+                    : that.setOfImplementations != null)
+            {
+                return false;
+            }
+
+            if (setOfBaseTypes != null ? !setOfBaseTypes.Equals(that.setOfBaseTypes) : that.setOfBaseTypes != null)
+            {
+                return false;
+            }
+
+            //TODO: to recover once Avro NuGet support it
+            //if (listOfBaseTypes != null ? !listOfBaseTypes.Equals(that.listOfBaseTypes) : that.listOfBaseTypes != null)
+            //{
+            //    return false;
+            //}
+            if (cyclicDependency != null
+                    ? !cyclicDependency.Equals(that.cyclicDependency)
+                    : that.cyclicDependency != null)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            int result;
+            result = requiredString != null ? requiredString.GetHashCode() : 0;
+            result = (31 * result) + (optionalString != null ? optionalString.GetHashCode() : 0);
+            result = (31 * result) + (anInterface != null ? anInterface.GetHashCode() : 0);
+            result = (31 * result) + anInt;
+            result = (31 * result) + aDouble.GetHashCode();
+            return result;
+       }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/RootInterface.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/RootInterface.cs b/lang/cs/Tests/TangTests/SmokeTest/RootInterface.cs
new file mode 100644
index 0000000..fa87f16
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/RootInterface.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public interface IRootInterface
+    {
+        bool IsValid();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/RoundTripTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/RoundTripTest.cs b/lang/cs/Tests/TangTests/SmokeTest/RoundTripTest.cs
new file mode 100644
index 0000000..36ead9c
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/RoundTripTest.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    [TestClass]
+    public abstract class RoundTripTest
+    {
+        public abstract IConfiguration RoundTrip(IConfiguration configuration);
+
+        [TestMethod]
+        public void TestRoundTrip() 
+        {
+            IConfiguration conf = ObjectTreeTest.GetConfiguration();
+            IRootInterface before = TangFactory.GetTang().NewInjector(conf).GetInstance<IRootInterface>();
+            IRootInterface after = TangFactory.GetTang().NewInjector(RoundTrip(conf)).GetInstance<IRootInterface>();
+            Assert.AreEqual(before, after, "Configuration conversion to and from Avro datatypes failed.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/SetInterface.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/SetInterface.cs b/lang/cs/Tests/TangTests/SmokeTest/SetInterface.cs
new file mode 100644
index 0000000..51cff2c
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/SetInterface.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    /**
+     * Interface used for the set injecttion test.
+     */
+    interface ISetInterface : IComparable
+    {
+        void AMethod();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplOne.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplOne.cs b/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplOne.cs
new file mode 100644
index 0000000..a5c8630
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplOne.cs
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class SetInterfaceImplOne : ISetInterface
+    {
+        private readonly int magicNumber;
+
+        [Inject]
+        public SetInterfaceImplOne() 
+        {
+            this.magicNumber = 42;
+        }
+
+        public void AMethod() 
+        {
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null || !(o is SetInterfaceImplOne))
+            {
+                return false;
+            }
+
+            SetInterfaceImplOne that = (SetInterfaceImplOne)o;
+
+            if (magicNumber != that.magicNumber)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            return magicNumber;
+        }
+
+        public int CompareTo(object obj)
+        {
+            if (this == obj)
+            {
+                return 0;
+            }
+
+            if (obj == null || !(obj is SetInterfaceImplOne))
+            {
+                return -1;
+            }
+
+            SetInterfaceImplOne that = (SetInterfaceImplOne)obj;
+
+            return magicNumber.CompareTo(that.magicNumber);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplTwo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplTwo.cs b/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplTwo.cs
new file mode 100644
index 0000000..859778b
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/SetInterfaceImplTwo.cs
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class SetInterfaceImplTwo : ISetInterface
+    {
+        private readonly double magicNumber;
+
+        [Inject]
+        SetInterfaceImplTwo() 
+        {
+            this.magicNumber = 42.0;
+        }
+
+        public void AMethod() 
+        {
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null || !(o is SetInterfaceImplTwo))
+            {
+                return false;
+            }
+
+            SetInterfaceImplTwo that = (SetInterfaceImplTwo)o;
+
+            if (that.magicNumber.CompareTo(magicNumber) != 0)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            return magicNumber.GetHashCode();
+        }
+
+        public int CompareTo(object obj)
+        {
+            if (this == obj)
+            {
+                return 0;
+            }
+
+            if (obj == null || !(obj is SetInterfaceImplTwo))
+            {
+                return -1;
+            }
+
+            SetInterfaceImplTwo that = (SetInterfaceImplTwo)obj;
+
+            return that.magicNumber.CompareTo(magicNumber);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/SetOfBaseTypes.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/SetOfBaseTypes.cs b/lang/cs/Tests/TangTests/SmokeTest/SetOfBaseTypes.cs
new file mode 100644
index 0000000..f2ee763
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/SetOfBaseTypes.cs
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class SetOfBaseTypes
+    {
+        private readonly ISet<int> integers;
+        private readonly ISet<double> doubles;
+        private readonly ISet<string> strings;
+        private readonly ISet<int> moreIntegers;
+
+        [Inject]
+        private SetOfBaseTypes([Parameter(typeof(Integers))] ISet<int> integers,
+                               [Parameter(typeof(Doubles))] ISet<double> doubles,
+                               [Parameter(typeof(Strings))] ISet<string> strings,
+                               [Parameter(typeof(MoreIntegers))] ISet<int> moreIntegers)
+        {
+            this.integers = integers;
+            this.doubles = doubles;
+            this.strings = strings;
+            this.moreIntegers = moreIntegers;
+        }
+
+        public override bool Equals(object o)
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null || !(o is SetOfBaseTypes))
+            {
+                return false;
+            }
+
+            SetOfBaseTypes that = (SetOfBaseTypes)o;
+
+            if (!Utilities.Utilities.Equals(doubles, that.doubles))
+            {
+                return false;
+            }
+
+            if (!Utilities.Utilities.Equals(integers, that.integers))
+            {
+                return false;
+            }
+
+            if (!Utilities.Utilities.Equals(strings, that.strings))
+            {
+                return false;
+            }
+
+            return true;
+        }
+        
+        public override int GetHashCode()
+        {
+            int result = integers.GetHashCode();
+            result = (31 * result) + doubles.GetHashCode();
+            result = (31 * result) + strings.GetHashCode();
+            return result;
+        }
+
+        [NamedParameter]
+        public class Integers : Name<ISet<int>>
+        {
+        }
+
+        [NamedParameter(DefaultValues = new string[] { "1", "2", "3" })]
+        public class MoreIntegers : Name<ISet<int>>
+        {
+        }
+
+        [NamedParameter]
+        public class Doubles : Name<ISet<double>>
+        {
+        }
+
+        [NamedParameter]
+        public class Strings : Name<ISet<string>>
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/SetOfImplementations.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/SetOfImplementations.cs b/lang/cs/Tests/TangTests/SmokeTest/SetOfImplementations.cs
new file mode 100644
index 0000000..0f75b9a
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/SetOfImplementations.cs
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    public class SetOfImplementations 
+    {
+        private readonly ISet<ISetInterface> theInstances;
+
+        [Inject]
+        SetOfImplementations([Parameter(typeof(TestConfigurationModuleBuilder.SetOfInstances))] ISet<ISetInterface> theInstances) 
+        {
+            this.theInstances = theInstances;
+        }
+
+        public override bool Equals(object o) 
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null || !(o is SetOfImplementations))
+            {
+                return false;
+            }
+
+            SetOfImplementations that = (SetOfImplementations)o;
+
+            if (that.theInstances.Count != this.theInstances.Count)
+            {
+                return false;
+            }
+
+            if (!Utilities.Utilities.Equals<ISetInterface>(theInstances, that.theInstances))
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode() 
+        {
+            return theInstances.GetHashCode();
+        }
+
+        public bool isValid() 
+        {
+            return this.theInstances.Count == 2;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/SmokeTest/TestConfigurationModuleBuilder.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/SmokeTest/TestConfigurationModuleBuilder.cs b/lang/cs/Tests/TangTests/SmokeTest/TestConfigurationModuleBuilder.cs
new file mode 100644
index 0000000..3eaeada
--- /dev/null
+++ b/lang/cs/Tests/TangTests/SmokeTest/TestConfigurationModuleBuilder.cs
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Tang.Test.Format;
+
+namespace Org.Apache.Reef.Tang.Test.SmokeTest
+{
+    class TestConfigurationModuleBuilder : ConfigurationModuleBuilder
+    {
+        public static readonly string RequiredStringValue = "Required String Value";
+
+        public static readonly string OptionaStringValue = "Optional String Value";
+
+        public static readonly RequiredParameter<string> REQUIREDSTRING = new RequiredParameter<string>();
+
+        public static readonly OptionalParameter<string> OPTIONALSTRING = new OptionalParameter<string>();
+
+        public static readonly int NamedParameterIntegerValue = 42;
+
+        public static readonly double NamedParameterDoubleValue = 42.0;
+
+        public static ConfigurationModule CONF
+        {
+            get
+            {
+                return new TestConfigurationModuleBuilder()
+                    .BindImplementation(GenericType<IRootInterface>.Class, GenericType<RootImplementation>.Class)
+                    .BindNamedParameter<NamedParameterInteger, int>(GenericType<NamedParameterInteger>.Class, NamedParameterIntegerValue.ToString(CultureInfo.CurrentCulture))
+                    .BindNamedParameter<NamedParameterDouble, double>(GenericType<NamedParameterDouble>.Class, NamedParameterDoubleValue.ToString(CultureInfo.CurrentCulture))
+                    .BindSetEntry<SetOfInstances, SetInterfaceImplOne, ISetInterface>(GenericType<SetOfInstances>.Class, GenericType<SetInterfaceImplOne>.Class)
+                    .BindSetEntry<SetOfInstances, SetInterfaceImplTwo, ISetInterface>(GenericType<SetOfInstances>.Class, GenericType<SetInterfaceImplTwo>.Class)
+                    .BindNamedParameter(GenericType<RequiredString>.Class, REQUIREDSTRING)
+                    .BindNamedParameter(GenericType<OptionalString>.Class, OPTIONALSTRING)
+                    .BindSetEntry<SetOfBaseTypes.Integers, int>(GenericType<SetOfBaseTypes.Integers>.Class, "1")
+                    .BindSetEntry<SetOfBaseTypes.Integers, int>(GenericType<SetOfBaseTypes.Integers>.Class, "2")
+                    .BindSetEntry<SetOfBaseTypes.Integers, int>(GenericType<SetOfBaseTypes.Integers>.Class, "3")
+                    .BindSetEntry<SetOfBaseTypes.Doubles, double>(GenericType<SetOfBaseTypes.Doubles>.Class, "1")
+                    .BindSetEntry<SetOfBaseTypes.Doubles, double>(GenericType<SetOfBaseTypes.Doubles>.Class, "2")
+                    .BindSetEntry<SetOfBaseTypes.Doubles, double>(GenericType<SetOfBaseTypes.Doubles>.Class, "3")
+                    .BindSetEntry<SetOfBaseTypes.Strings, string>(GenericType<SetOfBaseTypes.Strings>.Class, "1")
+                    .BindSetEntry<SetOfBaseTypes.Strings, string>(GenericType<SetOfBaseTypes.Strings>.Class, "2")
+                    .BindSetEntry<SetOfBaseTypes.Strings, string>(GenericType<SetOfBaseTypes.Strings>.Class, "3")
+                    .BindList<ListOfBaseTypes.Integers, int>(GenericType<ListOfBaseTypes.Integers>.Class, (new List<string>(new string[] { "1", "2", "3" })))
+                    .BindList<ListOfBaseTypes.Doubles, double>(GenericType<ListOfBaseTypes.Doubles>.Class, (new List<string>(new string[] { "1", "2", "3" })))
+                    .BindList<ListOfBaseTypes.Strings, string>(GenericType<ListOfBaseTypes.Strings>.Class, (new List<string>(new string[] { "1", "2", "3" })))
+                    .Build();
+            }
+        }
+
+        [NamedParameter]
+        public class RequiredString : Name<string>
+        {
+        }
+
+        [NamedParameter]
+        public class SetOfInstances : Name<ISet<ISetInterface>>
+        {
+        }
+
+        [NamedParameter()]
+        public class NamedParameterDouble : Name<double>
+        {
+        }
+
+        [NamedParameter()]
+        public class IntegerHandler : Name<IHandler<int>>
+        {
+        }
+
+        [NamedParameter()]
+        public class StringHandler : Name<IHandler<string>>
+        {
+        }
+
+        [NamedParameter()]
+        public class NamedParameterInteger : Name<int>
+        {
+        }
+
+        [NamedParameter(DefaultValue = "default_string_default_value")]
+        public class OptionalString : Name<string>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Tang/TestDefaultImpementaion.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Tang/TestDefaultImpementaion.cs b/lang/cs/Tests/TangTests/Tang/TestDefaultImpementaion.cs
new file mode 100644
index 0000000..87c37b2
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Tang/TestDefaultImpementaion.cs
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Tang
+{
+    [DefaultImplementation(Name = "Org.Apache.Reef.Tang.Test.Tang.HaveDefaultStringImplImpl")]
+    interface IHaveDefaultStringImpl
+    {
+    }
+
+    [DefaultImplementation(typeof(HaveDefaultImplImpl))]
+    interface IHaveDefaultImpl
+    {        
+    }
+
+    interface IfaceWithDefault
+    {
+    }
+
+    [DefaultImplementation(typeof(AnInterfaceImplementation), "default")]
+    interface IAnInterface
+    {
+        void aMethod();
+    }
+
+    [TestClass]
+    public class TestDefaultImplmentation
+    {
+        [TestMethod]
+        public void TestDefaultConstructor()
+        {
+            ClassWithDefaultConstructor impl = (ClassWithDefaultConstructor)TangFactory.GetTang().NewInjector().GetInstance(typeof(ClassWithDefaultConstructor));
+            Assert.IsNotNull(impl);
+        }
+
+        [TestMethod]
+        public void TestDefaultImplementaion()
+        {
+            ClassWithDefaultConstructor impl = (ClassWithDefaultConstructor)TangFactory.GetTang().NewInjector().GetInstance(typeof(ClassWithDefaultConstructor));
+            Assert.IsNotNull(impl);
+        }
+
+        [TestMethod]
+        public void TestDefaultImplOnInterface()
+        {
+            IAnInterface impl = (IAnInterface)TangFactory.GetTang().NewInjector().GetInstance(typeof(IAnInterface));
+            Assert.IsNotNull(impl);
+            impl.aMethod();
+        }
+
+        [TestMethod]
+        public void TestGetInstanceOfNamedParameter()
+        {
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IfaceWithDefault iwd = i.GetNamedInstance<IfaceWithDefaultName, IfaceWithDefault>(GenericType<IfaceWithDefaultName>.Class);
+            Assert.IsNotNull(iwd);
+        }
+
+        [TestMethod]
+        public void TestCantGetInstanceOfNamedParameter()
+        {
+            string msg = null;
+            try
+            {
+                IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                i.GetInstance<IfaceWithDefaultName>();
+                msg = "getInstance() called on Name IfaceWithDefaultName Did you mean to call getNamedInstance() instead?";
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void TestCanGetDefaultedInterface()
+        {
+            Assert.IsNotNull(TangFactory.GetTang().NewInjector().GetInstance<IHaveDefaultImpl>());
+        }
+
+        [TestMethod]
+        public void TestCanOverrideDefaultedInterface()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<IHaveDefaultImpl>.Class, GenericType<OverrideDefaultImpl>.Class);
+            var o = TangFactory.GetTang().NewInjector(cb.Build()).GetInstance<IHaveDefaultImpl>();
+            Assert.IsTrue(o is OverrideDefaultImpl);
+        }
+
+        [TestMethod]
+        public void TestCanGetStringDefaultedInterface()
+        {
+            Assert.IsNotNull(TangFactory.GetTang().NewInjector().GetInstance<IHaveDefaultStringImpl>());
+        }
+
+        [TestMethod]
+        public void TestCanOverrideStringDefaultedInterface()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<IHaveDefaultStringImpl>.Class, GenericType<OverrideDefaultStringImpl>.Class);
+            var o = TangFactory.GetTang().NewInjector(cb.Build()).GetInstance<IHaveDefaultStringImpl>();
+            Assert.IsTrue(o is OverrideDefaultStringImpl);
+        }
+    }
+
+    public class AnInterfaceImplementation : IAnInterface
+    {
+        [Inject]
+        private AnInterfaceImplementation()
+        {
+        }
+
+        public void aMethod()
+        {
+        }
+    }
+
+    class IfaceWithDefaultDefaultImpl : IfaceWithDefault
+    {
+        [Inject]
+        IfaceWithDefaultDefaultImpl()
+        {            
+        }
+    }
+
+    [NamedParameter(DefaultClass = typeof(IfaceWithDefaultDefaultImpl))]
+    class IfaceWithDefaultName : Name<IfaceWithDefault>
+    {
+    }
+
+    class HaveDefaultImplImpl : IHaveDefaultImpl
+    {
+        [Inject]
+        HaveDefaultImplImpl()
+        {            
+        }
+    }
+
+    class OverrideDefaultImpl : IHaveDefaultImpl
+    {
+        [Inject]
+        public OverrideDefaultImpl()
+        {            
+        }
+    }
+
+    class HaveDefaultStringImplImpl : IHaveDefaultStringImpl
+    {
+        [Inject]
+        HaveDefaultStringImplImpl()
+        {            
+        }
+    }
+
+    class OverrideDefaultStringImpl : IHaveDefaultStringImpl
+    {
+        [Inject]
+        public OverrideDefaultStringImpl()
+        {            
+        }
+    }
+
+    class ClassWithDefaultConstructor
+    {
+        [Inject]
+        public ClassWithDefaultConstructor()
+        {            
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Tang/TestExternalConstructors.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Tang/TestExternalConstructors.cs b/lang/cs/Tests/TangTests/Tang/TestExternalConstructors.cs
new file mode 100644
index 0000000..46a60c9
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Tang/TestExternalConstructors.cs
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Tang
+{
+    [TestClass]
+    public class TestExternalConstructors
+    {
+        static ITang tang;
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            tang = TangFactory.GetTang();
+        }
+
+        [TestMethod]
+        public void TestBindConstructor()
+        {
+            ICsConfigurationBuilder b = TangFactory.GetTang().NewConfigurationBuilder();
+            b.BindConstructor(GenericType<A>.Class, GenericType<ACons>.Class);
+            b.BindConstructor(GenericType<B>.Class, GenericType<BCons>.Class);
+
+            TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(B));
+        }
+
+        [TestMethod]
+        public void TestSImpleExternalConstructor()
+        {
+            ICsConfigurationBuilder b = TangFactory.GetTang().NewConfigurationBuilder();
+            b.BindConstructor(GenericType<A>.Class, GenericType<ACons>.Class);
+            A aRef = (A)TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(A));
+            Assert.IsNotNull(aRef);
+        }
+
+        [TestMethod]
+        public void TestExternalLegacyConstructor()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindConstructor(GenericType<ExternalConstructorExample.Legacy>.Class, GenericType<ExternalConstructorExample.LegacyWrapper>.Class);
+            IInjector i = tang.NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<int>.Class, 42);
+            i.BindVolatileInstance(GenericType<string>.Class, "The meaning of life is ");
+            ExternalConstructorExample.Legacy l = i.GetInstance<ExternalConstructorExample.Legacy>();
+            Assert.AreEqual(42, l.X);
+            Assert.AreEqual("The meaning of life is ", l.Y);
+        }
+
+        public class A
+        {
+            public A()
+            {
+            }
+        }
+
+        public class B
+        {
+            public B(A a)
+            {
+            }
+        }
+
+        public class ACons : IExternalConstructor<A>
+        {
+            [Inject]
+            ACons()
+            {
+            }
+
+            public A NewInstance()
+            {
+                return new A();
+            }
+        }
+
+        public class BCons : IExternalConstructor<B>
+        {
+            private A a;
+            [Inject]
+            BCons(A a)
+            {
+                this.a = a;
+            }
+
+            public B NewInstance()
+            {
+                return new B(a);
+            }
+        }
+    }
+
+    class ExternalConstructorExample
+    {
+        public class Legacy
+        {
+            public Legacy(int x, string y)
+            {
+                this.X = x;
+                this.Y = y;
+            }
+        
+            public int X { get; set; }
+
+            public string Y { get; set; }
+        }
+
+        public class LegacyWrapper : IExternalConstructor<Legacy>
+        {
+            [Inject]
+            LegacyWrapper(int x, string y)
+            {
+                this.X = x;
+                this.Y = y;
+            }
+
+            public int X { get; set; }
+
+            public string Y { get; set; }
+
+            public Legacy NewInstance()
+            {
+                return new Legacy(X, Y);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Tang/TestLegacyConstructors.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Tang/TestLegacyConstructors.cs b/lang/cs/Tests/TangTests/Tang/TestLegacyConstructors.cs
new file mode 100644
index 0000000..49e2609
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Tang/TestLegacyConstructors.cs
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Tang
+{
+    [TestClass]
+    public class TestLegacyConstructors
+    {   
+        static ITang tang;
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            tang = TangFactory.GetTang();
+        }
+
+        [TestMethod]
+        public void TestLegacyConstructor()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+
+            IList<string> constructorArg = new List<string>();
+            constructorArg.Add(ReflectionUtilities.GetAssemblyQualifiedName(typeof(int)));
+            constructorArg.Add(ReflectionUtilities.GetAssemblyQualifiedName(typeof(string)));
+            cb.RegisterLegacyConstructor(ReflectionUtilities.GetAssemblyQualifiedName(typeof(LegacyConstructor)), constructorArg);
+            //cb.Bind(typeof(LegacyConstructor), typeof(LegacyConstructor));
+            cb.BindImplementation(GenericType<LegacyConstructor>.Class, GenericType<LegacyConstructor>.Class);
+
+            IInjector i = tang.NewInjector(cb.Build());
+            i.BindVolatileInstance(GenericType<int>.Class, 42);
+            i.BindVolatileInstance(GenericType<string>.Class, "The meaning of life is ");
+            LegacyConstructor l = i.GetInstance<LegacyConstructor>();
+            Assert.AreEqual(42, l.X);
+            Assert.AreEqual("The meaning of life is ", l.Y);
+        }
+    }
+
+    class LegacyConstructor
+    {
+        public LegacyConstructor(int x, string y)
+        {
+            this.X = x;
+            this.Y = y;
+        }
+        
+        public int X { get; set; }
+        
+        public string Y { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Tang/TestTang.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Tang/TestTang.cs b/lang/cs/Tests/TangTests/Tang/TestTang.cs
new file mode 100644
index 0000000..4ac5158
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Tang/TestTang.cs
@@ -0,0 +1,1158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Reflection;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Types;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Examples;
+
+namespace Org.Apache.Reef.Tang.Test.Tang
+{
+    [TestClass]
+    public class TestTang
+    {
+        private static ITang tang;
+
+        private static Assembly asm = null;
+
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            asm = Assembly.Load(FileNames.Examples);
+        }
+
+        [ClassCleanup]
+        public static void ClassCleanup()
+        {
+        }
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+            MustBeSingleton.alreadyInstantiated = false;
+            tang = TangFactory.GetTang();
+        }
+
+        [TestCleanup()]
+        public void TestCleanup()
+        {
+        }
+
+        [TestMethod]
+        public void TestSingleton()
+        {
+            IInjector injector = tang.NewInjector();
+            Assert.IsNotNull(injector.GetInstance(typeof (TwoSingletons)));
+            Assert.IsNotNull(injector.GetInstance(typeof (TwoSingletons)));
+        }
+
+        [TestMethod]
+        public void TestNotSingleton()
+        {
+            TwoSingletons obj = null;
+            Assert.IsNotNull(tang.NewInjector().GetInstance(typeof (TwoSingletons)));
+            try
+            {
+                obj = (TwoSingletons) tang.NewInjector().GetInstance(typeof (TwoSingletons));
+            }
+            catch (InjectionException)
+            {
+
+            }
+            Assert.IsNull(obj);
+        }
+
+        [TestMethod]
+        public void TestRepeatedAmbiguousArgs()
+        {
+            INode node = null;
+            try
+            {
+                ICsConfigurationBuilder t = tang.NewConfigurationBuilder();
+                node =
+                    t.GetClassHierarchy()
+                     .GetNode(ReflectionUtilities.GetAssemblyQualifiedName(typeof (RepeatedAmbiguousArgs)));
+            }
+            catch (ClassHierarchyException)
+            {
+            }
+            Assert.IsNull(node);
+        }
+
+        [TestMethod]
+        public void TestRepeatedOKArgs()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindNamedParameter<RepeatedNamedArgs.A, Int32>(GenericType<RepeatedNamedArgs.A>.Class, "1");
+            cb.BindNamedParameter<RepeatedNamedArgs.B, Int32>(GenericType<RepeatedNamedArgs.B>.Class, "2");
+
+            IInjector injector = tang.NewInjector(cb.Build());
+            injector.GetInstance(typeof (RepeatedNamedArgs));
+        }
+
+        // NamedParameter A has no default_value, so this should throw.
+        [TestMethod]
+        public void TestOneNamedFailArgs()
+        {
+            string msg = null;
+            try
+            {
+                tang.NewInjector().GetInstance<OneNamedSingletonArgs>();
+                msg =
+                    "Cannot inject OneNamedSingletonArgs: cOneNamedSingletonArgs missing argument OneNamedSingletonArgs+A";
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        // NamedParameter A get's bound to a volatile, so this should succeed.
+        [TestMethod]
+        public void TestOneNamedSingletonOKArgs()
+        {
+            IInjector i = tang.NewInjector();
+            i.BindVolatileParameter(GenericType<OneNamedSingletonArgs.A>.Class, i.GetInstance<MustBeSingleton>());
+            OneNamedSingletonArgs o = i.GetInstance<OneNamedSingletonArgs>();
+            Assert.IsNotNull(o);
+        }
+
+
+        [TestMethod]
+        public void TestRepeatedNamedArgs()
+        {
+            IInjector i = tang.NewInjector();
+            i.BindVolatileParameter(GenericType<RepeatedNamedSingletonArgs.A>.Class,
+                                    (MustBeSingleton) i.GetInstance(typeof (MustBeSingleton)));
+            i.BindVolatileParameter(GenericType<RepeatedNamedSingletonArgs.B>.Class,
+                                    (MustBeSingleton) i.GetInstance(typeof (MustBeSingleton)));
+            i.GetInstance(typeof (RepeatedNamedSingletonArgs));
+        }
+
+        [TestMethod]
+        public void testStraightforwardBuild()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<Interf>.Class, GenericType<Impl>.Class);
+            tang.NewInjector(cb.Build()).GetInstance(typeof (Interf));
+        }
+
+        [TestMethod]
+        public void TestOneNamedStringArgCantRebind()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            OneNamedStringArg a =
+                (OneNamedStringArg) tang.NewInjector(cb.Build()).GetInstance(typeof (OneNamedStringArg));
+            Assert.AreEqual("default", a.s);
+            cb.BindNamedParameter<OneNamedStringArg.A, string>(GenericType<OneNamedStringArg.A>.Class, "not default");
+            IInjector i = tang.NewInjector(cb.Build());
+            Assert.AreEqual("not default", ((OneNamedStringArg) i.GetInstance(typeof (OneNamedStringArg))).s);
+            string msg = null;
+            try
+            {
+                i.BindVolatileParameter(GenericType<OneNamedStringArg.A>.Class, "volatile");
+                msg =
+                    "Attempt to re-bind named parameter Org.Apache.Reef.Tang.OneNamedStringArg$A.  Old value was [not default] new value is [volatile]";
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void TestOneNamedStringArgBind()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            OneNamedStringArg a = tang.NewInjector(cb.Build()).GetInstance<OneNamedStringArg>();
+            Assert.AreEqual("default", a.s);
+            cb.BindNamedParameter<OneNamedStringArg.A, string>(GenericType<OneNamedStringArg.A>.Class, "not default");
+            IInjector i = tang.NewInjector(cb.Build());
+            Assert.AreEqual("not default", i.GetInstance<OneNamedStringArg>().s);
+        }
+
+        [TestMethod]
+        public void TestOneNamedStringArgVolatile()
+        {
+            OneNamedStringArg a = tang.NewInjector().GetInstance<OneNamedStringArg>();
+            Assert.AreEqual("default", a.s);
+            IInjector i = tang.NewInjector();
+            i.BindVolatileParameter(GenericType<OneNamedStringArg.A>.Class, "volatile");
+            Assert.AreEqual("volatile", i.GetInstance<OneNamedStringArg>().s);
+        }
+
+        [TestMethod]
+        public void TestTwoNamedStringArgsBind()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            TwoNamedStringArgs a = tang.NewInjector(cb.Build()).GetInstance<TwoNamedStringArgs>();
+            Assert.AreEqual("defaultA", a.a);
+            Assert.AreEqual("defaultB", a.b);
+            cb.BindNamedParameter<TwoNamedStringArgs.A, string>(GenericType<TwoNamedStringArgs.A>.Class, "not defaultA");
+            cb.BindNamedParameter<TwoNamedStringArgs.B, string>(GenericType<TwoNamedStringArgs.B>.Class, "not defaultB");
+            IInjector i = tang.NewInjector(cb.Build());
+            Assert.AreEqual("not defaultA",
+                            i.GetInstance<TwoNamedStringArgs>().a);
+            Assert.AreEqual("not defaultB",
+                            i.GetInstance<TwoNamedStringArgs>().b);
+        }
+
+        [TestMethod]
+        public void TestTwoNamedStringArgsBindVolatile()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            TwoNamedStringArgs a = tang.NewInjector(cb.Build()).GetInstance<TwoNamedStringArgs>();
+            Assert.AreEqual("defaultA", a.a);
+            Assert.AreEqual("defaultB", a.b);
+            IInjector i = tang.NewInjector(cb.Build());
+            i.BindVolatileParameter(GenericType<TwoNamedStringArgs.A>.Class, "not defaultA");
+            i.BindVolatileParameter(GenericType<TwoNamedStringArgs.B>.Class, "not defaultB");
+            Assert.AreEqual("not defaultA",
+                            i.GetInstance<TwoNamedStringArgs>().a);
+            Assert.AreEqual("not defaultB",
+                            i.GetInstance<TwoNamedStringArgs>().b);
+        }
+
+        [TestMethod]
+        public void TestTwoNamedStringArgsReBindVolatileFail()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            TwoNamedStringArgs a = tang.NewInjector(cb.Build()).GetInstance<TwoNamedStringArgs>();
+            Assert.AreEqual("defaultA", a.a);
+            Assert.AreEqual("defaultB", a.b);
+            cb.BindNamedParameter<TwoNamedStringArgs.A, string>(GenericType<TwoNamedStringArgs.A>.Class, "not defaultA");
+            cb.BindNamedParameter<TwoNamedStringArgs.B, string>(GenericType<TwoNamedStringArgs.B>.Class, "not defaultB");
+            IInjector i = tang.NewInjector(cb.Build());
+            string msg = null;
+            try
+            {
+                i.BindVolatileParameter(GenericType<TwoNamedStringArgs.A>.Class, "not defaultA");
+                i.BindVolatileParameter(GenericType<TwoNamedStringArgs.B>.Class, "not defaultB");
+                msg =
+                    "Attempt to re-bind named parameter TwoNamedStringArgs+A.  Old value was [not defaultA] new value is [not defaultA]";
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void TestBextendsAinjectA()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<BextendsAinjectA.A>.Class, GenericType<BextendsAinjectA.A>.Class);
+            BextendsAinjectA.A a = tang.NewInjector(cb.Build()).GetInstance<BextendsAinjectA.A>();
+            Assert.IsNotNull(a);
+        }
+
+        [TestMethod]
+        public void TestNamedImpl()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindNamedParameter<AImplName, Aimpl, INamedImplA>(GenericType<AImplName>.Class, GenericType<Aimpl>.Class);
+            cb.BindNamedParameter<BImplName, Bimpl, INamedImplA>(GenericType<BImplName>.Class, GenericType<Bimpl>.Class);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            Aimpl a1 = (Aimpl) i.GetNamedInstance<AImplName, INamedImplA>(GenericType<AImplName>.Class);
+            Aimpl a2 = (Aimpl) i.GetNamedInstance<AImplName, INamedImplA>(GenericType<AImplName>.Class);
+            Bimpl b1 = (Bimpl) i.GetNamedInstance<BImplName, INamedImplA>(GenericType<BImplName>.Class);
+            Bimpl b2 = (Bimpl) i.GetNamedInstance<BImplName, INamedImplA>(GenericType<BImplName>.Class);
+            Assert.AreSame(a1, a2);
+            Assert.AreSame(b1, b2);
+        }
+
+        [TestMethod]
+        public void testThreeConstructors() 
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindNamedParameter<ThreeConstructors.TCInt, Int32>(GenericType<ThreeConstructors.TCInt>.Class, "1");
+            cb.BindNamedParameter<ThreeConstructors.TCString, string>(GenericType<ThreeConstructors.TCString>.Class, "s");
+            ThreeConstructors tc = tang.NewInjector(cb.Build()).GetInstance<ThreeConstructors>();
+            Assert.AreEqual(1, tc.i);
+            Assert.AreEqual("s", tc.s);
+    
+            cb = tang.NewConfigurationBuilder();
+            cb.BindNamedParameter<ThreeConstructors.TCInt, Int32>(GenericType<ThreeConstructors.TCInt>.Class, "1");
+            tc = tang.NewInjector(cb.Build()).GetInstance<ThreeConstructors>();
+            Assert.AreEqual(1, tc.i);
+            Assert.AreEqual("default", tc.s);
+
+            cb = tang.NewConfigurationBuilder();
+            cb.BindNamedParameter<ThreeConstructors.TCString, string>(GenericType<ThreeConstructors.TCString>.Class, "s");
+            tc = tang.NewInjector(cb.Build()).GetInstance<ThreeConstructors>();
+            Assert.AreEqual(-1, tc.i);
+            Assert.AreEqual("s", tc.s);
+
+            cb = tang.NewConfigurationBuilder();
+            cb.BindNamedParameter<ThreeConstructors.TCFloat, float>(GenericType<ThreeConstructors.TCFloat>.Class, "2");
+            tc = tang.NewInjector(cb.Build()).GetInstance<ThreeConstructors>();
+            Assert.AreEqual(-1, tc.i);
+            Assert.AreEqual("default", tc.s);
+            Assert.AreEqual(2.0f, tc.f, 1e-9);
+        }
+
+        [TestMethod]
+        public void TestThreeConstructorsAmbiguous()
+        {
+            string msg = null;
+
+            try
+            {
+                ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+                cb.BindNamedParameter<ThreeConstructors.TCString, string>(GenericType<ThreeConstructors.TCString>.Class, "s");
+                cb.BindNamedParameter<ThreeConstructors.TCFloat, float>(GenericType<ThreeConstructors.TCFloat>.Class, "-2");
+
+                // Ambiguous; there is a constructor that takes a string, and another that
+                // takes a float, but none that takes both.
+                tang.NewInjector(cb.Build()).GetInstance<ThreeConstructors>();
+                msg = @"Cannot inject Org.Apache.Reef.Tang.Test.Tang.ThreeConstructors, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null " + 
+                    "Ambiguous subplan Org.Apache.Reef.Tang.Test.Tang.ThreeConstructors, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null " + 
+                    "new Org.Apache.Reef.Tang.Test.Tang.ThreeConstructors(System.String Org.Apache.Reef.Tang.Test.Tang.ThreeConstructors+TCString = s) " + 
+                    "new Org.Apache.Reef.Tang.Test.Tang.ThreeConstructors(System.Single Org.Apache.Reef.Tang.Test.Tang.ThreeConstructors+TCFloat = -2) ";
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void TestTwoConstructorsAmbiguous()
+        {
+            string msg = null;
+            try
+            {
+                ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+                cb.BindNamedParameter<TwoConstructors.TCInt, Int32>(GenericType<TwoConstructors.TCInt>.Class, "1");
+                cb.BindNamedParameter<ThreeConstructors.TCString, string>(GenericType<ThreeConstructors.TCString>.Class, "s");
+                tang.NewInjector(cb.Build()).GetInstance<TwoConstructors>();
+                msg = @"Cannot inject Org.Apache.Reef.Tang.Test.Tang.TwoConstructors, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null "+
+                "Ambiguous subplan Org.Apache.Reef.Tang.Test.Tang.TwoConstructors, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" +
+                "new Org.Apache.Reef.Tang.Test.Tang.TwoConstructors(System.Int32 Org.Apache.Reef.Tang.Test.Tang.TwoConstructors+TCInt = 1, System.String Org.Apache.Reef.Tang.Test.Tang.TwoConstructors+TCString = s)" +
+                "new Org.Apache.Reef.Tang.Test.Tang.TwoConstructors(System.String Org.Apache.Reef.Tang.Test.Tang.TwoConstructors+TCString = s, System.Int32 Org.Apache.Reef.Tang.Test.Tang.TwoConstructors+TCInt = 1)";
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e); 
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void TestSingletonWithMultipleConstructors() 
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<SMC>.Class, GenericType<SingletonMultiConst>.Class);
+            cb.BindNamedParameter<SingletonMultiConst.A, string>(GenericType<SingletonMultiConst.A>.Class, "foo");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<SMC>();
+            Assert.IsNotNull(o);
+        }
+
+        [TestMethod]
+        public void TestSingletonWithMoreSpecificConstructors()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<SMC>.Class, GenericType<SingletonMultiConst>.Class);
+            cb.BindNamedParameter<SingletonMultiConst.A, string>(GenericType<SingletonMultiConst.A>.Class, "foo");
+            cb.BindNamedParameter<SingletonMultiConst.B, string>(GenericType<SingletonMultiConst.B>.Class, "bar");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<SMC>();
+            Assert.IsNotNull(o);
+        }
+
+        [TestMethod]
+        public void TestInjectInjector()
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            var ii = (InjectInjector) i.GetInstance(typeof(InjectInjector));
+            //Assert.IsTrue(ii.i is IInjector);
+            Assert.AreNotSame(i, ii.i);
+        }
+
+        [TestMethod]
+        public void TestGenericEventHandlers()
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            cba.BindNamedParameter<ABCName.XName, ABCName.XXBB, ABCName.X<ABCName.BB>>(GenericType<ABCName.XName>.Class, GenericType<ABCName.XXBB>.Class);
+            TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(ABCName.XName));
+
+            ICsConfigurationBuilder cbb = TangFactory.GetTang().NewConfigurationBuilder();
+            cbb.BindNamedParameter<ABCName.XName, ABCName.XBB, ABCName.X<ABCName.BB>>(GenericType<ABCName.XName>.Class, GenericType<ABCName.XBB>.Class);
+            TangFactory.GetTang().NewInjector(cbb.Build()).GetNamedInstance(typeof(ABCName.XName));
+        }
+
+        [TestMethod]
+        public void TestGenericEventHandlerDefaults() 
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            var xbb = TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(ABCName.XNameDB));
+            Assert.IsTrue(xbb is ABCName.XBB);
+        }
+
+        [TestMethod]
+        public void TestGenericEventHandlerDefaultsGoodTreeIndirection() 
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            var o = TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(ABCName.XNameDDAA));
+            Assert.IsTrue(o is ABCName.XXBB);
+        }
+
+        [TestMethod]
+        public void TestGenericUnrelatedGenericTypeParameters() 
+        {
+            string msg = null;
+            try
+            {
+                ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+                TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(WaterBottleName));
+                msg =
+                    "class WaterBottleName defines a default class GasCan with a type that does not extend its target's type Water";
+            }
+            catch (ClassHierarchyException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }    
+            Assert.IsNull(msg);        
+        }
+
+        [TestMethod]
+        public void TestGenericInterfaceUnboundTypeParametersName()
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            var o = TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(FooEventHandler));
+            Assert.IsTrue(o is MyEventHandler<Foo>);
+        }
+
+        [TestMethod]
+        public void TestGenericInterfaceUnboundTypeParametersNameIface()
+        {
+            ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+            var o = TangFactory.GetTang().NewInjector(cba.Build()).GetNamedInstance(typeof(IfaceEventHandler));
+            Assert.IsTrue(o is IEventHandler<SomeIface>);
+        }
+
+        [TestMethod]
+        public void TestGenericInterfaceUnboundTypeParametersIface()
+        {
+            string msg = null;
+            try
+            {
+                ICsConfigurationBuilder cba = TangFactory.GetTang().NewConfigurationBuilder();
+                TangFactory.GetTang().NewInjector(cba.Build()).IsInjectable(typeof(MyEventHandlerIface));
+                msg =
+                    "interface MyEventHandlerIface declares its default implementation to be non-subclass class MyEventHandler";
+            }
+            catch (ClassHierarchyException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }    
+            Assert.IsNull(msg);    
+        }
+
+        [TestMethod]
+        public void TestWantSomeHandlers() 
+        {
+            var o = TangFactory.GetTang().NewInjector().GetInstance<WantSomeHandlers>();
+            Assert.IsNotNull(o);
+        }
+        
+        [TestMethod]
+        public void TestWantSomeHandlersBadOrder() 
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            var o1 = i.GetInstance<IAHandler>();
+            var o2 = i.GetInstance<IBHandler>();
+            var o3 = i.GetInstance<WantSomeFutureHandlers>();
+            Assert.IsTrue(o1 is AHandlerImpl);            
+            Assert.IsTrue(o2 is BHandlerImpl);
+            Assert.IsNotNull(o3);
+        }
+
+        [TestMethod]
+        public void TestWantSomeFutureHandlersAlreadyBoundVolatile() 
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            i.BindVolatileInstance(GenericType<IAHandler>.Class, new AHandlerImpl());
+            i.BindVolatileInstance(GenericType<IBHandler>.Class, new BHandlerImpl());
+            i.GetInstance<WantSomeFutureHandlers>();
+        }
+
+        [TestMethod]
+        public void TestWantSomeFutureHandlers() 
+        {
+            TangFactory.GetTang().NewInjector().GetInstance<WantSomeFutureHandlers>();
+        }
+
+        [TestMethod]
+        public void TestWantSomeFutureHandlersName() 
+        {
+            TangFactory.GetTang().NewInjector().GetInstance<WantSomeFutureHandlersName>();
+        }
+
+        [TestMethod]
+        public void TestReuseFailedInjector() 
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            try 
+            {
+                i.GetInstance<Fail>();
+                Assert.Fail("Injecting Fail should not have worked!");
+            } catch (InjectionException) 
+            {
+                 i.GetInstance<Pass>();
+            }
+        }
+
+        [TestMethod]
+        public void TestMultipleLayersFromAbstractClass()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<MultiLayer>.Class, GenericType<LowerLayer>.Class);
+            MultiLayer o = tang.NewInjector(cb.Build()).GetInstance<MultiLayer>();
+            Assert.IsNotNull(o);
+        }
+
+        [TestMethod]
+        public void TestMultipleLayersFromInterface()
+        {
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<IMultiLayer>.Class, GenericType<LowerLayerImpl>.Class);
+            IMultiLayer o = tang.NewInjector(cb.Build()).GetInstance<IMultiLayer>();
+            Assert.IsNotNull(o);
+        }
+    }
+
+    internal class InjectInjector
+    {
+        public IInjector i;
+
+        [Inject]
+        private InjectInjector(IInjector i)
+        {
+            this.i = i;
+        }
+    }
+
+    internal class MustBeSingleton
+    {
+        public static bool alreadyInstantiated;
+
+        [Inject]
+        public MustBeSingleton()
+        {
+            if (alreadyInstantiated)
+            {
+                throw new IllegalStateException("Can't instantiate me twice!");
+            }
+            alreadyInstantiated = true;
+        }
+    }
+
+    internal class SubSingleton
+    {
+        [Inject]
+        private SubSingleton(MustBeSingleton a)
+        {
+            // Does not call super
+        }
+    }
+
+    internal class TwoSingletons
+    {
+        [Inject]
+        private TwoSingletons(SubSingleton a, MustBeSingleton b)
+        {
+        }
+    }
+
+    internal class RepeatedAmbiguousArgs
+    {
+        [Inject]
+        private RepeatedAmbiguousArgs(int x, int y)
+        {
+        }
+    }
+
+    public class RepeatedNamedArgs
+    {
+        [NamedParameter]
+        public class A : Name<Int32>
+        {
+        }
+
+        [NamedParameter()]
+        public class B : Name<Int32>
+        {
+        }
+
+        [Inject]
+        public RepeatedNamedArgs([Parameter(typeof (A))] int x, [Parameter(Value = typeof (B))] int y)
+        {
+        }
+    }
+
+    internal class RepeatedNamedSingletonArgs
+    {
+        [NamedParameter()]
+        public class A : Name<MustBeSingleton>
+        {
+        }
+
+        [NamedParameter()]
+        public class B : Name<MustBeSingleton>
+        {
+        }
+
+        [Inject]
+        public RepeatedNamedSingletonArgs([Parameter(typeof (A))] MustBeSingleton a,
+                                          [Parameter(typeof (B))] MustBeSingleton b)
+        {
+        }
+    }
+
+    internal class OneNamedSingletonArgs
+    {
+        [NamedParameter()]
+        public class A : Name<MustBeSingleton>
+        {
+        }
+
+        [NamedParameter()]
+        public class B : Name<MustBeSingleton>
+        {
+        }
+
+        [Inject]
+        public OneNamedSingletonArgs([Parameter(typeof (A))] MustBeSingleton a)
+        {
+        }
+    }
+
+    [NamedParameter(Documentation = "woo", ShortName = "woo", DefaultValue = "42")]
+    internal class Param : Name<Int32>
+    {
+    }
+
+    internal interface Interf
+    {
+    }
+
+    internal class Impl : Interf
+    {
+        [Inject]
+        private Impl([Parameter(Value = typeof (Param))] int p)
+        {
+        }
+    }
+
+    internal class OneNamedStringArg
+    {
+        [NamedParameter(DefaultValue = "default")]
+        public class A : Name<string>
+        {
+        }
+
+        public string s;
+
+        [Inject]
+        private OneNamedStringArg([Parameter(typeof (A))] string s)
+        {
+            this.s = s;
+        }
+    }
+
+    internal class TwoNamedStringArgs
+    {
+        [NamedParameter(DefaultValue = "defaultA")]
+        public class A : Name<string>
+        {
+        }
+
+        [NamedParameter(DefaultValue = "defaultB")]
+        public class B : Name<string>
+        {
+        }
+
+        public string a;
+        public string b;
+
+        [Inject]
+        private TwoNamedStringArgs([Parameter(typeof (A))] string a, [Parameter(typeof (B))] String b)
+        {
+            this.a = a;
+            this.b = b;
+        }
+    }
+
+    internal class BextendsAinjectA
+    {
+        public class A
+        {
+            [Inject]
+            public A()
+            {
+            }
+        }
+
+        public class B : A
+        {
+        }
+    }
+
+    public interface INamedImplA
+    {
+    }
+
+    public interface INamedImplC
+    {
+    }
+
+    [NamedParameter]
+    public class AImplName : Name<INamedImplA>
+    {
+    }
+
+    [NamedParameter]
+    public class BImplName : Name<INamedImplA>
+    {
+    }
+
+    [NamedParameter]
+    public class CImplName : Name<INamedImplC>
+    {
+    }
+
+    public class Aimpl : INamedImplA
+    {
+        [Inject]
+        private Aimpl()
+        {
+        }
+    }
+
+    public class Bimpl : INamedImplA
+    {
+        [Inject]
+        private Bimpl()
+        {
+        }
+    }
+
+    public class Cimpl : INamedImplC
+    {
+        [Inject]
+        private Cimpl()
+        {
+        }
+    }
+
+    internal class NamedImpl
+    {
+        [NamedParameter]
+        public class AImplName : Name<A>
+        {
+        }
+
+        [NamedParameter]
+        public class BImplName : Name<A>
+        {
+        }
+
+        [NamedParameter]
+        public class CImplName : Name<C>
+        {
+        }
+
+        public interface A
+        {
+        }
+
+        public interface C
+        {
+        }
+
+        public class Aimpl : A
+        {
+            [Inject]
+            private Aimpl()
+            {
+            }
+        }
+
+        public class Bimpl : A
+        {
+            [Inject]
+            private Bimpl()
+            {
+            }
+        }
+
+        public class Cimpl : C
+        {
+            [Inject]
+            private Cimpl()
+            {
+            }
+        }
+
+        public class ABtaker
+        {
+            [Inject]
+            private ABtaker([Parameter(typeof (AImplName))] INamedImplA a, [Parameter(typeof (BImplName))] INamedImplA b)
+            {
+                //Assert.IsTrue(a is Aimpl, "AImplName must be instance of Aimpl");
+                //Assert.IsTrue(b is Bimpl, "BImplName must be instance of Bimpl");
+            }
+        }
+    }
+    
+    class ThreeConstructors 
+    {
+        public int i;
+        public string s;
+        public float f;
+
+        [NamedParameter]
+        public class TCInt : Name<Int32> {}
+
+        [NamedParameter]
+        public class TCString : Name<string> { }
+
+        [NamedParameter]
+        public class TCFloat : Name<float> {}
+
+        [Inject]
+        public ThreeConstructors([Parameter(typeof(TCInt))] int i, [Parameter(typeof(TCString))] string s) 
+        { 
+            this.i = i;
+            this.s = s;
+            this.f = -1.0f;
+        }
+
+        [Inject]
+        public ThreeConstructors([Parameter(typeof(TCString))] string s) : this(-1, s)
+        {
+        }
+
+        [Inject]
+        public ThreeConstructors([Parameter(typeof(TCInt))] int i) : this(i, "default")
+        {
+        }
+
+        [Inject]
+        public ThreeConstructors([Parameter(typeof(TCFloat))] float f) 
+        {
+            this.i = -1;
+            this.s = "default";
+            this.f = f;
+        } 
+    }
+
+    class TwoConstructors
+    {
+        public int i;
+        public string s;
+
+        [NamedParameter]
+        public class TCInt : Name<Int32> { }
+
+        [NamedParameter]
+        public class TCString : Name<string> { }
+
+
+        [Inject]
+        public TwoConstructors([Parameter(typeof(TCInt))] int i, [Parameter(typeof(TCString))] string s)
+        {
+            this.i = i;
+            this.s = s;
+        }
+
+        [Inject]
+        public TwoConstructors([Parameter(typeof(TCString))] string s, [Parameter(typeof(TCInt))] int i)
+        {
+            this.i = i;
+            this.s = s;
+        }
+    }
+
+    interface SMC { }
+
+    class SingletonMultiConst : SMC 
+    {
+        [NamedParameter]
+        public class A : Name<string> { }
+  
+        [NamedParameter]
+        public class B : Name<string> { }
+  
+        [Inject]
+        public SingletonMultiConst([Parameter(typeof(A))] String a) { }
+        
+        [Inject]
+        public SingletonMultiConst([Parameter(typeof(A))] string a, [Parameter(typeof(B))] string b) { }
+    }
+
+    internal class ABCName
+    {
+        public interface X<T>
+        {
+        }
+
+        [NamedParameter]
+        public class XName : Name<X<BB>>
+        {
+        }
+
+        //[NamedParameter(DefaultClass = typeof(XAA))]
+        //public class XNameDA : Name<X<BB>>
+        //{
+        //}
+
+        [NamedParameter(DefaultClass = typeof(XBB))]
+        public class XNameDB : Name<X<BB>>
+        {
+        }
+
+        //[NamedParameter(DefaultClass = typeof(XCC))]
+        //public class XNameDC : Name<X<BB>>
+        //{
+        //}
+
+        //[NamedParameter(DefaultClass = typeof(XCC))]
+        //public class XNameDAA : Name<XBB>
+        //{
+        //}
+
+        [NamedParameter(DefaultClass = typeof(XXBB))]
+        public class XNameDDAA : Name<XBB>
+        {
+        }
+
+        [DefaultImplementation(typeof(AA))]
+        public class AA
+        {
+            [Inject]
+            public AA()
+            {
+            }
+        }
+
+        [DefaultImplementation(typeof(BB))]
+        public class BB : AA
+        {
+            [Inject]
+            public BB()
+            {
+            }
+        }
+
+        [DefaultImplementation(typeof(CC))]
+        public class CC : BB
+        {
+            [Inject]
+            public CC()
+            {
+            }
+        }
+
+        public class XAA : X<AA>
+        {
+            [Inject]
+            public XAA(AA aa)
+            {
+            }
+        }
+
+        [DefaultImplementation(typeof(XBB))]
+        public class XBB : X<BB>
+        {
+            [Inject]
+            public XBB(BB aa)
+            {
+            }
+        }
+
+        public class XXBB : XBB
+        {
+            [Inject]
+            public XXBB(BB aa)
+                : base(aa)
+            {
+            }
+        }
+
+        public class XCC : X<CC>
+        {
+            [Inject]
+            public XCC(CC aa)
+            {
+            }
+        }
+    }
+
+    interface Bottle<Y> {
+  
+    }
+    class WaterBottle : Bottle<Water> 
+    {  
+    }
+    class GasCan : Bottle<Gas> 
+    {  
+    }
+    class Water {}
+    class Gas {}
+
+    [NamedParameter(DefaultClass=typeof(GasCan))]
+    class WaterBottleName : Name<Bottle<Water>> { }
+
+    interface IEventHandler <T> { }
+    class MyEventHandler<T> : IEventHandler<T> 
+    { 
+        [Inject]
+        MyEventHandler () { }
+    }
+
+    [DefaultImplementation(typeof(MyEventHandler<Foo>))]
+    interface MyEventHandlerIface : IEventHandler<Foo> { }
+
+    [NamedParameter(DefaultClass = typeof(MyEventHandler<Foo>))]
+    class FooEventHandler : Name<IEventHandler<Foo>> { }
+
+    internal class Foo : Name<String>
+    {
+    }
+
+    interface SomeIface { }
+    [NamedParameter(DefaultClass = typeof(MyEventHandler<SomeIface>))]
+    class IfaceEventHandler : Name<IEventHandler<SomeIface>> { }
+
+    class AH
+    {
+        [Inject]
+        AH() {}
+    }
+    class BH
+    {
+        [Inject]
+        BH() {}
+    }
+
+    [DefaultImplementation(typeof(AHandlerImpl))]
+    interface IAHandler : IEventHandler<AH> { }
+
+    [DefaultImplementation(typeof(BHandlerImpl))]
+    interface IBHandler : IEventHandler<BH> { }
+
+    class AHandlerImpl : IAHandler
+    {
+        [Inject]
+        public AHandlerImpl() { }
+    }
+    class BHandlerImpl : IBHandler 
+    {
+        [Inject]
+        public BHandlerImpl() { }
+    }
+
+    class WantSomeHandlers 
+    {
+        [Inject]
+        WantSomeHandlers(IAHandler a, IBHandler b) { }
+    }
+    class WantSomeFutureHandlers 
+    {
+        [Inject]
+        WantSomeFutureHandlers(IInjectionFuture<IAHandler> a, IInjectionFuture<IBHandler> b) { }
+    }
+
+    [NamedParameter(DefaultClass = typeof(AHandlerImpl))]
+    class AHandlerName : Name<IEventHandler<AH>> { }
+    
+    [NamedParameter(DefaultClass = typeof(BHandlerImpl))]
+    class BHandlerName : Name<IEventHandler<BH>> { }
+
+    class WantSomeFutureHandlersName 
+    {
+        [Inject]
+        WantSomeFutureHandlersName(
+            [Parameter(typeof (AHandlerName))] IInjectionFuture<IEventHandler<AH>> a,
+            [Parameter(typeof (BHandlerName))] IInjectionFuture<IEventHandler<BH>> b)
+        {            
+        }
+    }
+
+    class Pass 
+    {
+        [Inject]
+        public Pass()
+        {            
+        }
+    }
+
+    class Fail 
+    {
+        [Inject]
+        public Fail()
+        {
+            throw new NotSupportedException();
+        }
+    }
+
+    abstract class MultiLayer
+    {
+         
+    }
+
+    class MiddleLayer : MultiLayer
+    {
+       [Inject]
+        public MiddleLayer() { }
+    }
+
+    class LowerLayer : MiddleLayer 
+    {
+       [Inject]
+        public LowerLayer() { }
+    }
+
+    interface IMultiLayer
+    {
+
+    }
+
+    class MiddleLayerImpl : IMultiLayer
+    {
+        [Inject]
+        public MiddleLayerImpl() { }
+    }
+
+    class LowerLayerImpl : MiddleLayerImpl
+    {
+        [Inject]
+        public LowerLayerImpl() { }
+    }
+}
\ No newline at end of file


[27/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/HeartBeatManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/HeartBeatManager.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/HeartBeatManager.cs
new file mode 100644
index 0000000..e495fda
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/HeartBeatManager.cs
@@ -0,0 +1,390 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Context;
+using Org.Apache.Reef.Common.Evaluator;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Common.Runtime;
+using Org.Apache.Reef.Evaluator;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Remote;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using Org.Apache.Reef.Wake.Time;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Threading;
+
+namespace Org.Apache.Reef.Common
+{
+    public class HeartBeatManager : IObserver<Alarm>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(HeartBeatManager));
+
+        private static readonly MachineStatus MachineStatus = new MachineStatus();
+
+        private readonly IRemoteManager<REEFMessage> _remoteManager;
+
+        private readonly IClock _clock;
+
+        private readonly int _heartBeatPeriodInMillSeconds;
+
+        private readonly int _maxHeartbeatRetries = 0;
+
+        private readonly string _evaluatorId;
+
+        private IRemoteIdentifier _remoteId;
+
+        private IObserver<REEFMessage> _observer;
+
+        private int _heartbeatFailures = 0;
+
+        private IDriverConnection _driverConnection;
+
+        private EvaluatorSettings _evaluatorSettings;
+
+        // the queue can only contains the following:
+        // 1. all failed heartbeats (regular and event-based) before entering RECOVERY state
+        // 2. event-based heartbeats generated in RECOVERY state (since there will be no attempt to send regular heartbeat)
+        private Queue<EvaluatorHeartbeatProto> _queuedHeartbeats = new Queue<EvaluatorHeartbeatProto>();
+
+        public HeartBeatManager(EvaluatorSettings settings, IRemoteIdentifier remoteId)
+        {
+            using (LOGGER.LogFunction("HeartBeatManager::HeartBeatManager"))
+            {
+                _remoteManager = settings.RemoteManager;
+                _remoteId = remoteId;
+                _evaluatorId = settings.EvalutorId;
+                _observer = _remoteManager.GetRemoteObserver(new RemoteEventEndPoint<REEFMessage>(_remoteId));
+                _clock = settings.RuntimeClock;
+                _heartBeatPeriodInMillSeconds = settings.HeartBeatPeriodInMs;
+                _maxHeartbeatRetries = settings.MaxHeartbeatFailures;
+                EvaluatorSettings = settings;
+                MachineStatus.ToString(); // kick start the CPU perf counter
+            }
+        }
+
+        [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Intended to be private, exposed now before using future injection")]
+        public EvaluatorRuntime _evaluatorRuntime { get; set; }
+
+        [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Intended to be private, exposed now before using future injection")]
+        public ContextManager _contextManager { get; set; }
+
+        public EvaluatorSettings EvaluatorSettings
+        {
+            get
+            {
+                return _evaluatorSettings;
+            }
+
+            private set
+            {
+                _evaluatorSettings = value;
+            }
+        }
+
+        public void Send(EvaluatorHeartbeatProto evaluatorHeartbeatProto)
+        {
+            lock (_queuedHeartbeats)
+            {
+                if (_evaluatorSettings.OperationState == EvaluatorOperationState.RECOVERY)
+                {
+                    LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "In RECOVERY mode, heartbeat queued as [{0}]. ", evaluatorHeartbeatProto));
+                    _queuedHeartbeats.Enqueue(evaluatorHeartbeatProto);
+                    return;
+                }
+
+                // NOT during recovery, try to send
+                REEFMessage payload = new REEFMessage(evaluatorHeartbeatProto);
+                try
+                {
+                    _observer.OnNext(payload);
+                    _heartbeatFailures = 0; // reset failure counts if we are having intermidtten (not continuous) failures
+                }
+                catch (Exception e)
+                {
+                    if (evaluatorHeartbeatProto.task_status == null || evaluatorHeartbeatProto.task_status.state != State.RUNNING)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, "Lost communications to driver when no task is running, recovery NOT supported for such scenario", LOGGER);
+                    }
+
+                    _heartbeatFailures++;
+
+                    _queuedHeartbeats.Enqueue(evaluatorHeartbeatProto);
+                    LOGGER.Log(Level.Error, string.Format(CultureInfo.InvariantCulture, "Sending heartbeat to driver experienced #{0} failure. Hearbeat queued as: [{1}]. ", _heartbeatFailures, evaluatorHeartbeatProto), e);
+
+                    if (_heartbeatFailures >= _maxHeartbeatRetries)
+                    {
+                        LOGGER.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Heartbeat communications to driver reached max of {0} failures. \n==== Driver is considered dead/unreachable. === \n=========== Entering RECOVERY mode. ===========", _heartbeatFailures));
+                        try
+                        {
+                            _driverConnection = _evaluatorSettings.Injector.GetInstance<IDriverConnection>();
+                        }
+                        catch (Exception ex)
+                        {
+                            Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, "Failed to inject the driver reconnect implementation", LOGGER);
+                        }
+                        LOGGER.Log(Level.Info, "instantiate driver reconnect implementation: " + _driverConnection);
+                        _evaluatorSettings.OperationState = EvaluatorOperationState.RECOVERY;
+
+                        // clean heartbeat failure
+                        _heartbeatFailures = 0;
+                    }
+                }
+            }     
+        }
+
+        /// <summary>
+        /// Assemble a complete new heartbeat and send it out.
+        /// </summary>
+        public void OnNext()
+        {
+            LOGGER.Log(Level.Verbose, "Before aqcuiring lock: HeartbeatManager::OnNext()");
+            lock (this)
+            {
+                LOGGER.Log(Level.Verbose, "HeartbeatManager::OnNext()");
+                EvaluatorHeartbeatProto heartbeatProto = GetEvaluatorHeartbeatProto();
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Triggered a heartbeat: {0}.", heartbeatProto));
+                Send(heartbeatProto);
+            }
+        }
+
+        /// <summary>
+        /// Called with a specific TaskStatus that must be delivered to the driver
+        /// </summary>
+        /// <param name="taskStatusProto"></param>
+        public void OnNext(TaskStatusProto taskStatusProto)
+        {
+            LOGGER.Log(Level.Verbose, "Before aqcuiring lock: HeartbeatManager::OnNext(TaskStatusProto)");
+            lock (this)
+            {
+                LOGGER.Log(Level.Verbose, "HeartbeatManager::OnNext(TaskStatusProto)");
+                EvaluatorHeartbeatProto heartbeatProto = GetEvaluatorHeartbeatProto(
+                    _evaluatorRuntime.GetEvaluatorStatus(),
+                    _contextManager.GetContextStatusCollection(),
+                     Optional<TaskStatusProto>.Of(taskStatusProto));
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Triggered a heartbeat: {0}.", heartbeatProto));
+                Send(heartbeatProto);
+            }
+        }
+
+        /// <summary>
+        ///  Called with a specific ContextStatusProto that must be delivered to the driver
+        /// </summary>
+        /// <param name="contextStatusProto"></param>
+        public void OnNext(ContextStatusProto contextStatusProto)
+        {
+            LOGGER.Log(Level.Verbose, "Before aqcuiring lock: HeartbeatManager::OnNext(ContextStatusProto)");
+            lock (this)
+            {
+                LOGGER.Log(Level.Verbose, "HeartbeatManager::OnNext(ContextStatusProto)");
+                List<ContextStatusProto> contextStatusProtos = new List<ContextStatusProto>();
+                contextStatusProtos.Add(contextStatusProto);
+                contextStatusProtos.AddRange(_contextManager.GetContextStatusCollection());
+                EvaluatorHeartbeatProto heartbeatProto = GetEvaluatorHeartbeatProto(
+                    _evaluatorRuntime.GetEvaluatorStatus(),
+                    contextStatusProtos,
+                    Optional<TaskStatusProto>.Empty());
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Triggered a heartbeat: {0}.", heartbeatProto));
+                Send(heartbeatProto);
+            }
+        }
+
+        /// <summary>
+        /// Called with a specific EvaluatorStatus that must be delivered to the driver
+        /// </summary>
+        /// <param name="evaluatorStatusProto"></param>
+        public void OnNext(EvaluatorStatusProto evaluatorStatusProto)
+        {
+            LOGGER.Log(Level.Verbose, "Before acquring lock: HeartbeatManager::OnNext(EvaluatorStatusProto)");
+            lock (this)
+            {
+                LOGGER.Log(Level.Verbose, "HeartbeatManager::OnNext(EvaluatorStatusProto)");
+                EvaluatorHeartbeatProto heartbeatProto = new EvaluatorHeartbeatProto()
+                {
+                    timestamp = CurrentTimeMilliSeconds(),
+                    evaluator_status = evaluatorStatusProto
+                };
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Triggered a heartbeat: {0}.", heartbeatProto));
+                Send(heartbeatProto);
+            }
+        }
+
+        public void OnNext(Alarm value)
+        {
+            LOGGER.Log(Level.Verbose, "Before acquring lock: HeartbeatManager::OnNext(Alarm)");
+            lock (this)
+            {
+                LOGGER.Log(Level.Verbose, "HeartbeatManager::OnNext(Alarm)");
+                if (_evaluatorSettings.OperationState == EvaluatorOperationState.OPERATIONAL && _evaluatorRuntime.State == State.RUNNING)
+                {
+                    EvaluatorHeartbeatProto evaluatorHeartbeatProto = GetEvaluatorHeartbeatProto();
+                    LOGGER.Log(Level.Verbose, string.Format(CultureInfo.InvariantCulture, "Triggered a heartbeat: {0}. {1}Node Health: {2}", evaluatorHeartbeatProto, Environment.NewLine, MachineStatus.ToString()));
+                    Send(evaluatorHeartbeatProto);
+                    _clock.ScheduleAlarm(_heartBeatPeriodInMillSeconds, this);
+                }
+                else
+                {
+                    LOGGER.Log(Level.Verbose, string.Format(CultureInfo.InvariantCulture, "Ignoring regular heartbeat since Evaluator operation state is [{0}] and runtime state is [{1}]. ", _evaluatorSettings.OperationState,  _evaluatorRuntime.State));
+                    try
+                    {
+                        DriverInformation driverInformation = _driverConnection.GetDriverInformation(_evaluatorSettings.ApplicationId);
+                        if (driverInformation == null)
+                        {
+                            LOGGER.Log(Level.Verbose, "In RECOVERY mode, cannot retrieve driver information, will try again later.");
+                        }
+                        else
+                        {
+                            LOGGER.Log(
+                                Level.Info, 
+                                string.Format(CultureInfo.InvariantCulture, "Detect driver restarted at {0} and is running on endpoint {1} with services {2}. Now trying to re-establish connection", driverInformation.DriverStartTime, driverInformation.DriverRemoteIdentifier, driverInformation.NameServerId));
+                            Recover(driverInformation);
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        // we do not want any exception to stop the query for driver status
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, LOGGER);
+                    }
+                    _clock.ScheduleAlarm(_heartBeatPeriodInMillSeconds, this);
+                }
+            }
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+
+        private static long CurrentTimeMilliSeconds()
+        {
+            // this is an implmenation to get current time milli second counted from Jan 1st, 1970
+            // it is chose as such to be compatible with java implmentation
+            DateTime jan1St1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            return (long)(DateTime.UtcNow - jan1St1970).TotalMilliseconds;
+        }
+
+        private void Recover(DriverInformation driverInformation)
+        {
+            IPEndPoint driverEndpoint = NetUtilities.ParseIpEndpoint(driverInformation.DriverRemoteIdentifier);
+            _remoteId = new SocketRemoteIdentifier(driverEndpoint);
+            _observer = _remoteManager.GetRemoteObserver(new RemoteEventEndPoint<REEFMessage>(_remoteId));
+            lock (_evaluatorSettings)
+            {
+                if (_evaluatorSettings.NameClient != null)
+                {
+                    try
+                    {
+                        LOGGER.Log(Level.Verbose, "Trying to reset and reconnect to name server" + driverInformation.NameServerId);
+                        _evaluatorSettings.NameClient.Restart(NetUtilities.ParseIpEndpoint(driverInformation.NameServerId));
+                        LOGGER.Log(Level.Info, "Reconnected to name server: " + driverInformation.NameServerId);
+                    }
+                    catch (Exception e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+                    }
+                }
+            }
+
+            lock (_queuedHeartbeats)
+            {
+                bool firstHeartbeatInQueue = true;
+                while (_queuedHeartbeats.Any())
+                {
+                    LOGGER.Log(Level.Info, "Sending cached recovery heartbeats to " + _remoteId);
+                    try
+                    {
+                        if (firstHeartbeatInQueue)
+                        {
+                            // first heartbeat is specially construted to include the recovery flag
+                            EvaluatorHeartbeatProto recoveryHeartbeat = ConstructRecoveryHeartBeat(_queuedHeartbeats.Dequeue());
+                            LOGGER.Log(Level.Info, "Recovery heartbeat to be sent:" + recoveryHeartbeat);
+                            _observer.OnNext(new REEFMessage(recoveryHeartbeat));
+                            firstHeartbeatInQueue = false;
+                        }
+                        else
+                        {
+                            _observer.OnNext(new REEFMessage(_queuedHeartbeats.Dequeue()));
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        // we do not handle failures during RECOVERY 
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(
+                            e,
+                            Level.Error,
+                            string.Format(CultureInfo.InvariantCulture, "Hearbeat attempt failed in RECOVERY mode to Driver {0} , giving up...", _remoteId),
+                            LOGGER);
+                    }
+                    Thread.Sleep(500);
+                }
+            }        
+            _evaluatorSettings.OperationState = EvaluatorOperationState.OPERATIONAL;
+            LOGGER.Log(Level.Info, "=========== Exiting RECOVERY mode. ===========");
+        }
+
+        private EvaluatorHeartbeatProto ConstructRecoveryHeartBeat(EvaluatorHeartbeatProto heartbeat)
+        {
+            heartbeat.recovery = true;
+            heartbeat.context_status.ForEach(c => c.recovery = true);
+            heartbeat.task_status.recovery = true;
+            return heartbeat;
+        }
+
+        private EvaluatorHeartbeatProto GetEvaluatorHeartbeatProto()
+        {
+            return GetEvaluatorHeartbeatProto(
+                _evaluatorRuntime.GetEvaluatorStatus(),
+                _contextManager.GetContextStatusCollection(),
+                _contextManager.GetTaskStatus());
+        }
+
+        private EvaluatorHeartbeatProto GetEvaluatorHeartbeatProto(
+            EvaluatorStatusProto evaluatorStatusProto,
+            ICollection<ContextStatusProto> contextStatusProtos,
+            Optional<TaskStatusProto> taskStatusProto)
+        {
+            EvaluatorHeartbeatProto evaluatorHeartbeatProto = new EvaluatorHeartbeatProto()
+            {
+                timestamp = CurrentTimeMilliSeconds(),
+                evaluator_status = evaluatorStatusProto
+            };
+            foreach (ContextStatusProto contextStatusProto in contextStatusProtos)
+            {
+                evaluatorHeartbeatProto.context_status.Add(contextStatusProto);
+            }
+            if (taskStatusProto.IsPresent())
+            {
+                evaluatorHeartbeatProto.task_status = taskStatusProto.Value;
+            }
+            return evaluatorHeartbeatProto;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/ReefMessageProtoObserver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/ReefMessageProtoObserver.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/ReefMessageProtoObserver.cs
new file mode 100644
index 0000000..8a7aa94
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/ReefMessageProtoObserver.cs
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake.Remote;
+using System;
+using System.Globalization;
+using System.Threading;
+
+namespace Org.Apache.Reef.Common
+{
+    public class ReefMessageProtoObserver :
+        IObserver<IRemoteMessage<REEFMessage>>,
+        IObservable<IRemoteMessage<REEFMessage>>,
+        IDisposable
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ReefMessageProtoObserver));
+        private volatile IObserver<IRemoteMessage<REEFMessage>> _observer = null;
+        private long _count = 0;
+        private DateTime _begin;
+        private DateTime _origBegin;
+
+        public void OnCompleted()
+        {
+        }
+
+        public void OnError(Exception error)
+        {
+        }
+
+        public void OnNext(IRemoteMessage<REEFMessage> value)
+        {
+            REEFMessage remoteEvent = value.Message;
+            IRemoteIdentifier id = value.Identifier;
+            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "receive a ReefMessage from {0} Driver at {1}.", remoteEvent, id));
+
+            if (remoteEvent.evaluatorControl != null)
+            {
+                if (remoteEvent.evaluatorControl.context_control != null)
+                {
+                    string context_message = null;
+                    string task_message = null;
+
+                    if (remoteEvent.evaluatorControl.context_control.context_message != null)
+                    {
+                        context_message = remoteEvent.evaluatorControl.context_control.context_message.ToString();
+                    }
+                    if (remoteEvent.evaluatorControl.context_control.task_message != null)
+                    {
+                        task_message = ByteUtilities.ByteArrarysToString(remoteEvent.evaluatorControl.context_control.task_message);
+                    }
+
+                    if (!(string.IsNullOrEmpty(context_message) && string.IsNullOrEmpty(task_message)))
+                    {
+                        LOGGER.Log(Level.Info, 
+                            string.Format(CultureInfo.InvariantCulture, "Control protobuf with context message [{0}] and task message [{1}]", context_message, task_message));
+                    }                   
+                    else if (remoteEvent.evaluatorControl.context_control.remove_context != null)
+                    {
+                         LOGGER.Log(Level.Info, 
+                            string.Format(CultureInfo.InvariantCulture, "Control protobuf to remove context {0}", remoteEvent.evaluatorControl.context_control.remove_context.context_id));
+                    }
+                    else if (remoteEvent.evaluatorControl.context_control.add_context != null)
+                    {
+                        LOGGER.Log(Level.Info, 
+                            string.Format(CultureInfo.InvariantCulture, "Control protobuf to add a context on top of {0}", remoteEvent.evaluatorControl.context_control.add_context.parent_context_id));
+                    }
+                    else if (remoteEvent.evaluatorControl.context_control.start_task != null)
+                    {
+                        LOGGER.Log(Level.Info, 
+                            string.Format(CultureInfo.InvariantCulture, "Control protobuf to start an task in {0}", remoteEvent.evaluatorControl.context_control.start_task.context_id));
+                    }
+                    else if (remoteEvent.evaluatorControl.context_control.stop_task != null)
+                    {
+                        LOGGER.Log(Level.Info, "Control protobuf to stop task");
+                    }
+                    else if (remoteEvent.evaluatorControl.context_control.suspend_task != null)
+                    {
+                        LOGGER.Log(Level.Info, "Control protobuf to suspend task"); 
+                    }
+                }
+            } 
+            if (_count == 0)
+            {
+                _begin = DateTime.Now;
+                _origBegin = _begin;
+            }
+            var count = Interlocked.Increment(ref _count);
+
+            int printBatchSize = 100000;
+            if (count % printBatchSize == 0)
+            {
+                DateTime end = DateTime.Now;
+                var diff = (end - _begin).TotalMilliseconds;
+                double seconds = diff / 1000.0;
+                long eventsPerSecond = (long)(printBatchSize / seconds);
+                _begin = DateTime.Now;
+            }
+
+            var observer = _observer;
+            if (observer != null)
+            {
+                observer.OnNext(value);
+            }
+        }
+
+        public IDisposable Subscribe(IObserver<IRemoteMessage<REEFMessage>> observer)
+        {
+            if (_observer != null)
+            {
+                return null;
+            }
+            _observer = observer;
+            return this;
+        }
+
+        public void Dispose()
+        {
+            _observer = null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextClientCodeException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextClientCodeException.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextClientCodeException.cs
new file mode 100644
index 0000000..31194a7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextClientCodeException.cs
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public class ContextClientCodeException : Exception
+    {
+        private readonly string _contextId;
+        private readonly Optional<string> _parentId;
+
+        /// <summary>
+        /// construt the exception that caused the error
+        /// </summary>
+        /// <param name="contextId"> the id of the failed context.</param>
+        /// <param name="parentId"> the id of the failed context's parent, if any.</param>
+        /// <param name="message"> the error message </param>
+        /// <param name="cause"> the exception that caused the error</param>
+        public ContextClientCodeException(
+                string contextId,
+                Optional<string> parentId,
+                string message,
+                Exception cause)
+            : base("Failure in context '" + contextId + "': " + message, cause)
+        {
+            _contextId = contextId;
+            _parentId = parentId;
+        }
+
+        public string ContextId
+        {
+            get { return _contextId; }
+        }
+
+        public Optional<string> ParentId
+        {
+            get { return _parentId; }
+        }
+
+        /// <summary>
+        /// Extracts a context id from the given configuration.
+        /// </summary>
+        /// <param name="c"></param>
+        /// <returns>the context id in the given configuration.</returns>
+        public static string GetId(IConfiguration c)
+        {
+            // TODO: update after TANG is available
+            return string.Empty;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextConfiguration.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextConfiguration.cs
new file mode 100644
index 0000000..ca6b949
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextConfiguration.cs
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using Org.Apache.Reef.Tang.Types;
+
+namespace Org.Apache.Reef.Common.Evaluator.Context
+{
+    public class ContextConfiguration : IConfiguration
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ContextConfiguration));
+        
+        private Dictionary<string, string> _settings;
+
+        public ContextConfiguration(string configString)
+        {
+            using (LOGGER.LogFunction("ContextConfiguration::ContextConfigurationn"))
+            {
+                ContainerDirectory = Directory.GetCurrentDirectory();
+
+                _settings = new Dictionary<string, string>();
+                AvroConfiguration avroConfiguration = AvroConfiguration.GetAvroConfigurationFromEmbeddedString(configString);
+                foreach (ConfigurationEntry config in avroConfiguration.Bindings)
+                {
+                    if (config.key.Contains(Reef.Evaluator.Constants.ContextIdentifier))
+                    {
+                        config.key = Reef.Evaluator.Constants.ContextIdentifier;
+                        LOGGER.Log(Level.Verbose, string.Format(CultureInfo.InvariantCulture, "{0} detected for context id with value {1}", config.key, config.value));
+                    }
+                    _settings.Add(config.key, config.value);
+                }
+                if (!_settings.ContainsKey(Reef.Evaluator.Constants.ContextIdentifier))
+                {
+                    string msg = "Required parameter ContextIdentifier not provided.";
+                    LOGGER.Log(Level.Error, msg);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException(msg), LOGGER);
+                }
+            }
+        }
+
+        public string Id
+        {
+            get { return _settings[Reef.Evaluator.Constants.ContextIdentifier]; }
+        }
+
+        public string ContainerDirectory { get; set; }
+
+        public IConfigurationBuilder newBuilder()
+        {
+            throw new NotImplementedException();
+        }
+
+        public string GetNamedParameter(INamedParameterNode np)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IClassHierarchy GetClassHierarchy()
+        {
+            throw new NotImplementedException();
+        }
+
+        public ISet<object> GetBoundSet(INamedParameterNode np)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IClassNode GetBoundConstructor(IClassNode cn)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IClassNode GetBoundImplementation(IClassNode cn)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IConstructorDef GetLegacyConstructor(IClassNode cn)
+        {
+            throw new NotImplementedException();
+        }
+
+        public ICollection<IClassNode> GetBoundImplementations()
+        {
+            throw new NotImplementedException();
+        }
+
+        public ICollection<IClassNode> GetBoundConstructors()
+        {
+            throw new NotImplementedException();
+        }
+
+        public ICollection<INamedParameterNode> GetNamedParameters()
+        {
+            throw new NotImplementedException();
+        }
+
+        public ICollection<IClassNode> GetLegacyConstructors()
+        {
+            throw new NotImplementedException();
+        }
+
+        public IList<object> GetBoundList(INamedParameterNode np)
+        {
+            throw new NotImplementedException();
+        }
+
+        public IEnumerator<KeyValuePair<INamedParameterNode, object>> GetBoundSets()
+        {
+            throw new NotImplementedException();
+        }
+
+        public IDictionary<INamedParameterNode, IList<object>> GetBoundList()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextLifeCycle.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextLifeCycle.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextLifeCycle.cs
new file mode 100644
index 0000000..9967258
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextLifeCycle.cs
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Events;
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    /// <summary>
+    /// This class is used to trigger all the context life-cycle dependent events.
+    /// </summary>
+    class ContextLifeCycle
+    {
+        private HashSet<IObserver<IContextStart>> _contextStartHandlers;
+
+        private HashSet<IObserver<IContextStop>> _contextStopHandlers;
+
+        private HashSet<IContextMessageSource> _contextMessageSources;
+
+        // @Inject
+        public ContextLifeCycle(
+            string id,
+            HashSet<IObserver<IContextStart>> contextStartHandlers,
+            HashSet<IObserver<IContextStop>> contextStopHandlers,
+            HashSet<IContextMessageSource> contextMessageSources)
+        {
+            Id = id;
+            _contextStartHandlers = contextStartHandlers;
+            _contextStopHandlers = contextStopHandlers;
+            _contextMessageSources = contextMessageSources;
+        }
+
+        public ContextLifeCycle(string contextId)
+        {
+            Id = contextId;
+            _contextStartHandlers = new HashSet<IObserver<IContextStart>>();
+            _contextStopHandlers = new HashSet<IObserver<IContextStop>>();
+            _contextMessageSources = new HashSet<IContextMessageSource>();
+        }
+
+        public string Id { get; private set; }
+
+        public HashSet<IContextMessageSource> ContextMessageSources
+        {
+            get { return _contextMessageSources; }
+        }
+
+        /// <summary>
+        /// Fires ContextStart to all registered event handlers.
+        /// </summary>
+        public void Start()
+        {
+            IContextStart contextStart = new ContextStartImpl(Id);
+            
+            // TODO: enable
+            //foreach (IObserver<IContextStart> startHandler in _contextStartHandlers)
+            //{
+            //    startHandler.OnNext(contextStart);
+            //}
+        }
+
+        /// <summary>
+        /// Fires ContextStop to all registered event handlers.
+        /// </summary>
+        public void Close()
+        {
+            //IContextStop contextStop = new ContextStopImpl(Id);
+            //foreach (IObserver<IContextStop> startHandler in _contextStopHandlers)
+            //{
+            //    startHandler.OnNext(contextStop);
+            //}
+        }
+
+        public void HandleContextMessage(byte[] message)
+        {
+            //contextMessageHandler.onNext(message);
+        }
+
+        /// <summary>
+        /// get the set of ContextMessageSources configured
+        /// </summary>
+        /// <returns>(a shallow copy of) the set of ContextMessageSources configured.</returns>
+        public HashSet<IContextMessageSource> GetContextMessageSources()
+        {
+            return new HashSet<IContextMessageSource>(_contextMessageSources);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextManager.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextManager.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextManager.cs
new file mode 100644
index 0000000..15b09b9
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextManager.cs
@@ -0,0 +1,362 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Evaluator.Context;
+using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Evaluator;
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Linq;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public class ContextManager : IDisposable
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ContextManager));
+        
+        private readonly Stack<ContextRuntime> _contextStack = new Stack<ContextRuntime>();
+
+        private readonly HeartBeatManager _heartBeatManager;
+
+        private RootContextLauncher _rootContextLauncher;
+
+        public ContextManager(HeartBeatManager heartBeatManager, Optional<ServiceConfiguration> rootServiceConfig, Optional<TaskConfiguration> rootTaskConfig)
+        {
+            using (LOGGER.LogFunction("ContextManager::ContextManager"))
+            {
+                _heartBeatManager = heartBeatManager;
+                _rootContextLauncher = new RootContextLauncher(_heartBeatManager.EvaluatorSettings.RootContextConfig, rootServiceConfig, rootTaskConfig);
+            }
+        }
+
+        /// <summary>
+        /// Start the context manager. This initiates the root context.
+        /// </summary>
+        public void Start()
+        {
+            lock (_contextStack)
+            {
+                ContextRuntime rootContext = _rootContextLauncher.GetRootContext();
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Instantiating root context with Id {0}", rootContext.Id));
+                _contextStack.Push(rootContext);
+
+                if (_rootContextLauncher.RootTaskConfig.IsPresent())
+                {
+                    LOGGER.Log(Level.Info, "Launching the initial Task");
+                    try
+                    {
+                        _contextStack.Peek().StartTask(_rootContextLauncher.RootTaskConfig.Value, _rootContextLauncher.RootContextConfig.Id, _heartBeatManager);
+                    }
+                    catch (TaskClientCodeException e)
+                    {
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Exception when trying to start a task.", LOGGER);
+                        HandleTaskException(e);
+                    }
+                }
+            }
+        }
+
+        public bool ContextStackIsEmpty()
+        {
+            lock (_contextStack)
+            {
+                return (_contextStack.Count == 0);
+            }
+        }
+
+        // TODO: codes here are slightly different from java since the protobuf.net does not generate the HasXXX method, may want to switch to proto-port later
+
+        /// <summary>
+        /// Processes the given ContextControlProto to launch / close / suspend Tasks and Contexts.
+        /// This also triggers the HeartBeatManager to send a heartbeat with the result of this operation.
+        /// </summary>
+        /// <param name="controlMessage"></param>
+        public void HandleTaskControl(ContextControlProto controlMessage)
+        {
+            try
+            {
+                byte[] message = controlMessage.task_message;
+                if (controlMessage.add_context != null && controlMessage.remove_context != null)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException("Received a message with both add and remove context. This is unsupported."), LOGGER);
+                }
+                if (controlMessage.add_context != null)
+                {
+                    LOGGER.Log(Level.Info, "AddContext");
+                    AddContext(controlMessage.add_context);
+                    // support submitContextAndTask()
+                    if (controlMessage.start_task != null)
+                    {
+                        LOGGER.Log(Level.Info, "StartTask");
+                        StartTask(controlMessage.start_task);
+                    }
+                    else
+                    {
+                        // We need to trigger a heartbeat here. In other cases, the heartbeat will be triggered by the TaskRuntime
+                        // Therefore this call can not go into addContext
+                        LOGGER.Log(Level.Info, "Trigger Heartbeat");
+                        _heartBeatManager.OnNext();
+                    }
+                }
+                else if (controlMessage.remove_context != null)
+                {
+                    LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "RemoveContext with id {0}", controlMessage.remove_context.context_id));
+                    RemoveContext(controlMessage.remove_context.context_id);
+                }
+                else if (controlMessage.start_task != null)
+                {
+                    LOGGER.Log(Level.Info, "StartTask only");
+                    StartTask(controlMessage.start_task);
+                }
+                else if (controlMessage.stop_task != null)
+                {
+                    LOGGER.Log(Level.Info, "CloseTask");
+                    _contextStack.Peek().CloseTask(message);
+                }
+                else if (controlMessage.suspend_task != null)
+                {
+                    LOGGER.Log(Level.Info, "SuspendTask");
+                    _contextStack.Peek().SuspendTask(message);
+                }
+                else if (controlMessage.task_message != null)
+                {
+                    LOGGER.Log(Level.Info, "DeliverTaskMessage");
+                    _contextStack.Peek().DeliverTaskMessage(message);
+                }
+                else if (controlMessage.context_message != null)
+                {
+                    LOGGER.Log(Level.Info, "Handle context contol message");
+                    ContextMessageProto contextMessageProto = controlMessage.context_message;
+                    bool deliveredMessage = false;
+                    foreach (ContextRuntime context in _contextStack)
+                    {
+                        if (context.Id.Equals(contextMessageProto.context_id))
+                        {
+                            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Handle context message {0}", controlMessage.context_message.message));
+                            context.HandleContextMessaage(controlMessage.context_message.message);
+                            deliveredMessage = true;
+                            break;
+                        }
+                    }
+                    if (!deliveredMessage)
+                    {
+                        InvalidOperationException e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Sent message to unknown context {0}", contextMessageProto.context_id));
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                    }
+                }
+                else
+                {
+                    InvalidOperationException e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unknown task control message: {0}", controlMessage.ToString()));
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                } 
+            }
+            catch (Exception e)
+            {
+                if (e is TaskClientCodeException)
+                {
+                    HandleTaskException((TaskClientCodeException)e);
+                }
+                else if (e is ContextClientCodeException)
+                {
+                    HandlContextException((ContextClientCodeException)e);
+                }
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(e, Level.Error, LOGGER);
+            }  
+        }
+
+        /// <summary>
+        /// Get TaskStatusProto of the currently running task, if there is any
+        /// </summary>
+        /// <returns>the TaskStatusProto of the currently running task, if there is any</returns>
+        public Optional<TaskStatusProto> GetTaskStatus()
+        {
+            if (_contextStack.Count == 0)
+            {
+                return Optional<TaskStatusProto>.Empty();
+
+                //throw new InvalidOperationException("Asked for an Task status while there isn't even a context running.");
+            }
+            return _contextStack.Peek().GetTaskStatus();
+        }
+
+        /// <summary>
+        /// get status of all contexts in the stack.
+        /// </summary>
+        /// <returns>the status of all contexts in the stack.</returns>
+        public ICollection<ContextStatusProto> GetContextStatusCollection()
+        {
+            ICollection<ContextStatusProto> result = new Collection<ContextStatusProto>();
+            foreach (ContextRuntime runtime in _contextStack)
+            {
+                ContextStatusProto contextStatusProto = runtime.GetContextStatus();
+                LOGGER.Log(Level.Verbose, string.Format(CultureInfo.InvariantCulture, "Add context status: {0}", contextStatusProto));
+                result.Add(contextStatusProto);
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// Shuts down. This forecefully kills the Task if there is one and then shuts down all Contexts on the stack,
+        /// starting at the top.
+        /// </summary>
+        public void Dispose()
+        {
+            lock (_contextStack)
+            {
+                if (_contextStack != null && _contextStack.Any())
+                {
+                    LOGGER.Log(Level.Info, "context stack not empty, forcefully closing context runtime.");
+                    ContextRuntime runtime = _contextStack.Last();
+                    if (runtime != null)
+                    {
+                        runtime.Dispose();
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Add a context to the stack.
+        /// </summary>
+        /// <param name="addContextProto"></param>
+        private void AddContext(AddContextProto addContextProto)
+        {
+            lock (_contextStack)
+            {
+                ContextRuntime currentTopContext = _contextStack.Peek();
+                if (!currentTopContext.Id.Equals(addContextProto.parent_context_id, StringComparison.OrdinalIgnoreCase))
+                {
+                    var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Trying to instantiate a child context on context with id '{0}' while the current top context id is {1}",
+                        addContextProto.parent_context_id,
+                        currentTopContext.Id));
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                string contextConfigString = addContextProto.context_configuration;
+                ContextConfiguration contextConfiguration = new ContextConfiguration(contextConfigString);
+                ContextRuntime newTopContext;
+                if (addContextProto.service_configuration != null)
+                {
+                    ServiceConfiguration serviceConfiguration = new ServiceConfiguration(addContextProto.service_configuration);
+                    newTopContext = currentTopContext.SpawnChildContext(contextConfiguration, serviceConfiguration.TangConfig);
+                }
+                else
+                {
+                    newTopContext = currentTopContext.SpawnChildContext(contextConfiguration);
+                }
+                _contextStack.Push(newTopContext);
+            }
+        }
+
+        /// <summary>
+        /// Remove the context with the given ID from the stack.
+        /// </summary>
+        /// <param name="contextId"> context id</param>
+        private void RemoveContext(string contextId)
+        {
+            lock (_contextStack)
+            {
+                string currentTopContextId = _contextStack.Peek().Id;
+                if (!contextId.Equals(_contextStack.Peek().Id, StringComparison.OrdinalIgnoreCase))
+                {
+                    var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Trying to close context with id '{0}' while the top context id is {1}", contextId, currentTopContextId));
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                _contextStack.Peek().Dispose();
+                if (_contextStack.Count > 1)
+                {
+                    // We did not close the root context. Therefore, we need to inform the
+                    // driver explicitly that this context is closed. The root context notification
+                    // is implicit in the Evaluator close/done notification.
+                    _heartBeatManager.OnNext(); // Ensure Driver gets notified of context DONE state
+                }
+                _contextStack.Pop();
+            }
+            //  System.gc(); // TODO: garbage collect?
+        }
+
+        /// <summary>
+        /// Launch an Task.
+        /// </summary>
+        /// <param name="startTaskProto"></param>
+        private void StartTask(StartTaskProto startTaskProto)
+        {
+            lock (_contextStack)
+            {
+                ContextRuntime currentActiveContext = _contextStack.Peek();
+                string expectedContextId = startTaskProto.context_id;
+                if (!expectedContextId.Equals(currentActiveContext.Id, StringComparison.OrdinalIgnoreCase))
+                {
+                    var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Task expected context '{0}' but the active context has Id '{1}'", expectedContextId, currentActiveContext.Id));
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                TaskConfiguration taskConfiguration = new TaskConfiguration(startTaskProto.configuration);
+                currentActiveContext.StartTask(taskConfiguration, expectedContextId, _heartBeatManager);
+            }
+        }
+
+        /// <summary>
+        ///  THIS ASSUMES THAT IT IS CALLED ON A THREAD HOLDING THE LOCK ON THE HeartBeatManager
+        /// </summary>
+        /// <param name="e"></param>
+        private void HandleTaskException(TaskClientCodeException e)
+        {
+            LOGGER.Log(Level.Error, "TaskClientCodeException", e);
+            byte[] exception = ByteUtilities.StringToByteArrays(e.ToString());
+            TaskStatusProto taskStatus = new TaskStatusProto()
+            {
+                context_id = e.ContextId,
+                task_id = e.TaskId,
+                result = exception,
+                state = State.FAILED
+            };
+            LOGGER.Log(Level.Error, string.Format(CultureInfo.InvariantCulture, "Sending Heartbeatb for a failed task: {0}", taskStatus.ToString()));
+            _heartBeatManager.OnNext(taskStatus);
+        }
+
+        /// <summary>
+        /// THIS ASSUMES THAT IT IS CALLED ON A THREAD HOLDING THE LOCK ON THE HeartBeatManager
+        /// </summary>
+        /// <param name="e"></param>
+        private void HandlContextException(ContextClientCodeException e)
+        {
+            LOGGER.Log(Level.Error, "ContextClientCodeException", e);
+            byte[] exception = ByteUtilities.StringToByteArrays(e.ToString());
+            ContextStatusProto contextStatusProto = new ContextStatusProto()
+            {
+                context_id = e.ContextId,
+                context_state = ContextStatusProto.State.FAIL,
+                error = exception
+            };
+            if (e.ParentId.IsPresent())
+            {
+                contextStatusProto.parent_id = e.ParentId.Value;
+            }
+            LOGGER.Log(Level.Error, string.Format(CultureInfo.InvariantCulture, "Sending Heartbeat for a failed context: {0}", contextStatusProto.ToString()));
+            _heartBeatManager.OnNext(contextStatusProto);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextRuntime.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextRuntime.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextRuntime.cs
new file mode 100644
index 0000000..012e436
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextRuntime.cs
@@ -0,0 +1,478 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Evaluator.Context;
+using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto;
+using Org.Apache.Reef.Common.Task;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    public class ContextRuntime
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ContextRuntime));
+        // Context-local injector. This contains information that will not be available in child injectors.
+        private readonly IInjector _contextInjector;
+        //// Service injector. State in this injector moves to child injectors.
+        private readonly IInjector _serviceInjector;
+
+        // Convenience class to hold all the event handlers for the context as well as the service instances.
+        private readonly ContextLifeCycle _contextLifeCycle;
+
+        // The child context, if any.
+        private Optional<ContextRuntime> _childContext = Optional<ContextRuntime>.Empty();
+
+        // The parent context, if any.
+        private Optional<ContextRuntime> _parentContext = Optional<ContextRuntime>.Empty();
+
+        // The currently running task, if any.
+        private Optional<TaskRuntime> _task = Optional<TaskRuntime>.Empty();
+
+        private ContextStatusProto.State _contextState = ContextStatusProto.State.READY;
+
+        /// <summary>
+        /// Create a new ContextRuntime.
+        /// </summary>
+        /// <param name="serviceInjector"></param>
+        /// <param name="contextConfiguration">the Configuration for this context.</param>
+        /// <param name="parentContext"></param>
+        public ContextRuntime(
+                IInjector serviceInjector,
+                IConfiguration contextConfiguration,
+                Optional<ContextRuntime> parentContext)
+        {
+            ContextConfiguration config = contextConfiguration as ContextConfiguration;
+            if (config == null)
+            {
+                var e = new ArgumentException("contextConfiguration is not of type ContextConfiguration");
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+            }
+            _contextLifeCycle = new ContextLifeCycle(config.Id);
+            _serviceInjector = serviceInjector;
+            _parentContext = parentContext;
+            try
+            {
+                _contextInjector = serviceInjector.ForkInjector();
+            }
+            catch (Exception e)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+
+                Optional<string> parentId = ParentContext.IsPresent() ?
+                    Optional<string>.Of(ParentContext.Value.Id) :
+                    Optional<string>.Empty();
+                ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(contextConfiguration), parentId, "Unable to spawn context", e);
+                
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+            }
+            // Trigger the context start events on contextInjector.
+            _contextLifeCycle.Start();
+        }
+
+        /// <summary>
+        ///  Create a new ContextRuntime for the root context.
+        /// </summary>
+        /// <param name="serviceInjector"> </param> the serviceInjector to be used.
+        /// <param name="contextConfiguration"> the Configuration for this context.</param>
+        public ContextRuntime(
+            IInjector serviceInjector,
+            IConfiguration contextConfiguration)
+            : this(serviceInjector, contextConfiguration, Optional<ContextRuntime>.Empty())
+        {
+            LOGGER.Log(Level.Info, "Instantiating root context");
+        }
+
+        public string Id
+        {
+            get { return _contextLifeCycle.Id; }
+        }
+
+        public Optional<ContextRuntime> ParentContext
+        {
+            get { return _parentContext; }
+        }
+
+        /// <summary>
+        ///  Spawns a new context.
+        ///  The new context will have a serviceInjector that is created by forking the one in this object with the given
+        ///  serviceConfiguration. The contextConfiguration is used to fork the contextInjector from that new serviceInjector.
+        /// </summary>
+        /// <param name="contextConfiguration">the new context's context (local) Configuration.</param>
+        /// <param name="serviceConfiguration">the new context's service Configuration.</param>
+        /// <returns>a child context.</returns>
+        public ContextRuntime SpawnChildContext(IConfiguration contextConfiguration, IConfiguration serviceConfiguration)
+        {
+            ContextRuntime childContext = null;
+            lock (_contextLifeCycle)
+            {
+                if (_task.IsPresent())
+                {
+                    var e = new InvalidOperationException(
+                        string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId)); // note: java code is putting thread id here
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                if (_childContext.IsPresent())
+                {
+                    var e = new InvalidOperationException("Attempting to instantiate a child context on a context that is not the topmost active context.");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                try
+                {
+                    IInjector childServiceInjector = _serviceInjector.ForkInjector(new IConfiguration[] { serviceConfiguration });
+                    childContext = new ContextRuntime(childServiceInjector, contextConfiguration, Optional<ContextRuntime>.Of(this));
+                    _childContext = Optional<ContextRuntime>.Of(childContext);
+                    return childContext;
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
+
+                    Optional<string> parentId = ParentContext.IsPresent() ?
+                        Optional<string>.Of(ParentContext.Value.Id) :
+                        Optional<string>.Empty();
+                    ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(contextConfiguration), parentId, "Unable to spawn context", e);
+                    
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+            }
+            return childContext;
+        }
+
+        /// <summary>
+        /// Spawns a new context without services of its own.
+        /// The new context will have a serviceInjector that is created by forking the one in this object. The
+        /// contextConfiguration is used to fork the contextInjector from that new serviceInjector.
+        /// </summary>
+        /// <param name="contextConfiguration">the new context's context (local) Configuration.</param>
+        /// <returns> a child context.</returns>
+        public ContextRuntime SpawnChildContext(IConfiguration contextConfiguration)
+        {
+            lock (_contextLifeCycle)
+            {
+                if (_task.IsPresent())
+                {
+                    var e = new InvalidOperationException(
+                        string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId)); // note: java code is putting thread id here
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                if (_childContext.IsPresent())
+                {
+                    var e = new InvalidOperationException("Attempting to instantiate a child context on a context that is not the topmost active context.");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                IInjector childServiceInjector = _serviceInjector.ForkInjector();
+                ContextRuntime childContext = new ContextRuntime(childServiceInjector, contextConfiguration, Optional<ContextRuntime>.Of(this));
+                _childContext = Optional<ContextRuntime>.Of(childContext);
+                return childContext;
+            }
+        }
+
+        /// <summary>
+        ///  Launches an Task on this context.
+        /// </summary>
+        /// <param name="taskConfiguration"></param>
+        /// <param name="contextId"></param>
+        /// <param name="heartBeatManager"></param>
+        public void StartTask(TaskConfiguration taskConfiguration, string contextId, HeartBeatManager heartBeatManager)
+        {
+            lock (_contextLifeCycle)
+            {
+                bool taskPresent = _task.IsPresent();
+                bool taskEnded = taskPresent && _task.Value.HasEnded();
+
+                LOGGER.Log(Level.Info, "ContextRuntime::StartTask(TaskConfiguration)" + "task is present: " + taskPresent + " task has ended: " + taskEnded);
+                if (taskPresent)
+                {
+                    LOGGER.Log(Level.Info, "Task state: " + _task.Value.GetTaskState());
+                }
+
+                if (taskEnded)
+                {
+                    // clean up state
+                    _task = Optional<TaskRuntime>.Empty();
+                    taskPresent = false;
+                }
+                if (taskPresent)
+                {
+                    var e = new InvalidOperationException(
+                        string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId)); // note: java code is putting thread id here
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                if (_childContext.IsPresent())
+                {
+                    var e = new InvalidOperationException("Attempting to instantiate a child context on a context that is not the topmost active context.");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+                try
+                {
+                    IInjector taskInjector = _contextInjector.ForkInjector(new IConfiguration[] { taskConfiguration.TangConfig });
+                    LOGGER.Log(Level.Info, "Trying to inject task with configuration" + taskConfiguration.ToString());
+                    TaskRuntime taskRuntime = new TaskRuntime(taskInjector, contextId, taskConfiguration.TaskId, heartBeatManager); // taskInjector.getInstance(TaskRuntime.class);
+                    taskRuntime.Initialize();
+                    System.Threading.Tasks.Task.Run(new Action(taskRuntime.Start));                    
+                    _task = Optional<TaskRuntime>.Of(taskRuntime);
+                }
+                catch (Exception e)
+                {
+                    var ex = new TaskClientCodeException(taskConfiguration.TaskId, Id, "Unable to instantiate the new task", e);
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, "Task start error.", LOGGER);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Close this context. If there is a child context, this recursively closes it before closing this context. If
+        /// there is an Task currently running, that will be closed.
+        /// </summary>
+        public void Dispose()
+        {
+            lock (_contextLifeCycle)
+            {
+                _contextState = ContextStatusProto.State.DONE;
+                if (_task.IsPresent())
+                {
+                    LOGGER.Log(Level.Warning, "Shutting down an task because the underlying context is being closed.");
+                    _task.Value.Close(null);
+                }
+                if (_childContext.IsPresent())
+                {
+                    LOGGER.Log(Level.Warning, "Closing a context because its parent context is being closed.");
+                    _childContext.Value.Dispose();
+                }
+                _contextLifeCycle.Close();
+                if (_parentContext.IsPresent())
+                {
+                    ParentContext.Value.ResetChildContext();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Issue a suspend call to the Task
+        /// Note that due to races, the task might have already ended. In that case, we drop this call and leave a WARNING
+        /// in the log.
+        /// </summary>
+        /// <param name="message"> the suspend message to deliver or null if there is none.</param>
+        public void SuspendTask(byte[] message)
+        {
+            lock (_contextLifeCycle)
+            {
+                if (!_task.IsPresent())
+                {
+                    LOGGER.Log(Level.Warning, "Received a suspend task while there was no task running. Ignored");
+                }
+                else
+                {
+                    _task.Value.Suspend(message);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Issue a close call to the Task
+        /// Note that due to races, the task might have already ended. In that case, we drop this call and leave a WARNING
+        /// in the log.
+        /// </summary>
+        /// <param name="message">the close  message to deliver or null if there is none.</param>
+        public void CloseTask(byte[] message)
+        {
+            lock (_contextLifeCycle)
+            {
+                if (!_task.IsPresent())
+                {
+                    LOGGER.Log(Level.Warning, "Received a close task while there was no task running. Ignored");
+                }
+                else
+                {
+                    _task.Value.Close(message);
+                }
+            }
+        }
+
+        /// <summary>
+        ///  Deliver a message to the Task
+        /// Note that due to races, the task might have already ended. In that case, we drop this call and leave a WARNING
+        /// in the log.
+        /// </summary>
+        /// <param name="message">the message to deliver or null if there is none.</param>
+        public void DeliverTaskMessage(byte[] message)
+        {
+            lock (_contextLifeCycle)
+            {
+                if (!_task.IsPresent())
+                {
+                    LOGGER.Log(Level.Warning, "Received an task message while there was no task running. Ignored");
+                }
+                else
+                {
+                    _task.Value.Deliver(message);
+                }
+            }
+        }
+
+        public void HandleContextMessaage(byte[] mesage)
+        {
+            _contextLifeCycle.HandleContextMessage(mesage);
+        }
+
+        /// <summary>
+        /// get state of the running Task
+        /// </summary>
+        /// <returns> the state of the running Task, if one is running.</returns>
+        public Optional<TaskStatusProto> GetTaskStatus()
+        {
+            lock (_contextLifeCycle)
+            {
+                if (_task.IsPresent())
+                {
+                    if (_task.Value.HasEnded())
+                    {
+                        _task = Optional<TaskRuntime>.Empty();
+                        return Optional<TaskStatusProto>.Empty();
+                    }
+                    else
+                    {
+                        TaskStatusProto taskStatusProto = _task.Value.GetStatusProto();
+                        if (taskStatusProto.state == State.RUNNING)
+                        {
+                            // only RUNNING status is allowed to rurn here, all other state pushed out to heartbeat 
+                            return Optional<TaskStatusProto>.Of(taskStatusProto);
+                        }
+                        var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Task state must be RUNNING, but instead is in {0} state", taskStatusProto.state));
+                        Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                        return Optional<TaskStatusProto>.Empty();
+                    }
+                }
+                else
+                {
+                    return Optional<TaskStatusProto>.Empty();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Reset child context when parent is being closed
+        /// </summary>
+        public void ResetChildContext()
+        {
+            lock (_contextLifeCycle)
+            {
+                if (_childContext.IsPresent())
+                {
+                    _childContext = Optional<ContextRuntime>.Empty();
+                }
+                else
+                {
+                    var e = new InvalidOperationException("no child context set");
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
+                }
+            }
+        }
+
+        /// <summary>
+        /// get context's status in protocol buffer
+        /// </summary>
+        /// <returns>this context's status in protocol buffer form.</returns>
+        public ContextStatusProto GetContextStatus()
+        {
+            lock (_contextLifeCycle)
+            {
+                ContextStatusProto contextStatusProto = new ContextStatusProto()
+                {
+                    context_id = Id,
+                    context_state = _contextState,
+                };
+                if (_parentContext.IsPresent())
+                {
+                    contextStatusProto.parent_id = _parentContext.Value.Id;
+                }
+
+                foreach (IContextMessageSource source in _contextLifeCycle.ContextMessageSources)
+                {
+                    Optional<ContextMessage> contextMessageOptional = source.Message;
+                    if (contextMessageOptional.IsPresent())
+                    {
+                        ContextStatusProto.ContextMessageProto contextMessageProto
+                            = new ContextStatusProto.ContextMessageProto()
+                            {
+                                source_id = contextMessageOptional.Value.MessageSourceId,
+                            };
+                        contextMessageProto.message = ByteUtilities.CopyBytesFrom(contextMessageOptional.Value.Bytes);
+                        contextStatusProto.context_message.Add(contextMessageProto);
+                    }
+                }
+                return contextStatusProto;
+            }
+        }
+    }
+}
+        ///// <summary>
+        ///// TODO: remove and use parameterless GetContextStatus above
+        ///// </summary>
+        ///// <returns>this context's status in protocol buffer form.</returns>
+        //public ContextStatusProto GetContextStatus(string contextId)
+        //{
+        //    ContextStatusProto contextStatusProto = new ContextStatusProto()
+        //    {
+        //        context_id = contextId,
+        //        context_state = _contextState,
+        //    };
+        //    return contextStatusProto;
+        //}
+
+        ////// TODO: remove and use injection
+        //public void StartTask(ITask task, HeartBeatManager heartBeatManager, string taskId, string contextId)
+        //{
+        //    lock (_contextLifeCycle)
+        //    {
+        //        if (_task.IsPresent() && _task.Value.HasEnded())
+        //        {
+        //            // clean up state
+        //            _task = Optional<TaskRuntime>.Empty();
+        //        }
+        //        if (_task.IsPresent())
+        //        {
+        //            throw new InvalidOperationException(
+        //                string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId)); // note: java code is putting thread id here
+        //        }
+        //        if (_childContext.IsPresent())
+        //        {
+        //            throw new InvalidOperationException("Attempting to instantiate a child context on a context that is not the topmost active context.");
+        //        }
+        //        try
+        //        {
+        //            // final Injector taskInjector = contextInjector.forkInjector(taskConfiguration);
+        //            TaskRuntime taskRuntime  // taskInjector.getInstance(TaskRuntime.class);
+        //                = new TaskRuntime(task, heartBeatManager);
+        //            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Starting task '{0}'", taskId));
+        //            taskRuntime.Initialize(taskId, contextId);
+        //            taskRuntime.Start();
+        //            _task = Optional<TaskRuntime>.Of(taskRuntime);
+        //        }
+        //        catch (Exception e)
+        //        {
+        //            throw new InvalidOperationException("Unable to instantiate the new task");
+        //        }
+        //    }
+        //}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStartImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStartImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStartImpl.cs
new file mode 100644
index 0000000..3cf31b5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStartImpl.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Events;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    class ContextStartImpl : IContextStart
+    {
+        public ContextStartImpl(string id)
+        {
+            Id = id;
+        }
+
+        public string Id { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStopImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStopImpl.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStopImpl.cs
new file mode 100644
index 0000000..5db45d1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/ContextStopImpl.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Events;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    class ContextStopImpl : IContextStop
+    {
+        public ContextStopImpl(string id)
+        {
+            Id = id;
+        }
+        
+        public string Id { get; set; }   
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/RootContextLauncher.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/RootContextLauncher.cs b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/RootContextLauncher.cs
new file mode 100644
index 0000000..d31aeed
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-common/ReefCommon/runtime/evaluator/context/RootContextLauncher.cs
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.Evaluator.Context;
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Common.Context
+{
+    /// <summary>
+    ///  Helper class that encapsulates the root context configuration: With or without services and an initial task.
+    /// </summary>
+    public sealed class RootContextLauncher
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(RootContextLauncher));
+        
+        private readonly IInjector _rootServiceInjector = null;
+
+        private ContextRuntime _rootContext = null;
+
+        private ContextConfiguration _rootContextConfiguration = null;
+
+        public RootContextLauncher(ContextConfiguration rootContextConfig, Optional<ServiceConfiguration> rootServiceConfig, Optional<TaskConfiguration> rootTaskConfig)
+        {
+            _rootContextConfiguration = rootContextConfig;
+            _rootServiceInjector = InjectServices(rootServiceConfig);
+            RootTaskConfig = rootTaskConfig;
+        }
+
+        public Optional<TaskConfiguration> RootTaskConfig { get; set; }
+
+        public ContextConfiguration RootContextConfig
+        {
+            get { return _rootContextConfiguration; }
+            set { _rootContextConfiguration = value; }
+        }
+
+        public ContextRuntime GetRootContext()
+        {
+            if (_rootContext == null)
+            {
+                _rootContext = GetRootContext(_rootServiceInjector, _rootContextConfiguration);
+            }
+            return _rootContext;
+        }
+
+        private IInjector InjectServices(Optional<ServiceConfiguration> serviceConfig)
+        {
+            IInjector rootServiceInjector;
+
+            if (serviceConfig.IsPresent())
+            {
+                rootServiceInjector = TangFactory.GetTang().NewInjector(serviceConfig.Value.TangConfig);
+                InjectedServices services = null;
+                try
+                {
+                    services = rootServiceInjector.GetInstance<InjectedServices>();
+                }
+                catch (Exception e)
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Failed to instantiate service.", LOGGER);
+                    InvalidOperationException ex = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Failed to inject service: encoutned error {1} with message [{0}] and stack trace:[{1}]", e, e.Message, e.StackTrace));
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
+                }
+                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "injected {0} service(s)", services.Services.Count));
+            }
+            else
+            {
+                rootServiceInjector = TangFactory.GetTang().NewInjector();
+                LOGGER.Log(Level.Info, "no service provided for injection.");
+            }
+            
+            return rootServiceInjector;
+        }
+
+        private ContextRuntime GetRootContext( 
+            IInjector rootServiceInjector,
+            IConfiguration rootContextConfiguration)
+        {
+            ContextRuntime result;
+            result = new ContextRuntime(rootServiceInjector, rootContextConfiguration);
+            return result;
+        }
+    }
+}
+//if (rootServiceInjector != null)
+//{
+//    try
+//    {
+//        rootServiceInjector = rootServiceInjector.ForkInjector(serviceConfigs);
+//    }
+//    catch (Exception e)
+//    {
+//        throw new ContextClientCodeException(ContextClientCodeException.GetId(rootContextConfiguration),
+//                                             Optional<String>.Empty(),
+//                                             "Unable to instatiate the root context", e);
+//    }
+//    result = new ContextRuntime(rootServiceInjector, rootContextConfiguration);
+//}
+//else
+//{
+//    result = new ContextRuntime(rootServiceInjector.ForkInjector(), rootContextConfiguration);
+//}
\ No newline at end of file


[18/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsMessage.cs b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsMessage.cs
new file mode 100644
index 0000000..46f41e0
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/NetworkService/NsMessage.cs
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Wake;
+
+namespace Org.Apache.Reef.IO.Network.NetworkService
+{
+    /// <summary>
+    /// Message sent between NetworkServices
+    /// </summary>
+    /// <typeparam name="T">The type of data being sent</typeparam>
+    public class NsMessage<T>
+    {
+        /// <summary>
+        /// Create a new NsMessage with no data.
+        /// </summary>
+        /// <param name="sourceId">The identifier of the sender</param>
+        /// <param name="destId">The identifier of the receiver</param>
+        public NsMessage(IIdentifier sourceId, IIdentifier destId)
+        {
+            SourceId = sourceId;
+            DestId = destId;
+            Data = new List<T>();
+        }
+
+        /// <summary>
+        /// Create a new NsMessage with data.
+        /// </summary>
+        /// <param name="sourceId">The identifier of the sender</param>
+        /// <param name="destId">The identifier of the receiver</param>
+        /// <param name="message">The message to send</param>
+        public NsMessage(IIdentifier sourceId, IIdentifier destId, T message) 
+        {
+            SourceId = sourceId;
+            DestId = destId;
+            Data = new List<T> { message };
+        }
+
+        /// <summary>
+        /// The identifier of the sender of the message.
+        /// </summary>
+        public IIdentifier SourceId { get; private set; }
+
+        /// <summary>
+        /// The identifier of the receiver of the message.
+        /// </summary>
+        public IIdentifier DestId { get; private set; }
+
+        /// <summary>
+        /// A list of data being sent in the message.
+        /// </summary>
+        public List<T> Data { get; private set; } 
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-io/Network/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..82fb3ba
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("NetWork")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("NetWork")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b3f5e608-8908-4f06-a87e-5e41c88133ac")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Utilities/BlockingCollectionExtensions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Utilities/BlockingCollectionExtensions.cs b/lang/cs/Source/REEF/reef-io/Network/Utilities/BlockingCollectionExtensions.cs
new file mode 100644
index 0000000..e9d9555
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Utilities/BlockingCollectionExtensions.cs
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.IO.Network.Utilities
+{
+    public static class BlockingCollectionExtensions
+    {
+        /// <summary>
+        /// Removes the given item from the BlockingCollection if it is present.
+        /// If it is not present, it blocks until any item is available in the 
+        /// BlockingCollection.  It then removes and returns that first available
+        /// item.
+        /// </summary>
+        /// <typeparam name="T">The type of BlockingCollection</typeparam>
+        /// <param name="collection">The BlockingCollection to remove the specified item</param>
+        /// <param name="item">The item to remove from the BlockingCollection, if it exists</param>
+        /// <returns>The specified item, or the first available item if the specified item is 
+        /// not present in the BlockingCollection</returns>
+        public static T Take<T>(this BlockingCollection<T> collection, T item)
+        {
+            T ret = default(T);
+            bool foundItem = false; 
+            List<T> removedItems = new List<T>();
+
+            // Empty the collection
+            for (int i = 0; i < collection.Count; i++)
+            {
+                T removed;
+                if (collection.TryTake(out removed))
+                {
+                    removedItems.Add(removed);
+                }
+            }
+
+            // Add them back to the collection minus the specified item
+            foreach (T removedItem in removedItems)
+            {
+                if (removedItem.Equals(item))
+                {
+                    ret = removedItem;
+                    foundItem = true;
+                }
+                else
+                {
+                    collection.Add(removedItem);
+                }
+            }
+
+            if (!foundItem)
+            {
+                // Error: the element wasn't in the collection
+                throw new InvalidOperationException(item + " not found in blocking collection");
+            }
+
+            return ret;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Utilities/Utils.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Utilities/Utils.cs b/lang/cs/Source/REEF/reef-io/Network/Utilities/Utils.cs
new file mode 100644
index 0000000..91bb90e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Utilities/Utils.cs
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.IO;
+using Microsoft.Hadoop.Avro;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.IO.Network.Utilities
+{
+    internal class Utils
+    {
+        private static Logger LOGGER = Logger.GetLogger(typeof(Utils));
+
+        /// <summary>
+        /// Returns the TaskIdentifier from the Configuration.
+        /// </summary>
+        /// <param name="taskConfiguration">The Configuration object</param>
+        /// <returns>The TaskIdentifier for the given Configuration</returns>
+        public static string GetTaskId(IConfiguration taskConfiguration)
+        {
+            try
+            {
+                IInjector injector = TangFactory.GetTang().NewInjector(taskConfiguration);
+                return injector.GetNamedInstance<TaskConfigurationOptions.Identifier, string>(
+                    GenericType<TaskConfigurationOptions.Identifier>.Class);
+            }
+            catch (InjectionException)
+            {
+                LOGGER.Log(Level.Error, "Unable to find task identifier");
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// Returns the Context Identifier from the Configuration.
+        /// </summary>
+        /// <param name="contextConfiguration">The Configuration object</param>
+        /// <returns>The TaskIdentifier for the given Configuration</returns>
+        public static string GetContextId(IConfiguration contextConfiguration)
+        {
+            try
+            {
+                IInjector injector = TangFactory.GetTang().NewInjector(contextConfiguration);
+                return injector.GetNamedInstance<ContextConfigurationOptions.ContextIdentifier, string>(
+                    GenericType<ContextConfigurationOptions.ContextIdentifier>.Class);
+            }
+            catch (InjectionException)
+            {
+                LOGGER.Log(Level.Error, "Unable to find task identifier");
+                throw;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/packages.config b/lang/cs/Source/REEF/reef-io/Network/packages.config
new file mode 100644
index 0000000..88cf17b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/packages.config
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+  <package id="Rx-Core" version="2.2.5" targetFramework="net45" />
+  <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/FailedTask/FailedTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/FailedTask/FailedTask.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/FailedTask/FailedTask.cs
new file mode 100644
index 0000000..64e1d96
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/FailedTask/FailedTask.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Threading;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class FailedTask : ITask
+    {
+        [Inject]
+        public FailedTask()
+        {
+        }
+
+        public byte[] Call(byte[] memento)
+        {
+            Console.WriteLine("I am about to fail.");
+            Thread.Sleep(2 * 1000);
+            throw new ApplicationException("bite me.");
+        }
+
+        public void Dispose()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloService.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloService.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloService.cs
new file mode 100644
index 0000000..ee3beeb
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloService.cs
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Services;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class HelloService : IService
+    {
+        private IList<string> _guests;
+
+        [Inject]
+        public HelloService()
+        {
+            if (_guests == null)
+            {
+                _guests = new List<string>();
+                _guests.Add("MR.SMITH");
+            }
+        }
+
+        public IList<string> Guests
+        {
+            get
+            {
+                return _guests;
+            }
+        }
+
+        public void AddGuest(string guestName)
+        {
+            if (string.IsNullOrWhiteSpace(guestName))
+            {
+                throw new ArgumentException("can't do with empty name.");
+            }
+            Guests.Add(guestName);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTask.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTask.cs
new file mode 100644
index 0000000..f1a7328
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTask.cs
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Tasks.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Linq;
+using System.Net;
+using System.Threading;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class HelloTask : ITask
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(HelloTask));
+
+        private INameClient _nameClient = null;
+
+        [Inject]
+        public HelloTask()
+        {
+            Console.WriteLine("HelloTask constructor 0");
+        }
+
+        [Inject]
+        public HelloTask(HelloService service, INameClient nameClient)
+        {
+            Console.WriteLine("HelloTask constructor 2");
+            Service = service;
+            _nameClient = nameClient;
+        }
+
+        [Inject]
+        public HelloTask(HelloService service)
+        {
+            Console.WriteLine("HelloTask constructor 1");
+            Service = service;
+        }
+
+        public HelloService Service { get; set; }
+
+        public byte[] Call(byte[] memento)
+        {
+            Console.WriteLine("Hello, CLR REEF!");
+            if (_nameClient != null)
+            {
+                _nameClient.Register("abc", new IPEndPoint(IPAddress.Any, 8080));
+                Console.WriteLine("IP Address: {0}", _nameClient.Lookup("abc"));
+            }
+            PrintGuestList();
+            Thread.Sleep(5 * 1000);
+            Console.WriteLine("Bye, CLR REEF!");
+
+            return null;
+        }
+
+        public void Dispose()
+        {
+            LOGGER.Log(Level.Info, "Hello task disposed.");
+        }
+
+        private void HandleDriverMessage(string message)
+        {
+            using (LOGGER.LogFunction("HelloTask::HandleDriverMessage"))
+            {
+                LOGGER.Log(Level.Info, "I handle message by logging : " + message);
+            }
+        }
+
+        private void PrintGuestList()
+        {
+            if (Service == null || !Service.Guests.Any())
+            {
+                Console.WriteLine("No service provided.");
+            }
+            else
+            {
+                Console.WriteLine("Serving guest: " + string.Join(";", Service.Guests));
+            }
+        }
+
+        public class HelloDriverMessageHandler : IDriverMessageHandler
+        {
+            private HelloTask _parentTask;
+
+            [Inject]
+            public HelloDriverMessageHandler(HelloTask task)
+            {
+                _parentTask = task;
+            }
+
+            public void Handle(IDriverMessage value)
+            {
+                string message = string.Empty;
+                LOGGER.Log(Level.Verbose, "Receieved a message from driver, handling it with HelloDriverMessageHandler");
+                if (value.Message.IsPresent())
+                {
+                    message = ByteUtilities.ByteArrarysToString(value.Message.Value);
+                }
+                _parentTask.HandleDriverMessage(message);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTaskMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTaskMessage.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTaskMessage.cs
new file mode 100644
index 0000000..b04043e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/HelloTask/HelloTaskMessage.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class HelloTaskMessage : ITaskMessageSource
+    {
+        [Inject]
+        public HelloTaskMessage()
+        {
+        }
+
+        public Optional<TaskMessage> Message
+        {
+            get
+            {
+                TaskMessage defaultTaskMessage = TaskMessage.From(
+                    "helloSourceId",
+                    ByteUtilities.StringToByteArrays("hello message generated at " + DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+                return Optional<TaskMessage>.Of(defaultTaskMessage);
+            }
+
+            set
+            {
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4a41805
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tasks")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tasks")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b9e219f1-a02c-468c-ab26-3ef5c91310f7")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/ShellTask/ShellTask.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/ShellTask/ShellTask.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/ShellTask/ShellTask.cs
new file mode 100644
index 0000000..07ab0b2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/ShellTask/ShellTask.cs
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Text;
+
+[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "allow name parameter class to be embedded")]
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class ShellTask : ITask
+    {
+        [Inject]
+        public ShellTask([Parameter(Value = typeof(Command))] string command)
+        {
+            Cmd = command;
+        }
+
+        public string Cmd { get; set; }
+
+        public byte[] Call(byte[] memento)
+        {
+            return Encoding.UTF8.GetBytes(CommandLineExecute(Cmd));
+        }
+
+        public void Dispose()
+        {
+        }
+
+        private string CommandLineExecute(string command)
+        {
+            string output = string.Empty;
+            try
+            {
+                ProcessStartInfo startInfo = new ProcessStartInfo()
+                {
+                    FileName = "cmd.exe",
+                    Arguments = @"/c " + command,
+                    RedirectStandardOutput = true,
+                    UseShellExecute = false,
+                    CreateNoWindow = true
+                };
+
+                using (Process process = Process.Start(startInfo))
+                {
+                    StringBuilder standardOutput = new StringBuilder();
+
+                    process.WaitForExit(1000);
+
+                    standardOutput.Append(process.StandardOutput.ReadToEnd());
+                    output = standardOutput.ToString();
+                }
+            }
+            catch (Exception e)
+            {
+                output = string.Format(CultureInfo.InvariantCulture, "Failed to execute command [{0}] and capture the output, exception {1} with message {2} ", command, e, e.Message);
+                Exceptions.Caught(e, Level.Error, output, Logger.GetLogger(typeof(ShellTask)));
+            }
+
+            return output;
+        }
+
+        [NamedParameter("Shell Command", "cmd", "")]
+        public class Command : Name<string>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask1.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask1.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask1.cs
new file mode 100644
index 0000000..8e05a76
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask1.cs
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Threading;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class StreamTask1 : ITask
+    {
+        private string _ipAddress;
+
+        [Inject]
+        public StreamTask1([Parameter(typeof(IpAddress))] string ipAddress)
+        {
+            this._ipAddress = ipAddress;
+        }
+
+        [Inject]
+        public StreamTask1()
+        {
+        }
+
+        public byte[] Call(byte[] memento)
+        {
+            System.Console.WriteLine("Hello, Streaming 1!!, Ip: " + _ipAddress);
+
+            Thread.Sleep(10000);
+
+            SIFirstNode();
+
+            return null;
+        }
+
+        public void Dispose()
+        {
+        }
+
+        public void SIFirstNode()
+        {
+            //var a = new SIFirstNodeXAM();
+            //a.Process(1111, 2222, ipAddress);
+        }
+
+        [NamedParameter("Ip Address", "IP", "10.121.32.158")]
+        public class IpAddress : Name<string>
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask2.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask2.cs b/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask2.cs
new file mode 100644
index 0000000..7c521f1
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/StreamingTasks/StreamTask2.cs
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tasks
+{
+    public class StreamTask2 : ITask
+    {
+        [Inject]
+        public StreamTask2()
+        {
+        }
+
+        public byte[] Call(byte[] memento)
+        {
+            System.Console.WriteLine("Hello, Streaming 2!!");
+
+            SISecondNode();
+
+            return null;
+        }
+
+        public void Dispose()
+        {
+        }
+
+        public void SISecondNode()
+        {
+            //var a = new SISecondNodeXAM();
+            //a.Process(2222, 1111);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-tasks/Tasks/Tasks.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-tasks/Tasks/Tasks.csproj b/lang/cs/Source/REEF/reef-tasks/Tasks/Tasks.csproj
new file mode 100644
index 0000000..8cae084
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-tasks/Tasks/Tasks.csproj
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{75503F90-7B82-4762-9997-94B5C68F15DB}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Tasks</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Tasks</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Tasks\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Tasks\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="FailedTask\FailedTask.cs" />
+    <Compile Include="HelloTask\HelloService.cs" />
+    <Compile Include="HelloTask\HelloTask.cs" />
+    <Compile Include="HelloTask\HelloTaskMessage.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ShellTask\ShellTask.cs" />
+    <Compile Include="StreamingTasks\StreamTask1.cs" />
+    <Compile Include="StreamingTasks\StreamTask2.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Utilities</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>ReefCommon</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/AnonymousType.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/AnonymousType.cs b/lang/cs/Source/TANG/Examples/AnonymousType.cs
new file mode 100644
index 0000000..9124409
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/AnonymousType.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class MyEventStreamDefinition
+    {
+        public ISet<int> Shards { get; set; }
+
+        public Type Type { get; set; }
+    }
+
+    public class AnonymousType
+    {
+        private Dictionary<string, MyEventStreamDefinition> d = new Dictionary<string, MyEventStreamDefinition>();
+        private Dictionary<string, int> d2;
+
+        //Anonymous class in injectable constructor
+        [Inject]
+        public AnonymousType()
+        {
+            d2 = d
+                .Select((e, i) => new { e.Key, i })
+                .ToDictionary(e => e.Key, e => e.i);
+        }
+
+        //Anonymous class in other constructor
+        public AnonymousType(Dictionary<string, MyEventStreamDefinition> d)
+        {
+            this.d = d;            
+            d2 = d
+                .Select((e, i) => new { e.Key, i })
+                .ToDictionary(e => e.Key, e => e.i);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/CheckChild.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/CheckChild.cs b/lang/cs/Source/TANG/Examples/CheckChild.cs
new file mode 100644
index 0000000..b4415cb
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/CheckChild.cs
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public interface CheckChildIface 
+    {
+    }   
+    
+    public class CheckChildImpl : CheckChildIface
+    {
+        [Inject]
+        public CheckChildImpl() {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/DocumentedLocalNamedParameter.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/DocumentedLocalNamedParameter.cs b/lang/cs/Source/TANG/Examples/DocumentedLocalNamedParameter.cs
new file mode 100644
index 0000000..a23a424
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/DocumentedLocalNamedParameter.cs
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class DocumentedLocalNamedParameter
+    {
+        string value;
+        [NamedParameter(Documentation = "doc stuff", ShortName = "DocFoo", DefaultValue = "some value")]
+        public sealed class Foo : Name<String> 
+        {
+        }
+
+        [Inject]
+        public DocumentedLocalNamedParameter([Parameter(typeof(Foo))] String s) 
+        {
+            value = s;
+        }
+
+        public override string ToString()
+        {
+            return value;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/Examples.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/Examples.csproj b/lang/cs/Source/TANG/Examples/Examples.csproj
new file mode 100644
index 0000000..ac5a7e3
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/Examples.csproj
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{31B4389E-925A-4181-A1F6-21A1A0AD8A1C}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Tang.Examples</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Tang.Examples</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.Tang.Examples\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\bin\Release\Microsoft.Tang.Examples\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AnonymousType.cs" />
+    <Compile Include="CheckChild.cs" />
+    <Compile Include="DocumentedLocalNamedParameter.cs" />
+    <Compile Include="FileNames.cs" />
+    <Compile Include="ForksInjectorInConstructor.cs" />
+    <Compile Include="GenericArgument.cs" />
+    <Compile Include="GenericAsArgument.cs" />
+    <Compile Include="NamedParameterConstructors.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ShortNameFooAB.cs" />
+    <Compile Include="SimpleConstructors.cs" />
+    <Compile Include="TestClasses.cs" />
+    <Compile Include="Timer.cs" />
+    <Compile Include="TweetExample.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\WAKE\Wake\Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Wake</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Tang\Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Tang</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/FileNames.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/FileNames.cs b/lang/cs/Source/TANG/Examples/FileNames.cs
new file mode 100644
index 0000000..d371908
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/FileNames.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class FileNames
+    {
+        public static string Examples = @"Org.Apache.Reef.Tang.Examples";
+        public static string Common = @"Org.Apache.Reef.Common";
+        public static string Tasks = @"Org.Apache.Reef.Tasks";
+        public static string Seconds = "Org.Apache.Reef.Tang.Examples.Timer+Seconds";
+        public static string Timer = "Org.Apache.Reef.Tang.Examples.Timer";
+        public static string B = "Org.Apache.Reef.Tang.Examples.B";
+        public static string B1 = "Org.Apache.Reef.Tang.Examples.B+B1";
+        public static string B2 = "Org.Apache.Reef.Tang.Examples.B+B1+B2";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/ForksInjectorInConstructor.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/ForksInjectorInConstructor.cs b/lang/cs/Source/TANG/Examples/ForksInjectorInConstructor.cs
new file mode 100644
index 0000000..c78141a
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/ForksInjectorInConstructor.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class ForksInjectorInConstructor
+    {
+        [Inject]
+        public ForksInjectorInConstructor(IInjector i)
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { @"Org.Apache.Reef.Tang.Examples" });
+            //cb.BindImplementation(Number.class, typeof(Int32));
+            i.ForkInjector(new IConfiguration[] { cb.Build() });
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/GenericArgument.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/GenericArgument.cs b/lang/cs/Source/TANG/Examples/GenericArgument.cs
new file mode 100644
index 0000000..dd1a228
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/GenericArgument.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.RX;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class GenericArgument<T> : AbstractObserver<T>
+    {
+        [Inject]
+        public GenericArgument()
+        {        
+        }
+
+        public override void OnNext(T arg1)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public class ClassWithGenericArgument<T>
+    {
+        private T _obj;
+
+        public ClassWithGenericArgument(T obj)
+        {
+            _obj = obj;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/GenericAsArgument.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/GenericAsArgument.cs b/lang/cs/Source/TANG/Examples/GenericAsArgument.cs
new file mode 100644
index 0000000..54e73ab
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/GenericAsArgument.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Examples
+{
+    public class Event<TPayload>
+    {
+        public Event()
+        {
+        }
+
+        public Event(StreamEvent<TPayload> trillEvent)
+        {
+        }
+
+        public StreamEvent<TPayload> ToStreamEvent()
+        {
+            return null;
+        }
+    }
+
+    public class StreamEvent<T>
+    {
+        public StreamEvent()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/NamedParameterConstructors.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/NamedParameterConstructors.cs b/lang/cs/Source/TANG/Examples/NamedParameterConstructors.cs
new file mode 100644
index 0000000..347c6a4
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/NamedParameterConstructors.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class NamedParameterConstructors
+    {
+        [NamedParameter()]
+        public class X : Name<String> 
+        {
+        };
+
+        [Inject]
+        public NamedParameterConstructors(String x, [Parameter(typeof(X))] String y) 
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/Properties/AssemblyInfo.cs b/lang/cs/Source/TANG/Examples/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..dcb9bc5
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Examples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Examples")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("cb44520c-2fd1-4d3b-9b9a-250f94a11239")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/ShortNameFooAB.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/ShortNameFooAB.cs b/lang/cs/Source/TANG/Examples/ShortNameFooAB.cs
new file mode 100644
index 0000000..ae81a82
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/ShortNameFooAB.cs
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    [NamedParameter(ShortName = "fooA")]
+    public class ShortNameFooA : Name<String> 
+    {
+    }
+
+    //when same short name is used, exception would throw when building the class hierarchy
+    [NamedParameter(ShortName = "fooB")]
+    public class ShortNameFooB : Name<Int32> 
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/SimpleConstructors.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/SimpleConstructors.cs b/lang/cs/Source/TANG/Examples/SimpleConstructors.cs
new file mode 100644
index 0000000..2a4aa4c
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/SimpleConstructors.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class SimpleConstructors 
+    {
+        [Inject]
+        public SimpleConstructors() 
+        {
+        }
+
+        [Inject]
+        public SimpleConstructors(int x) 
+        {
+        }
+
+        [Inject]
+        public SimpleConstructors(int x, String y) 
+        {
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/TestClasses.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/TestClasses.cs b/lang/cs/Source/TANG/Examples/TestClasses.cs
new file mode 100644
index 0000000..03a7c70
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/TestClasses.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public interface A
+    {
+
+    }
+
+    public class B : A
+    {
+        public class B1
+        {
+            public class B2 { }
+        }
+    }
+
+    public class C : B
+    {
+        string s;
+        int v;
+
+        [Inject]
+        public C(string s, int v)
+        {
+            this.s = s;
+            this.v = v;
+        }
+    }
+
+    public static class E
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/Timer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/Timer.cs b/lang/cs/Source/TANG/Examples/Timer.cs
new file mode 100644
index 0000000..a65d717
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/Timer.cs
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Threading;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public class Timer
+    {
+        [NamedParameter("Number of seconds to sleep", "sec", "10")]
+        public class Seconds : Name<Int32> { }
+        private readonly int seconds;
+
+        [Inject]
+        public Timer([Parameter(typeof(Seconds))] int seconds)
+        {
+            if (seconds < 0)
+            {
+                throw new ArgumentException("Cannot sleep for negative time!");
+            }
+            this.seconds = seconds;
+        }
+
+        public void sleep()  
+        {
+            Thread.Sleep(seconds * 1000);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Examples/TweetExample.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Examples/TweetExample.cs b/lang/cs/Source/TANG/Examples/TweetExample.cs
new file mode 100644
index 0000000..774f48d
--- /dev/null
+++ b/lang/cs/Source/TANG/Examples/TweetExample.cs
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Tang.Examples
+{
+    public interface ISMS
+    {
+        void SendSMS(String msg, long phoneNumber);
+    }
+
+    public interface ITweetFactory
+    {
+        String GetTweet();
+    } 
+
+    public class MockTweetFactory : ITweetFactory 
+    {
+        [Inject]
+        public MockTweetFactory() {
+        }
+
+        public String GetTweet() 
+        {
+            return "@tw #bbq bbqftw!!! gopher://vuwed.wefd/bbqftw!";
+        }
+    }
+
+    public class MockSMS : ISMS 
+    {
+        [Inject]
+        public MockSMS() 
+        {
+        }
+
+        public void SendSMS(String msg, long phoneNumber) 
+        {
+            if (phoneNumber != 8675309) 
+            {
+                throw new ArgumentException("Unknown recipient");
+            }
+            // success!
+        }
+    }
+
+    public class Tweeter
+    {
+        ITweetFactory tw;
+        ISMS sms;
+        long phoneNumber;
+
+        [NamedParameter(Documentation="Phone number", ShortName="number", DefaultValue="1800")]
+        public class PhoneNumber : Name<long> { }
+        [Inject]
+        public Tweeter(ITweetFactory tw, ISMS sms, [Parameter(typeof(PhoneNumber))] long phoneNumber)
+        {
+            this.tw = tw;
+            this.sms = sms;
+            this.phoneNumber = phoneNumber;
+        }
+
+        [Inject]
+        public Tweeter([Parameter(typeof(PhoneNumber))] long phoneNumber)
+        {
+            this.phoneNumber = phoneNumber;
+        }
+
+        public void sendMessage()
+        {
+            sms.SendSMS(tw.GetTweet(), phoneNumber);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Annotations/DefaultImplementation.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Annotations/DefaultImplementation.cs b/lang/cs/Source/TANG/Tang/Annotations/DefaultImplementation.cs
new file mode 100644
index 0000000..26ac15b
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Annotations/DefaultImplementation.cs
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Tang.Annotations
+{
+    /// <summary>
+    /// DefaultImplementationAttribute
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
+    public class DefaultImplementationAttribute : System.Attribute
+    {
+        public Type Value { get; set; }
+        public string Name { get; set; }
+
+        public DefaultImplementationAttribute(Type val = null, string n = "")
+        {
+            Name = n;
+            Value = val;
+        }
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Annotations/Inject.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Annotations/Inject.cs b/lang/cs/Source/TANG/Tang/Annotations/Inject.cs
new file mode 100644
index 0000000..2816a18
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Annotations/Inject.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Annotations
+{
+    /// <summary>
+    /// InjectAttribute
+    /// </summary>
+    [System.AttributeUsage(System.AttributeTargets.Constructor)]
+    public class InjectAttribute : System.Attribute 
+    { 
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Annotations/Name.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Annotations/Name.cs b/lang/cs/Source/TANG/Tang/Annotations/Name.cs
new file mode 100644
index 0000000..a9316c4
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Annotations/Name.cs
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Tang.Annotations
+{
+    /// <summary>
+    /// Base class for named parameters
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public interface Name<T>
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Annotations/NamedParameter.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Annotations/NamedParameter.cs b/lang/cs/Source/TANG/Tang/Annotations/NamedParameter.cs
new file mode 100644
index 0000000..d156a32
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Annotations/NamedParameter.cs
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Annotations
+{
+    [System.AttributeUsage(System.AttributeTargets.Class)]
+    public class NamedParameterAttribute : System.Attribute
+    {
+        public string Documentation { get; set; }
+        public string ShortName { get; set; }
+        public string DefaultValue { get; set; }
+        public Type DefaultClass { get; set; }
+        public string[] DefaultValues { get; set; }
+        public Type[] DefaultClasses { get; set; }
+
+        public NamedParameterAttribute(string documentation = "", string shortName = "",
+            string defaultValue = "", Type defaultClass = null, string[] defaultValues = null, Type[] defaultClasses = null)
+        {
+            this.Documentation = documentation;
+            this.ShortName = shortName;
+            this.DefaultValue = defaultValue;
+            this.DefaultClass = defaultClass;
+            this.DefaultValues = defaultValues;
+            this.DefaultClasses = defaultClasses;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Annotations/Parameter.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Annotations/Parameter.cs b/lang/cs/Source/TANG/Tang/Annotations/Parameter.cs
new file mode 100644
index 0000000..7c3c2ae
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Annotations/Parameter.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+namespace Org.Apache.Reef.Tang.Annotations
+{
+    /// <summary>
+    /// ParameterAttribute
+    /// </summary>
+    [System.AttributeUsage(System.AttributeTargets.Parameter)]
+    public class ParameterAttribute : System.Attribute
+    {
+        public ParameterAttribute()
+        {
+        }
+
+        public ParameterAttribute(Type value)
+        {
+            Value = value;
+        }
+
+        public Type Value { get; set; } 
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Annotations/Unit.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Annotations/Unit.cs b/lang/cs/Source/TANG/Tang/Annotations/Unit.cs
new file mode 100644
index 0000000..bd3cad0
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Annotations/Unit.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+namespace Org.Apache.Reef.Tang.Annotations
+{
+    /// <summary>
+    /// UnitAttribute
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Class, Inherited = false)]
+    public class UnitAttribute : System.Attribute 
+    { 
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Exceptions/BindException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Exceptions/BindException.cs b/lang/cs/Source/TANG/Tang/Exceptions/BindException.cs
new file mode 100644
index 0000000..2ad1658
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Exceptions/BindException.cs
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Exceptions
+{
+    public class BindException : SystemException
+    {
+        //private static readonly long serialVersionUID = 1L;
+        public BindException(String message)
+            : base(message)
+        {           
+        }
+
+        public BindException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Exceptions/ClassHierarchyException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/TANG/Tang/Exceptions/ClassHierarchyException.cs b/lang/cs/Source/TANG/Tang/Exceptions/ClassHierarchyException.cs
new file mode 100644
index 0000000..5b29f35
--- /dev/null
+++ b/lang/cs/Source/TANG/Tang/Exceptions/ClassHierarchyException.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+using System;
+
+namespace Org.Apache.Reef.Tang.Exceptions
+{
+    public class ClassHierarchyException : SystemException
+    {
+        public ClassHierarchyException(String msg) :  base(msg)
+        {           
+        }
+
+        public ClassHierarchyException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}
\ No newline at end of file


[05/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Configuration/TestCsConfigurationBuilderExtension.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Configuration/TestCsConfigurationBuilderExtension.cs b/lang/cs/Tests/TangTests/Configuration/TestCsConfigurationBuilderExtension.cs
new file mode 100644
index 0000000..f8defdf
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Configuration/TestCsConfigurationBuilderExtension.cs
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Tang.Test.Injection;
+using Org.Apache.Reef.Tang.Test.Tang;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Configuration
+{
+    /// <summary>
+    /// This class is to test extension API defined in ICsConfigurationBuilder
+    /// </summary>
+    [TestClass]
+    public class TestCsConfigurationBuilderExtension
+    {
+        [TestMethod]
+        public void TestBindNamedParameter1()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParameter<AImplName, Aimpl, INamedImplA>();
+            cb.BindNamedParameter<BImplName, Bimpl, INamedImplA>();
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            Aimpl a1 = (Aimpl)i.GetNamedInstance<AImplName, INamedImplA>(GenericType<AImplName>.Class);
+            Aimpl a2 = (Aimpl)i.GetNamedInstance<AImplName, INamedImplA>(GenericType<AImplName>.Class);
+            Bimpl b1 = (Bimpl)i.GetNamedInstance<BImplName, INamedImplA>(GenericType<BImplName>.Class);
+            Bimpl b2 = (Bimpl)i.GetNamedInstance<BImplName, INamedImplA>(GenericType<BImplName>.Class);
+            Assert.AreSame(a1, a2);
+            Assert.AreSame(b1, b2);
+        }
+
+        [TestMethod]
+        public void TestBindStringNamedParam()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindStringNamedParam<StringTest.NamedString>("foo");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<StringTest>();
+            o.Verify("foo");
+        }
+
+        [TestMethod]
+        public void TestBindIntNamedParam()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindIntNamedParam<Int32Test.NamedInt>("8");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<Int32Test>();
+            o.Verify(8);
+        }
+
+        [TestMethod]
+        public void TestBindNamedParam()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindNamedParam<BooleanTest.NamedBool, bool>("true");
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance<BooleanTest>();
+            o.Verify(true);
+        }
+
+        [TestMethod]
+        public void TestBindSetEntryImplValue()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindSetEntry<TestSetInjection.SetOfClasses, TestSetInjection.Integer1, INumber>()  //bind an impl to the interface of the set
+              .BindIntNamedParam<TestSetInjection.Integer1.NamedInt>("4"); //bind parameter for the impl
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            ISet<INumber> actual = i.GetInstance<TestSetInjection.Pool>().Numbers;
+            ISet<INumber> expected = new HashSet<INumber>();
+            expected.Add(new TestSetInjection.Integer1(4));
+
+            Assert.IsTrue(Utilities.Utilities.Equals<INumber>(actual, expected));
+        }
+
+        [TestMethod]
+        public void TestBindSetEntryStringValue()
+        {
+            IConfiguration conf = TangFactory.GetTang().NewConfigurationBuilder()
+                .BindSetEntry<SetOfNumbers, string>("four")
+                .BindSetEntry<SetOfNumbers, string>("five")
+                .BindSetEntry<SetOfNumbers, string>("six")
+                .Build();
+
+            Box b = (Box)TangFactory.GetTang().NewInjector(conf).GetInstance(typeof(Box));
+            ISet<string> actual = b.Numbers;
+
+            Assert.IsTrue(actual.Contains("four"));
+            Assert.IsTrue(actual.Contains("five"));
+            Assert.IsTrue(actual.Contains("six"));
+        }
+
+        [TestMethod]
+        public void TestBindImplementation()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation<Interf, Impl>();
+            Interf o = TangFactory.GetTang().NewInjector(cb.Build()).GetInstance<Interf>();
+            Assert.IsTrue(o is Impl);
+        }
+
+        [TestMethod]
+        public void TestBindList()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add("hi");
+            injected.Add("hello");
+            injected.Add("bye");
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindList<StringList, string>(injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IList<string> actual = ((StringClass)i.GetInstance(typeof(StringClass))).StringList;
+
+            Assert.IsTrue(actual.Contains("hi"));
+            Assert.IsTrue(actual.Contains("hello"));
+            Assert.IsTrue(actual.Contains("bye"));
+            Assert.AreEqual(actual.Count, 3);
+        }
+
+        [TestMethod]
+        public void TestObjectInjectWithInjectableSubclassesMultipleInstances()
+        {
+            IList<string> injected = new List<string>();
+            injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Integer1).AssemblyQualifiedName);
+            injected.Add(typeof(TestSetInjection.Float1).AssemblyQualifiedName);
+
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindIntNamedParam<TestSetInjection.Integer1.NamedInt>("5");
+            cb.BindNamedParam<TestSetInjection.Float1.NamedFloat, float>("12.5");
+            cb.BindList<ListOfClasses, INumber>(injected);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+
+            IList<INumber> actual = ((PoolListClass)i.GetInstance(typeof(PoolListClass))).Numbers;
+
+            Assert.IsTrue(actual.Count == 3);
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Integer1(5)));
+            Assert.IsTrue(actual.Contains(new TestSetInjection.Float1(12.5f)));
+        }
+
+        [TestMethod]
+        public void TestBindConstructor()
+        {
+            ICsConfigurationBuilder b = TangFactory.GetTang().NewConfigurationBuilder();
+            b.BindConstructor<TestExternalConstructors.A, TestExternalConstructors.ACons>();
+            b.BindConstructor<TestExternalConstructors.B, TestExternalConstructors.BCons>();
+
+            TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(TestExternalConstructors.B));
+            TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(TestExternalConstructors.A));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Format/TestConfigurationModule.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Format/TestConfigurationModule.cs b/lang/cs/Tests/TangTests/Format/TestConfigurationModule.cs
new file mode 100644
index 0000000..94d3ad2
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Format/TestConfigurationModule.cs
@@ -0,0 +1,522 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Format
+{
+    public interface IFoo
+    {
+        int getFooness();
+    }
+
+    interface ISuper
+    {
+    }
+
+    [TestClass]
+    public class TestConfigurationModule
+    {
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+        }
+
+        [ClassCleanup]
+        public static void ClassCleanup()
+        {
+        }
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+        }
+
+        [TestCleanup()]
+        public void TestCleanup()
+        {
+        }
+    
+        [TestMethod]
+        public void SmokeTest() 
+        {
+            // Here we set some configuration values.  In true tang style,
+            // you won't be able to set them more than once ConfigurationModule's
+            // implementation is complete.
+            Type fooType = typeof(Org.Apache.Reef.Tang.Test.Format.IFoo);
+            
+            IConfiguration c = MyConfigurationModule.Conf
+                .Set(MyConfigurationModule.TheFoo, GenericType<FooImpl>.Class)
+                .Set(MyConfigurationModule.FooNess, "12")
+                .Build();
+                IFoo f = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(fooType);
+                Assert.AreEqual(f.getFooness(), 12);
+          }
+
+        [TestMethod]
+        public void SmokeTestConfig()
+        {
+            // Here we set some configuration values.  In true tang style,
+            // you won't be able to set them more than once ConfigurationModule's
+            // implementation is complete.
+            Type fooType = typeof(Org.Apache.Reef.Tang.Test.Format.IFoo);
+
+            IConfiguration c = MyConfigurationModule.Conf
+                .Set(MyConfigurationModule.TheFoo, GenericType<FooImpl>.Class)
+                .Set(MyConfigurationModule.FooNess, "12")
+                .Build();
+            IFoo f = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(fooType);
+            Assert.AreEqual(f.getFooness(), 12);
+            AvroConfigurationSerializer serializerCs = new AvroConfigurationSerializer();
+
+            serializerCs.ToFileStream(c, "TangTestCs.avroconf");
+            var c3 = serializerCs.FromFileStream("TangTestCs.avroconf");
+            IFoo f3 = (IFoo)TangFactory.GetTang().NewInjector(c3).GetInstance(fooType);
+            Assert.AreEqual(f3.getFooness(), 12);
+
+            serializerCs.ToFile(c, "TangTestCs1.avro");
+            var c4 = serializerCs.FromFile("TangTestCs1.avro");
+            IFoo f4 = (IFoo)TangFactory.GetTang().NewInjector(c4).GetInstance(fooType);
+            Assert.AreEqual(f4.getFooness(), 12);
+
+            IConfigurationSerializer serializerImpl = (IConfigurationSerializer)TangFactory.GetTang().NewInjector().GetInstance(typeof(IConfigurationSerializer));
+            serializerImpl.ToFile(c, "TangTestCs1.avro");
+            var c5 = serializerImpl.FromFile("TangTestCs1.avro");
+            IFoo f5 = (IFoo)TangFactory.GetTang().NewInjector(c5).GetInstance(fooType);
+            Assert.AreEqual(f5.getFooness(), 12);
+           
+            //this is to test the file generated from Java. name,value b=must be recognized by C# class hierarchy
+            AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+            var avroConfig = serializer.AvroDeseriaizeFromFile("Evaluator.conf");
+            Assert.IsNotNull(avroConfig);
+        }
+
+        [TestMethod]
+        public void OmitOptionalTest()  
+        {
+            Type fooType = typeof(Org.Apache.Reef.Tang.Test.Format.IFoo);
+
+            IConfiguration c = MyConfigurationModule.Conf
+                .Set(MyConfigurationModule.TheFoo, GenericType<FooImpl>.Class)
+                .Build();
+            IFoo f = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(fooType);
+            Assert.AreEqual(f.getFooness(), 42);
+        }
+
+        [TestMethod]
+        public void OmitRequiredTest()
+        {
+            string msg = null;
+            try 
+            {
+                MyConfigurationModule.Conf
+                .Set(MyConfigurationModule.FooNess, "12")
+                .Build();
+                msg = "Attempt to build configuration before setting required option(s): { THE_FOO }";
+            } 
+            catch (Exception) 
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void BadConfTest()
+        {
+            string msg = null;
+            try
+            {
+                object obj = MyMissingBindConfigurationModule.BadConf;
+                msg = "Found declared options that were not used in binds: { FOO_NESS }" + obj;
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void NonExistentStringBindOK()
+        {
+            new MyBadConfigurationModule().BindImplementation(GenericType<IFoo>.Class, "i.do.not.exist");
+        }
+
+        [TestMethod]
+        public void NonExistentStringBindNotOK()
+        {
+            string msg = null;
+            try
+            {
+                new MyBadConfigurationModule().BindImplementation(GenericType<IFoo>.Class, "i.do.not.exist").Build();
+                msg = "ConfigurationModule refers to unknown class: i.do.not.exist";
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);            
+        }
+
+        [TestMethod]
+        public void MultiBindTest() 
+        {
+            // Here we set some configuration values.  In true tang style,
+            // you won't be able to set them more than once ConfigurationModule's
+            // implementation is complete.
+            IConfiguration c = MultiBindConfigurationModule.Conf
+                .Set(MultiBindConfigurationModule.TheFoo, GenericType<FooImpl>.Class)
+                .Set(MultiBindConfigurationModule.FOONESS, "12")
+                .Build();
+            IFoo f = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(typeof(IFoo));
+            IFoo g = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(typeof(object));
+            Assert.AreEqual(f.getFooness(), 12);
+            Assert.AreEqual(g.getFooness(), 12);
+            Assert.IsFalse(f == g);
+          }
+
+        [TestMethod]
+        public void ForeignSetTest()
+        {
+            string msg = null;
+            try
+            {
+                MultiBindConfigurationModule.Conf.Set(MyConfigurationModule.TheFoo, GenericType<FooImpl>.Class);
+                msg = "Unknown Impl/Param when setting RequiredImpl.  Did you pass in a field from some other module?";
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void ForeignBindTest()
+        {
+            string msg = null;
+            try
+            {
+                new MyConfigurationModule().BindImplementation(GenericType<object>.Class, MultiBindConfigurationModule.TheFoo);
+                msg = "Unknown Impl/Param when binding RequiredImpl.  Did you pass in a field from some other module?";
+            }
+            catch (Exception)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+        [TestMethod]
+        public void SingletonTest() 
+        {
+            IConfiguration c = new MyConfigurationModule()
+              .BindImplementation(GenericType<IFoo>.Class, MyConfigurationModule.TheFoo)
+              .BindNamedParameter(GenericType<Fooness>.Class, MyConfigurationModule.FooNess)
+              .Build()
+              .Set(MyConfigurationModule.TheFoo, GenericType<FooImpl>.Class)
+              .Build();
+            IInjector i = TangFactory.GetTang().NewInjector(c);
+            Assert.IsTrue(i.GetInstance(typeof(IFoo)) == i.GetInstance(typeof(IFoo)));
+        }
+
+        [TestMethod]
+        public void ImmutablilityTest() 
+        {
+            // builder methods return copies; the original module is immutable
+            ConfigurationModule builder1 = MyConfigurationModule.Conf
+            .Set(MyConfigurationModule.TheFoo, GenericType<FooImpl>.Class);
+   
+            Assert.IsFalse(builder1 == MyConfigurationModule.Conf);
+
+            IConfiguration config1 = builder1.Build();
+  
+            // reusable
+            IConfiguration config2 = MyConfigurationModule.Conf
+            .Set(MyConfigurationModule.TheFoo, GenericType<FooAltImpl>.Class)
+            .Build();
+
+            // instantiation of each just to be sure everything is fine in this situation
+            IInjector i1 = TangFactory.GetTang().NewInjector(config1);
+            IInjector i2 = TangFactory.GetTang().NewInjector(config2);
+            Assert.AreEqual(42, ((IFoo)i1.GetInstance(typeof(IFoo))).getFooness());
+            Assert.AreEqual(7, ((IFoo)i2.GetInstance(typeof(IFoo))).getFooness());
+        }
+
+        [TestMethod]
+        public void SetParamTest() 
+        {
+            IConfiguration c = SetConfigurationModule.CONF
+                .Set(SetConfigurationModule.P, "a")
+                .Set(SetConfigurationModule.P, "b")
+                .Build();
+    
+            ISet<string> s = (ISet<string>)TangFactory.GetTang().NewInjector(c).GetNamedInstance(typeof(SetName));
+            Assert.AreEqual(s.Count, 2);
+            Assert.IsTrue(s.Contains("a"));
+            Assert.IsTrue(s.Contains("b"));
+        }
+
+        [TestMethod]
+        public void SetClassTest() 
+        {
+            IConfiguration c = SetClassConfigurationModule.CONF
+                .Set(SetClassConfigurationModule.P, GenericType<SubA>.Class)
+                .Set(SetClassConfigurationModule.P, GenericType<SubB>.Class)
+                .Build();
+            ISet<ISuper> s = (ISet<ISuper>)TangFactory.GetTang().NewInjector(c).GetNamedInstance(typeof(SetClass));
+            Assert.AreEqual(2, s.Count);
+            
+            bool sawA = false, sawB = false;    
+            foreach (ISuper sup in s)
+            {
+                if (sup is SubA) 
+                {
+                    sawA = true;
+                } 
+                else if (sup is SubB) 
+                {
+                    sawB = true;
+                } 
+                else 
+                {
+                    Assert.Fail();
+                }
+            }
+            Assert.IsTrue(sawA && sawB);
+        }
+
+        [TestMethod]
+        public void SetClassRoundTripTest() 
+        {
+            IConfiguration c = SetClassConfigurationModule.CONF
+                .Set(SetClassConfigurationModule.P, GenericType<SubA>.Class)
+                .Set(SetClassConfigurationModule.P, GenericType<SubB>.Class)
+                .Build();
+            IConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(c);
+
+            AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
+            IConfiguration c2 = serializer.FromString(serializer.ToString(cb.Build()));
+
+            //ConfigurationFile.AddConfiguration(cb, ConfigurationFile.ToConfigurationString(c));
+            ISet<ISuper> s = (ISet<ISuper>)TangFactory.GetTang().NewInjector(c2).GetNamedInstance(typeof(SetClass));
+            Assert.AreEqual(2, s.Count);
+            bool sawA = false, sawB = false;
+            foreach (ISuper sup in s)
+            {
+                if (sup is SubA)
+                {
+                    sawA = true;
+                }
+                else if (sup is SubB)
+                {
+                    sawB = true;
+                }
+                else
+                {
+                    Assert.Fail();
+                }
+            }
+            Assert.IsTrue(sawA && sawB);
+        }
+
+        [TestMethod]
+        public void ErrorOnStaticTimeSet()
+        {
+            string msg = null;
+            try
+            {
+                StaticTimeSet.CONF.AssertStaticClean();
+                msg =
+                    " Detected statically set ConfigurationModule Parameter / Implementation.  set() should only be used dynamically.  Use bind...() instead.";
+            }
+            catch (ClassHierarchyException)
+            {
+            }
+            Assert.IsNull(msg);
+        }
+
+         [TestMethod]
+         public void ErrorOnSetMerge()
+         {
+             ConfigurationModuleBuilder cb = null;
+             try
+             {
+                 ConfigurationModuleBuilder b = new ConfigurationModuleBuilder();
+                 cb = b.Merge(StaticTimeSet.CONF);
+             }
+             catch (ClassHierarchyException e)
+             {
+                 System.Diagnostics.Debug.WriteLine(e);
+             }
+             Assert.IsNull(cb);
+        }
+    }
+
+    [NamedParameter("Fooness", "Fooness", "42")]
+    public class Fooness : Name<int>
+    {        
+    }
+
+    public class FooImpl : IFoo
+    {
+        private readonly int fooness;
+
+        [Inject]
+        FooImpl([Parameter(typeof(Fooness))] int fooness) 
+        { 
+            this.fooness = fooness; 
+        }
+
+        public int getFooness()
+        {
+            return this.fooness;
+        }
+    }
+    
+    public class FooAltImpl : IFoo 
+    {
+        private readonly int fooness;
+        
+        [Inject]
+        FooAltImpl([Parameter(Value = typeof(Fooness))] int fooness)
+        {
+            this.fooness = fooness;
+        }
+    
+        public int getFooness() 
+        {
+            return 7;
+        }
+    }
+
+    public sealed class MyConfigurationModule : ConfigurationModuleBuilder 
+    {    
+      // Tell us what implementation you want, or else!!    
+      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+      public static readonly RequiredImpl<IFoo> TheFoo = new RequiredImpl<IFoo>();
+
+      // If you want, you can change the fooness.
+      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+      public static readonly OptionalParameter<int> FooNess = new OptionalParameter<int>();
+
+      // This binds the above to tang configuration stuff.  You can use parameters more than
+      // once, but you'd better use them all at least once, or I'll throw exceptions at you.
+      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+      public static readonly ConfigurationModule Conf = new MyConfigurationModule()
+        .BindImplementation(GenericType<IFoo>.Class, MyConfigurationModule.TheFoo)
+        .BindNamedParameter(GenericType<Fooness>.Class, MyConfigurationModule.FooNess)
+        .Build();
+    }
+
+    public class MyMissingBindConfigurationModule : ConfigurationModuleBuilder 
+    {    
+      // Tell us what implementation you want, or else!!    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+        public static readonly RequiredImpl<IFoo> TheFoo = new RequiredImpl<IFoo>();
+  
+        // If you want, you can change the fooness.
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+        public static readonly OptionalParameter<int> FooNess = new OptionalParameter<int>();
+  
+        // This conf doesn't use FOO_NESS.  Expect trouble below
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+        public static readonly ConfigurationModule BadConf = new MyMissingBindConfigurationModule()
+            .BindImplementation(GenericType<IFoo>.Class, MyMissingBindConfigurationModule.TheFoo)
+            .Build();
+    }
+
+    public class MyBadConfigurationModule : ConfigurationModuleBuilder 
+    {    
+    }
+
+    public class MultiBindConfigurationModule : ConfigurationModuleBuilder 
+    {    
+        // Tell us what implementation you want, or else!!    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+        public static readonly RequiredImpl<IFoo> TheFoo = new RequiredImpl<IFoo>();
+
+        // If you want, you can change the fooness.
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+        public static readonly OptionalParameter<int> FOONESS = new OptionalParameter<int>();
+
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Required by Tang")]
+        public static readonly ConfigurationModule Conf = new MultiBindConfigurationModule()
+          .BindImplementation(GenericType<IFoo>.Class, MultiBindConfigurationModule.TheFoo)
+          .BindImplementation(GenericType<object>.Class, MultiBindConfigurationModule.TheFoo)
+          .BindNamedParameter(GenericType<Fooness>.Class, MultiBindConfigurationModule.FOONESS)
+          .Build();    
+    }
+
+    [NamedParameter]
+    class SetName : Name<ISet<string>> 
+    {
+    }
+
+    class SetConfigurationModule : ConfigurationModuleBuilder 
+    {
+        public static readonly RequiredParameter<string> P = new RequiredParameter<string>();
+
+        public static readonly ConfigurationModule CONF = new SetConfigurationModule()
+            .BindSetEntry(GenericType<SetName>.Class, SetConfigurationModule.P)
+            .Build();
+    }
+
+    [NamedParameter]
+    class SetClass : Name<ISet<ISuper>> 
+    {
+    }
+
+    class SetClassConfigurationModule : ConfigurationModuleBuilder 
+    {
+        public static readonly RequiredParameter<ISuper> P = new RequiredParameter<ISuper>();
+        public static readonly ConfigurationModule CONF = new SetClassConfigurationModule()
+        .BindSetEntry(GenericType<SetClass>.Class, SetClassConfigurationModule.P)
+        .Build();
+    }
+
+    class SubA : ISuper 
+    {
+        [Inject]
+        public SubA() 
+        {
+        }
+    }
+
+    class SubB : ISuper 
+    {
+        [Inject]
+        public SubB() 
+        {
+        }
+    }
+    
+    class StaticTimeSet : ConfigurationModuleBuilder 
+    {
+        public static readonly OptionalImpl<ISuper> X = new OptionalImpl<ISuper>();
+        public static readonly ConfigurationModule CONF = new StaticTimeSet()
+            .BindImplementation(GenericType<ISuper>.Class, X)
+            .Build()
+            .Set(X, GenericType<SubA>.Class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Format/TestConfigurationModuleForList.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Format/TestConfigurationModuleForList.cs b/lang/cs/Tests/TangTests/Format/TestConfigurationModuleForList.cs
new file mode 100644
index 0000000..b560ec0
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Format/TestConfigurationModuleForList.cs
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Format
+{
+    interface IListSuper
+    {
+    }
+
+    [TestClass]
+    public class TestConfigurationModuleForList
+    {
+        //ConfigurationModuleBuilder BindList<U, T>(GenericType<U> iface, IParam<IList<T>> opt)
+        //public ConfigurationModule Set<T>(IImpl<IList<T>> opt, IList<string> impl)
+        [TestMethod]
+        public void ListParamTest()
+        {
+            IList<string> v = new List<string>();
+            v.Add("a");
+            v.Add("b");
+
+            IConfiguration c = ListConfigurationModule.CONF
+                .Set(ListConfigurationModule.P, v)
+                .Build();
+
+            IList<string> s = (IList<string>)TangFactory.GetTang().NewInjector(c).GetNamedInstance(typeof(ListName));
+            Assert.AreEqual(s.Count, 2);
+            Assert.IsTrue(s.Contains("a"));
+            Assert.IsTrue(s.Contains("b"));
+        }
+
+        // public ConfigurationModuleBuilder BindList<U, T>(GenericType<U> iface, IImpl<IList<T>> opt) where U : Name<IList<T>>
+        // public ConfigurationModule Set<T>(IImpl<IList<T>> opt, IList<Type> impl)
+        [TestMethod]
+        public void ListImplTest()
+        {
+            IList<Type> v = new List<Type>();
+            v.Add(typeof(ListSubA));
+            v.Add(typeof(ListSubB));
+
+            IConfiguration c = ListClassConfigurationModule.CONF
+                .Set(ListClassConfigurationModule.P, v)
+                .Build();
+
+            IList<IListSuper> s = (IList<IListSuper>)TangFactory.GetTang().NewInjector(c).GetNamedInstance(typeof(ListClass));
+            Assert.AreEqual(s.Count, 2);
+            Assert.IsTrue(s[0] is ListSubA);
+            Assert.IsTrue(s[1] is ListSubB);
+        }
+
+        //public ConfigurationModuleBuilder BindList<U, T>(GenericType<U> iface, IList<string> impl)
+        [TestMethod]
+        public void ListStringTest()
+        {
+            IConfiguration c = ListIntConfigurationModule.CONF                
+                .Build();
+
+            IList<int> i = (IList<int>)TangFactory.GetTang().NewInjector(c).GetNamedInstance(typeof(ListIntName));
+            Assert.AreEqual(i.Count, 2);
+            Assert.IsTrue(i.Contains(1));
+            Assert.IsTrue(i.Contains(2));
+        }
+    }
+
+    [NamedParameter]
+    class ListName : Name<IList<string>>
+    {
+    }
+
+    class ListConfigurationModule : ConfigurationModuleBuilder
+    {
+        public static readonly RequiredParameter<IList<string>> P = new RequiredParameter<IList<string>>();
+
+        public static readonly ConfigurationModule CONF = new ListConfigurationModule()
+            .BindList(GenericType<ListName>.Class, ListConfigurationModule.P)
+            .Build();
+    }
+
+    [NamedParameter]
+    class ListClass : Name<IList<IListSuper>> 
+    {
+    }
+
+    class ListClassConfigurationModule : ConfigurationModuleBuilder 
+    {
+        public static readonly RequiredImpl<IList<IListSuper>> P = new RequiredImpl<IList<IListSuper>>();
+
+        public static readonly ConfigurationModule CONF = new ListClassConfigurationModule()
+        .BindList(GenericType<ListClass>.Class, ListClassConfigurationModule.P)
+        .Build();
+    }
+
+    class ListSubA : IListSuper 
+    {
+        [Inject]
+        public ListSubA() 
+        {
+        }
+    }
+
+    class ListSubB : IListSuper 
+    {
+        [Inject]
+        public ListSubB() 
+        {
+        }
+    }
+
+    [NamedParameter]
+    class ListIntName : Name<IList<int>>
+    {
+    }
+
+    class ListIntConfigurationModule : ConfigurationModuleBuilder
+    {
+        public static readonly ConfigurationModule CONF = new ListIntConfigurationModule()
+            .BindList<ListIntName, int>(GenericType<ListIntName>.Class, (new List<string>(new string[] { "1", "2" })))
+            .Build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Format/TestTaskConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Format/TestTaskConfiguration.cs b/lang/cs/Tests/TangTests/Format/TestTaskConfiguration.cs
new file mode 100644
index 0000000..7d77602
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Format/TestTaskConfiguration.cs
@@ -0,0 +1,389 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Formats;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Format
+{
+    public interface ISuspendEvent
+    {
+        string GetId();
+    }
+
+    public interface IDriverMessage
+    {
+        string GetId();
+    }
+
+    public interface ITaskMessageSource
+    {
+        string GetId();
+    }
+
+    public interface ITaskStop
+    {
+        string GetId();
+    }
+
+    public interface IEventHandler<T>
+    {
+        void OnNext(T t);
+    }
+
+    public interface ITaskStart
+    {
+        string GetId();
+    }
+
+    public interface ICloseEvent
+    {
+        string GetId();
+    }
+
+    [TestClass]
+    public class TestTaskConfiguration
+    {
+        [TestMethod]
+        public void TaskConfigurationTestWith3Parameters()
+        {
+            TaskConfigurationWith3Parameters.Conf
+                .Set(TaskConfigurationWith3Parameters.ONCLOSE, GenericType<TaskCloseHandler>.Class)
+                .Build();
+        }
+
+        [TestMethod]
+        public void TaskConfigurationWithMyEventHandlerTest()
+        {
+            TaskConfigurationWithMyEventHandler.Conf
+                .Set(TaskConfigurationWithMyEventHandler.ONCLOSE2, GenericType<MyTaskCloseHandler>.Class)
+                .Build();
+        }
+
+        [TestMethod]
+        public void TaskConfigurationTest()
+        {
+            IConfiguration conf1 = TaskConfiguration.Conf
+                                                    .Set(TaskConfiguration.IDENTIFIER, "sample task")
+                                                    .Set(TaskConfiguration.TASK, GenericType<HelloTask>.Class)
+                                                    .Set(TaskConfiguration.ONCLOSE, GenericType<TaskCloseHandler>.Class)
+                                                    .Set(TaskConfiguration.MEMENTO, "Test")
+                                                    .Set(TaskConfiguration.ONSUSPEND, GenericType<SuspendHandler>.Class)
+                                                    .Set(TaskConfiguration.ONMESSAGE,
+                                                         GenericType<DriverMessageHandler>.Class)
+                                                    .Set(TaskConfiguration.ONSENDMESSAGE, GenericType<TaskMsg>.Class)
+                                                    .Set(TaskConfiguration.ONTASKSTARTED,
+                                                         GenericType<TaskStartHandler>.Class)
+                                                    .Set(TaskConfiguration.ONTASKSTOP,
+                                                         GenericType<TaskStopHandler>.Class)
+                                                    .Build();
+
+            IInjector injector1 = TangFactory.GetTang().NewInjector(conf1);
+            var task1 = (Org.Apache.Reef.Tasks.HelloTask)injector1.GetInstance(typeof(ITask));
+            Assert.IsNotNull(task1);
+
+            var serializer = new AvroConfigurationSerializer();
+            byte[] bytes = serializer.ToByteArray(conf1);
+            IConfiguration conf2 = serializer.FromByteArray(bytes);
+
+            IInjector injector2 = TangFactory.GetTang().NewInjector(conf2);
+            var task2 = (Org.Apache.Reef.Tasks.HelloTask)injector2.GetInstance(typeof(ITask));
+            Assert.IsNotNull(task2);
+        }
+
+        [TestMethod]
+        public void TaskConfigurationSerializationTest()
+        {
+            IConfiguration conf1 = TaskConfiguration.Conf
+                .Set(TaskConfiguration.IDENTIFIER, "sample task")
+                .Set(TaskConfiguration.TASK, GenericType<HelloTask>.Class)
+                .Set(TaskConfiguration.ONCLOSE, GenericType<TaskCloseHandler>.Class)
+                .Set(TaskConfiguration.MEMENTO, "Test")
+                .Set(TaskConfiguration.ONSUSPEND, GenericType<SuspendHandler>.Class)
+                .Set(TaskConfiguration.ONMESSAGE, GenericType<DriverMessageHandler>.Class)
+                .Set(TaskConfiguration.ONSENDMESSAGE, GenericType<TaskMsg>.Class)
+                .Set(TaskConfiguration.ONTASKSTARTED, GenericType<TaskStartHandler>.Class)
+                .Set(TaskConfiguration.ONTASKSTOP, GenericType<TaskStopHandler>.Class)
+                .Build();
+
+            IInjector injector1 = TangFactory.GetTang().NewInjector(conf1);
+            var task1 = (Org.Apache.Reef.Tasks.HelloTask)injector1.GetInstance(typeof(ITask));
+            Assert.IsNotNull(task1);
+
+            var serializer = new AvroConfigurationSerializer();
+            byte[] bytes = serializer.ToByteArray(conf1);
+            IConfiguration conf2 = serializer.FromByteArray(bytes);
+
+            IInjector injector2 = TangFactory.GetTang().NewInjector(conf2);
+            var task2 = (Org.Apache.Reef.Tasks.HelloTask)injector2.GetInstance(typeof(ITask));
+            Assert.IsNotNull(task2);
+
+            serializer.ToFileStream(conf1, "TaskConfiguration.bin");
+            IConfiguration conf3 = serializer.FromFileStream("TaskConfiguration.bin");
+
+            IInjector injector3 = TangFactory.GetTang().NewInjector(conf3);
+            var task3 = (Org.Apache.Reef.Tasks.HelloTask)injector3.GetInstance(typeof(ITask));
+            Assert.IsNotNull(task3);
+        }
+    }
+
+    public class TaskConfigurationWith3Parameters : ConfigurationModuleBuilder
+    {
+        public static readonly OptionalImpl<IEventHandler<ICloseEvent>> ONCLOSE = new OptionalImpl<IEventHandler<ICloseEvent>>();
+
+        public static ConfigurationModule Conf 
+        {
+            get
+            {
+                return new TaskConfigurationWith3Parameters()
+                    .BindNamedParameter<TaskConfigurationOptions.CloseHandler, IEventHandler<ICloseEvent>, IEventHandler<ICloseEvent>>(GenericType<TaskConfigurationOptions.CloseHandler>.Class, ONCLOSE)
+                    .Build();
+            }
+        }
+    }
+
+    public class TaskConfiguration : ConfigurationModuleBuilder
+    {
+        public static readonly OptionalImpl<IEventHandler<ICloseEvent>> ONCLOSE = new OptionalImpl<IEventHandler<ICloseEvent>>();
+        public static readonly RequiredParameter<string> IDENTIFIER = new RequiredParameter<string>();
+        public static readonly RequiredImpl<ITask> TASK = new RequiredImpl<ITask>();
+        public static readonly OptionalImpl<IEventHandler<ISuspendEvent>> ONSUSPEND = new OptionalImpl<IEventHandler<ISuspendEvent>>();
+        public static readonly OptionalImpl<IEventHandler<IDriverMessage>> ONMESSAGE = new OptionalImpl<IEventHandler<IDriverMessage>>();
+        public static readonly OptionalParameter<string> MEMENTO = new OptionalParameter<string>();
+        public static readonly OptionalImpl<ITaskMessageSource> ONSENDMESSAGE = new OptionalImpl<ITaskMessageSource>();
+        public static readonly OptionalImpl<IEventHandler<ITaskStart>> ONTASKSTARTED = new OptionalImpl<IEventHandler<ITaskStart>>();
+        public static readonly OptionalImpl<IEventHandler<ITaskStop>> ONTASKSTOP = new OptionalImpl<IEventHandler<ITaskStop>>();
+
+        public static ConfigurationModule Conf 
+        {
+            get
+            {
+                return new TaskConfiguration()
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.Identifier>.Class, IDENTIFIER)
+                    .BindImplementation(GenericType<ITask>.Class, TASK)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.Memento>.Class, MEMENTO)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.CloseHandler>.Class, ONCLOSE)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.SuspendHandler>.Class, ONSUSPEND)
+                    .BindNamedParameter(GenericType<TaskConfigurationOptions.MessageHandler>.Class, ONMESSAGE)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.TaskMessageSources>.Class, ONSENDMESSAGE)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.StartHandlers>.Class, ONTASKSTARTED)
+                    .BindSetEntry(GenericType<TaskConfigurationOptions.StopHandlers>.Class, ONTASKSTOP)
+                    .Build();
+            }
+        }
+    }
+
+    public class TaskConfigurationWithMyEventHandler : ConfigurationModuleBuilder
+    {
+        public static readonly OptionalImpl<MyEventHandler<ICloseEvent>> ONCLOSE2 = new OptionalImpl<MyEventHandler<ICloseEvent>>();
+
+        public static ConfigurationModule Conf 
+        {
+            get
+            {
+                return new TaskConfigurationWithMyEventHandler()
+                    .BindNamedParameter<MyTaskConfigurationOptions.MyCloseHandler, MyEventHandler<ICloseEvent>, IEventHandler<ICloseEvent>>(GenericType<MyTaskConfigurationOptions.MyCloseHandler>.Class, ONCLOSE2)
+                    .Build();
+            }
+        }
+    }
+
+    public class MyEventHandler<T> : IEventHandler<T>
+    {
+        public void OnNext(T t)
+        {
+        }
+    }
+    
+    public class TaskConfigurationOptions
+    {
+        [NamedParameter(DefaultValue = "Unnamed Task", Documentation = "The Identifier of the Task")]
+        public class Identifier : Name<string> 
+        {
+        }
+
+        [NamedParameter(Documentation = "The event handler that receives the close event", DefaultClass = typeof(DefaultCloseHandler))]
+        public class CloseHandler : Name<IEventHandler<ICloseEvent>>
+        {
+        }
+
+        [NamedParameter(Documentation = "The memento to be used for the Task.")]
+        public class Memento : Name<string> 
+        {
+        }
+
+        [NamedParameter(Documentation = "The event handler that receives the suspend event", DefaultClass = typeof(DefaultSuspendHandler))]
+        public class SuspendHandler : Name<IEventHandler<ISuspendEvent>> 
+        {
+        }
+
+        [NamedParameter(Documentation = "The event handler that receives messages from the driver", DefaultClass = typeof(DefaultDriverMessageHandler))]
+        public class MessageHandler : Name<IEventHandler<IDriverMessage>> 
+        {
+        }
+
+        [NamedParameter(Documentation = "TaskMessageSource instances.")]
+        public class TaskMessageSources : Name<ISet<ITaskMessageSource>> 
+        {
+        }
+
+        [NamedParameter(Documentation = "The set of event handlers for the TaskStart event.")]
+        public class StartHandlers : Name<ISet<IEventHandler<ITaskStart>>> 
+        {
+        }
+
+        [NamedParameter(Documentation = "The set of event handlers for the TaskStop event.")]
+        public class StopHandlers : Name<ISet<IEventHandler<ITaskStop>>> 
+        {
+        }
+    }
+
+    public class MyTaskConfigurationOptions
+    {
+        [NamedParameter(Documentation = "The event handler that receives the close event", DefaultClass = typeof(MyDefaultCloseHandler))]
+        public class MyCloseHandler : Name<IEventHandler<ICloseEvent>>
+        {
+        }
+    }
+
+    public class DefaultCloseHandler : IEventHandler<ICloseEvent>
+    {
+        [Inject]
+        public DefaultCloseHandler()
+        {
+        }
+
+        public void OnNext(ICloseEvent closeEvent)
+        {
+        }
+    }
+
+    public class MyDefaultCloseHandler : MyEventHandler<ICloseEvent>
+    {
+        [Inject]
+        public MyDefaultCloseHandler()
+        {
+        }
+    }
+
+    public class TaskCloseHandler : IEventHandler<ICloseEvent>
+    {
+        [Inject]
+        public TaskCloseHandler()
+        {
+        }
+
+        public void OnNext(ICloseEvent closeEvent)
+        {
+        }
+    }
+
+    public class MyTaskCloseHandler : MyEventHandler<ICloseEvent>
+    {
+        [Inject]
+        public MyTaskCloseHandler()
+        {
+        }
+    }
+
+    public class DefaultSuspendHandler : IEventHandler<ISuspendEvent> 
+    {
+      [Inject]
+      public DefaultSuspendHandler() 
+      {
+      }
+
+      public void OnNext(ISuspendEvent suspendEvent) 
+      {
+            throw new Exception("No handler for SuspendEvent registered. event: " + suspendEvent);
+      }
+    }
+
+    public class SuspendHandler : IEventHandler<ISuspendEvent> 
+    {
+        public void OnNext(ISuspendEvent suspendEvent) 
+        {
+        }
+    }
+
+    public class DefaultDriverMessageHandler : IEventHandler<IDriverMessage> 
+    {
+        [Inject]
+        public DefaultDriverMessageHandler() 
+        {
+        }
+
+        public void OnNext(IDriverMessage driverMessage) 
+        {
+            throw new Exception("No DriverMessage handler bound. Message received:" + driverMessage);
+        }
+    }
+
+    public class DriverMessageHandler : IEventHandler<IDriverMessage> 
+    {
+        public void OnNext(IDriverMessage driverMessage) 
+        {
+        }
+    }
+
+    public class TaskStartHandler : IEventHandler<ITaskStart> 
+    {
+        public void OnNext(ITaskStart t)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+    public class TaskStopHandler : IEventHandler<ITaskStop>
+    {
+        public void OnNext(ITaskStop t)
+        {
+            throw new NotImplementedException();
+        }
+    }
+    
+    public class TaskMsg : ITask, ITaskMessageSource 
+    {
+        [Inject]
+        public TaskMsg() 
+        {
+        }
+
+        public byte[] Call(byte[] memento)
+        {
+            throw new NotImplementedException();
+        }
+
+        public string GetId()
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Dispose()
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestAmbigousConstructors.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestAmbigousConstructors.cs b/lang/cs/Tests/TangTests/Injection/TestAmbigousConstructors.cs
new file mode 100644
index 0000000..feb34ab
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestAmbigousConstructors.cs
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Exceptions;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    [TestClass]
+    public class TestAmbigousConstructors
+    {
+        [TestMethod]
+        public void AmbigousConstructorTest()
+        {
+            //Cannot inject Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
+            //Ambiguous subplan Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass, Org.Apache.Reef.Tang.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+            //  new Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass(System.String Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass+NamedString = foo, System.Int32 Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass+NamedInt = 8) 
+            //  new Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass(System.Int32 Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass+NamedInt = 8, System.String Org.Apache.Reef.Tang.Test.Injection.AmbigousConstructorClass+NamedString = foo) 
+            //]
+            AmbigousConstructorClass obj = null;
+            try
+            {
+                ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+                cb.BindNamedParameter<AmbigousConstructorClass.NamedString, string>(GenericType<AmbigousConstructorClass.NamedString>.Class, "foo");
+                cb.BindNamedParameter<AmbigousConstructorClass.NamedInt, int>(GenericType<AmbigousConstructorClass.NamedInt>.Class, "8");
+                IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+                obj = i.GetInstance<AmbigousConstructorClass>();
+            }
+            catch (InjectionException e)
+            {
+                System.Diagnostics.Debug.WriteLine(e);
+            }
+            Assert.IsNull(obj);
+        }
+    }
+
+    class AmbigousConstructorClass
+    {
+        [Inject]
+        public AmbigousConstructorClass([Parameter(typeof(NamedString))] string s, [Parameter(typeof(NamedInt))] int i)
+        {
+        }
+
+        [Inject]
+        public AmbigousConstructorClass([Parameter(typeof(NamedInt))] int i, [Parameter(typeof(NamedString))] string s)
+        {
+        }
+
+        [NamedParameter]
+        public class NamedString : Name<string>
+        {
+        }
+
+        [NamedParameter]
+        public class NamedInt : Name<int>
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestForkInjection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestForkInjection.cs b/lang/cs/Tests/TangTests/Injection/TestForkInjection.cs
new file mode 100644
index 0000000..2d9dde5
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestForkInjection.cs
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Examples;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+using System.Reflection;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    [TestClass]
+    public class TestForkInjection
+    {        
+        static Assembly asm = null;
+
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            asm = Assembly.Load(FileNames.Examples);
+        }
+
+        [ClassCleanup]
+        public static void ClassCleanup()
+        {
+        }
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+        }
+
+        [TestCleanup()]
+        public void TestCleanup()
+        {
+        }
+
+        [TestMethod]
+        public void TestForksInjectorInConstructor()
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { FileNames.Examples });
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            var o = i.GetInstance(typeof(ForksInjectorInConstructor));
+        }
+
+        [TestMethod]
+        public void TestForkWorks()
+        {
+            Type checkChildIfaceType = typeof(CheckChildIface);
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindImplementation(GenericType<CheckChildIface>.Class, GenericType<CheckChildImpl>.Class);
+
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IInjector i1 = i.ForkInjector();
+            CheckChildIface c1 = (CheckChildIface)i1.GetInstance(checkChildIfaceType);
+            IInjector i2 = i.ForkInjector();
+            CheckChildIface c2 = (CheckChildIface)i2.GetInstance(checkChildIfaceType);
+            Assert.AreNotEqual(c1, c2);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestInjection.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestInjection.cs b/lang/cs/Tests/TangTests/Injection/TestInjection.cs
new file mode 100644
index 0000000..4e765bc
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestInjection.cs
@@ -0,0 +1,386 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Examples;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Org.Apache.Reef.Tasks;
+using System;
+using System.Reflection;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    [DefaultImplementation(typeof(AReferenceClass))]
+    internal interface IAInterface
+    {
+    }
+
+    [TestClass]
+    public class TestInjection
+    {
+        static Assembly asm = null;
+
+        [ClassInitialize]
+        public static void ClassSetup(TestContext context)
+        {
+            asm = Assembly.Load(FileNames.Examples);
+        }
+
+        [ClassCleanup]
+        public static void ClassCleanup()
+        {
+        }
+
+        [TestInitialize()]
+        public void TestSetup()
+        {
+        }
+
+        [TestCleanup()]
+        public void TestCleanup()
+        {
+        }
+
+        [TestMethod]
+        public void TestTimer()
+        {
+            Type timerType = typeof(Timer);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindNamedParameter<Timer.Seconds, int>(GenericType<Timer.Seconds>.Class, "2");
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var timer = (Timer)injector.GetInstance(timerType);
+
+            Assert.IsNotNull(timer);
+
+            timer.sleep();
+        }
+
+        [TestMethod]
+        public void TestTimerWithClassHierarchy()
+        {
+            Type timerType = typeof(Timer);
+
+            ClassHierarchyImpl classHierarchyImpl = new ClassHierarchyImpl(FileNames.Examples);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder((ICsClassHierarchy)classHierarchyImpl);
+
+            cb.BindNamedParameter<Timer.Seconds, int>(GenericType<Timer.Seconds>.Class, "2");
+            IConfiguration conf = cb.Build();
+
+            IInjector injector = tang.NewInjector(conf);
+            var timer = (Timer)injector.GetInstance(timerType);
+
+            Assert.IsNotNull(timer);
+
+            timer.sleep();
+        }
+
+        [TestMethod]
+        public void TestDocumentLoadNamedParameter()
+        {
+            Type documentedLocalNamedParameterType = typeof(DocumentedLocalNamedParameter);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            cb.BindNamedParameter<DocumentedLocalNamedParameter.Foo, string>(GenericType<DocumentedLocalNamedParameter.Foo>.Class, "Hello");
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var doc = (DocumentedLocalNamedParameter)injector.GetInstance(documentedLocalNamedParameterType);
+
+            Assert.IsNotNull(doc);
+        }
+
+        [TestMethod]
+        public void TestDocumentLoadNamedParameterWithDefaultValue()
+        {
+            ITang tang = TangFactory.GetTang();
+            IConfiguration conf = tang.NewConfigurationBuilder(new string[] { FileNames.Examples }).Build();
+            IInjector injector = tang.NewInjector(conf);
+            var doc = (DocumentedLocalNamedParameter)injector.GetInstance(typeof(DocumentedLocalNamedParameter));
+
+            Assert.IsNotNull(doc);
+        }
+
+        [TestMethod]
+        public void TestSimpleConstructor()
+        {
+            Type simpleConstructorType = typeof(SimpleConstructors);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var simpleConstructor = (SimpleConstructors)injector.GetInstance(simpleConstructorType);
+            Assert.IsNotNull(simpleConstructor);
+        }
+
+        [TestMethod]
+        public void TestActivity()
+        {
+            Type activityType = typeof(HelloTask);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Tasks, FileNames.Common });
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var activityRef = (ITask)injector.GetInstance(activityType);
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestStreamActivity1()
+        {
+            Type activityType = typeof(StreamTask1);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Tasks, FileNames.Common });
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var activityRef = (ITask)injector.GetInstance(activityType);
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestStreamActivity2()
+        {
+            Type activityType = typeof(StreamTask2);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Tasks, FileNames.Common });
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var activityRef = (ITask)injector.GetInstance(activityType);
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestMultipleAssemlies()
+        {
+            Type activityInterfaceType1 = typeof(ITask);
+            Type tweeterType = typeof(Tweeter);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples, FileNames.Tasks, FileNames.Common });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            cb.BindImplementation(GenericType<ITweetFactory>.Class, GenericType<MockTweetFactory>.Class);
+            cb.BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class);
+            cb.BindNamedParameter<Tweeter.PhoneNumber, long>(GenericType<Tweeter.PhoneNumber>.Class, "8675309");
+
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var activityRef = (ITask)injector.GetInstance(activityInterfaceType1);
+            var tweeter = (Tweeter)injector.GetInstance(tweeterType);
+
+            Assert.IsNotNull(activityRef);
+            Assert.IsNotNull(tweeter);
+
+            tweeter.sendMessage();
+        }
+
+        [TestMethod]
+        public void TestActivityWithBinding()
+        {
+            Type activityInterfaceType = typeof(ITask);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Tasks, FileNames.Common });
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            cb.BindNamedParameter<TaskConfigurationOptions.Identifier, string>(GenericType<TaskConfigurationOptions.Identifier>.Class, "Hello Task");
+
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            ITask activityRef1 = injector.GetInstance<ITask>();
+            var activityRef2 = (ITask)injector.GetInstance(activityInterfaceType);
+            Assert.IsNotNull(activityRef2);
+            Assert.IsNotNull(activityRef1);
+            Assert.AreEqual(activityRef1, activityRef2);
+        }
+
+        [TestMethod]
+        public void TestHelloStreamingActivityWithBinding()
+        {
+            Type activityInterfaceType = typeof(ITask);
+
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Tasks, FileNames.Common });
+
+            cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class);
+            cb.BindNamedParameter<TaskConfigurationOptions.Identifier, string>(GenericType<TaskConfigurationOptions.Identifier>.Class, "Hello Stereamingk");
+            cb.BindNamedParameter<StreamTask1.IpAddress, string>(GenericType<StreamTask1.IpAddress>.Class, "127.0.0.0");
+            IConfiguration conf = cb.Build();
+            IInjector injector = tang.NewInjector(conf);
+            var activityRef = (ITask)injector.GetInstance(activityInterfaceType);
+            Assert.IsNotNull(activityRef);
+        }
+
+        [TestMethod]
+        public void TestTweetExample()
+        {
+            Type tweeterType = typeof(Tweeter);
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });
+
+            IConfiguration conf = cb.BindImplementation(GenericType<ITweetFactory>.Class, GenericType<MockTweetFactory>.Class)
+            .BindImplementation(GenericType<ISMS>.Class, GenericType<MockSMS>.Class)
+            .BindNamedParameter<Tweeter.PhoneNumber, long>(GenericType<Tweeter.PhoneNumber>.Class, "8675309")
+            .Build();
+            IInjector injector = tang.NewInjector(conf);
+            var tweeter = (Tweeter)injector.GetInstance(tweeterType);
+            tweeter.sendMessage();
+
+            var sms = (ISMS)injector.GetInstance(typeof(ISMS));
+            var factory = (ITweetFactory)injector.GetInstance(typeof(ITweetFactory));
+            Assert.IsNotNull(sms);
+            Assert.IsNotNull(factory);
+        }
+
+        [TestMethod]
+        public void TestReferenceType()
+        {
+            AReferenceClass o = (AReferenceClass)TangFactory.GetTang().NewInjector().GetInstance(typeof(IAInterface));
+        }
+
+        [TestMethod]
+        public void TestGeneric()
+        {
+            var o = (AGenericClass<int>)TangFactory.GetTang().NewInjector().GetInstance(typeof(AGenericClass<int>));
+            var o2 = (AClassWithGenericArgument<int>)TangFactory.GetTang().NewInjector().GetInstance(typeof(AClassWithGenericArgument<int>));
+            Assert.IsNotNull(o);
+            Assert.IsNotNull(o2);
+        }
+
+        [TestMethod]
+        public void TestNestedClass()
+        {
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+
+            IConfiguration conf = cb
+            .BindNamedParameter<ClassParameter.Named1, int>(GenericType<ClassParameter.Named1>.Class, "5")
+            .BindNamedParameter<ClassParameter.Named2, string>(GenericType<ClassParameter.Named2>.Class, "hello")
+            .Build();
+
+            IInjector injector = tang.NewInjector(conf);
+            ClassHasNestedClass h = injector.GetInstance<ClassHasNestedClass>();
+
+            Assert.IsNotNull(h);
+        }
+
+        [TestMethod]
+        public void TestExternalObject()
+        {
+            ITang tang = TangFactory.GetTang();
+            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
+
+            IInjector injector = tang.NewInjector(cb.Build());
+
+            //bind an object to the injetor so that Tang will get this instance from cache directly instead of inject it when injecting ClassWithExternalObject
+            injector.BindVolatileInstance(GenericType<ExternalClass>.Class, new ExternalClass());
+            ClassWithExternalObject o = injector.GetInstance<ClassWithExternalObject>();
+
+            Assert.IsNotNull(o.ExternalObject is ExternalClass);
+        }
+    }
+
+    class AReferenceClass : IAInterface
+    {
+        [Inject]
+        public AReferenceClass(AReferenced refclass)
+        {            
+        }
+    }
+
+    class AReferenced
+    {
+        [Inject]
+        public AReferenced()
+        {
+        }
+    }
+
+    class AGenericClass<T>
+    {
+        [Inject]
+        public AGenericClass()
+        {
+        }
+    }
+
+    class AClassWithGenericArgument<T>
+    {
+        [Inject]
+        public AClassWithGenericArgument(AGenericClass<T> g)
+        {           
+        }
+    }
+
+    class ClassHasNestedClass
+    {
+        [Inject]
+        public ClassHasNestedClass(ClassParameter h1)
+        {
+        }
+    }
+
+    class ClassParameter
+    {        
+        private int i;
+        private string s;
+
+        [Inject]
+        public ClassParameter([Parameter(typeof(Named1))] int i, [Parameter(typeof(Named2))] string s)
+        {
+            this.i = i;
+            this.s = s;
+        }
+
+        [NamedParameter]
+        public class Named1 : Name<int>
+        {
+        }
+        
+        [NamedParameter]
+        public class Named2 : Name<string>
+        {            
+        }
+    }
+
+    class ClassWithExternalObject
+    {
+        [Inject]
+        public ClassWithExternalObject(ExternalClass ec)
+        {
+            ExternalObject = ec;
+        }
+
+        public ExternalClass ExternalObject { get; set; }
+    }
+
+    class ExternalClass
+    {
+        public ExternalClass()
+        {            
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Tests/TangTests/Injection/TestInjectionFuture.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Tests/TangTests/Injection/TestInjectionFuture.cs b/lang/cs/Tests/TangTests/Injection/TestInjectionFuture.cs
new file mode 100644
index 0000000..17349e2
--- /dev/null
+++ b/lang/cs/Tests/TangTests/Injection/TestInjectionFuture.cs
@@ -0,0 +1,240 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Org.Apache.Reef.Tang.Test.Injection
+{
+    interface IAinj
+    {
+    }
+
+    [DefaultImplementation(typeof(C), "C")]
+    interface IBinj : IAinj
+    {
+    }
+
+    [TestClass]
+    public class TestInjectionFuture
+    {
+        [TestMethod]
+        public void TestProactiveFutures()
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            IsFuture.Instantiated = false;
+            i.GetInstance(typeof(NeedsFuture));
+            Assert.IsTrue(IsFuture.Instantiated);
+        }
+
+        [TestMethod]
+        public void testFutures() 
+        {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IInjector i2 = TangFactory.GetTang().NewInjector(cb.Build());
+    
+            Futurist f = (Futurist)i.GetInstance(typeof(Futurist));
+            Assert.IsTrue(f == f.getMyCar().getDriver());
+            Assert.IsTrue(f.getMyCar() == f.getMyCar().getDriver().getMyCar());
+    
+            Futurist f2 = (Futurist)i2.GetInstance(typeof(Futurist));
+            Assert.IsTrue(f2 == f2.getMyCar().getDriver());
+            Assert.IsTrue(f2.getMyCar() == f2.getMyCar().getDriver().getMyCar());
+
+            Assert.IsTrue(f != f2.getMyCar().getDriver());
+            Assert.IsTrue(f.getMyCar() != f2.getMyCar().getDriver().getMyCar());
+        }
+        
+        [TestMethod]
+          public void testFutures2()  
+          {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            IInjector i2 = i.ForkInjector(new IConfiguration[] { });
+    
+            FlyingCar c = (FlyingCar)i.GetInstance(typeof(FlyingCar));
+            Assert.IsTrue(c == c.getDriver().getMyCar());
+            Assert.IsTrue(c.getDriver() == c.getDriver().getMyCar().getDriver());
+
+            FlyingCar c2 = (FlyingCar)i2.GetInstance(typeof(FlyingCar));
+            Assert.IsTrue(c2 == c2.getDriver().getMyCar());
+            Assert.IsTrue(c2.getDriver() == c2.getDriver().getMyCar().getDriver());
+
+            Assert.IsTrue(c2 != c.getDriver().getMyCar());
+            Assert.IsTrue(c2.getDriver() != c.getDriver().getMyCar().getDriver());
+          }
+
+        [TestMethod]
+          public void TestNamedParameterInjectionFuture() 
+          {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<FlyingCar>.Class, GenericType<FlyingCar>.Class);
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            PickyFuturist f = (PickyFuturist)i.GetInstance(typeof(PickyFuturist));
+            Assert.IsNotNull(f.getMyCar());
+          }
+
+         [TestMethod]
+          public void TestNamedParameterInjectionFutureDefaultImpl() 
+          {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            PickyFuturist f = (PickyFuturist)i.GetInstance(typeof(PickyFuturist));
+            Assert.IsNotNull(f.getMyCar());
+          }
+
+        [TestMethod]
+          public void TestNamedParameterInjectionFutureBindImpl()
+          {
+            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+            cb.BindImplementation(GenericType<Futurist>.Class, GenericType<PickyFuturist>.Class);
+            cb.BindNamedParameter<MyFlyingCar, BigFlyingCar, FlyingCar>(GenericType<MyFlyingCar>.Class, GenericType<BigFlyingCar>.Class);
+            IInjector i = TangFactory.GetTang().NewInjector(cb.Build());
+            PickyFuturist f = (PickyFuturist)i.GetInstance(typeof(PickyFuturist));
+            Assert.IsNotNull((BigFlyingCar)f.getMyCar());
+          }
+
+        [TestMethod]
+        public void TestNamedParameterBoundToDelegatingInterface() 
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            C c = (C)i.GetNamedInstance(typeof(AName));
+            Assert.IsNotNull(c);
+        }
+
+        [TestMethod]
+        public void TestBoundToDelegatingInterface() 
+        {
+            IInjector i = TangFactory.GetTang().NewInjector();
+            C c = (C)i.GetInstance(typeof(IBinj));
+            Assert.IsNotNull(c);
+        }
+
+        [DefaultImplementation(typeof(Futurist), "Futurist")]
+        public class Futurist 
+        {
+            private IInjectionFuture<FlyingCar> fcar;
+            [Inject]
+            public Futurist(IInjectionFuture<FlyingCar> car) 
+            {
+                this.fcar = car;
+            }
+
+            public virtual FlyingCar getMyCar() 
+            {
+                FlyingCar c = fcar.Get();
+                return c;
+            }    
+        }
+  
+        public class PickyFuturist : Futurist 
+        {
+            private IInjectionFuture<FlyingCar> fCar;
+            [Inject]
+            public PickyFuturist([Parameter(typeof(MyFlyingCar))] IInjectionFuture<FlyingCar> myFlyingCar) : base(myFlyingCar)
+            {
+                fCar = myFlyingCar;
+            }
+
+            public override FlyingCar getMyCar() 
+            {
+                FlyingCar c = fCar.Get();
+                return c;
+            }    
+        }
+
+        [DefaultImplementation(typeof(FlyingCar), "")]
+        public class FlyingCar 
+        {
+            private string color;
+            private Futurist driver;
+            
+            [Inject]
+            public FlyingCar([Parameter(typeof(Color))] string color, Futurist driver) 
+            {
+                this.color = color;
+                this.driver = driver;
+            }
+    
+            public string getColor() 
+            {
+                return color;
+            }
+    
+            public Futurist getDriver() 
+            {
+                return driver;
+            }
+        }
+
+        [NamedParameter(DefaultValue = "blue")]
+        public class Color : Name<string>
+        {
+        }
+
+        public class BigFlyingCar : FlyingCar 
+        {
+            [Inject]
+            BigFlyingCar([Parameter(typeof(Color))] string color, Futurist driver) : base(color, driver)
+            {
+            }
+        }
+  
+        [NamedParameter(DefaultClass = typeof(FlyingCar))]
+        public class MyFlyingCar : Name<FlyingCar>
+        {            
+        }
+    }
+
+    [NamedParameter(DefaultClass = typeof(IBinj))]
+    class AName : Name<IAinj>
+    {        
+    }
+
+    class C : IBinj
+    {
+        [Inject]
+        C()
+        {            
+        }
+    }
+
+    class IsFuture
+    {
+        [Inject]
+        IsFuture(NeedsFuture nf)
+        {
+            Instantiated = true;
+        }
+    
+        public static bool Instantiated { get; set; }    
+    }
+
+    class NeedsFuture
+    {
+        [Inject]
+        NeedsFuture(IInjectionFuture<IsFuture> isFut)
+        {
+        }
+    }
+}
\ No newline at end of file


[11/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code base

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Diagnostics/Exceptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Diagnostics/Exceptions.cs b/lang/cs/Source/Utilities/Diagnostics/Exceptions.cs
new file mode 100644
index 0000000..1308144
--- /dev/null
+++ b/lang/cs/Source/Utilities/Diagnostics/Exceptions.cs
@@ -0,0 +1,282 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using System.Text;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Utilities.Diagnostics
+{
+    public static class Exceptions
+    {
+        #region methods
+        /// <summary>
+        /// Call this method to throw an exception.
+        /// </summary>
+        /// <remarks>
+        /// Calling this method will trace the exception and do other common processing, 
+        /// and then it will throw the exception. This method traces the exception type 
+        /// and message at error level and the full stack trace at all other levels.
+        /// </remarks>
+        /// <example>
+        ///     Exceptions.Throw(new Exception("Some exception"));
+        /// </example>
+        /// <param name="exception">The exception to be thrown.</param>
+        /// <param name="message">The message from the caller class.</param>
+        /// <param name="logger">The logger from the caller class.</param>
+        public static void Throw(Exception exception, string message, Logger logger)
+        {
+            string logMessage = string.Concat(DiagnosticsMessages.ExceptionThrowing, " ", exception.GetType().Name, " ", message);
+            if (logger == null)
+            {
+                Console.WriteLine("Exception caught before logger is initiated, error message: " + logMessage + exception.Message);
+            }
+            else
+            {
+                logger.Log(Level.Error, logMessage, exception);
+            }
+            throw exception;
+        }
+
+        /// <summary>
+        /// Call this method to throw an exception.
+        /// </summary>
+        /// <remarks>
+        /// Calling this method will trace the exception and do other common processing, 
+        /// and then it will throw the exception. This method traces the exception type 
+        /// and message at error level and the full stack trace at all other levels.
+        /// </remarks>
+        /// <example>
+        ///     Exceptions.Throw(new Exception("Some exception"));
+        /// </example>
+        /// <param name="exception">The exception to be thrown.</param>
+        /// <param name="logger">The logger of the caller class.</param>
+        public static void Throw(Exception exception, Logger logger)
+        {
+            Throw(exception, string.Empty, logger);
+        }
+
+        /// <summary>
+        /// Call this method every time when an exception is caught.
+        /// </summary>
+        /// <remarks>
+        /// Calling this method will trace the exception and do other common processing.
+        /// This method traces the exception type and message at error level and the full
+        /// stack trace at all other levels.
+        /// </remarks>
+        /// <example>
+        ///     try
+        ///     {
+        ///         // Some code that can throw
+        ///     }
+        ///     catch (Exception e)
+        ///     {
+        ///         Exceptions.Caught(e);
+        ///         // Exception handling code
+        ///     }
+        /// </example>
+        /// <param name="exception">The exception being caught.</param>
+        /// <param name="level">The log level.</param>
+        /// <param name="logger">The logger from the caller class.</param>
+        public static void Caught(Exception exception, Level level, Logger logger)
+        {
+            Caught(exception, level, string.Empty, logger);
+        }
+
+        /// <summary>
+        /// Call this method every time when an exception is caught.
+        /// </summary>
+        /// <remarks>
+        /// Calling this method will trace the exception and do other common processing.
+        /// This method traces the exception type and message at error level and the full
+        /// stack trace at all other levels.
+        /// </remarks>
+        /// <example>
+        ///     try
+        ///     {
+        ///         // Some code that can throw
+        ///     }
+        ///     catch (Exception e)
+        ///     {
+        ///         Exceptions.Caught(e);
+        ///         // Exception handling code
+        ///     }
+        /// </example>
+        /// <param name="exception">The exception being caught.</param>
+        /// <param name="level">The log level.</param>
+        /// <param name="message">The additional messag to log.</param>
+        /// <param name="logger">The Logger from the caller class.</param>
+        public static void Caught(Exception exception, Level level, string message, Logger logger)
+        {
+            string logMessage = string.Concat(DiagnosticsMessages.ExceptionCaught, " ", exception.GetType().Name, " ", message);
+            if (logger == null)
+            {
+                Console.WriteLine("Exception caught before logger is initiated, error message: " + logMessage + exception.Message);
+            }
+            else
+            {
+                logger.Log(level, logMessage, exception);
+            }
+        }
+
+        public static void CaughtAndThrow(Exception exception, Level level, Logger logger)
+        {
+            CaughtAndThrow(exception, level, string.Empty, logger);
+        }
+
+        public static void CaughtAndThrow(Exception exception, Level level, string message, Logger logger)
+        {
+            string logMessage = string.Concat(DiagnosticsMessages.ExceptionCaught, " ", exception.GetType().Name, " ", message);
+            if (logger == null)
+            {
+                Console.WriteLine("Exception caught before logger is initiated, error message: " + logMessage + exception.Message);
+            }
+            else
+            {
+                logger.Log(level, logMessage, exception);
+            }
+            throw exception;
+        }
+
+        /// <summary>
+        /// This method returns true if the exception passed as parameter is a critical exception
+        /// that should have not been caught. Examples for such exceptions are StackOverflowException
+        /// and OutOfMemoryException.
+        /// </summary>
+        /// <remarks>
+        /// Catch statements which catch all exceptions must call this method immediately and rethrow
+        /// wihtout further processing if the method returns true.
+        /// </remarks>
+        /// <example>
+        /// try
+        /// {
+        ///     // Some code that can throw
+        /// }
+        /// catch (Exception e)
+        /// {
+        ///     if (Exceptions.MustRethrow(e))
+        ///     {
+        ///         throw;
+        ///     }
+        ///     // Exception handling code
+        /// }
+        /// </example>
+        /// <param name="exception">The exception to be checked.</param>
+        /// <returns>True if the exceptions is critical one and should not be caught and false otherwise.</returns>
+        public static bool MustRethrow(Exception exception)
+        {
+            return (exception is OutOfMemoryException ||
+                    exception is StackOverflowException);
+        }
+
+        /// <summary>
+        /// Gets an exception message that includes the messages of the inner exceptions..
+        /// </summary>
+        /// <param name="e">The excption.</param>
+        /// <returns>The meessage</returns>
+        public static string GetFullMessage(Exception e)
+        {
+            var fullMessage = new StringBuilder();
+            bool firstLevel = true;
+            while (e != null)
+            {
+                if (firstLevel)
+                {
+                    firstLevel = false;
+                }
+                else
+                {
+                    fullMessage.Append("-->");
+                }
+                fullMessage.Append(e.Message);
+                e = e.InnerException;
+            }
+
+            return fullMessage.ToString();
+        }
+
+        /// <summary>
+        /// Call this method to throw ArgumentException for an invalid argument.
+        /// </summary>
+        /// <param name="argumentName">The invalid argument name.</param>
+        /// <param name="message">A message explaining the reason for th exception.</param>
+        /// <param name="logger">The logger of the caller class.</param>
+        public static void ThrowInvalidArgument(string argumentName, string message, Logger logger)
+        {
+            Throw(new ArgumentException(message, argumentName), logger);
+        }
+
+        /// <summary>
+        /// Call this method to throw ArgumentOutOfRangeException exception.
+        /// </summary>
+        /// <param name="argumentName">The invalid argument name.</param>
+        /// <param name="message">A message explaining the reason for th exception.</param>
+        /// <param name="logger">The logger of the caller class.</param>
+        public static void ThrowArgumentOutOfRange(string argumentName, string message, Logger logger)
+        {
+            Throw(new ArgumentOutOfRangeException(argumentName, message), logger);
+        }
+
+        /// <summary>
+        /// Call this method to check if an argument is null and throw ArgumentNullException exception.
+        /// </summary>
+        /// <param name="argument">The argument to be checked.</param>
+        /// <param name="name">The name of the argument.</param>
+        /// <param name="logger">The logger of the caller class.</param>
+        public static void ThrowIfArgumentNull(object argument, string name, Logger logger)
+        {
+            if (argument == null)
+            {
+                Exceptions.Throw(new ArgumentNullException(name), logger);
+            }
+        }
+
+        /// <summary>
+        /// Call this method to throw ObjectDisposedException if an object is disposed.
+        /// </summary>
+        /// <remarks>
+        /// All disposable objects should check their state and throw in the beginning of each public method.
+        /// This helper method provides a shorter way to do this.
+        /// </remarks>
+        /// <example>
+        /// class SomeClass : IDisposable
+        /// {
+        ///     bool _disposed;
+        ///     // ...
+        ///     public void SomePublicMethod()
+        ///     {
+        ///         Exceptions.ThrowIfObjectDisposed(_disposed, this);
+        ///         // Method's code
+        ///     }
+        /// }
+        /// </example>
+        /// <param name="disposed">True if the object is disposed.</param>
+        /// <param name="o">The object.</param>
+        /// <param name="logger">The logger of the caller class.</param>
+        public static void ThrowIfObjectDisposed(bool disposed, object o, Logger logger)
+        {
+            if (disposed)
+            {
+                Throw(new ObjectDisposedException(o.GetType().Name), logger);
+            }
+        }
+        #endregion
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/IIdentifiable.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/IIdentifiable.cs b/lang/cs/Source/Utilities/IIdentifiable.cs
new file mode 100644
index 0000000..798f53c
--- /dev/null
+++ b/lang/cs/Source/Utilities/IIdentifiable.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Utilities
+{
+    public interface IIdentifiable
+    {
+        string Id { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/IMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/IMessage.cs b/lang/cs/Source/Utilities/IMessage.cs
new file mode 100644
index 0000000..35ed55d
--- /dev/null
+++ b/lang/cs/Source/Utilities/IMessage.cs
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Utilities
+{
+    /// <summary>
+    /// A message from a REEF component
+    /// </summary>
+    public interface IMessage
+    {
+        /// <summary>
+        ///  Get Message payload
+        /// </summary>
+        /// <returns></returns>
+        byte[] Message { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Logging/JavaLoggingSetting.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Logging/JavaLoggingSetting.cs b/lang/cs/Source/Utilities/Logging/JavaLoggingSetting.cs
new file mode 100644
index 0000000..cabf1a7
--- /dev/null
+++ b/lang/cs/Source/Utilities/Logging/JavaLoggingSetting.cs
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Utilities.Logging
+{
+    public enum JavaLoggingSetting
+    {
+         /// <summary>
+        /// info level log, and not transferred to CLR 
+        /// </summary>
+        INFO = 0,
+
+        /// <summary>
+        /// verbose log, but not to CLR
+        /// </summary>
+        VERBOSE = 1,
+
+        /// <summary>
+        /// verbose log, transferred to CLR
+        /// </summary>
+        VERBOSE_TO_CLR = 2,
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Logging/Level.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Logging/Level.cs b/lang/cs/Source/Utilities/Logging/Level.cs
new file mode 100644
index 0000000..71dd62f
--- /dev/null
+++ b/lang/cs/Source/Utilities/Logging/Level.cs
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Utilities.Logging
+{
+    public enum Level
+    {
+        /// <summary>
+        /// Output no tracing and debugging messages.
+        /// </summary>
+        Off = 0,
+
+        /// <summary>
+        /// Output error-handling messages.
+        /// </summary>
+        Error = 1,
+
+        /// <summary>
+        /// Output warnings and error-handling messages.
+        /// </summary>
+        Warning = 2,
+
+        /// <summary>
+        /// Trace a start event
+        /// </summary>
+        Start = 3,
+
+        /// <summary>
+        /// Trace a stop event
+        /// </summary>
+        Stop = 4,
+
+        /// <summary>
+        /// Output informational messages, warnings, and error-handling messages.
+        /// </summary>
+        Info = 5,
+
+        /// <summary>
+        /// Output all debugging and tracing messages.
+        /// </summary>
+        Verbose = 6,
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Logging/Logger.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Logging/Logger.cs b/lang/cs/Source/Utilities/Logging/Logger.cs
new file mode 100644
index 0000000..99ea80f
--- /dev/null
+++ b/lang/cs/Source/Utilities/Logging/Logger.cs
@@ -0,0 +1,227 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+
+namespace Org.Apache.Reef.Utilities.Logging
+{
+    public class Logger
+    {
+        private static readonly string[] LogLevel = new string[]
+            {
+                "OFF",
+                "ERROR",
+                "WARNING",
+                "START",
+                "EXIT",
+                "INFO",
+                "VERBOSE"
+            };
+
+        private static readonly Dictionary<Level, TraceEventType> EventTypes
+            = new Dictionary<Level, TraceEventType>()
+                    {
+                        { Level.Off, TraceEventType.Stop },
+                        { Level.Error, TraceEventType.Error },
+                        { Level.Warning, TraceEventType.Warning },
+                        { Level.Start, TraceEventType.Start },
+                        { Level.Stop, TraceEventType.Stop },
+                        { Level.Info, TraceEventType.Information },
+                        { Level.Verbose, TraceEventType.Verbose },
+                    };
+
+        private static Level _customLevel = Level.Verbose;
+
+        private static List<TraceListener> _traceListeners;
+
+        private string _name;       
+
+        private TraceSource _traceSource;
+
+        private Logger(string name)
+        {
+            _name = name;
+            _traceSource = new TraceSource(_name, SourceLevels.All);
+            CustcomLevel = _customLevel;
+            if (TraceListeners.Count == 0)
+            {
+                // before customized listener is added, we would need to log to console
+                _traceSource.Listeners.Add(new ConsoleTraceListener());
+            }
+            else
+            {
+                _traceSource.Listeners.Clear();
+                foreach (TraceListener listener in TraceListeners)
+                {
+                    _traceSource.Listeners.Add(listener);
+                }  
+            }
+        }
+
+        public static Level CustcomLevel
+        {
+            get
+            {
+                return _customLevel;
+            }
+
+            set
+            {
+                _customLevel = value;
+            }
+        }
+
+        public static List<TraceListener> TraceListeners
+        {
+            get
+            {
+                if (_traceListeners == null)
+                {
+                    _traceListeners = new List<TraceListener>();
+                }
+                return _traceListeners;
+            }
+        }
+
+        public static void SetCustomLevel(Level customLevel)
+        {
+            _customLevel = customLevel;
+        }
+
+        public static void AddTraceListner(TraceListener listener)
+        {
+            TraceListeners.Add(listener);
+        }
+
+        public static Logger GetLogger(Type type)
+        {
+            return GetLogger(type.FullName);
+        }
+
+        public static Logger GetLogger(string name)
+        {
+            return new Logger(name);
+        }
+
+        /// <summary>
+        /// Log the message with the specified Log Level.
+        ///
+        /// If addtional arguments are passed, the message will be treated as
+        /// a format string.  The format string and the additional arguments 
+        /// will be formatted according to string.Format()
+        /// </summary>
+        /// <param name="level"></param>
+        /// <param name="formatStr"></param>
+        /// <param name="args"></param>
+        public void Log(Level level, string formatStr, params object[] args)
+        {
+            if (CustcomLevel >= level)
+            {
+                string msg = FormatMessage(formatStr, args);
+                string logMessage = 
+                    DateTime.Now.ToString("o", CultureInfo.InvariantCulture) 
+                    + " " 
+                    + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString("D4", CultureInfo.InvariantCulture) 
+                    + Environment.NewLine + LogLevel[(int)level] + ": " 
+                    + msg;
+
+                _traceSource.TraceEvent(
+                    EventTypes[level],
+                    0, // we don't use event id for now, but this can be useful for e2e logging later  
+                    logMessage);
+            }
+        }
+
+        public void Log(Level level, string msg, Exception exception)
+        {
+            string exceptionLog = string.Empty;
+            if (exception != null)
+            {
+                exceptionLog = string.Format(
+                    CultureInfo.InvariantCulture,
+                    "encountered error [{0}] with mesage [{1}] and stack trace [{2}]",
+                    exception,
+                    exception.Message,
+                    exception.StackTrace);
+            }
+            Log(level, msg + exceptionLog);
+        }
+
+        public IDisposable LogFunction(string function, params object[] args)
+        {
+            return LogScope(function, args);
+        }
+
+        public IDisposable LogScope(string format, params object[] args)
+        {
+            return new LoggingScope(this, DateTime.Now + " " + format, args);
+        }
+
+        private string FormatMessage(string formatStr, params object[] args)
+        {
+            return args.Length > 0 ? string.Format(CultureInfo.CurrentCulture, formatStr, args) : formatStr;
+        }
+
+        /// <summary>
+        /// Represents a logging scope.
+        /// </summary>
+        /// <remarks>
+        /// A start log is written when an instance is created 
+        /// and a stop trace is written when the instance is disposed.
+        /// </remarks>
+        private sealed class LoggingScope : IDisposable
+        {
+            private readonly Stopwatch _stopWatch;
+
+            private readonly Logger _logger;
+
+            private readonly string _content;
+
+            /// <summary>
+            /// Initializes a new instance of the LoggingScope class. 
+            /// </summary>
+            /// <param name="logger"></param>
+            /// <param name="format"></param>
+            /// <param name="args"></param>
+            public LoggingScope(Logger logger, string format, params object[] args)
+            {
+                _logger = logger;
+
+                _stopWatch = Stopwatch.StartNew();
+
+                string content  = args.Length > 0 ? string.Format(CultureInfo.InvariantCulture, format, args) : format;
+                _content = content;
+
+                _logger.Log(Level.Start, content);
+            }
+
+            /// <summary>
+            /// Logs the end of a scope.
+            /// </summary>
+            public void Dispose()
+            {
+                _logger.Log(Level.Stop, string.Format(CultureInfo.InvariantCulture, "{0}. Duration: [{1}].", _content, _stopWatch.Elapsed));
+                _stopWatch.Stop();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/NetUtilities.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/NetUtilities.cs b/lang/cs/Source/Utilities/NetUtilities.cs
new file mode 100644
index 0000000..5a56645
--- /dev/null
+++ b/lang/cs/Source/Utilities/NetUtilities.cs
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Diagnostics;
+using Org.Apache.Reef.Utilities.Logging;
+using System;
+using System.Net;
+
+namespace Org.Apache.Reef.Utilities
+{
+    public class NetUtilities
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(NetUtilities));
+
+        public static IPEndPoint ParseIpEndpoint(string ipWithPort)
+        {
+            string ip = ipWithPort.TrimStart().TrimEnd();
+            if (char.IsDigit(ip[0]))
+            {
+                ip = @"socket://" + ip;
+            }
+            Uri uri = new Uri(ip);
+            string driverAddress = uri.Host;
+            int driverCommunicationPort = uri.Port;
+            IPAddress ipAddress;
+            IPAddress.TryParse(driverAddress, out ipAddress);
+            if (ipAddress == null)
+            {
+                Exceptions.Throw(new FormatException("invalid format for ip: " + ipWithPort), LOGGER);
+            }
+
+            return new IPEndPoint(ipAddress, driverCommunicationPort);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Optional.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Optional.cs b/lang/cs/Source/Utilities/Optional.cs
new file mode 100644
index 0000000..2d85ff4
--- /dev/null
+++ b/lang/cs/Source/Utilities/Optional.cs
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Utilities
+{
+    [Serializable]
+    public sealed class Optional<T>
+    {
+        private readonly T _value;
+
+        private Optional(T value)
+        {
+            _value = value;
+        }
+
+        private Optional()
+        {
+            _value = default(T);
+        }
+
+        public T Value 
+        {
+            get { return _value; }
+        }
+
+        public static Optional<T> Of(T value)
+        {
+            if (value == null)
+            {
+                Diagnostics.Exceptions.Throw(new ArgumentNullException("value", "Passed a null value. Use OfNullable() instead"), Logger.GetLogger(typeof(Optional<T>))); 
+            }
+            return new Optional<T>(value);
+        }
+
+        public static Optional<T> Empty()
+        {
+            return new Optional<T>();
+        }
+
+        public static Optional<T> OfNullable(T value)
+        {
+            if (value == null)
+            {
+                return Empty();
+            }
+            else
+            {
+                return Of(value);
+            }
+        }
+
+        public T OrElse(T other)
+        {
+            if (IsPresent())
+            {
+                return Value;
+            }
+            else
+            {
+                return other;
+            }
+        }
+
+        public bool IsPresent()
+        {
+            return (_value != null);
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (this == obj)
+            {
+                return true;
+            }
+            if (obj == null || obj.GetType() != this.GetType())
+            {
+                return false;
+            }
+            Optional<T> optional = (Optional<T>)obj;
+            if (_value != null ? !_value.Equals(optional.Value) : optional.Value != null)
+            {
+                return false;
+            }
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            return _value != null ? _value.GetHashCode() : 0;
+        }
+
+        public override string ToString()
+        {
+            return "Optional{value=" + _value + "}";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Properties/AssemblyInfo.cs b/lang/cs/Source/Utilities/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..50e52c5
--- /dev/null
+++ b/lang/cs/Source/Utilities/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Utilities")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Utilities")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a7bda51a-552a-4fba-a834-f715c19454ab")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Utilities.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/Utilities.csproj b/lang/cs/Source/Utilities/Utilities.csproj
new file mode 100644
index 0000000..f3fd129
--- /dev/null
+++ b/lang/cs/Source/Utilities/Utilities.csproj
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{79E7F89A-1DFB-45E1-8D43-D71A954AEB98}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.Reef.Utilities</RootNamespace>
+    <AssemblyName>Org.Apache.Reef.Utilities</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\bin\Debug\Org.Apache.Reef.Utilities\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\bin\Release\Microsoft.Reef.Utilities\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Hadoop.Avro">
+      <HintPath>..\..\packages\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AvroUtils.cs" />
+    <Compile Include="ByteUtilities.cs" />
+    <Compile Include="Diagnostics\DiagnosticsMessages.cs" />
+    <Compile Include="Diagnostics\Exceptions.cs" />
+    <Compile Include="IIdentifiable.cs" />
+    <Compile Include="IMessage.cs" />
+    <Compile Include="Logging\JavaLoggingSetting.cs" />
+    <Compile Include="Logging\Level.cs" />
+    <Compile Include="Logging\Logger.cs" />
+    <Compile Include="NetUtilities.cs" />
+    <Compile Include="Optional.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ValidationUtilities.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/ValidationUtilities.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/ValidationUtilities.cs b/lang/cs/Source/Utilities/ValidationUtilities.cs
new file mode 100644
index 0000000..a452f1f
--- /dev/null
+++ b/lang/cs/Source/Utilities/ValidationUtilities.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Globalization;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Utilities
+{
+    public class ValidationUtilities
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ValidationUtilities));
+
+        public static string ValidateEnvVariable(string env)
+        {
+            string envVariable = Environment.GetEnvironmentVariable(env);
+            if (string.IsNullOrWhiteSpace(envVariable))
+            {
+                Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} not set. Please set the environment variable first. Exiting...", env));
+                string msg = string.Format(CultureInfo.InvariantCulture, "No {0} found.", env);
+                Diagnostics.Exceptions.Throw(new InvalidOperationException(msg), msg, LOGGER);
+            }
+            return envVariable;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Source/Utilities/packages.config b/lang/cs/Source/Utilities/packages.config
new file mode 100644
index 0000000..c60eef8
--- /dev/null
+++ b/lang/cs/Source/Utilities/packages.config
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<packages>
+  <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" />
+  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/AbstractEStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/AbstractEStage.cs b/lang/cs/Source/WAKE/Wake/AbstractEStage.cs
new file mode 100644
index 0000000..c2b1188
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/AbstractEStage.cs
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake
+{
+    /// <summary>
+    /// An estage that implements metering
+    /// </summary>
+    /// <typeparam name="T">The estage type</typeparam>
+    public abstract class AbstractEStage<T> : IEStage<T>
+    {
+        /// <summary>Constructs an abstract estage</summary>
+        /// <param name="meterName">the meter name</param>
+        protected AbstractEStage(string meterName)
+        {
+        }
+
+        /// <summary>Updates the meter</summary>
+        /// <param name="value">an event</param>
+        public virtual void OnNext(T value)
+        {
+        }
+
+        public abstract void Dispose();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/IEStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/IEStage.cs b/lang/cs/Source/WAKE/Wake/IEStage.cs
new file mode 100644
index 0000000..cc88d26
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/IEStage.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake
+{
+    /// <summary>Stage that executes an event handler</summary>
+    public interface IEStage<T> : IEventHandler<T>, IStage
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/IEventHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/IEventHandler.cs b/lang/cs/Source/WAKE/Wake/IEventHandler.cs
new file mode 100644
index 0000000..db6f0c1
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/IEventHandler.cs
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake
+{
+    /// <summary>
+    /// Handler to process an event
+    /// </summary>
+    /// <typeparam name="T">The type of event</typeparam>
+    public interface IEventHandler<T>
+    {
+        /// <summary>
+        /// Process an event
+        /// </summary>
+        /// <param name="value">The event to process</param>
+        void OnNext(T value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/IIdentifier.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/IIdentifier.cs b/lang/cs/Source/WAKE/Wake/IIdentifier.cs
new file mode 100644
index 0000000..38e63aa
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/IIdentifier.cs
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake
+{
+    /// <summary>
+    /// Identifier class for REEF.
+    ///
+    /// Identifiers are a generic naming primitive that carry some information about
+    /// the type of object that they point to. 
+    ///
+    /// Examples include remote sockets or filenames.
+    /// </summary>
+    public abstract class IIdentifier
+    {
+        /// <summary>
+        /// Returns a hash code for the object
+        /// </summary>
+        /// <returns>The hash code value for this object</returns>
+        public abstract override int GetHashCode();
+
+        /// <summary>
+        /// Checks that another object is equal to this object
+        /// </summary>
+        /// <param name="o">The object to compare</param>
+        /// <returns>True if the object is the same as the object argument; false, otherwise</returns>
+        public abstract override bool Equals(object o);
+
+        /// <summary>
+        /// Returns a string representation of this object
+        /// </summary>
+        /// <returns>A string representation of this object</returns>
+        public abstract override string ToString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/IIdentifierFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/IIdentifierFactory.cs b/lang/cs/Source/WAKE/Wake/IIdentifierFactory.cs
new file mode 100644
index 0000000..a06928a
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/IIdentifierFactory.cs
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Remote.Impl;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake
+{
+    [DefaultImplementation(typeof(StringIdentifierFactory))]
+    public interface IIdentifierFactory
+    {
+        IIdentifier Create(string s);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/IObserverFactory.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/IObserverFactory.cs b/lang/cs/Source/WAKE/Wake/IObserverFactory.cs
new file mode 100644
index 0000000..32242d1
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/IObserverFactory.cs
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Org.Apache.Reef.Wake
+{
+    public interface IObserverFactory
+    {
+        object Create();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/IStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/IStage.cs b/lang/cs/Source/WAKE/Wake/IStage.cs
new file mode 100644
index 0000000..afc72a5
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/IStage.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+
+namespace Org.Apache.Reef.Wake
+{
+    /// <summary>Stage is an execution unit for events and provides a way to reclaim its resources
+    ///     </summary>
+    public interface IStage : IDisposable
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/LoggingEventHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/LoggingEventHandler.cs b/lang/cs/Source/WAKE/Wake/Impl/LoggingEventHandler.cs
new file mode 100644
index 0000000..35549ae
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/LoggingEventHandler.cs
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>A logging event handler</summary>
+    public class LoggingEventHandler<T> : IObserver<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(T));
+
+        [Inject]
+        public LoggingEventHandler()
+        {
+        }
+
+        /// <summary>Logs the event</summary>
+        /// <param name="value">an event</param>
+        public void OnNext(T value)
+        {
+            LOGGER.Log(Level.Verbose, "Event: " + DateTime.Now + value);
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/MissingStartHandlerHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/MissingStartHandlerHandler.cs b/lang/cs/Source/WAKE/Wake/Impl/MissingStartHandlerHandler.cs
new file mode 100644
index 0000000..60e7fa0
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/MissingStartHandlerHandler.cs
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    public class MissingStartHandlerHandler : IObserver<StartTime>
+    {
+        [Inject]
+        public MissingStartHandlerHandler()
+        {
+        }
+
+        public void OnNext(StartTime value)
+        {
+            // Do nothing, since we only use this for evaluator, not for driver.
+            // LOGGER.Log(Level.Info, "No binding to Clock.StartHandler. It is likely that the clock will immediately go idle and close.");
+        }
+
+        public void OnError(Exception error)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void OnCompleted()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/MultiEventHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/MultiEventHandler.cs b/lang/cs/Source/WAKE/Wake/Impl/MultiEventHandler.cs
new file mode 100644
index 0000000..855e459
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/MultiEventHandler.cs
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>Event handler that dispatches an event to a specific handler based on an event class type
+    /// </summary>
+    public class MultiEventHandler<T> : IEventHandler<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(MultiEventHandler<T>));
+        private readonly IDictionary<Type, IEventHandler<T>> _map;
+
+        /// <summary>Constructs a multi-event handler</summary>
+        /// <param name="map">a map of class types to event handlers</param>
+        public MultiEventHandler(IDictionary<Type, IEventHandler<T>> map)
+        {
+            foreach (Type item in map.Keys)
+            {
+                if (!typeof(T).IsAssignableFrom(item))
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new WakeRuntimeException(typeof(T) + " is not assignable from " + item), LOGGER);
+                }
+            }
+            _map = map;
+        }
+
+        /// <summary>
+        /// Invokes a specific handler for the event class type if it exists
+        /// </summary>
+        /// <param name="value">The event to handle</param>
+        public void OnNext(T value)
+        {
+            IEventHandler<T> handler = null;
+            bool success = _map.TryGetValue(value.GetType(), out handler);
+            if (success)
+            {
+                handler.OnNext(value);
+            }
+            else
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new WakeRuntimeException("No event " + value.GetType() + " handler"), LOGGER);
+            }            
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/PeriodicEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/PeriodicEvent.cs b/lang/cs/Source/WAKE/Wake/Impl/PeriodicEvent.cs
new file mode 100644
index 0000000..417f008
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/PeriodicEvent.cs
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>Periodic event for timers</summary>
+    public class PeriodicEvent
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/PubSubEventHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/PubSubEventHandler.cs b/lang/cs/Source/WAKE/Wake/Impl/PubSubEventHandler.cs
new file mode 100644
index 0000000..ba4a5a0
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/PubSubEventHandler.cs
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+ 
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Org.Apache.Reef.Utilities.Logging;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>
+    /// Event handler to provide publish/subscribe interfaces
+    /// </summary>
+    /// <typeparam name="T">The type of event handler</typeparam>
+    public class PubSubEventHandler<T> : IEventHandler<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(PubSubEventHandler<T>));
+
+        private Dictionary<Type, List<object>> _classToHandlersMap;
+
+        /// <summary>
+        /// Construct a pub-sub event handler
+        /// </summary>
+        public PubSubEventHandler()
+        {
+            _classToHandlersMap = new Dictionary<Type, List<object>>();
+        }
+
+        /// <summary>
+        /// Subscribe an event handler for an event type
+        /// </summary>
+        /// <typeparam name="U">The type of event handler</typeparam>
+        /// <param name="handler">The event handler</param>
+        public void Subscribe<U>(IEventHandler<U> handler) where U : T
+        {
+            lock (_classToHandlersMap)
+            {
+                List<object> handlers;
+                if (!_classToHandlersMap.TryGetValue(typeof(U), out handlers))
+                {
+                    handlers = new List<object>();
+                    _classToHandlersMap[typeof(U)] = handlers;
+                }
+                handlers.Add(handler);
+            }
+        }
+
+        /// <summary>
+        /// Invoke the subscribed handlers for the event class type
+        /// </summary>
+        /// <param name="value">The event to process</param>
+        public void OnNext(T value)
+        {
+            if (value == null)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("value"), LOGGER);
+            }
+
+            lock (_classToHandlersMap)
+            {
+                // Check that the event type has been subscribed
+                List<object> handlers;
+                if (!_classToHandlersMap.TryGetValue(value.GetType(), out handlers))
+                {
+                    Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("No event for type " + value.GetType()), LOGGER);
+                }
+
+                // Invoke each handler for the event type
+                foreach (object handler in handlers)
+                {
+                    Type handlerType = typeof(IEventHandler<>).MakeGenericType(new[] { value.GetType() });
+                    MethodInfo info = handlerType.GetMethod("OnNext");
+                    info.Invoke(handler, new[] { (object)value });
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/SingleThreadStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/SingleThreadStage.cs b/lang/cs/Source/WAKE/Wake/Impl/SingleThreadStage.cs
new file mode 100644
index 0000000..163d347
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/SingleThreadStage.cs
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System;
+using System.Collections.Concurrent;
+using System.Threading;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>Single thread stage that runs the event handler</summary>
+    public class SingleThreadStage<T> : AbstractEStage<T>
+    {
+        private readonly BlockingCollection<T> queue;
+
+        private readonly Thread thread;
+
+        private bool interrupted;
+
+        public SingleThreadStage(IEventHandler<T> handler, int capacity) : base(handler.GetType().FullName)
+        {
+            queue = new BlockingCollection<T>(capacity);
+            interrupted = false;
+            thread = new Thread(new ThreadStart(new Producer<T>(queue, handler, interrupted).Run));
+            thread.Start();
+        }
+
+        /// <summary>
+        /// Puts the value to the queue, which will be processed by the handler later
+        /// if the queue is full, IllegalStateException is thrown
+        /// </summary>
+        /// <param name="value">the value</param>
+        public override void OnNext(T value)
+        {
+            base.OnNext(value);
+            queue.Add(value);
+        }
+
+        /// <summary>
+        /// Closes the stage
+        /// </summary>
+        public override void Dispose()
+        {
+            interrupted = true;
+            thread.Interrupt();
+        }
+    }
+
+    /// <summary>Takes events from the queue and provides them to the handler</summary>
+    /// <typeparam name="T">The type</typeparam>
+    internal class Producer<T> 
+    {
+        private readonly BlockingCollection<T> _queue;
+
+        private readonly IEventHandler<T> _handler;
+
+        private volatile bool _interrupted;
+
+        internal Producer(BlockingCollection<T> queue, IEventHandler<T> handler, bool interrupted)
+        {
+            _queue = queue;
+            _handler = handler;
+            _interrupted = interrupted;
+        }
+
+        public void Run()
+        {
+            while (true)
+            {
+                try
+                {
+                    T value = _queue.Take();
+                    _handler.OnNext(value);
+                }
+                catch (Exception)
+                {
+                    if (_interrupted)
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/SyncStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/SyncStage.cs b/lang/cs/Source/WAKE/Wake/Impl/SyncStage.cs
new file mode 100644
index 0000000..bfa3fe0
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/SyncStage.cs
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+ 
+using Org.Apache.Reef.Wake;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>Stage that synchronously executes an event handler</summary>
+    public class SyncStage<T> : AbstractEStage<T>
+    {
+        private readonly IEventHandler<T> _handler;
+
+        /// <summary>Constructs a synchronous stage</summary>
+        /// <param name="handler">an event handler</param>
+        public SyncStage(IEventHandler<T> handler) : base(handler.GetType().FullName)
+        {
+            _handler = handler;
+        }
+
+        /// <summary>Invokes the handler for the event</summary>
+        /// <param name="value">an event</param>
+        public override void OnNext(T value)
+        {
+            base.OnNext(value);
+            _handler.OnNext(value);
+        }
+
+        public override void Dispose()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/ThreadPoolStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/ThreadPoolStage.cs b/lang/cs/Source/WAKE/Wake/Impl/ThreadPoolStage.cs
new file mode 100644
index 0000000..6054f86
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/ThreadPoolStage.cs
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Threading;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Wake;
+using Org.Apache.Reef.Wake.Util;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>Stage that executes an event handler with a thread pool</summary>
+    public class ThreadPoolStage<T> : AbstractEStage<T>
+    {
+        private static readonly Logger LOGGER = Logger.GetLogger(typeof(ThreadPoolStage<T>));
+
+        private readonly IEventHandler<T> _handler;
+
+        private readonly ITaskService _taskService;
+
+        private readonly int _numThreads;
+
+        /// <summary>Constructs a thread-pool stage</summary>
+        /// <param name="handler">An event handler to execute</param>
+        /// <param name="numThreads">The number of threads to use</param>
+        public ThreadPoolStage(IEventHandler<T> handler, int numThreads) 
+            : base(handler.GetType().FullName)
+        {
+            _handler = handler;
+            if (numThreads <= 0)
+            {
+                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new WakeRuntimeException("numThreads " + numThreads + " is less than or equal to 0"), LOGGER);
+            }
+            _numThreads = numThreads;
+            _taskService = new FixedThreadPoolTaskService(numThreads);
+        }
+
+        /// <summary>Constructs a thread-pool stage</summary>
+        /// <param name="handler">an event handler to execute</param>
+        /// <param name="taskService">an external executor service provided</param>
+        public ThreadPoolStage(IEventHandler<T> handler, ITaskService taskService) : base(
+            handler.GetType().FullName)
+        {
+            _handler = handler;
+            _numThreads = 0;
+            _taskService = taskService;
+        }
+
+        /// <summary>Handles the event using a thread in the thread pool</summary>
+        /// <param name="value">an event</param>
+        public override void OnNext(T value)
+        {
+            base.OnNext(value);
+            _taskService.Execute(new _Startable_74(this, value).Start);
+        }
+
+        /// <summary>
+        /// Closes resources
+        /// </summary>
+        public override void Dispose()
+        {
+            if (_numThreads > 0)
+            {
+                _taskService.Shutdown();
+            }
+        }
+
+        private sealed class _Startable_74 : IStartable
+        {
+            private readonly ThreadPoolStage<T> _enclosing;
+            private readonly T _value;
+
+            public _Startable_74(ThreadPoolStage<T> enclosing, T value)
+            {
+                _enclosing = enclosing;
+                _value = value;
+            }
+
+            public void Start()
+            {
+                _enclosing._handler.OnNext(_value);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Impl/TimerStage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Impl/TimerStage.cs b/lang/cs/Source/WAKE/Wake/Impl/TimerStage.cs
new file mode 100644
index 0000000..3b1e612
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Impl/TimerStage.cs
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Timers;
+
+using Org.Apache.Reef.Wake;
+
+namespace Org.Apache.Reef.Wake.Impl
+{
+    /// <summary>Stage that triggers an event handler periodically</summary>
+    public class TimerStage : IStage
+    {
+        //private readonly ScheduledExecutorService executor;
+        private readonly Timer _timer;
+        private readonly PeriodicEvent _value = new PeriodicEvent();
+        private readonly IEventHandler<PeriodicEvent> _handler;
+
+        /// <summary>Constructs a timer stage with no initial delay</summary>
+        /// <param name="handler">an event handler</param>
+        /// <param name="period">a period in milli-seconds</param>
+        public TimerStage(IEventHandler<PeriodicEvent> handler, long period) : this(handler, 0, period)
+        {
+        }
+
+        /// <summary>Constructs a timer stage</summary>
+        /// <param name="handler">an event handler</param>
+        /// <param name="initialDelay">an initial delay</param>
+        /// <param name="period">a period in milli-seconds</param>
+        public TimerStage(IEventHandler<PeriodicEvent> handler, long initialDelay, long period)
+        {
+            _handler = handler;
+            _timer = new Timer(period);
+            _timer.Elapsed += (sender, e) => OnTimedEvent(sender, e, _handler, _value);
+            _timer.Enabled = true;
+        }
+
+        /// <summary>
+        /// Closes resources
+        /// </summary>
+        public void Dispose()
+        {
+            _timer.Stop();
+        }
+
+        private static void OnTimedEvent(object source, ElapsedEventArgs e, IEventHandler<PeriodicEvent> handler, PeriodicEvent value)
+        {
+            handler.OnNext(value);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Properties/AssemblyInfo.cs b/lang/cs/Source/WAKE/Wake/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..c0d8070
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Wake")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Wake")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("86a66ac8-0c8e-4652-b533-670e800cb0ea")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/WAKE/Wake/Protobuf/RemoteProtocol.proto
----------------------------------------------------------------------
diff --git a/lang/cs/Source/WAKE/Wake/Protobuf/RemoteProtocol.proto b/lang/cs/Source/WAKE/Wake/Protobuf/RemoteProtocol.proto
new file mode 100644
index 0000000..cd28d13
--- /dev/null
+++ b/lang/cs/Source/WAKE/Wake/Protobuf/RemoteProtocol.proto
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+option java_package = "org.apache.reef.wake.remote.proto";
+option java_outer_classname = "WakeRemoteProtos";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+message WakeMessagePBuf {
+  required bytes data = 1;
+  required int64 seq = 2; 
+  optional string source = 3; 
+  optional string sink = 4; 
+}
+
+message WakeTuplePBuf {
+  required string className = 1;
+  required bytes data = 2; 
+}
+