lunes, 28 de junio de 2010

Configuración de un proxy en un sitio de sharepoint

Estabamos teniendo problemas al momento de que uno de nuestros sitios se conectaba a un web services externo. Dicho problema empezo cuando en la empresa se implemento un proxy. La solución es muy sencilla, en el web.config del sitio, agregar las siguientes lineas

y buala... todo funciona correctament...

Como validar un valor Guid

Buenas tardes.. Hay veces que necesitamos verificar si un valor es un campo de tipo guid. A continuación les coparto una función que me encontre en la red para eso...


private static Regex isGuid = new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", RegexOptions.Compiled);

internal static bool IsGuid(string candidate, out Guid output)

{

bool isValid = false;

output=Guid.Empty;

if(candidate!=null)

{

if (isGuid.IsMatch(candidate))

{

output=new Guid(candidate);

isValid = true;

}

}

return isValid;

}

Como convertir un Array a Generic List

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
static void Main()
{
// 1.
// String array

string[] s = new string[]
{
"one",
"two",
"three",
"four",
"five"
};
// 2A.
// Convert with new List constructor.

List l = new List(s);

// 2B.
List l2 = s.ToList();
}
}