Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                IObjectDefinition objectBeingSelected;

                try
                {
                    string selectedObjectsName = (string)value;

                    if (selectedObjectsName.Length == 0)
                    {
                        return(null);
                    }

                    if (context.Instance is IObjectDefinition)
                    {
                        IObjectDefinition objectBeingEditted = (IObjectDefinition)context.Instance;
                        objectBeingSelected = LookupObject(objectBeingEditted.TestSequence(), selectedObjectsName);
                    }
                    else if (context.Instance is FavoriteSettings)
                    {
                        objectBeingSelected = LookupObject(((FavoriteSettings)context.Instance).mTestSequence, selectedObjectsName);
                    }
                    else
                    {
                        throw new ArgumentException("alksdjalksdlkajlkaj");
                    }
                }
                catch (ArgumentException e)
                {
                    throw e;
                }
                catch (Exception e)
                {
                    throw new ArgumentException("Problem finding object '" + (string)value + "'");
                }
                return(objectBeingSelected);
            }
            return(base.ConvertFrom(context, culture, value));
        }
Exemplo n.º 3
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                GlobalValue namedGlobalValue;

                try
                {
                    string globalValueName = (string)value;
                    if (globalValueName.Length == 0)
                    {
                        return(null);
                    }

                    if (context.Instance is IObjectDefinition)
                    {
                        IObjectDefinition objectBeingEditted = (IObjectDefinition)context.Instance;
                        namedGlobalValue = objectBeingEditted.TestSequence().GetGlobalValueIfExists(globalValueName);
                    }
                    else if (context.Instance is FavoriteSettings)
                    {
                        namedGlobalValue = ((FavoriteSettings)context.Instance).mTestSequence.GetGlobalValueIfExists(globalValueName);
                    }
                    else
                    {
                        throw new ArgumentException("alksdjalksdlkajlkaj");
                    }
                }
                catch
                {
                    throw new ArgumentException("Can not convert '" + (string)value + "' to an GlobalValue");
                }
                if (namedGlobalValue == null)
                {
                    throw new ArgumentException("GlobalValue '" + (string)value + "' couldn't be found.");
                }
                return(namedGlobalValue);
            }
            return(base.ConvertFrom(context, culture, value));
        }