Tuesday, March 17, 2015

Solution for "DestinationUnreachable" Problem When Using SOAPUI to Test Your Web Service

This error occurs when you try to test one of the web service methods by using SoapUI.

All you need to do is;

  • Check "Add default wsa:To" from WS-A tab as shown below.













That is all!

Happy coding!

Tuesday, March 10, 2015

Solution for Umbraco Mvc Project Error: "Could not load file or assembly 'ClientDependency.Core, Version=1.7.1.2, Culture=neutral, PublicKeyToken=null.' or one of its dependencies"

This error occurs  when trying to add a new controller to a Umbraco Mvc project(Umbraco version is 7.1.x.). This is an Umbraco bug and this is because of umbraco assemblies were built with specific versions.

All you need to do is;
  • Upgrade the umbraco mvc version to 7.2.2 or later by using Nuget Package Manager.
  • If you don't want to upgrade your umbraco mvc version, then you can just copy an existing controller and paste it and change it according to your project needs. This is the other way.
That's all!

Error Message:









Happy coding!

Wednesday, March 4, 2015

Solution for "This configuration section cannot be used at this path. This happens when the section is locked at a parent level..."

This error occurs  when there is a problem reading the configuration file for the Web server or Web application.

All you need to do is;

  • Click "Start" button.
  • Search for "Turn windows features on or off".
  • In the Windows Features window, go to "Internet Information Services\World Wide Web Services\Application Development Features".
  • Check all the features apart from CGI.
  • Restart your IIS.

That's all!

Error Message:
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

Happy coding!

Monday, September 15, 2014

Design Patterns - Abstract Factory Pattern

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_AbstractFactoryApp
{
   class Program
   {
      static void Main(string[] args)
      {
         /* ABSTRACT FACTORY PATTERN:
          * The abstract factory pattern provides a way to 
          * encapsulate a group of individual factories 
          * that have a common theme without 
          * specifying their concrete classes.
          * Use of this pattern makes it possible to 
          * interchange concrete implementations 
          * without changing the code 
          * that uses them, even at runtime. 
          * However, employment of this pattern, 
          * as with similar design patterns, 
          * may result in unnecessary complexity 
          * and extra work in the initial writing of code
          */

         var samsungSmartPhone = new GenericFactory<SamsungSmartPhone>();
         SmartPhone smartPhone1 = new SamsungSmartPhone();
         samsungSmartPhone.CreateInstance().TestSmartPhone(smartPhone1);

         var appleSmartPhone = new GenericFactory<AppleSmartPhone>();
         SmartPhone smartPhone2 = new SamsungSmartPhone();
         appleSmartPhone.CreateInstance().TestSmartPhone(smartPhone2);

         Console.ReadKey();
      }
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_AbstractFactoryApp
{
   public class GenericFactory<T>
      where T : new()
   {
      public T CreateInstance()
      {
         return new T();
      }
   }
}


**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_AbstractFactoryApp
{
   public abstract class PhoneFactory
   {
      public abstract SmartPhone CreateSmartPhone();
      public abstract DummyPhone CreateDummyPhone();
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern_AbstractFactoryApp
{
   public abstract class SmartPhone
   {
      public abstract void TestSmartPhone(SmartPhone phone);
   }
}

**************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern_AbstractFactoryApp
{
   public abstract class DummyPhone
   {
      public abstract void TestDummyPhone(DummyPhone phone);
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_AbstractFactoryApp
{
   public class AppleFactory : PhoneFactory
   {
      public override SmartPhone CreateSmartPhone()
      {
         return new AppleSmartPhone();
      }

      public override DummyPhone CreateDummyPhone()
      {
         return new AppleDummyPhone();
      }
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern_AbstractFactoryApp
{
   class AppleSmartPhone : SmartPhone
   {
      public override void TestSmartPhone(SmartPhone phone)
      {
         Console.WriteLine("Apple Smart: " + phone.GetType().Name);
      }
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern_AbstractFactoryApp
{
   class AppleDummyPhone : DummyPhone
   {
      public override void TestDummyPhone(DummyPhone phone)
      {
         Console.WriteLine("Apple Dummy: " + phone.GetType().Name);
      }
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_AbstractFactoryApp
{
   class SamsungFactory:PhoneFactory
   {
      public override SmartPhone CreateSmartPhone()
      {
         return new SamsungSmartPhone();
      }

      public override DummyPhone CreateDummyPhone()
      {
         return new SamsungDummyPhone();
      }
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern_AbstractFactoryApp
{
   class SamsungSmartPhone : SmartPhone
   {
      public override void TestSmartPhone(SmartPhone phone)
      {
         Console.WriteLine("Samsung Smart: " + phone.GetType().Name);
      }
   }
}

**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern_AbstractFactoryApp
{
   class SamsungDummyPhone:DummyPhone
   {
      public override void TestDummyPhone(DummyPhone phone)
      {
         Console.WriteLine("Samsung Dummy: " + phone.GetType().Name);
      }
   }
}


Friday, September 5, 2014

Design Patterns - Strategy Pattern

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_StrategyPattern
{
   class Program
   {
      static void Main(string[] args)
      {
         /* STRATEGY PATTERN (POLICY PATTERN):
          * Strategy lets the algorithm vary independently 
          * from clients that use it.
          * When the program is running, we can switch between different 
          * type of algorithms
          * For instance, a class that performs validation on incoming data
          * may use a strategy pattern to select a validation 
          * algorithm based on the type of data, 
          * the source of the data, user choice,
          * or other discriminating factors. These factors are not known 
          * for each case until run-time, and may require 
          * radically different validation to be performed.
          */

          ICalculate calculate = null;

          while (true)
          {
             try
             {
                Console.WriteLine("Choose an operation! ( 1 = Plusus, 2 = Minus )");
                StrategyType strategyType = (StrategyType)Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter the first number");
                int value1 = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter the second number");
                int value2 = Convert.ToInt32(Console.ReadLine());

                switch (strategyType)
                {
                   case StrategyType.Plussus:
                      calculate = new Plussus();
                      Console.WriteLine("Operation: Plusus, Result: " + calculate.Calculate(value1, value2));
                      break;
                   case StrategyType.Minus:
                      calculate = new Minus();
                      Console.WriteLine("Operation: Minus, Result: " + calculate.Calculate(value1, value2));
                      break;
                }
             }
             catch (Exception)
             {
                Console.WriteLine("Enter a valid number!");
             }
         }
      }
   }
}


*********************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_StrategyPattern
{
   //The interface for the strategies
   public interface ICalculate
   {
      //Method is defined in the interface
      int Calculate(int value1, int value2);
   }
}

*********************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_StrategyPattern
{
   //Strategy: Minus
   public class Minus : ICalculate
   {
      public int Calculate(int value1, int value2)
      {
         //The minus logis is defined
         return value1 - value2;
      }
   }
}

*********************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_StrategyPattern
{
   //Strategy: Plussus
   public class Plussus:ICalculate
   {
      public int Calculate(int value1, int value2)
      {
         //The plussus logic is defined
         return value1 + value2;
      }
   }
}

*********************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_StrategyPattern
{
   enum StrategyType
   {
      Plussus = 1,
      Minus = 2
   }
}

*********************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPattern_StrategyPattern
{
   //The client
   public class CalculateClient
   {
      private ICalculate calculate;

      public CalculateClient(ICalculate strategy)
      {
         this.calculate = strategy;
      }

      public int Calculate(int value1, int value2)
      {
         return calculate.Calculate(value1, value2);
      }
   }
}