public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { NetworkCamera namedCamera; try { string cameraName = (string)value; if (context.Instance is IObjectDefinition) { IObjectDefinition objectBeingEditted = (IObjectDefinition)context.Instance; namedCamera = objectBeingEditted.Project().FindCamera(cameraName); } else if (context.Instance is FavoriteSettings) { namedCamera = ((FavoriteSettings)context.Instance).mTestSequence.project().FindCamera(cameraName); } else { throw new ArgumentException("alksdjaqwhkajlkaj"); } } catch { throw new ArgumentException("Can not convert '" + (string)value + "' to a camera"); } return(namedCamera); } return(base.ConvertFrom(context, culture, value)); }
public static string ExpandPath(IObjectDefinition theObject, string path) { path = path.Replace("<PROJECT>", theObject.Project().Name); path = path.Replace("<TESTSEQ>", theObject.TestSequence().Name); path = path.Replace("<TOOL>", theObject.TestSequence().Name); DateTime now = DateTime.Now; path = path.Replace("<YYYYMMDD>", now.ToString("yyyyMMdd")); path = path.Replace("<MM>", now.ToString("MM")); path = path.Replace("<DD>", now.ToString("dd")); path = path.Replace("<YY>", now.ToString("yy")); return(path); }