Example Of Client Dispatcher Server

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

For each of the underlined items above describe and explain the item (or a closely related set of items working together) using diagrams appropriately—this may include two or more items featuring in the same diagram to show their relationship(s). Each of your item explanations should refer to a relevant operating system and/or software sub-system and/or software library as appropriate.

Process is sequence of micro-operations that run and perform on job, and a well-defined context at which instant it is executing the task in operating system.  When talking about other attributes of operating system, thread is again an execution stream in the context of a thread state. Key difference between processes and threads is that multiple threads share parts of their state. Typically, allow multiple threads to read and write same memory. (Recall that no processes could directly access memory of another process). But, each thread still has its own registers. Also has its own stack, but other threads can read and write the stack memory. On other attributes memory management is next one. Memory management is the process of controlling and coordinating computer memory, assigning portions called blocks to various running programs to optimize overall system performance. It resides in hardware, in operating system and in programs.

Inter-process communication is such attributes of operating system, which sets up a data structure in kernel space. These data structures are often persistent. So once the purpose of IPC has been fulfilled, this set-up needs to be deleted. The usage pattern of the IPC package in a system can be seen by using explicit commands like IPCS.

Middleware is a medium which provide a more functional set of Application Programming Interfaces (API) than the operating system and network services to allow an application to locate transparently across the network, providing interaction with another application or service, to be independent from network services, to be reliable and available and scale up in capacity without losing function.

Software framework libraries are an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software.

An Application domain is a mechanism used within the common language infrastructure to isolate executed software applications from one another so that they do not affect each other

The Application specific Library is a multipurpose auxiliary library that provides various functions related to the development and use of applications. The very concept of application is a relatively recent addition to operating system. Before, the system only distinguished between different types of program on a very low level, seeing them as either tasks or processes. 

[5 marks]

Differentiate between a paradigm, a design pattern and an architectural pattern giving two examples of each and justifying why each of your six examples fits into the category you have selected for it.

Answer:

Many programming paradigms are as well-known for what they do not do as for what they do. This avoidance of certain techniques can make it easier to prove theorems about a program's correctness and to simply understand its behaviour, without limiting it. The programming paradigm and the languages that use them inform how the code gets written. For example, in Object Oriented programming the code is divided up into classes (sometimes a language feature, sometimes not (e.g. java script), and typically supports inheritance and some type of polymorphism. The programmer creates the classes, and then instances of the classes (i.e. the objects) to carry out the operation of the program. In functional languages, the state changes on the computer are very heavily controlled by the language itself. Functions are first class objects, although not all languages where functions are first class objects are functional programming language (this topic is one of good debate). Code written with functional languages involves lots of nested functions; almost every step of the program is new function invocation. For procedural programming, C programs and bash scripting are good examples, you just say do step 1, do step 2, etc without creating classes and whatnot.

Design Pattern: A design pattern is a useful abstraction that can be implemented in any language. It is a "pattern" for doing things. Like if you have a bunch of steps you want to implement, you might use the 'composite' and 'command' patterns so make your implementation more generic. Think of a pattern as an established template for solving a common coding task in a generic way.

Architecture pattern takes into consideration how you build a system to do stuff. So, for a web application, the architecture might involve x number of gateways behind a load balancer, that asynchronously feed queues. Messages are picked up by y processes running on z machines, with 1 primary db and a backup slave. Application architecture involves choosing the platform, languages, frameworks used. This is different than software architecture, which speaks more to how to actually implement the program given the software stack.

[5 marks]

Describe and explain the Pipes and Filters Architectural Pattern with particular reference to its use in the UNIX command shell (or similar) context. You should use examples to explain the advantages when pipes are used effectively and point out the problems that can occur when they are not used appropriately.

Answer:

The pipe and filter architectural pattern are structural systems that process a stream of data. Each processing step is a filter and data is passed through pipes between adjacent filters.

As we know that UNIX commands alone are powerful, but combining them together can accomplish complex tasks easily. The way to combine UNIX commands is through using pipes and filters.

The Known uses of pipes and filter architectural pattern are:

UNIX popularized the pipes and filter paradigm. The flexibility of UNIX pipes made the operating system a suitable platform for the binary reuse of filter programs and for application integration.

CMS pipelines are an extension to the operating system of IBM mainframes to support pipes and filters architectures. CMS pipelines provide a reuse and integration platform in the same way as UNIX.

LASSP Tools is a toolset to support numerical analysis and graphics. The toolset consists of filter programs that can be combined using UNIX pipes .it contains graphical input devices for analog input of numerical data, filters for numerical analysis and data extraction, and data sinks that produce animations from numerical data streams.

The advantages of using pipes and filters architectural pattern are:-

Using pipes and filters removes the need for intermediate files, but allows investigating intermediate data by using a T- junction in pipeline.

Flexibility by filter exchange: Filters have a simple interface that allows their easy exchange within a processing pipeline.

Flexibility by recombination: Reusability of filter components allows creating new processing pipelines by rearranging filters or by adding new ones.

Reuse of filter components

Efficiency by parallel processing

The problems are as follows:

Sharing state information is expensive or inflexible. If your processing stages need to share a large amount of global data, applying the pipes and filters pattern is either inefficient or does not provide the full benefits of the pattern.

[5 marks]

Describe, using text and diagrams, and discuss how pipes can be implemented effectively (i) between two processes on the same computer, and (ii) between two processes on two different computers connected by a network. You should take into consideration in each case whether synchronization is required and, if it is, describe and explain a suitable mechanism.

Answer:

unix_pipes.gif

Pipes can be implemented between the two processes on the same computer is described below:

A pipeline consists of a chain of processing elements (processes, threads, co-routines, etc.), arranged so that the output of each element is the input of the next. So, by launching elements at the same time and servicing the data read requests by each process with the data written by the upstream process. In this way, the CPU will be naturally switched among the processes by the scheduler so as to minimize its idle time. In other common models, elements are implemented as lightweight threads or as co-routines to reduce the OS overhead often involved with processes.

Pipes can be implemented between the two processes on two different computer is described below:

Connect the stream which is managed by the scheduler together with all other process running on the machine. When the receiving program is ready to read data, the OS sends data from the queue, after that it removes that data from the queue. . If the queue buffer fills up, the sending program is suspended until the receiving program has had a chance to read some data and make room in the buffer.

Question 2 [20 marks]

[5 marks]

Describe and draw diagrams for each of the following patterns and explain why they are related to the Broker pattern:

Forwarder-Receiver

Proxy

Client-Dispatcher-Server

Mediator

Cite the sources you referred to in formulating your answers.

Answer:

Forwarder Receiver

This pattern is used in communicating between peers. Each peer communicates with the other with the help of forwarder and receiver. The forwarder acts as a client and allows a communicating peer to forward message to it. The receiver acts as a server and waits for the peer to read a message. forwarder_receiver_szen1.png

Figure: Forwarder Receiver

Proxy

Proxy object acts as the agent between the client and the target object.

The classes and or object participating in this pattern are:

Proxy

Maintains a reference that lets the proxy access the real subject.

Controls access to the real subject and may be responsible for creating and deleting it.

Other responsibilities depends on the kind of proxy

Remote proxies are responsible for encoding a request and its arguments and for sending, the encoded request to the real subject is a different address space.

Virtual proxies may cache additional information about the real subject.

Protection proxies checks that the caller has the access permissions required to perform a request

Subject

If defines the common interface for Real Subject and Proxy.

Real Subject

It defines the real object that the proxy represents.

proxy

+ request()

real subject

+ request()

Client

subject

+request()

real subject

Real Subject

Request()

Client Dispatcher Server

In this pattern, the server registers itself with the dispatcher. After a while, a client asks the dispatcher for a communication channel to a specified server. As the dispatcher is responsible for establishing the communication channel between a client and a server, it establishes a communication link to the server. If it cannot initiate the communication, it sends the client an error message.IC135451.gif

Figure: Example of Client Dispatcher Server

The client uses the communication channel to send a request directly to the server. After recognizing the incoming request, the server executes the appropriate service. After the service execution is completed, the server sends the result back to the client.

Mediator

Mediator defines an object that encapsulates how a set of object interacts. Mediator component helps to communicate between two objects that reduce those dependencies between communicating objects. The mediator component helps in communicating between two objects.

MediatorPattern.jpg

Figure: Mediator

[5 marks]

Describe and explain how the Broker pattern could be applied to peer-to-peer networking and what advantages would thereby accrue. Discuss why multiple Brokers might be preferable. Draw relevant diagrams and cite the sources you referred to in formulating your answers.

Answer

Peer to peer is an approach to computer networking where all computers share equivalent responsibility for processing data.US06865599-20050308-D00000.png

On the internet, they handle a very high volume of file sharing traffic by distributing the load across many computers. Clients access web services by connecting to a broker, where there is no presence of client in online. Clients then maintain active connections to the hosting broker throughout the duration that they use the service.

The advantages of broker pattern are:

Isolation: Separating all the communication-related code into its own layer isolates it from the application.

Simplicity: Encapsulating complex communication logic into a separate layer breaks down the problem space. The engineers coding the broker do not have to concern themselves with arcane user requirements and business logic, and the application developers do not have to concern themselves with multicast protocols and TCP/IP routing.

Flexibility:. Encapsulating functions in a layer allow swapping this layer with a different implementation.

The advantages of using multiple brokers are:

It enables to establish contractual offers of compensation (among brokers), facilitates cooperation with other broker participants, accumulates and disseminates information to enable appraisals, and is a facility for the orderly correlation and dissemination of listing information to better serve broker's clients, customers and the public.

[10 marks]

Consider application processes that cooperate at the level of objects via published interfaces (for example COM, DCOM, CORBA). A process calls a method of an interface implemented in a second process. The method has parameters including complex data structure values and reference parameters but is a procedure with no return value. The two processes are on different computers.

Describe and explain in detail, with appropriate diagrams, how DCOM enables the calling process so that it is able to (i) determine whether an object of the specified class exists and can be instantiated on the target computer, (ii) cause an object of the said class to be instantiated on the target computer and gain access to the desired interface, and (iii) make a successful call to the method taking into account the types of parameters described above.

Answer:

Microsoft launch Distributed Component Object Model technology as an advance form of Component Object Model. COM enables different programs resident on the same computer to be "called" to provide services to other programs. DCOM extends this operation over a network. Networked communication requires port numbers, which are addresses for applications. DCOM is a set of Microsoft concepts and program interfaces in which client program object s can request services from server program objects on other computers in a network.

1-s2.0-S0168169900000910-gr1.gif

The right way to access DCOM object is as follows:

var type = Type.GetTypeFromCLSID(new Guid(CLSID), Environment.MachineName, true);

var COMObject = Activator.CreateInstance(type);

var returnValue = COMObject.GetType().InvokeMember(methodName, flags, null, COMObject, args, argModifiers, null, null);

Question 3 [20 marks]

[7 marks]

Software Architecture ‘principles’ are intended to ‘improve’ the software we create. What does this mean in real-world terms? How do we measure such ‘improvement’? What are the ‘quality factors’ we must consider? What are the costs we must be concerned with? What failures are we trying to avoid?

Describe and explain the factors that contribute to the creation of high quality software by answering the questions above. Cite the sources you referred to in formulating your answers.

Answer:

Software architecture ‘principles’ are sure for with the intention to improve the software we create. In real-world terms too, it has reached every sector, from health to education, commercial to health, security, automobile and many more where this level of principles has given a great height to be reliable software.

We measure such improvement by its reliability, efficiency. There are many factors. One should not evaluate "speed" or "security" of software but they should evaluate the general quality.

The quality factors we must consider are

Correctness

Reliability

Efficiency

Integrity

Usability

Maintainability

Testability

Flexibility

Portability

Reusability

Interoperability

The factors that contribute to the creation of high quality software are described below.

Good software management : Good advice can be taken from many sources explaining good software management(open source, commercial) and for software development (embedded, in house etc)

Good communication skills: communication between a project leader and other participants play an important role. If there is good communication between them, then there will be good working environment. Good communication skills include tactful, very good English, good phrasing, clear writing; patience etc. if the project leader do not have good communication skills then people will get hard to work with.

No bad politics: maintaining a good policy in project is important thing. People became frustrate and compelled to leave the project due to bad political processes which became more common in a project. The important features get lost due to bad political processes. So it is important to maintain good policies which do not let the people being frustrated.

Good social engineering skills: a project leader should have good social skills which include saying thanks and congratulating people for their contribution, from tactfulness, to humour etc. All of these things make contributing to a project which makes using the program more fun and less frustrating.

Bad testers: if there is a beta tester for code, a lot of positive feedback can be get for various different platforms.

Automated tests: it means to test the behaviour of the code automatically. Accumulating such test is a good sign for maintaining high quality software.

Moving modular, well written code: the more modular a project’s code is, the easier it is to change it and extend it, and the faster development will take.

A lot of negative hype helps in making the successful project. The less hype and general noise makes the software project better.

A good name: a good name also helps a lot in software quality.

The costs we most concerned with are the time of software development phase which longs till the date before released, participated man power and other resources in making the software. The failures we are trying to avoid are simply the one which can hamper the operation of program totally and damages the data partially or wholly.

[7 marks]

In the context of object-oriented design SOLID brings together a set of principles that can contribute positively to the creation of software systems.

Describe and explain, in your own words, inventing your own examples and citing your sources, (i) what positive contributions are to be expected, and (ii) what each principle is and why each principal is useful.

Answer:

To implement OOPS and use them in right manner, there are where 5 Object Oriented Principles (also called as SOLID Principles) comes into picture. SOLID programming is a collection of 5 programming patterns for object oriented programming and design. The principle of SOLID are

S - Single Responsibility Principle (SRP)

O - Open Closed Principle (OCP)

L – Liskov Substitution Principle (LSP)

I – Interface Segregation Principle (ISP)

D – Dependency Inversion Principle (DIP)

Single Responsibility Principle

The Single Responsibility Principle states that every object should have a single responsibility. Responsibility is the main theme of this principle, so there should not be more than are responsibility per class.

The reason it is important to keep a class focused on a single concern is that it makes the class more robust.

E.g.

Want to Insert data into database and want to log the details.

If we create a class to represent Data Access, it should not be used to save to the database (task 1), as well as log the details (task 2)

Open Closed Principle

This states that software entities such as classes, modules, functions should be open for extension but closed for modification. This is the basis of "keep all object variables private" argument.

Following this principle should make behaviour easier to change and also help us avoid breaking existing behaviours while making changes. This also gets to think about the likely areas of change in a class, which helps us to choose the right abstractions required for design.

Liskov Substitution Principle

This states that sub classes should be substitutable for the classes from which they were derived. If you are calling a method defined at a base class upon an abstracted class, the function must be implemented properly on the subtype class. Whenever you use inheritance it’s a good idea to keep the LSP firmly in mind.

E.g.

If we are calling a method defined at a base class upon an abstracted class, the function must be implemented properly on the subtype class

Interface Segregation Principle

This Interface Segregation Principle states that clients should not be forced to depend an methods they don’t use. When a client depends upon a class that contain interface that the client does not use but that other client do choose. Then that client will be affected by the changes that those other clients force upon the class.

E.g.

When a client depends upon a class that contains interfaces that the client does not use, but that other clients do use, then that client will be affected by the changes that those other clients force upon the class

 

Base Interface:                IDataProvider

Derived Interfaces:         ISqlDataProvider, IOracleDataProvider

Derived Classes:              SqlDataClient, OracleDataClient

 

Each Derived class should implement functions from their respective interfaces.

No derived interface force other derived classes to implement the functionalities which they won't use.

Dependency Inversion Principle

Dependency Inversion Principle states that high-level modules should not depend on low level modules but both should depend on shared abstraction. Abstraction should not depend upon details but details should depend upon abstractions.

E.g:

An Employee class that needs to be able to save to XML and a database.

[6 marks]

Using Visual Studio 2012 and C# create a well-documented console application that demonstrates clearly the following three forms of Dependency Injection (sometimes referred to as Inversion of Control): (i) interface injection, (ii) setter injection, and (iii) constructor injection.

Answer:

The following program is console application that demonstrates clearly the three forms of Dependency injection developed in Visual Studio 2012 and C#.

using System;

usingConst=DependencyInjection.Constructor;

using Prop=DependencyInjection.Property;

using Inter = DependencyInjection.Interface;

namespaceDependencyInjection

{

class Program

{

static void Main(string[] args)

{

IRateCalculatorconstAsianCalculator = new AsianRateCalculator();

//Contructor Dependency Injection

//Dependent Calculator passed through constructor

Const.RateCalculatorconstCalculator = new Const.RateCalculator(constAsianCalculator);

constCalculator.Rate = 2.0;

Console.WriteLine("Constructor Injection : {0}", constCalculator.CalculatedRate);

IRateCalculatorpropEuropeanCalculator = new EuropeanRateCalculator();

Prop.RateCalculatorpropCalculator = new Prop.RateCalculator();

//Setter Dependency Injection

//Dependent Calculator set on the Calculator property of RateCalculator

propCalculator.Calculator = propEuropeanCalculator;

propCalculator.Rate = 4.0;

Console.WriteLine("Property Injection : {0}",propCalculator.CalculatedRate);

IRateCalculatorinterAmericanCalculator = new AmericianRateCalculator();

Inter.RateCalculatorinterCalculator=new Inter.RateCalculator();

//Interface Dependency Injection

//Dependent Calculator set on the Interface through method SetRateCalculator method

interCalculator.SetRateCalculator(interAmericanCalculator);

interCalculator.Rate = 2.0;

Console.WriteLine("Interface Injection : {0}", interCalculator.CalculatedRate);

Console.ReadKey();

}

}

}

Question 4 [40 marks]

[10 marks]

Draw a diagram of an interactive application that implements the Model View Controller (MVC) pattern. The application can display two views of the application’s data (but only one view at a time). Label the Model, View(s) and Controller elements in your diagram. Show (and label appropriately) the interactions between the Model, View(s) and Controller elements as well as where the application’s data is received, manipulated and returned to an associated data store.

Describe and explain, with reference to your MVC diagram, the role of each of the three elements and the interactions between the elements, the data store, the user interface and the user.

Answer:mvc4.jpg

Figure : Interaction between the elements by using MVC pattern

Model view controller (MVC) is a software architecture pattern. MVC separates the representation of information from the users’ interaction with it. MVC pattern separates the modelling of the domain, the presentation and their action based on user input into 3 separate classes:

Model: A model notifies its associated views and controllers when there has been change in its state. The notification allows the view to produce updated output and the controller to change the available set of commands.

View: A view requests the model for the information that it needs to generate and output representation to the user.

Controller: A controller sends commands to its associated model to change the views presentation of the model and also to the model to update the models state

[8 marks]

Present and discuss the rationale of the MVC pattern in the context of an application that must work well on both smart phones and desktop computer systems where the application data store is only accessible over the Internet. Set out, with justification, why MVC is best suited to this type of application and the problem sit is designed to avoid.

Answer:

The Model-View-Controller (MVC) pattern separates the modelling of the domain, the presentation, and the actions based on user input into three separate classes as model, view and controller. In some cases, the application displays the same data in different ways. For example, when an analyst prefers a spread sheet view of data whereas management prefers a pie chart of the same data. In some rich-client user interfaces, multiple views of the same data are shown at the same time. If the user changes data in one view, the system must update all other views of the data automatically.

Same wise, the users of desktop computer and Smartphone calls to the same data source in surface. But the element of MVC tends by the controller decides the user of desktop computer or Smartphone and give the view to their correspondence model. As in the given figure below:

images.jpg

This is also very much best suited for this types of application because of the advantage of the MVC pattern is that it creates clear distinction, thereby allowing multiple displays from the same model. For instance, several pages on a web application can use the same data objects. The other example is a website application that allows you to completely transform the look of the pages. This simply means the pages display the same information but show it using a different way.

[12 marks]

Draw a diagram of an interactive application that implements the Model View View-Model (MVVM) pattern. The application can display several views of the application’s data simultaneously. Label the Model, View(s) and View-Model elements in your diagram. Show (and label appropriately) the interactions between the Model, View(s) and View-Model elements as well as where the application’s data is received, manipulated and returned to an associated data store.

Describe and explain, with reference to your MVVM diagram, the role of each of the three elements and the interactions between the elements, the data store, the user interface and the user.

Answer:

MVVM_Overview.jpg

Elements of the MVVM pattern are

The Model

The model refers to as the domain object. It represents the actual data or information that we deal with. It holds the information, but not behaviours or services that manipulate the information for e.g.: contact (which contains name, phone number, address etc)

The View

In MVVM pattern, the view is active element. It is the presentation of the data. The view contains behaviours, events and data binding that require that knowledge of the model and view model. It is responsible for handling its own events also.

The viewmodel

It is also called as controller/presenter. It exposes methods, commands and other paints that help to maintain the state of the view, manipulates model and trigger events in the view.

It takes input from the view and place it as the model which translate properties and place it as the view.

[10 marks]

Explain (using an appropriate example and code snippets) why the MVVM application pattern is favoured for applications built using Microsoft Windows Presentation Foundation (WPF). Your explanation should include the relevance of XAML and data binding in this context. Cite the sources you referred to in formulating your answers.

Answer:

WPF without MVVM is bewildering and frustrating. WPF with MVVM is liberating and exciting. Once a developer becomes comfortable with WPF and MVVM, it can be difficult to differentiate the two. MVVM is the lingua franca of WPF developers because it is well suited to the WPF platform, and WPF was designed to make it easy to build applications using the MVVM pattern (amongst others). In fact, Microsoft was using MVVM internally to develop WPF applications, such as Microsoft Expression Blend, while the core WPF platform was under construction. Many aspects of WPF, such as the look-less control model and data templates, utilize the strong separation of display from state and behaviour promoted by MVVM.

The single most important aspect of WPF that makes MVVM a great pattern to use is the data binding infrastructure. By binding properties of a view to a ViewModel, you get loose coupling between the two and entirely remove the need for writing code in a ViewModel that directly updates a view. The data binding system also supports input validation, which provides a standardized way of transmitting validation errors to a view.

Two other features of WPF that make this pattern so usable are data templates and the resource system. Data templates apply Views to ViewModel objects shown in the user interface. You can declare templates in XAML and let the resource system automatically locate and apply those templates for you at run time. You can learn more about binding and data templates in my July 2008 article, "Data and WPF: Customize Data Display with Data Binding and WPF."

                            default:

                                thrownewNotImplementedException();

                        }

                    }

                );

            }

 

            returnselectViewModelCommand;

        }

    }

}

 

The source properties of the data bindings in the MainView are found in the MainViewModel. The TreeViewItem Command is bounded to the SelectViewModelCommand property. The SelectViewModelCommand returns a RelayCommand object. The RelayCommand class implements the ICommand interface. Generally, we have to create a new class for every custom command and implement Execute and CanExecute methods. The RelayCommand eliminates this by passing delegates to the constructor, so you only need to create one or two methods, not a class.

 

There are two RelayCommand constructors. The first one accepts an Action<object> parameter. It represents the Execute method of the ICommand. Its CanExecute method always return true. On the other hand, the second constructor also accepts a Predicate<object> which represents the CanExecute method.

 

In the above code listing, we used the first constructor where the first parameter uses a lambda expression. Here, the param is an object wherein its value is set by setting the value of the CommandParameter property. This property is useful if we have multiple TreeViewItem objects and we need to differentiate them from one another.

 

In order to use the ViewModel, the DataContext of the MainView window should be set, which is shown below.

 

publicpartialclassMainView : Window

{

    publicMainView()

    {

        InitializeComponent();

 

        DataContext = newMainViewModel();

    }

}

 

Implementing the ICommandSource

Some controls, like a Button, have a Command dependency property already. It is because the Button class implements the ICommandSource. However, some controls like the TreeViewItem do not. As mentioned before, we need to create a class that inherits from TreeViewItem and implement ICommandSource. The following code listing shows this class.

 

internalclassCommandTreeViewItem : TreeViewItem, ICommandSource

{

    #region Constructor

 

    publicCommandTreeViewItem()

        : base()

    {

    }

 

    #endregion

 

    #regionICommandSource Members

 

    publicstaticreadonlyDependencyPropertyCommandProperty =

        DependencyProperty.Register

        (

            "Command",

            typeof(ICommand),

            typeof(CommandTreeViewItem),

            newPropertyMetadata((ICommand)null, newPropertyChangedCallback(CommandChanged))

        );

 

    publicstaticreadonlyDependencyPropertyCommandParameterProperty =

        DependencyProperty.Register

        (

            "CommandParameter",

            typeof(object),

            typeof(CommandTreeViewItem),

            newPropertyMetadata((object)null)

        );

 

    publicstaticreadonlyDependencyPropertyCommandTargetProperty =

        DependencyProperty.Register

        (

            "CommandTarget",

            typeof(IInputElement),

            typeof(CommandTreeViewItem),

            newPropertyMetadata((IInputElement)null)

        );

 

    publicICommand Command

    {

        get

        {

            return (ICommand)GetValue(CommandProperty);

        }

        set

        {

            SetValue(CommandProperty, value);

        }

    }

 

    publicobjectCommandParameter

    {

        get

        {

            return (object)GetValue(CommandParameterProperty);

        }

        set

        {

            SetValue(CommandParameterProperty, value);

        }

    }

 

    publicIInputElementCommandTarget

    {

        get

        {

            return (IInputElement)GetValue(CommandTargetProperty);

        }

        set

        {

            SetValue(CommandTargetProperty, value);

        }

    }

 

    #endregion

 

    #regionICommandSource-Related

 

    privatestaticEventHandlercanExecuteChangedHandler;

 

      privatestaticvoidCommandChanged(DependencyObject d,

        DependencyPropertyChangedEventArgs e)

    {

        CommandTreeViewItemcommandTreeViewItem = (CommandTreeViewItem)d;

        commandTreeViewItem.HookUpCommand((ICommand)e.OldValue, (ICommand)e.NewValue);

    }

 

      privatevoidHookUpCommand(ICommandoldCommand, ICommandnewCommand)

    {

       

        if (oldCommand != null)

        {

            RemoveCommand(oldCommand, newCommand);

        }

        AddCommand(oldCommand, newCommand);

    }

 

       privatevoidRemoveCommand(ICommandoldCommand, ICommandnewCommand)

    {

        EventHandler handler = CanExecuteChanged;

        oldCommand.CanExecuteChanged -= handler;

    }

 

  

    privatevoidAddCommand(ICommandoldCommand, ICommandnewCommand)

    {

        EventHandler handler = newEventHandler(CanExecuteChanged);

        canExecuteChangedHandler = handler;

        if (newCommand != null)

        {

            newCommand.CanExecuteChanged += canExecuteChangedHandler;

        }

    }

 

    privatevoidCanExecuteChanged(object sender, EventArgs e)

    {

 

        if (this.Command != null)

        {

            RoutedCommand command = this.CommandasRoutedCommand;

 

            if (command != null)

            {

                if (command.CanExecute(CommandParameter, CommandTarget))

                {

                    this.IsEnabled = true;

                }

                else

                {

                    this.IsEnabled = false;

                }

            }

                       else

            {

                if (Command.CanExecute(CommandParameter))

                {

                    this.IsEnabled = true;

                }

                else

                {

                    this.IsEnabled = false;

                }

            }

        }

    }

 

    protectedoverridevoidOnSelected(RoutedEventArgs e)

    {

        base.OnSelected(e);

 

        if (this.Command != null)

        {

            RoutedCommand command = Command asRoutedCommand;

 

            if (command != null)

            {

                command.Execute(CommandParameter, CommandTarget);

            }

            else

            {

                ((ICommand)Command).Execute(CommandParameter);

            }

        }

    }

 

    #endregion

}

 

Actually, when implementing the ICommandSource interface, we only need to implement the following read-only properties: Command, CommandParameter and CommandTarget. We could implement these as normal properties. However, we need to implement them as dependency properties so that we can set their values using XAML.

Submission

Before the deadline—which is 12:00 on the 7th of May 2013—you must submit your work by uploading it to the Software Architecture (COM3020-N-BJ1-2012) Blackboard site. The upload facility with instructions will appear in the Assessment section of the site and there will be an announcement and you will each receive an email to inform you when the upload facility is ready.

You must upload a single .zip file whose filename consists of the string ‘SA ICA 2012-13’ followed by your first name, your surname, and your student number separated by spaces, for example:

SA ICA 2012-13 Jay Chapman u0019195.zip

This .zip file must contain two items.

The first item must be your ICA answer document as a .pdf file using the same filename as above, with the string ‘Answers’ appended following a space character, for example:

SA ICA 2012-13 Jay Chapman u0019195 Answers.pdf

The second item must be a .zip file containing the complete folder hierarchy of your ‘well-documented console application’ that satisfies the requirements of Question 3 part (c). The name of the .zip file is constructed as above except that the string ‘Answer 3 part (c)’ must be appended following a space, for example:

SA ICA 2012-13 Jay Chapman u0019195 Answer 3 part (c).zip

The extracted folder hierarchy must be loadable, buildable and runnable using Visual Studio 2012.

===============================END OF ICA SPECIFICATION===============================

REFERENCES ARE REMAINING



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now