Reflection tip, IsOverridden

September 19th, 2008 by Matteo Valdina

Reflection is a power tool of managed language like Java and .NET (C#, VB.NET,C++/CLI and others). In the last days I have discovered that MethodInfo class don’t provide a method to check if is overridden or not.This activity is vary simple but on internet you can found a dozen of example about Reflection without one about this case.


   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Text;
   4:  using System.Reflection;
   5:  
   6:  namespace ReflectionMethod
   7:  {
   8:      internal class Program
   9:      {
  10:          static void Main(string[] args)
  11:          {
  12:              BaseClass derived = new DerivedClass();
  13:  
  14:              Type type = derived.GetType();
  15:  
  16:              MethodInfo method1 = type.GetMethod("Method2");
  17:  
  18:              Console.WriteLine(String.Format("This method is overridden? {0}",
  19:                  IsOverridden(method1)));
  20:  
  21:              Console.ReadKey();
  22:          }
  23:  
  24:          public static Boolean IsOverridden(MethodInfo info)
  25:          {
  26:              MethodInfo baseDef = info.GetBaseDefinition();
  27:  
  28:              return !(info.DeclaringType.FullName == baseDef.DeclaringType.FullName);
  29:          }
  30:      }
  31:  }

Hug a developer today

September 14th, 2008 by Matteo Valdina

Thanks Franks

Rapporti…

September 14th, 2008 by Matteo Valdina

A destra uno storico 20SC (che fa la polvere sul mio scaffale :-( ) a sinistra una comune micro SD della SanDisk. Il primo 20 MB il secondo nella foto 1GB. Un rapporto di 1 : 50 di capacita. Di dimensioni:

  • Micro SD: 15 mm × 11 mm × 1 mm
  • 20SC: invece 70 mm 240 mm x 265 mm

Volume :

  • Micro SD: 165 mm3
  • 20SC: 4452000 mm3

Il che significa che il 20SC è 27 mila volte più grande della Micro SD  :-o

Make WiX setup for a Wizard of Visual Studio

August 31st, 2008 by Matteo Valdina

For learns the WiX toolset I have decided to write a setup for install a Wizard of Visual Studio. This setup is very easy with WiX and his Visual Studio extension.

This wxs file make the follow steps:

  1. Install the IWizard implementation in the GAC repository of target system.
  2. Copy the Template for Visual Studio 2005 or 2008 in his ProjectTemplate folder.
  3. Execute the command to install the template in visual studio (devenv /installvstemplates)

Read the rest of this entry »

STRIP Planner RoboCaffè

August 25th, 2008 by Matteo Valdina

Si tratta di un progettino per il corso di inteligenza artificiale, in sostanza è un pianificatore STRIPS scritto in prolog (algoritmo usato A*).
Il problema che modella è quello di un robot che deve portare il caffè a varie persone disponendo di due macchinette del caffè.
Read the rest of this entry »

How to Domain Name Service

August 25th, 2008 by Matteo Valdina

I DNS, acronimo di “Domain Name Service”, è uno dei servizi essenziali di Internet. Questo servizio ha il compito di gestire la risoluzione di nomi in indirizzi IP e l’inverso, possiamo quindi scrivere www.spremuta.com invece di 154.34.22.7.
Prima di addentrarci nel lato tecnico vediamo cosa e perché è stato inventato il servizio dei DNS.
Agli albori della rete, quando erano pochi i computer, la gestione dei nomi e degli indirizzi IP era affidata al file di nome “hosts” presente nelle macchine colllegate alla rete. Questo file è presente nella cartella /etc dei sistemi UNIX-like o in Windows sotto la cartella di sistema, in system32/drivers/etc (per dire due nomi noti ;-) ).
Il file hosts è una semplice lista di indirizzi e nomi che vengono consultati localmente per risolvere i nomi e gli indirizzi.

Read the rest of this entry »

Quick install JBoss + MySQL su Win

August 24th, 2008 by Matteo Valdina

Questa piccola guida serve a spiegare a chi non ha conoscenze tecniche da Sistemista/Programmatore di installare delle Web Applicazioni e testarle.

Prima di tutto bisogna procurarsi gli installer di MySQL (io installo la 4.1) e l’installer di JBoss (scarico la 4.0.x l’installar che è un file jar). Come prerequisito deve essere gia installato Java nella versione 1.4 o superiore dal sito di sun. Read the rest of this entry »

Conversioni

August 15th, 2008 by Matteo Valdina

Il computer fin dalle origini comprende un ristretto vocabolario di simboli, cosi ristretto che sono solo due, 0 e 1, anche detti true e false, vero o falso 0V +5V, on off, comunque due restano.

Noi invece siamo abituati ad avere un vocabolario di simboli estremamente più ampio, nel nostro alfabeto possiamo contare ben 22 lettere e con esse possiamo sbizzarrirci con le parole più strane.

Invece per i numeri possiamo lavorare direttamente con 10 simboli questa però non è l’unica possibile rappresentazione dei numeri. E’ solo una delle tante possibili rappresentazioni dei numeri detta appunto rappresentazione in base 10. Ne esistono altre come la rappresentazione in base 8 o 16 o ancora 2. Il computer rappresenta i numeri in base 2, sfruttando cosi il suo povero vocabolario di due simboli.

Read the rest of this entry »

Replace a node with a set of nodes

July 13th, 2008 by Matteo Valdina

In the last days in a my program, I should substitute a single node with a set of Node. The DOM interface (in this program I’m using the Xerces library) doesn’t provides an useful method to replace a single Node to a set of Nodes.

For apply this piece of code you should have:

  • parent node: The parent of the node that you want substitute;
  • target node: The node that you want substitute;
  • newNodes nodes: A set of nodes that you want add to the place of target node;

The code is the follow:

   1:  Node previous = null;
   2:  for(int i = newNodes.size() -1 ; i >= 0 ; i--) {
   3:      Node current = newNodes.get(i);
   4:  
   5:      if(i == newNodes.size() -1) {
   6:          parent.replaceChild(current, target);
   7:      } else {
   8:          parent.insertBefore(current, previous);
   9:      }
  10:      previous = current;
  11:  }

Pianificatore Ak

July 6th, 2008 by Matteo Valdina

Ed adesso un pò di teoria sui pianificatori. Eccovi un documento che riassume un breve scorcio sul pianificatore condizonale “Ak”.

http://www.matteozan.it/data/Ak.pdf