RSS

Are we professionals – quotes from the legendary uncle bob

Are we PROFESSIONAL software engineers?

I mean are we really that professional as we claim to be !!?

First we should know what does it mean to be a professional software engineer:

  • We must take our job very seriously.
  • We must know we are hired for our knowledge and we must act with that in mind
  • We must go home every day proud of what we accomplished.
  • We must know what we need to do and when to do it and how to do it.
  • We must know for sure that our craft is so serious and critical and it’s time to act like it
  • We will not ship shit even when our managers are yelling and screaming because it’s our responsibility and we will be blamed for any issues after we do.
  • We must make no compromises in our craft.
  • We should be always ready to release a new version in a few hours.
  • Our teams should have stable productivity. this means we write clean software that stays this way for all time.
  • We must keep learning, enhancing, improving aggressively.
  • We must make our software maintainable and open for changes in little time.
  • We must keep the code cleaner every time we touch it.
  • We must be fearless of change.
  • We should expect QA will find nothing. in fact we should even question the existence of QA.
  • We should take responsibility of our mistakes and not pointing fingers at others for blame.
  • We should cover for each other and there will be no crises if one of our team is absent.
  • We must make honest estimates. The estimate is a range not fixed date (realistic).
  • We must get used to say no for bad decision and feel good about it. because it’s our responsibility.
  • We must automate repetitive tasks.
  •  We must teach others what we learned.

So are we really that professional???

 
Leave a comment

Posted by on May 1, 2017 in C#

 

ASP.NET Core 1.0

The new open-source and cross-platform framework for building modern web applications. It was built to provide an optimized framework for building applications that can be composed of modular components with minimal overhead on the server. You can use only the packages you need for your web application. This model helps you build more secure applications and improve performance.

ASP.NET Core is no longer based on the fat beast System.Web.dll, It’s now focused on open source packages published on NuGet. ASP.NET Core apps can run on .NET Core or on the full .NET Framework.

.NET Core

It is a new cross-platform .NET product. The primary architectural concerns unique to .NET Core are related to providing platform-specific implementations for supported platforms. The primary points of .NET Core are:

  • Cross-platform: Runs on Windows, macOS and Linux.
  • Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.
  • Command-line tools: All product scenarios can be exercised at the command-line.
  • Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.
  • Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project.
  • Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support

The new features of ASP.Net core:

  • Asp.Net web forms is no longer supported. It was the wrong way to do web development because it was trying so hard to treat web as desktop applications and hiding the stateless nature of the web by using viewstate and html spitting controls now the situation is so much better. Now Microsoft has done many improvements by adopting the latest web standards and ideas.
  • In ASP.NET Core web applications are built on OWIN. you compose your request pipeline using Middleware.
  • ASP.NET Core is completely decoupled from the web server environment that hosts the application. It supports hosting in IIS and IIS Express, and self-hosting using the Kestrel.
  • The content root is the base path to any content used by the app, such as its views and web content.
  • Web root is the directory in your project for public, static resources like css, js, and image files. The static files middleware will only serve files from the web root directory.
  • ASP.NET Core uses a new configuration model for handling simple name-value pairs.  Which is based on configuration providers with built-in providers for (XML, JSON, INI).
  • Tag Helpers are used instead of Html Helpers. They enable server-side code to participate in creating and rendering HTML elements with html attributes like syntax
  • MVC controllers and Web API controllers are now based on the same classes and inherit from the same class Microsoft.AspNet.Mvc.Controller.
  • Depedency injection, ASP.NET Core includes a simple built-in container (represented by the IServiceProvider interface) that supports constructor injection by default. You configure the built-in container’s services in the ConfigureServices method in your application’s Startup class.
  • Save and run feature is awesome, you don’t have to build every time you change code.
  • Bower, NPM and Gulp are fully supported by visual studio. NuGet now recommend you to download client side libraries from Bower package manager.

 

 

 
Leave a comment

Posted by on August 29, 2016 in C#

 

Summarizing the scrum guide

SCRUM definition:
Its a framework (can employ various processes and techniques) to address complex and adaptive problems.

  • The goal is to deliver the highest possible value.
  • It’s a framework not a process or a technique.
  • SCRUM asserts that knowledge comes from experience and making decisions based on what is known (empiricism).
  • SCRUM team consists of product owner, development team, SCRUM master.
  • The team is designed this way to optimize flexpility, creativity, productivity.
  • SCRUM team delivers iteratively to maxmize opportunities for feedback.
  • Incremental deliveries of done product ensures a potential version of working product is always available.

SCRUM Pillars:

Transparency: Significant aspect of the process is visible to those responsible for the outcome. Common language referring to the process must be shared. The definition of done should be visible and clear.

Inspection: Users must inspect artifacts and progress toward sprint goal to detect variances.

Adaption: Adjustment must be made as soon as possible to minimize further deviation.

SCRUM Roles

The product owner:

  • Responsible for maximizing the value of the product and the work of the development team.
  • Responsible for managing the product backlog items to make sure they are clearly expressed and ordered to best achieve the goals.
  • Ensures that product backlog is visible, transparent and clear to all
  • Ensures that the team understands the items and knows what is next.
  • The product owner can delegate backlog management tasks to team members but he remains accountable.
  • The product owner is one person not a committee.
  • No one else is allowed to take decisions on the product backlog without the product owner approval.

The development team:

  • Is a team of 3-9 cross-functional professionals to maximize efficiency and effectiveness.
  • they are self organizing and not managed by anyone not even the SCRUM master.
  • SCRUM doesn’t recognize any titles nor sub-teams in the development team.

SCRUM Master:

  • Is a servant leader for the development team.
  • Helps everyone to understand which of their interactions with the development team are helpful.
  • Helps the product owner managing the backlog.
  • Facilitates agility, planing and events.
  • Coaching the development team the SCRUM practices.
  • Remove impediments

SCRUM events:

  • All events are time boxed.
  • Each event is a formal opportunity for inspection and adaption
  • Once a sprint begins, its duration can’t be changed.

The sprint:

  • Time-boxed with one month or less.
  • During a sprint a done and potentially releasable increment is created.
  • A new sprint starts immediately after the previous one ends.
  • The sprint must have a clear goal.
  • No change is allowed that would endanger that goal.
  • Quality goals don’t decrease.
  • Scope may be clarified and renegotiated
  • Ensuring inspection and adaption of progress toward the sprint goal.
  • Sprint limits risk to one month or less.
  • Sprint may be canceled by only the product owner if the goal is obsolete.
  • If the sprint is canceled the done work is reviewed and the remaining work is re-estimated

Sprint planing:

  • Time-boxed to maximum 8 hours for one month sprint.
  • The SCRUM team discusses what can be done this sprint?
  • The SCRUM team works to forcast the work that will be developed through the sprint
  • Identify the backlog items that will achieve the sprint goal
  • The number of items selected is up to the development team according to the previous capacity
  • How will the chosen work get done?
  • The develpment team designs the system for the current sprint
  • The development team decompose tasks as units of one day or less during the planning meeting or as needed during the sprint
  • If there is too much or too little the development team can renegotiate with the product owner.
  • The product owner can help the development team with decisions and trade-offs

Daily scrum:

  • A 15 min time-boxed event to synchronize activities and create plan for the next day
  • Only development team participate in this meeting
  • This is done through inspecting the work done the day before and forcasting the work to be done throughout the day
  • SCRUM is held at the same time and place each day to avoid complexities
  • Each team member answers three questions (what did I do yesterday, what will I do today, Do I see any impediment?)
  • Team members can meet after the daily scrum for detailed discussions, adapt or re-plan
  • The development team is responsible for conducting this meeting

Sprint Review:

  • A four hours time-boxed for one month sprint meeting at the end of the sprint to inspect the increment and adopt the product backlog if needed
  • The product owner explains the done items and what is not done
  • The development team discusses what went well and what problems they ran into and how they were solved
  • The development team explains the work done and answers questions about the increment
  • The product owner discusses the likely completion date based on the progress so far
  • The attendees collaborate on what to do next
  • Review the marketplace and the potential use of the product
  • The result of the review meeting is the revised product backlog
  • It’s not a status meeting

Sprint retrospective:

  • Three hours time-boxed for one month sprint
  • Scrum team inspect itself and create a plan for improvement
  • Held after the sprint review and before the next planing meeting
  • The team inspects how the last sprint went with regards to people, relationships, process, and tools
  • What went well and improvements
  • Plan for implementing improvements
  • Ways to increase quality by adopting the definition of done

SCRUM artifacts:

Product backlog

  • Is the single source of requirements
  • Identifies what the product needs to be appropriate, competitive, and useful
  • Lists all features, functions, requirements, enhancements and fixes
  • Attributes are description, order, estimate, and value
  • It’s refined to add details, estimates and order in an ongoing process by the product owner with the development team help.
  • Higher ordered items are usually clearer and more detailed.
  • Items for the upcoming sprint should be refined so that it could be developed in the time-box of the sprint.
  • Development team is responsible for the estimates
  • At least every sprint review the product owner can sum up all the remaining work to reach a goal

Sprint backlog

  • Backlog items forcasted by the development team to be done during the sprint time-box
  • It’s a highly visible and real time picture of work that the development team accomplish during the sprint
  • Plan for delivering the product increment to achieve the sprint goal
  • Can be changed during the sprint as the team understands more about the work needed to achieve the goal
  • The estimated and the remaining work is updated according to the work done

Increment

  • Is the sum of all the sprint backlog items completed during the sprint and the value of the previous increments
  • It must satisfy the difinition of done and in a usable state
 
Leave a comment

Posted by on February 5, 2016 in Agile, Scrum, SDLC, Teamwork

 

Introduction to Katana and OWIN

Imagine you’re building a framework for web developers like ASP.Net. How are you going to interact with the web server “the process hosting your framework”.

ASP.NET is built on top of IIS. Both provide a lot of features like session state, caching, Membership, Modules, Handlers, and so on. But not all applications need all these features.

In the last few years there was a shift in the architecture of web applications with the rise of HTML5 and its new features. We see more processing happens on the client side rather than relying only on the server to generate the html. The server is only required to respond to AJAX requests and returns the required data for the client to process. This also is great for mobile apps which are insanely popular these days.

What we need these days is a fast, light weight and extensible host for web applications and services. Particularly with clouding services where you pay for every byte of bandwidth and CPU cycle. For example NodeJS which is not a web server by itself but you can add packages for exactly the features you need to make a web server. this means the server is efficient, fast and easier to scale. and this is one of the goals of Katana, which is to build a light weight and blugable software that can be used to host web applications and API

Katana

Katana is a flexible set of components for building and hosting OWIN-based web applications.This is how they defined katana in it’s codeplex site. and to clarify what that means let me say that Katana is Microsoft’s implementation of a standard named OWIN.

OWIN (The Open Web Interface for .Net)

OWIN is a standard that defines the simplest interface between .NET web servers and web applications. This means if your application is OWIN compatible then you can run your application on broader number of platforms more easily. Simplicity and decoupling from other frameworks are the key Goals for OWIN that ensured that new components could be more easily developed and consumed and also applications could be more easily ported between hosts and potentially entire platforms/operating systems.

Historical Overview

ASP.Net was created to target classic ASP developers and Desktop developers. It gave the classic ASP developers the chance to separate the HTML from the logic and made use of the power of object oriented languages in .net and enabled the desktop developers to build web applications with the same developing experience they are used to (Web Forms). All ASP.Net features was put into the System.Web.dll assembly which is part of the .net framework. This made it difficult for ASP.NET to keep pace with all of the changes happening in rapidly evolving Web development. Finally, System.Web.dll itself was coupled in a few different ways to a specific Web hosting option: Internet Information Services (IIS). ASP.Net MVC and Web API was created by microsoft as a response to the hot and well-known design pattern model-view-controller (MVC) design pattern after the rise of Web development frameworks like Ruby on Rails. But the smart move was

  • Separate the ASP.Net MVC and Web API from the core ASP.Net and to release them as an independent download. This gave the engineering team the flexibility to deliver updates much more frequently than had been previously possible to cope with the fast pace of the web.
  • Remove external dependencies to System.Web.dll, and therefore, no dependencies to IIS, ASP.NET Web API included the capability to run in a custom host

By decoupling framework components from one another and then releasing them on NuGet, frameworks could now iterate more independently and more quickly.Additionally, the power and flexibility of Web API’s self-hosting capability proved very attractive to developers who wanted a small, lightweight host for their services.

 
 

Tags: , , , , , , , ,

Paint Your Future with Apps in Style – Apps Contest

Developer? Who said so..? You are the App’s Artist, start to re-imagine your iOS/Android applications and build it on Windows 8 Platform.

Windows 8 is a completely reimagined Windows. You can code once and have a great app experience that scales across devices from tablets to all-in-one PCs, from 10″ to 27″ screen sizes. The new Windows Store provides flexibility for selling your app and higher profit potential than any other App Store – with an 80% revenue share when you reach $25,000 USD or more in total sales. Windows Runtime gives you the flexibility to build native apps using C#, C++ and JavaScript. Or you can build apps using web technologies like HTML5, Level 3 (CSS3).

Now you can easily migrate any application to be on Windows Store:

Migrate iOS apps http://msdn.microsoft.com/en-us/library/windows/apps/jj657966.aspx

Migrate Android apps http://msdn.microsoft.com/en-us/library/windows/apps/jj945420.aspx

Migrate Web apps http://msdn.microsoft.com/en-us/library/windows/apps/hh465143.aspx

Migrate Windows Phone apps http://msdn.microsoft.com/en-us/library/windows/apps/hh452743.aspx

Innovate… Build… And Exhibit your apps in the biggest Apps Exhibition promoting Egyptian developers from all over Egypt to the most well-known investment firms.

On the Exhibition day 5th of June 2013, we will announce the Winning app that will be promoted in the Spotlight section (Featured) in the Egyptian Windows Store.

via Paint Your Future with Apps in Style – Code vNext.

 
Leave a comment

Posted by on April 21, 2013 in Windows 8

 

Tags:

Windows 8 App Lifecycle

Overview

One of the foundations required for developing windows 8 apps is understanding page lifecycle. The lifecycle enables you to properly take design decisions about how your application will behave when users first launch the app, and when they navigate back and forth between other applications and yours. Also, You need to account for what happens when the system needs to shut down the app in the background.

We used to the fact that the applications are started or activated by a user explicitly opening them, but there are other ways in Windows 8. The operating system makes the distinction between two different types of programmatic interaction with your app, which are extensions and contracts.

Extensions

Extensions are a way of extending Windows and allowing your application to tap into an array of extensibility points, of VOS. For instance, the protocol activation extension allows your application to register for a certain protocol scheme and launch when that scheme is run in the system.

Contracts

Contracts are extensibility points between your application and other apps or the operating system. The contract behaves much like an interface in object oriented environments. The contract is an agreement by the source and the target to do things like share data, facilitate searching and the like.

Lifecycle

app lifecycle

The first state in the lifecycle is the Not Running state. After the first install or removal from memory, that app is in the Not Running state. And the application goes from not running to running when you see the splash screen. In this stage of the lifecycle you need only to prepare the UI and avoid expensive startup procedures or contacting any time consuming resources. It’s very important that the app should activate and launch very quickly. If you do need to work with data or resources that will take time, I recommend using loading indicators other than the default splash screen. For instance, you can initialize the default screen and load your data asynchronously with loading indicator on each section.

There are 12 different ways to activate a Windows 8 app represented by the enumeration activation.ActivationKind

  • Launch activation: An app is launched when the user explicitly starts the application, usually by taping on its tile.
  • Search contract: Implementing the search contract in your application allows the user to conduct a search using the search Charm. Then your app is activated and receive search parameters. Then you have to search and display results within your app.
  • Share Target contract: When the share Charm is used your app can appear in the list of available share targets. It will be activated when the user selects it.
  • file Association contract: When the user double-click on a file where the extension is registered to your application, your app has the opportunity to activate via the file activatio.
  • Protocol contract: The protocol activation refers to a situation where a URL is navigated to, in which your application is registered to handle. And this works in the same way as when you click on a link that’s prefixed with the Mail 2 Protocol and it launches your mail client. So you can register a protocol and when that’s initiated, your application can tap into that pipeline.
  • File Open Picker: The File Open Picker Activation contacts your app if the user tries to pick a file that’s associated to your application.
  • File Save Picker: File Save Picker Activation allows a user to save a file into your application. This would then activate your app and allow you handle the save operation from within your application.
  • Cache File Updater contract: activates when the app provides content management capabilities for files in a cache location. The idea here is that a file is available in the cache location and your application is activated and given a chance to manipulate it and save the result. You do have the option to process user input first or just process the file itself.
  • Contact Picker contract: As users pick contacts in the system, your app has the opportunity to plug into that process when you implement the Contact Picker extension.
  • Device AutoPlay contract: allows your app to handle an auto-play scenario. as devices are connected to the machine, your application has the opportunity to tap into that action.
  • Print Task Settings contract: allows your app to plug into the Print pipeline.
  • Camera Settings contract: which grants your app the ability to capture both video and still pictures from the camera.

Windows 8 app goes into suspension When the user switchs to another app or if the OS goes into power save mode then execution is halted. But the app’s not completely removed from memory. The operating system gives your app a slight delay of a few seconds before suspension begins. The idea here is that, if the user’s quickly switching around and then returns to your app, then it won’t go through the whole suspension and resuming process for a very quick switchback to the application. If, though, the OS recognizes that the user isn’t likely coming immediately back to the application, then the suspension state is invoked.

Once an app is being suspended, your app has a very short period of time to do any clean-up and prepare for the suspension state. You have five seconds only so you make sure the application isn’t stuck through a bunch of processing or data, right before suspension. It’s best to implement the spirit of a Windows Store application, in that you want to do the work of persisting data and doing clean-up as a continual process, as the user is interacting with your application, rather than saving that action right before suspension.

If the app indeed makes it into suspension state and remains in memory while the user switches back to the application, then the app is resumed and taken back into the running state. While the app very well may be resumed, there are no guarantees. Windows 8 tries to keep as many apps in the suspended state as possible, your app may be terminated and there’s no event handler for this. Once your app is suspended, you want to be prepared to have it terminated. Also, you need to prepare your app to resume from suspention or even from termination by the OS as if the user just left it. In order to create the illusion for the user that the application was never closed or terminated in the first place.

Windows 8 app can run in the background, like if you want to play music while users are doing other things on the machine.

 
Leave a comment

Posted by on April 21, 2013 in Windows 8

 

Tags: , ,

Windows 8 glossary

WinRT: It’s just another layer over Win32 written in native code and COM-based API. It exposes Win32 to any programming language through what are called language projections. WinRT supports native C++, JavaScript and HTML, C#, Visual Basic.

Windows RT: is a version of Microsoft Windows operating system designed to run on mobile devices (such as Tablet computers) that are built upon ARM architecture. Unlike Windows 8, Windows RT is only distributed as a pre-loaded operating system on devices produced by OEMs.

App Bar: A toolbar user interface element that is typically hidden until needed and houses commands, which are generally user interface elements like buttons and other graphical controls.

Charms: A set of five icons, available from the so-called Edge UI, which appears when you swipe into the interior of the screen from the right side of the screen. These icons include Search, Share, Start, Devices, and Settings.

Contracts: A new aspect of the WinRT (Windows Run Time) development model that provides communications capabilities between separately and independently developed apps. Similar but more powerful to the Windows clipboard from two decades ago, Contracts provide a number of useful services including Search and Share.

Flip: The process by which you visually flip through the available running apps and Windows desktop by flicking right from the leftmost edge of the screen. Flicking and holding will result in a Snap, and the division of the screen into two zones, Snap View and Fill View. (See Snap.)

Glyphs: The icons that appear on the new Windows 8 lock screen, including network, power, and so on.

Groups: Sections of tiles on the Start screen that are visually grouped and can optionally be named. You can move entire groups of tiles around the Start screen as needed.

Lock screen: The Windows 8 welcome screen, which appears when the computer first boots. It features the time, date, and a series of notification glyphs.

Flyouts: It’s a panel that slides in from the right to present the user with either information, questions, error or a menu of options.

Picker: A tailored app user interface that provides the capabilities of a File Open dialog in classic Windows. It incorporates a basket for holding multiple items, which can be derived from any number of sources, including the local file system and various online services.

Search: A Windows 8 Contract that provides searching capabilities, be it for apps, settings, files, or whatever. Search is globally accessible from the Search charm in the edge UI on the right edge of the screen.

Secondary Tile: A special kind of Start screen tile that is created from within an app. For example, an address book app would have its own tile, but it could optionally provide you with the ability to create a secondary tile from any one of your contacts so that you could access that contact more easily and directly from the Start screen.

Semantic zoom: A process whereby the user employs two fingers on the screen of a Windows 8 PC to pinch onscreen elements (or “reverse pinch” them) to enable a secondary display. On the Windows 8 Start screen, you can use semantic zoom to view the entire (multiscreen) display on a single screen, and arrange and rename onscreen elements like groups.

Sensors: Windows 8 supports a wide range of device sensors, including accelerometer, inclinometer, gyrometer, compass, ambient-light, and orientation/simple orientation.

Share: A Windows 8 Contract that allows one app to share information with another. For example, a photo app might use Share to provide a way to share pictures online. Share is globally accessible from the Share charm in the edge UI on the right edge of the screen.

SmartScreen: A Windows 8 security technology that prevents malware from infecting your system using behavioral and manual, reputation-based methods. Microsoft previously provided this functionality in its IE browser, but is extending it to the Windows Explorer in Windows 8.

Snap: The process by which two apps can be displayed, or docked, side-by-side in Windows 8. These apps can consists of two apps or one app and one Windows desktop application. When in this mode, the leftmost app, which is said to occupy the Snap View, takes up about 30 percent of the onscreen real estate, while the rightmost app, said to occupy the Fill View, takes up the rest. You can change the space each occupies by dragging on the dividing line between them and flip their positions, so that the Fill View is on the left and the Snap View is on the right.

Start screen: The new Windows 8 shell, or user experience, which involves an immersive, full-screen user interface, tailored full-screen apps, and a new runtime environment called Windows Run Time (WinRT).

Tiles: User interface elements found in the Windows 8 Start screen that replace icons and represents applications and other items. Windows 8 tiles can be small (square) or large (rectangular) and present “live” information to the user. They are thus sometimes called Live Tiles. Tiles are said to be “pinned” to the Start screen; when removed they are “unpinned.” (This does not delete the application.)

 
Leave a comment

Posted by on April 20, 2013 in Windows 8

 

Tags: , ,

WCF service configurable maintenance mode

Didn’t you have a requirement to set a WCF service to record its requests in special location for later processing and reply with a fake response. I had and instead of hard coding the solution I wrote a general and reusable C# Attribute that you can make use of.

This case was introduced because we had a service that is used heavily and we can’t afford bring it down for maintenance such as server or database. We had simulate that the service is online and log the incoming requests during maintenance time and play them back after the service is back on.

Features:

  • Attribute that can be used on any WCF service or Method
  • Abstract the logging implementation (interface)
  • Abstract the maintenance mode configuration (enable, disable)
  • support for dependency injection for logging and configuration
  • Block the service execution (the actual implementation will not run)
  • Log the request message for later use
  • The message can be called again (replayed after the maintenance mode is disabled)
  • Reply to the client with dummy response (you can change this response)

How to:

  • Use IServiceBehavior to attach the this custom class to each service that has it as attribute and this will run our code each time the service is called
  • Use IDispatchMessageInspector to run custom code just after receiving the request (before processing) and also before sending the response
  • In the case of after receiving the request we will extract the request message (SOAP) and log it
  • In the case of before send reply we return a dummy response to simulate the process is correct

Code:

/// When applying this attribute to a WCF service contract,
/// if maintenance mode is set to true (in config file for example) these actions will happen
/// - Messages will be logged
/// - Service will not be executed
/// - Response will be dummy.
[AttributeUsage(AttributeTargets.Class)]
public class EnableMaintenanceMode : Attribute, IDispatchMessageInspector, IServiceBehavior
{
	private readonly IMaintenanceModeLogManager _maintenanceModeLogManager;

	public EnableMaintenanceMode(IMaintenanceModeLogManager maintenanceModeLogManager)
	{
		_maintenanceModeLogManager = maintenanceModeLogManager;
	}

	#region IDispatchMessageInspector Members

	public object AfterReceiveRequest(ref Message request,
									  System.ServiceModel.IClientChannel channel,
									  System.ServiceModel.InstanceContext instanceContext)
	{
		if (!_maintenanceModeLogManager.IsMaintenanceModeActive)
			return null;

		var doc = new XmlDocument();
		doc.LoadXml(request.ToString());
		var envelop = doc.DocumentElement;
		var node = envelop.FirstChild;

		node.ParentNode.RemoveChild(node);
		var msgObject = new MaintenanceModeMessageLog
							{
								Body = envelop.OuterXml,
								SOAPTo = node.FirstChild.InnerText,
								SOAPAction = node.LastChild.InnerText
							};
		_maintenanceModeLogManager.EnqueueMessage(msgObject);

		request = null;
		return msgObject;
	}

	public void BeforeSendReply(ref Message reply, object correlationState)
	{
		if (correlationState == null)
			return;
		var request = correlationState as MaintenanceModeMessageLog;
		if (request == null)
			return;
		var methodName = request.SOAPAction.Remove(0, request.SOAPAction.LastIndexOf("/") + 1);
		var memoryStream = new MemoryStream();
		var xmlDictionary = XmlDictionaryWriter.CreateBinaryWriter(memoryStream);

		xmlDictionary.WriteStartElement(methodName + "Response", "http://tempuri.org/");
		xmlDictionary.WriteStartElement(methodName + "Result", "http://tempuri.org/");
		xmlDictionary.WriteEndElement();
		xmlDictionary.WriteEndElement();
		xmlDictionary.Flush();

		memoryStream.Position = 0;
		var quotas = new XmlDictionaryReaderQuotas();
		var xmlReader = XmlDictionaryReader.CreateBinaryReader (memoryStream, quotas);
		var newMessage =Message.CreateMessage(reply.Version,null, xmlReader);
		newMessage.Headers.CopyHeadersFrom(reply.Headers);
		newMessage.Properties.CopyProperties(reply.Properties);
		reply = newMessage;
	}

	#endregion

	#region IServiceBehavior Members

	public void AddBindingParameters(ServiceDescription serviceDescription,
									 System.ServiceModel.ServiceHostBase serviceHostBase,
									 System.Collections.ObjectModel.Collection endpoints,
									 System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
	{
	}

	public void ApplyDispatchBehavior(ServiceDescription serviceDescription,
									  System.ServiceModel.ServiceHostBase serviceHostBase)
	{
		foreach (ChannelDispatcher chDisp in serviceHostBase.ChannelDispatchers)
		{
			foreach (EndpointDispatcher epDisp in chDisp.Endpoints)
			{
				epDisp.DispatchRuntime.MessageInspectors.Add(new EnableMaintenanceMode());
			}
		}
	}

	public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
	{
	}

	#endregion

}
 
Leave a comment

Posted by on April 18, 2013 in C#, WCF

 

Tags: , , , ,

OAuth & OpenID are not the same

OpenID

When you want to get a service from a website you have to sign up first, right? and if this website is famous you won’t get the name you want and you’ll have to try different names untill you get one. This will happen whenever you try a new website. Wouldn’t it be nice if you have only one ID to login to every website you want. so you don’t have to remember all of these accounts. This is when the OpenID came to the rescue. It’s about global authentication.

OpenID allows you to use an existing account to sign in to multiple websites, without needing to create new passwords.

You may choose to associate information with your OpenID that can be shared with the websites you visit, such as a name or email address. With OpenID, you control how much of that information is shared with the websites you visit.

With OpenID, your password is only given to your identity provider, and that provider then confirms your identity to the websites you visit. Other than your provider, no website ever sees your password, so you don’t need to worry about an insecure website compromising your identity.

OAuth

OAuth emerged from the social web, in order to authorize an application or site to act on your behalf (Read, Write) your data in another site (Facebook, Twitter,…), you have to authorize the third-party site to do this without giving the third-party your login credintials.

Allowing an application (tweetdeck) to act on your behalf (Read, Write) on information from an application that you use (Twitter, Facebook) without giving this application (tweetdeck) your password.

Summary

Open ID gives you one login for multiple sites (Each time you need to log into a site you will be redirected to your Open ID site where you login, and then back).

OAuth lets you authorise one website (the consumer) to access your data from another website – the provider.

 
Leave a comment

Posted by on April 18, 2013 in OAuth, Security

 

Tags: , , , ,

 
Create your own website, free on WordPress.com.Create your own website.
Start free