WordPress iPhone app

The wordpress app has a place in the Rewind 2010: iPhone apps list. I’m using it to publish this item. Works great. Go install it.

Posted in Tooling | Leave a comment

WCF Discovery

A new feature in WCF4.0 is buildin Discovery. With Discovery a Hello message is send to the Discovery service when a service starts. This way the Discovery service knows the services is available. Whenever the service stops a Goodbye message is send to notify the Discovery service it is no longer available. Microsoft has a greate sample about this here. I expanded the sample to find a service by its contract.

[ServiceContract]
public interface IDiscoveryService
{
     [OperationContract]
     string[] GetOnlineServices(XmlQualifiedName criteria);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class DiscoveryService : DiscoveryProxy, IDiscoveryService
{
// DiscoveryProxy overides must come here
// GetOnlineServices implementation
public string[] GetOnlineServices(XmlQualifiedName criteria)
{
     List<string> result = new List<string>();
     List<EndpointDiscoveryMetadata> foundServices = _theLogic.FindInOnlineServices(criteria);
     foreach (EndpointDiscoveryMetadata foundService in foundServices)
     {
          result.Add(foundService.Address.ToString());
     }
     return result.ToArray();
}
}
// client code to find IPrint service addresses
IDiscoveryService discoveryProxy = new DiscoveryServiceProxy();
ContractDescription cd = ContractDescription.GetContract(typeof(IPrint));
XmlQualifiedName qn = new XmlQualifiedName(cd.Name, cd.Namespace);
string[] addresses = discoveryProxy.GetOnlineServices(qn);
Posted in Development | Leave a comment

Many-to-any link back to parent

ActivRecord has a feature to create relations between tables with the name of the table as a variable.
The example deals with payment and order. A payment can be iDeal or PayPal. The dotNET code uses a interface (IPayment) which both classes implement.

public partial class Order
{
  [HasManyToAny(typeof(IPayment), "OrderId", "OrderPayments", typeof(Guid), "PaymentType", "PaymentId", MetaType = typeof(string))]
  [Any.MetaValue("iDeal", typeof(iDeal))]
  [Any.MetaValue("PayPal", typeof(PayPal))]
  public virtual IList<IPayment> Payments { get; set; }
}

In the database a table is created with fields OrderId, PaymentType and PaymentId. OrderId contains the key of the Order table, PaymentId contains the key of the referenced table and PaymentType contains the name of the referenced table. (iDeal or PayPal)
Now I need a link from Payment to Order. But no examples shows me that implementation.
Looking at it functionaly: it should be the same relation but the other way around, where the type always is the actual type of the class we are starting from.

public partial class iDeal : IPayment
{
  [HasManyToAny(typeof(Order), "OrderId", "OrderPayments", typeof(Guid), "PaymentType", "PaymentId", MetaType = typeof(string))]
  [Any.MetaValue("iDeal", typeof(Order))] // PaymentType should always be iDeal 
  public virtual IList<Order> Orders { get; set; }
}

Now create a property that reads and writes the first element of the Orders list and the many-to-any link back to the parent is created.

Posted in Development, Tooling | Leave a comment

Azure configuration

My cloud project with Azure progresses. The packages must be installable to multiple Azure environments. This means configuration. But how to make changes to the web.config of my WebRoles?
One option is to NOT encrypt the package as described here, but that means changing twee files. In the scfg file the DiagnosticsConnectionString lives. Why can’t I put everything int he cscfg file?
I removed the endpoints (that’s what started all this) from the web.config. Using unity for environment switching I construct a proxy that reads the endpoint information from the cscfg file. Now I only have to change one file. As a bonus I can change the endpoints after it is installed in the cloud.

Posted in Development | Leave a comment

Frameworks puzzle

I’m building a new tool and my focus should be on the new problem the tool is going to solve. The basic problems a developer faces I want to solve with known solutions/frameworks. These are my choises:

  • Antlrworks + Antlr: generate a parser to validate and parse the input
  • ActiveRecord: build on top of nHibernate to manage my data
  • Sqlite: lightweight database, not realy a framework, but a solution for my problem
  • ExcelLibrary: read and write to MS Excel, without MS Excel, more a util

Now my focus can be on the real tool: an EVT tool.

Posted in Development | Leave a comment