Skip to content

Instantly share code, notes, and snippets.

@ToJans
Created February 3, 2010 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToJans/293741 to your computer and use it in GitHub Desktop.
Save ToJans/293741 to your computer and use it in GitHub Desktop.
// we need macros in c#, look at the need for all the implicit operator stuff !!!
public class XLat<T>
{
public virtual T DefaultInstance { get; set; }
public virtual IList<XLatInstance<T>> XLatInstances { get; set; }
public XLat()
{
XLatInstances = new List<XLatInstance<T>>();
}
public static implicit operator XLat<T>(T instance)
{
return new XLat<T>() { DefaultInstance = instance };
}
public static implicit operator XLat<T>(string instance)
{
return new XLat<T>() { DefaultInstance = (T)Convert.ChangeType(instance,typeof(T))};
}
}
public class XLatInstance<T> : ModelBase
{
public virtual Taal Taal { get; set; }
public virtual T Tekst { get; set; }
}
public class XNonEmptyShortText : XLat<NonEmptyShortText>
{
public static implicit operator XNonEmptyShortText(string x)
{
return new XNonEmptyShortText() { DefaultInstance = x};
}
}
public class XNonEmptyNormalText : XLat<NonEmptyNormalText>
{
public static implicit operator XNonEmptyNormalText(string x)
{
return new XNonEmptyNormalText() { DefaultInstance = x };
}
}
public class XNonEmptyLongText : XLat<NonEmptyLongText>
{
public static implicit operator XNonEmptyLongText(string x)
{
return new XNonEmptyLongText() { DefaultInstance = x };
}
}
public class XNonEmptyMemoText : XLat<NonEmptyMemoText>
{
public static implicit operator XNonEmptyMemoText(string x)
{
return new XNonEmptyMemoText() { DefaultInstance = x };
}
}
public class XShortText : XLat<ShortText>
{
public static implicit operator XShortText(string x)
{
return new XShortText() { DefaultInstance = x };
}
}
public class XNormalText : XLat<NormalText>
{
public static implicit operator XNormalText(string x)
{
return new XNormalText() { DefaultInstance = x };
}
}
public class XLongText : XLat<LongText>
{
public static implicit operator XLongText(string x)
{
return new XLongText() { DefaultInstance = x };
}
}
public class XMemoText : XLat<MemoText>
{
public static implicit operator XMemoText(string x)
{
return new XMemoText() { DefaultInstance = x };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment