Mostrando las entradas con la etiqueta Methods. Mostrar todas las entradas
Mostrando las entradas con la etiqueta Methods. Mostrar todas las entradas

viernes, 30 de septiembre de 2016

El Libro del Día: Exam Ref 70-480 Programming in HTML5 with JavaScript and CSS3

El Libro del Día: 2016-09-30

Titulo: Exam Ref 70-480 Programming in HTML5 with JavaScript and CSS3
Autor: Rick Delorme
Editorial: Microsoft Press
Nro Paginas: 353

Capítulos:
Chapter 1 Implement and manipulate document structures and objects
- Objective 1.1: Create the document structure
- Objective 1.2: Write code that interacts with UI controls
- Objective 1.3: Apply styling to HTML elements programmatically
- Objective 1.4: Implement HTML5 APIs
- Objective 1.5: Establish the scope of objects and variables
- Objective 1.6: Create and implement objects and methods
Chapter 2 Implement program flow
- Objective 2.1: Implement program flow
- Objective 2.2: Raise and handle an event
- Objective 2.3: Implement exception handling
- Objective 2.4: Implement a callback
- Objective 2.5: Create a web worker process
Chapter 3 Access and secure data
- Objective 3.1: Validate user input by using HTML5 elements
- Objective 3.2: Validate user input by using JavaScript
- Objective 3.3: Consume data
- Objective 3.4: Serialize, deserialize, and transmit data
Chapter 4 Use CSS3 in applications
- Objective 4.1: Style HTML text properties
- Objective 4.2: Style HTML box properties
- Objective 4.3: Create a flexible content layout
- Objective 4.4: Create an animated and adaptive UI
- Objective 4.5: Find elements using CSS selectors and jQuery
- Objective 4.6: Structure a CSS file by using CSS selectors

Descarga:
ExamRef_70480_Programming_HTML5_JavaScript_CSS3

jueves, 28 de julio de 2016

El Libro del Día: Essential C# 6.0

El Libro del Día: 2016-07-28

Titulo: Essential C# 6.0 (5th Edition)
Autor: Mark Michaelis, Eric Lippert
Editorial: Addison Wesley
Nro Paginas: 1046

Capítulos:
1 Introducing C#
2 Data Types
3 Operators and Control Flow
4 Methods and Parameters
5 Classes
6 Inheritance
7 Interfaces
8 Value Types
9 Well-Formed Types
10 Exception Handling
11 Generics
12 Delegates and Lambda Expressions
13 Events
14 Collection Interfaces with Standard Query Operators
15 LINQ with Query Expressions
16 Building Custom Collections
17 Reflection, Attributes, and Dynamic Programming
18 Multithreading
19 Thread Synchronization
20 Platform Interoperability and Unsafe Code
21 The Common Language Infrastructure
A Downloading and Installing the C# Compiler and CLI Platform
B Tic-Tac-Toe Source Code Listing
C Interfacing with Multithreading Patterns prior to the TPL and C# 6.0
D Timers Prior to the Async/Await Pattern of C# 5.0

Descarga:
Essential_C#_6.0

martes, 9 de febrero de 2016

El Libro del Día: Meteor in Action

El Libro del Día: 2016-02-09

Titulo: Meteor in Action 
Autor: Stephan Hochhaus, Manuel Schoebel
Editorial: Manning
Nro Paginas: 372

Capítulos:
Part 1: Look - A Shoting Start
1. A better way to build apps
2. My fridge. A reactive game
Part 2: 3,2,1 - Impact
3. Working with templates
4. Working with data
5. Fully reactive editing
6. Users, authentications, and permissions
7. Exchanging data
8. Routing using Iron.Router
9. The package system
10. Advanced server methods
Part 3: Leaving the Crater
11. Building and debugging
12. Going into production

Descarga:
Meteor_in_Action

jueves, 29 de enero de 2015

El Libro del Día: Microsoft Visual C# 2013 Step by Step

El Libro del Día: 2015-01-29

Titulo: Microsoft Visual C# 2013 Step by Step
Autor: John Sharp
Editorial: Microsoft Press
Nro Paginas: 824

Capítulos:
Part I INTRODUCING MICROSOFT VISUAL C# AND MICROSOFT VISUAL STUDIO 2013
Chapter 1 Welcome to C#
Chapter 2 Working with variables, operators, and expressions
Chapter 3 Writing methods and applying scope
Chapter 4 Using decision statements
Chapter 5 Using compound assignment and iteration statements
Chapter 6 Managing errors and exceptions
Part II UNDERSTANDING THE C# OBJECT MODEL
Chapter 7 Creating and managing classes and objects
Chapter 8 Understanding values and references
Chapter 9 Creating value types with enumerations and structures
Chapter 10 Using arrays
Chapter 11 Understanding parameter arrays
Chapter 12 Working with inheritance
Chapter 13 Creating interfaces and defining abstract classes
Chapter 14 Using garbage collection and resource management
Part III DEFINING EXTENSIBLE TYPES WITH C#
Chapter 15 Implementing properties to access fields
Chapter 16 Using indexers
Chapter 17 Introducing generics
Chapter 18 Using collections
Chapter 19 Enumerating collections
Chapter 20 Decoupling application logic and handling events
Chapter 21 Querying in-memory data by using query expressions
Chapter 22 Operator overloading
Chapter 23 Improving throughput by using tasks
Chapter 24 Improving response time by performing asynchronous operations
Chapter 25 Implementing the user interface for a Windows Store app
Chapter 26 Displaying and searching for data in a Windows Store app
Chapter 27 Accessing a remote database from a Windows Store app

Descarga:
Microsoft_Visual_C#_2013_Step_by_Step

lunes, 13 de octubre de 2014

El Libro del Día: Head First jQuery

El Libro del Día: 2014-10-13

Titulo: Head First jQuery
Autor: Ryan Benedetti, Ronan Cranley
Editorial: O'Reilly
Nro Paginas: 538

Capítulos:
1 Getting Started with jQuery: Web Page Action
2 Selectors and Methods: Grab and Go
3 jQuery Events and Functions: Making Things Happen on Your Page
4 jQuery Web Page Manipulation: Mod the DOM
5 jQuery Effects and Animation: A Little Glide in Your Stride
6 jQuery and JavaScript: Luke jQuery, I Am Your Father
7 Custom Functions for Custom Effects: What Have You Done for Me Lately
8 jQuery and Ajax: Please Pass the Data
9 Handling JSON Data: Client, Meet Server
10 jQuery UI: Extreme Form Makeover
11 jQuery and APIs: Objects, Objects Everywhere
i Leftovers: The Top Ten Things (We Didn’t Cover)
ii Set Up a Development Environment: Get Ready for the Big Times

Descarga:
Head_First_jQuery

viernes, 26 de septiembre de 2014

El Libro del Día: jQuery Mobile Cookbook

El Libro del Día: 2014-09-26

Titulo: jQuery Mobile Cookbook
Autor: Chetan K Jain
Editorial: Packt
Nro Paginas: 320

Capítulos:
Chapter 1: Get Rolling
Chapter 2: Pages and Dialogs
Chapter 3: Toolbars
Chapter 4: Buttons and Content Formatting
Chapter 5: Forms
Chapter 6: List Views
Chapter 7: Configurations
Chapter 8: Events
Chapter 9: Methods and Utilities
Chapter 10: The Theme Framework
Chapter 11: HTML5 and jQuery Mobile

Descarga:
jQuery_Mobile_Cookbook

miércoles, 27 de agosto de 2014

El Libro del Día: Expert C# 5.0

El Libro del Día: 2014-08-27

Titulo: Expert C# 5.0
Autor: Mohammad Rahman
Editorial: Apress
Nro Paginas: 609

Capítulos:
Chapter 1: Reintroducing C#:-A Detailed Look at the Language We All Know
Chapter 2: C# Objects in Memory
Chapter 3: Parameters
Chapter 4: Methods
Chapter 5: Automatic Property Declaration
Chapter 6: Enum
Chapter 7: Delegate
Chapter 8: Event
Chapter 9: Foreach and Iterator
Chapter 10: The String Data Type
Chapter 11: Collections Explained
Chapter 12: Linq in C#
Chapter 13: Exception Management
Chapter 14: Asynchrony
Chapter 15: Diagnostic Tools in .NET

Descarga:
Expert_C#_5.0

martes, 15 de julio de 2014

El Demo del Día: Visor de Objetos con Reflection (NET Object Viewer)

Visor de Objetos con Reflection (NET Object Viewer)

Requerimientos
- Se desea ver los tipos que hay dentro de un ensamblado .NET: interfaces, enumeraciones, clases, etc.
- Se desea listar las propiedades de un tipo.
- Se desea listar los métodos de un tipo.
- Se desea ver los parámetros de un método.
- Se desea abrir dinámicamente un formulario pasando como parámetro su nombre.
- Se desea ejecutar cualquier método pasando los valores de sus parámetros, incluyendo métodos sobrecargados (varios con el mismo nombre pero con diferentes parámetros).

Solución
Usar Reflection para obtener información del Ensamblado, sus Tipos y miembros, también para crear instancias de objetos en forma dinámica y ejecutar cualquier método.

A continuación les detallo el código de un Utilitario que he creado hace varios años pero que lo he mejorado para probar los métodos sobre cargados y para pasar parámetros.

Crear la Aplicación Windows Forms en C#

Crear un proyecto Windows Forms en C# llamado: "NetObjectViewer" y agregar una clase llamada "Rutinas" para poder probar sus métodos mediante el visor.

using System;
using System.Windows.Forms;

namespace NetObjectViewer
{
    public class Rutinas
    {
        public void mostrarMensaje()
        {
            MessageBox.Show("Hola que tal");
        }

        public void mostrarMensaje(string nombre)
        {
            MessageBox.Show("Hola que tal " + nombre);
        }

        public void mostrarMensaje(string nombre,string apellido)
        {
            MessageBox.Show("Hola que tal " + nombre + " " + apellido);
        }

        public int sumaEnteros(int x, int y)
        {
            return (x+y);
        }

        public int sumaEnteros(int x, int y,int z)
        {
            return (x + y +z);
        }

        public decimal sumaDecimal(decimal x, decimal y)
        {
            return (x + y);
        }

        public decimal sumaDecimal(decimal x, decimal y, decimal z)
        {
            return (x + y + z);
        }
    }
}

Crear el Formulario con el Visor de Objetos

Cambiar el nombre del formulario a "frmVisor" y realizar el diseño tal como se muestra a continuación.


Escribir el siguiente código en el formulario:
using System;
using System.Text; //StringBuilder
using System.Drawing;
using System.Collections.Generic; //List
using System.Reflection; //Assembly, Type, PropertyInfo, MethodInfo
using System.Windows.Forms;

namespace NetObjectViewer
{
    public partial class frmVisor : Form
    {
        private Assembly oEnsamblado;
        private Type[] oTipos;

        public frmVisor()
        {
            InitializeComponent();
        }

        private void configurarGrilla(object sender, EventArgs e)
        {
            DataGridViewTextBoxColumn col1=new DataGridViewTextBoxColumn();
            col1.Width=100;
            col1.ReadOnly = true;
            dgvParametro.Columns.Add(col1);
            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
            col2.Width = 80;
            dgvParametro.Columns.Add(col2);
        }

        private void abrirEnsamblado_ListarTipos(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Selecciona Archivo exe o dll de .NET";
            ofd.Filter = "Archivos ensamblados .NET|*.exe;*.dll";
            if (ofd.ShowDialog().Equals(DialogResult.OK))
            {
                txtEnsamblado.Text = ofd.FileName;
                try
                {
                    oEnsamblado = Assembly.LoadFrom(ofd.FileName);
                    //Limpiar las listas
                    dgvParametro.Rows.Clear();
                    lstMetodo.Items.Clear();
                    lstPropiedad.Items.Clear();
                    lstTipo.Items.Clear();
                    //Listar los tipos
                    oTipos = oEnsamblado.GetTypes();
                    lstTipo.BeginUpdate();
                    foreach (Type oTipo in oTipos)
                    {
                        lstTipo.Items.Add(oTipo.Name);
                    }
                    lstTipo.EndUpdate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        private void listarMiembros(object sender, EventArgs e)
        {
            Type oTipo = oTipos[lstTipo.SelectedIndex];
            //Limpiar las listas
            dgvParametro.Rows.Clear();
            lstMetodo.Items.Clear();
            lstPropiedad.Items.Clear();
            //Listar las propiedades
            PropertyInfo[] oPropiedades = oTipo.GetProperties();
            lstPropiedad.BeginUpdate();
            foreach (PropertyInfo oPropiedad in oPropiedades)
            {
                lstPropiedad.Items.Add(oPropiedad.Name);
            }
            lstPropiedad.EndUpdate();
            //Listar los metodos
            MethodInfo[] oMetodos = oTipo.GetMethods();
            lstMetodo.BeginUpdate();
            StringBuilder sb=new StringBuilder();
            ParameterInfo[] oParametros;
            foreach (MethodInfo oMetodo in oMetodos)
            {
                sb.Clear();
                sb.Append(oMetodo.Name);
                sb.Append("(");
                oParametros = oMetodo.GetParameters();
                for (int i = 0; i < oParametros.Length; i++)
                {
                    sb.Append(oParametros[i].ParameterType.Name);
                    if (i < oParametros.Length-1) sb.Append(",");
                }
                sb.Append(")");
                lstMetodo.Items.Add(sb.ToString());
            }
            lstMetodo.EndUpdate();
        }

        private MethodInfo obtenerMetodo()
        {
            MethodInfo oMetodo = null;          
            string firmaMetodo = lstMetodo.Text;
            int posInicio = firmaMetodo.IndexOf("(");
            int posFin = firmaMetodo.Length - 1;
            string nombreMetodo = firmaMetodo.Substring(0, posInicio);
            string tipos = firmaMetodo.Substring(posInicio + 1, posFin - posInicio - 1);
            Type[] oPars = null;
            if (tipos.Length.Equals(0)) oPars = new Type[0] { };
            else
            {
                string[] entradas = tipos.Split(',');
                List<Type> listaPars = new List<Type>();
                for (int i = 0; i < entradas.Length; i++)
                {
                    listaPars.Add(Type.GetType("System." + entradas[i]));
                }
                oPars = listaPars.ToArray();
            }
            Type oTipo = oTipos[lstTipo.SelectedIndex];
            oMetodo= oTipo.GetMethod(nombreMetodo, oPars);
            return (oMetodo);
        }

        private void listarParametros(object sender, EventArgs e)
        {
            if (lstMetodo.SelectedIndex > -1)
            {
                MethodInfo oMetodo = obtenerMetodo();
                if (oMetodo != null)
                {
                    ParameterInfo[] oParametros = oMetodo.GetParameters();
                    dgvParametro.Rows.Clear();
                    dgvParametro.RowCount = oParametros.Length;
                    for (int i = 0; i < oParametros.Length; i++)
                    {
                        dgvParametro.Rows[i].Cells[0].Value = oParametros[i].Name;
                    }
                }
            }
            else MessageBox.Show("Selecciona el método a ver sus parámetros");
        }

        private void abrirFormulario(object sender, EventArgs e)
        {
            if (lstTipo.SelectedIndex > -1)
            {
                Type oTipo = oTipos[lstTipo.SelectedIndex];
                if (oTipo.BaseType.Name.Equals("Form"))
                {
                    object obj = Activator.CreateInstance(oTipo);
                    if (obj != null)
                    {
                        Form frm = (Form)obj;
                        frm.ShowDialog();
                    }
                }
                else MessageBox.Show("El tipo seleccionado No es un formulario");
            }
            else MessageBox.Show("Selecciona el formulario a abrir");
        }

        private void ejecutarMetodo(object sender, EventArgs e)
        {
            if (lstMetodo.SelectedIndex > -1)
            {
                MethodInfo oMetodo = obtenerMetodo();
                if (oMetodo != null)
                {
                    object[] pars = null;
                    ParameterInfo[] oParametros = oMetodo.GetParameters();
                    if (oParametros.Length > 0)
                    {
                        List<object> listaPars = new List<object>();
                        Type tipo=null;
                        object valor=null;
                        for (int i = 0; i < oParametros.Length; i++)
                        {
                            tipo = oParametros[i].ParameterType;
                            valor=dgvParametro.Rows[i].Cells[1].Value;
                            if (valor != null) listaPars.Add(Convert.ChangeType(valor, tipo));
                            else listaPars.Add(valor);
                        }
                        pars = listaPars.ToArray();
                    }
                    Type oTipo = oTipos[lstTipo.SelectedIndex];
                    object obj = Activator.CreateInstance(oTipo);
                    if (obj != null)
                    {
                        object rpta = oMetodo.Invoke(obj, pars);
                        if (rpta != null) MessageBox.Show(rpta.ToString());
                    }
                }
            }
            else MessageBox.Show("Selecciona el método a ejecutar");
        }
    }
}

Nota: El método controlador: "configurarGrilla"esta asociado al evento "Load" del formulario.

Ejecutar y Probar el Formulario Creado

Grabar la aplicación, compilar y ejecutar. En el evento load se crean las 2 columnas de la grilla de parámetros del método seleccionado.

Seleccionar un ensamblado, por ejemplo el propio ejecutable: "NetObjectViewer.exe" y luego seleccionar un tipo, por ejemplo el propio formulario.


Estando seleccionado el formulario "frmVisor" clic al botón "Abrir Formulario" y este se mostrará como un diálogo.

Seleccionar la clase "Rutinas" y luego seleccionar cualquier método, observar que aparece la grilla mostrando sus parámetros. Probar primero las funciones que no retornan valores y luego las que retornan valores, dando clic al botón "Ejecutar Método".

Si no se llenan los valores de los parámetros, por defecto es nulo, pero igual devuelve un resultado, ahora probar pasar parámetros escribiendo directamente sobre la segunda columna de la grilla y dando Enter para configurar el valor del parámetro. Luego clic al botón "Ejecutar Método" y ver el resultado con parámetros.


Nota: Si se selecciona un método que tiene parámetros de tipo objeto, la aplicación se caerá, falta controlar los parámetros de tipo objetos.

Comentario Final

En esta demostración hemos visto "Reflection" en acción para inspeccionar cualquier ensamblado (exe o dll) creado en .NET, listando algunos miembros como propiedades y métodos, también hemos creado dinámicamente objetos y ejecutado métodos, inclusive sobrecargados. Espero les guste y comenten.

Descarga
Demo11_NetObjectViewer