Question: What is RadCube?
In simple terms "It enables to wrap application logic and binds it to six different sides of a cube. So the accessing of small information is associated with each component in the cube (six dimensional) which provides a much better way to view the information".
I think we are now good to go to implement this wonderful concept.
Step 1: The complete code of IService1.cs looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfCubeApp
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService1
{
[OperationContract]double add(double a, double b);
[OperationContract]double sub(double a, double b);
[OperationContract]double mul(double a, double b);
[OperationContract]double div(double a, double b);
[OperationContract]double mod(double a, double b);
[OperationContract]double total(double a, double b);
}
}
Step 2: The complete code of Service1.svc.cs looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfCubeApp
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class Service1 : IService1
{
public double add(double a, double b)
{
return a + b;
}
public double sub(double a, double b)
{
return a - b;
}
public double mul(double a, double b){return a * b;
}
public double div(double a, double b)
{
return a / b;
}
public double mod(double a, double b)
{
return a % b;
}
public double total(double a, double b)
{
return a + b * a / b;
}
}
}
Step 3: The complete code of Web.Config looks like this:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Step 4: The complete code of ClientAccessPolicy.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Step 5: The complete code of MainPage.xaml looks like this:
<UserControl x:Class="RadCubeApplication.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot" Width="626">
<TextBlock Grid.Row="1"Height="23"HorizontalAlignment="Left"Margin="72,61,0,0"Name="textBlock1"FontFamily="Verdana"FontSize="15"Text="Please Enter First Number: "VerticalAlignment="Top"Width="214" />
<TextBox Grid.Row="1"Height="23"HorizontalAlignment="Left"Margin="320,60,0,0"Name="textBox1"VerticalAlignment="Top"Width="120" />
<TextBlock Grid.Row="1"Height="23"HorizontalAlignment="Left"Margin="58,121,0,0"FontFamily="Verdana"FontSize="15"Name="textBlock2"Text="Please Enter Second Number: "VerticalAlignment="Top"Width="228" />
<TextBox Grid.Row="1"Height="23"HorizontalAlignment="Left"Margin="320,120,0,0"Name="textBox2"VerticalAlignment="Top"Width="120" />
<Button Content="Arthmetic Operation" Height="23" HorizontalAlignment="Left" Margin="320,180,0,0" Name="button1" VerticalAlignment="Top" Width="120" Background="DeepSkyBlue"Click="button1_Click"/>
<telerik:RadCube XWidth="200" YWidth="200" ZWidth="200" Margin="339,360,301,120"IsRotateOnClickEnabled="True"HorizontalAlignment="Center"VerticalAlignment="Center"Name="radCube1"
Side1Background="LightBlue"Side2Background="LightCoral"Side3Background="LightCyan"Side4Background="LightGray"Side5Background="LightGreen"
Side6Background="LightGoldenrodYellow">
<!--Addition Operation Cube Side-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontFamily="Verdana"FontSize="12"HorizontalAlignment="Stretch"VerticalAlignment="Center"FontWeight="Bold" Name="textBlockAdd" Width="200"/>
</Grid>
<!--Subtraction Operation Cube Side-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontFamily="Verdana"FontSize="12"HorizontalAlignment="Stretch"VerticalAlignment="Center"FontWeight="Bold" Name="textBlockSub" Width="200"/>
</Grid>
<!--Multiplication Operation Cube Side-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontFamily="Verdana"FontSize="12"HorizontalAlignment="Stretch"VerticalAlignment="Center"FontWeight="Bold" Name="textBlockMul" Width="200"/>
</Grid>
<!--Division Operation Cube Side-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontFamily="Verdana"FontSize="12"HorizontalAlignment="Stretch"VerticalAlignment="Center"FontWeight="Bold" Name="textBlockDiv" Width="200"/>
</Grid>
<!--Modulos Operation Cube Side-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontFamily="Verdana"FontSize="12"HorizontalAlignment="Stretch"VerticalAlignment="Center"FontWeight="Bold" Name="textBlockMod" Width="200"/>
</Grid>
<!--Total Operation Cube Side-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontFamily="Verdana"FontSize="12"HorizontalAlignment="Stretch"VerticalAlignment="Center"FontWeight="Bold" Name="textBlockTotal" Width="200"/>
</Grid>
</telerik:RadCube>
</Grid>
</UserControl>
Step 6: The complete code of MainPage.xaml.cs looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using RadCubeApplication.ServiceReference1;namespace RadCubeApplication
{
public partial class MainPage : UserControl
{
public MainPage(){InitializeComponent();
}
private void add_Call(object sender, addCompletedEventArgs e)
{
textBlockAdd.Text = "Addition Result is: " + e.Result.ToString();
}
private void sub_Call(object sender, subCompletedEventArgs e)
{
textBlockSub.Text = "Subtraction Result is: " + e.Result.ToString();
}
private void mul_Call(object sender, mulCompletedEventArgs e)
{
textBlockMul.Text = "Multiplication Result is: " + e.Result.ToString();
}
private void div_Call(object sender, divCompletedEventArgs e)
{
textBlockDiv.Text = "Division Result is: " + e.Result.ToString();
}
private void mod_Call(object sender, modCompletedEventArgs e)
{
textBlockMod.Text = "Modulos Result is: " + e.Result.ToString();
}
private void total_Call(object sender, totalCompletedEventArgs e)
{
textBlockTotal.Text = "Total Result is: " + e.Result.ToString();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
textBlockAdd.Text = "";
textBlockSub.Text = "";
textBlockMul.Text = "";
textBlockDiv.Text = "";
textBlockMod.Text = "";
textBlockTotal.Text = "";
RadWindow.Alert("Please Enter Some Values");
}
else
{
objClient.addCompleted +=new EventHandler<addCompletedEventArgs>(add_Call);
objClient.addAsync(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
objClient.subCompleted += new EventHandler<subCompletedEventArgs>(sub_Call);
objClient.subAsync(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
objClient.mulCompleted += new EventHandler<mulCompletedEventArgs>(mul_Call);
objClient.mulAsync(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
objClient.divCompleted += new EventHandler<divCompletedEventArgs>(div_Call);
objClient.divAsync(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
objClient.modCompleted += new EventHandler<modCompletedEventArgs>(mod_Call);
objClient.modAsync(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
objClient.totalCompleted += new EventHandler<totalCompletedEventArgs>(total_Call);
objClient.totalAsync(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
textBox1.Text = "";
textBox2.Text = "";
}
}
#region Instance VariablesService1Client objClient = new Service1Client();
#endregion
}
}
Step 7: The output of the application looks like this:
Step 8: The output of the nothing entered application looks like this:
Step 9: The output of the addition side cube application looks like this:
Step 10: The output of the multiplication side cub application looks like this:
Step 11: The output of the division side cub application looks like this:
I hope this article is useful for you.