concept Microsoft in category .net

appears as: Microsoft, Microsoft
.NET Core in Action

This is an excerpt from Manning's book .NET Core in Action.

Historically, Microsoft has been very tight-lipped about new products and features under development. There are good reasons for this. First, the competition has less time to respond if they find out about a feature on the day it ships. Also, if a feature was targeted for a particular release date and wasn’t done on time, it could be postponed without causing an issue, because customers didn’t know about it. Plus, it always helps to have new stuff to announce at conferences.

But modern software developers aren’t content to ask for a feature and hope it’s delivered in the next release, which could be a year away. This is especially true when there may be an open source project that could fulfill their needs. As large companies warm to open source software, even the most faithful Microsoft developers turn to other frameworks and libraries to get their own projects done on time and within budget. Microsoft needed to make a change.

There are many logging frameworks for .NET Core. To keep things simple, you’ll use another Microsoft.Extensions library called Microsoft.Extensions.Logging. Start by restructuring the classes. Figure 10.1 shows a class diagram for the restructured code using the Microsoft.Extensions.Logging library.

10.2.1. Using the Microsoft .Extensions.Logging library

To use the Microsoft.Extensions.Logging library, you’ll need to add a reference to the project file, as follows.

Listing 10.11. Add a reference to Microsoft logging extensions
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Logging"
                      Version="2.0.0" />
  </ItemGroup>
</Project>

The AddRobust() extension method in listing 10.10 adds what’s called a logging provider to the factory. If you wanted to write logs to the console, you’d use the console logging provider through the AddConsole() extension method defined in Microsoft.Extensions.Logging.Console, which is part of a separate package. But as mentioned before, your air conditioner controller doesn’t have a console. You need a way to send logs back to the manufacturer that’s robust enough to handle connectivity issues, power failures, and so on. You need to create your own logger implementation.

Dependency Injection in .NET

This is an excerpt from Manning's book Dependency Injection in .NET.

Even though the .NET platform is a product of Microsoft, other organizations (often single individuals) are much more prominent when it comes to DI in .NET. In short, this can be attributed to the fact that Microsoft doesn’t offer any DI CONTAINER in the Base Class Library (BCL). Even as a separate offering, Microsoft’s only DI CONTAINER is the relatively recent Unity.

I think it’s fair to say that for the first many years of the .NET Framework’s life, Microsoft blissfully ignored the very concept of DI. It’s not easy to explain exactly why, and I doubt that it was ever an explicit strategy.

According to one completely unscientific internet poll,[1] Unity is the most widely used DI CONTAINER. This is surprising given its relatively late entry on the scene, but is likely to be related to the fact that Microsoft is behind it. The existing contenders, like Castle Windsor or StructureMap, haven’t noticed any drop in interest, so it seems likely that Unity has introduced the concept of DI CONTAINERS to a completely new segment of users who weren’t aware of it before.

Entity Framework 4 in Action

This is an excerpt from Manning's book Entity Framework 4 in Action.

  • It’s included in the .NET Framework. Microsoft fully supports Entity Framework and guarantees bug fixes, documentation, and improvements at a pace its competitors can’t keep up with. Often, customers choose Entity Framework instead of NHibernate because Entity Framework’s presence in the .NET Framework reassures them about the overall quality of the project. What’s more, because the .NET Framework is free, Entity Framework is free as well.
  • There are a number of unit-testing tools out there, with NUnit and MSTest being the most widely used today. NUnit is an open-source port of the well-established Java JUnit test framework, and MSTest is provided by Microsoft and is completely integrated into the Visual Studio IDE. It’s included in every edition of Microsoft Visual Studio 2010, and it’s the one you’ll use for the rest of this chapter.

    Because testing the raising of expected exceptions is as important as testing the correctness of a method’s results, every test framework provides built-in support for doing this. In Microsoft’s Unit Testing Framework, for example, you can decorate the test code with the attribute ExpectedException, as shown in this listing.

    LINQ in Action

    This is an excerpt from Manning's book LINQ in Action.

    LINQ is the result of a long-term research process inside Microsoft. Several projects involving evolutions of programming languages and data-access methods can be considered to be the parents of LINQ to Objects, LINQ to XML (formerly known as XLinq), and LINQ to SQL (formerly known as DLinq).

    ObjectDumper is a utility class we already used in several places, like in chapters 2 and 4. It’s provided by Microsoft as part of the LINQ code samples. You’ll be able to find it in the downloadable source code that comes with this book.

    Listing 11.4. The SampleData class introduced in chapter 4
    using System; using System.Collections.Generic; using System.Text; namespace LinqInAction.LinqBooks.Common { static public class SampleData { static public User[] Users ={ new User { Name="Steve Eichert"}, new User { Name="Fabrice Marguerie"}, new User { Name="Jim Wooley"} }; static public Publisher[] Publishers = { new Publisher {Name="FunBooks"}, new Publisher {Name="Joe Publishing"}, new Publisher {Name="I Publisher"} }; static public Author[] Authors = { new Author {FirstName="Johnny", LastName="Good"}, new Author {FirstName="Graziella", LastName="Simplegame"}, new Author {FirstName="Octavio", LastName="Prince"}, new Author {FirstName="Jeremy", LastName="Legrand"} }; static public Book[] Books = { new Book { Title="Funny Stories", Publisher=Publishers[0], Authors=new[]{Authors[0], Authors[1]}, Price=25.55M, Isbn="0-000-77777-2", Reviews=new Review[] { new Review { User=Users[0], Rating=5, Comments="It was very funny indeed!" }, new Review { User=Users[1], Rating=4, Comments="It was Fabulous."} } }, new Book { Title="LINQ rules", Publisher=Publishers[1], Authors=new[]{Authors[2]}, Price=12M, Isbn="0-111-77777-2" }, new Book { Title="C# on Rails", Publisher=Publishers[1], Authors=new[]{Authors[2]}, Price=35.5M, Isbn="0-222-77777-2", Reviews=new Review[] { new Review { User=Users[0], Rating=5, Comments="Say goodnight to the Rails Party, Microsoft is here!"}, new Review { User=Users[1], Rating=5, Comments="Don Box said he likes Ruby, little did we know he'd turn C# into Ruby.NET!"} } }, new Book { Title="All your base are belong to us", Publisher=Publishers[1], Authors=new[]{Authors[3]}, Price=35.5M, Isbn="0-333-77777-2" }, new Book { Title="Bonjour mon Amour", Publisher=Publishers[0], Authors=new[]{Authors[1], Authors[0]}, Price=29M, Isbn="2-444-77777-2" } }; } }