Question

In: Computer Science

C# Assignment: Create a DLL that contains a class used to generate QR codes. From a...

C# Assignment:

Create a DLL that contains a class used to generate QR codes. From a console application, reference the project that generates the DLL. Allow the user to enter an address and pass it to the method in the separate DLL that will generate the QR code. You only need to allow the user to generate a single QR code at a time (you may close the application once you have generated it).

Solutions

Expert Solution

Following is the code for Class Library:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;

namespace QRGenWrapper
{
public class QRCodeGenerator
{
public Stream Generate(string address)
{
var url = string.Format("http://chart.apis.google.com/chart?cht=qr&chs={1}x{2}&chl={0}", address, 200, 200);
WebResponse response = default(WebResponse);
Stream remoteStream = default(Stream);
StreamReader readStream = default(StreamReader);
WebRequest request = WebRequest.Create(url);
response = request.GetResponse();
remoteStream = response.GetResponseStream();
readStream = new StreamReader(remoteStream);
return remoteStream;
}
}
}

After you build this class library project, Refer the dll in console application.

Here is the code for generating QR code and download that QR code in your local computer as png format

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QRGenWrapper;
using System.Drawing;

namespace QRUsage
{
class QRGenerator
{
  
static void Main(string[] args)
{
QRCodeGenerator generator = new QRCodeGenerator();
Console.WriteLine("Enter Address");
var address = Console.ReadLine();
Stream output = generator.Generate(address);
Image img = Image.FromStream(output);
img.Save("D:/QRCode/" + address + ".png");
Console.WriteLine(img);
output.Close();
Console.ReadLine();
}
}
}


Related Solutions

DO IN C++ Secret Codes! Create a program that will accept a message from the user...
DO IN C++ Secret Codes! Create a program that will accept a message from the user and either encrypt ordecrypt it with the following algorithms: To encrypt: - get the character you wish to encrypt - find the index of that character in the alphabet array - add the shift offset to the index - add the increment to the index - "wrap around" the new index so the result is between 0 and 29 - find the character at...
Needed in C++ In this assignment, you are asked to create a class called Account, which...
Needed in C++ In this assignment, you are asked to create a class called Account, which models a bank account. The requirement of the account class is as follows (1) It contains two data members: accountNumber and balance, which maintains the current account name and balance, respectively. (1) It contains three functions: functions credit() and debit(), which adds or subtracts the given amount from the balance, respectively. The debit() function shall print ”amount withdrawn exceeds the current balance!” if the...
C++ HW Aim of the assignment is to write classes. Create a class called Student. This...
C++ HW Aim of the assignment is to write classes. Create a class called Student. This class should contain information of a single student. last name, first name, credits, gpa, date of birth, matriculation date, ** you need accessor and mutator functions. You need a constructor that initializes a student by accepting all parameters. You need a default constructor that initializes everything to default values. write the entire program.
This assignment will test your knowledge and skills in C++. Create a class named employee and...
This assignment will test your knowledge and skills in C++. Create a class named employee and have the data members of: Name ID Salary Create a class named manager that inherits the employee class and adds the data members: Managed_Employees (Array of up to 3 employees) Department Create methods to update each data member in the employee class. Create a method to print out the managed employees sorted by their salary in the manager class. (You can use one of...
Using C# Create a class called Artist that contains 4 pieces of information as instance variables:...
Using C# Create a class called Artist that contains 4 pieces of information as instance variables: name (datatype string), specialization – i.e., music, pottery, literature, paintings (datatype string), number of art items (datatype int), country of birth (datatype string). Create a constructor that initializes the 4 instance variables. The Artist class must contain a property for each instance variable with get and set accessors. The property for number should verify that the Artist contributions is greater than zero. If a...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class,...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) id: String   (5 pts) hours: int   (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an exception...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
C++ Create an ArrayBag template class from scratch. This will require you to create two files:...
C++ Create an ArrayBag template class from scratch. This will require you to create two files: ArrayBag.hpp for the interface and ArrayBag.cpp for the implementation. The ArrayBag class must contain the following protected members: static const int DEFAULT_CAPACITY = 200; // max size of items_ ItemType items_[DEFAULT_CAPACITY]; // items in the array bag int item_count_; // Current count of items in bag /** @param target to be found in items_ @return either the index target in the array items_ or...
A header file contains a class template, and in that class there is a C++ string...
A header file contains a class template, and in that class there is a C++ string object. Group of answer choices(Pick one) 1)There should be a #include for the string library AND a using namespace std; in the header file. 2)There should be a #include for the string library. 3)There should be a #include for the string library AND a using namespace std; in the main program's CPP file, written before the H file's include.
directions: use c++ Create a  ContactInfo class that contains the following member variables: name age phoneNumber The...
directions: use c++ Create a  ContactInfo class that contains the following member variables: name age phoneNumber The ContactInfo class should have a default constructor that sets name = "", phoneNumber = "", and age = 0. The ContactInfo class should have a constructor that accepts the name and phone number as parameters and sets name = <value of parameter name>, aAge = 0, and phoneNumber = <value of parameter phone number>. The ContactInfo class should have accessor and mutator functions for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT