Exemplo n.º 1
0
        public string this[string name]
        {
            get
            {
                if (name == "Name")
                {
                    if (string.IsNullOrEmpty(Name.Trim()))
                    {
                        return("The name is empty.");
                    }

                    // Validate the invalid characters
                    try
                    {
                        string toValidate = _package.Name;
                        if (Path.IsPathRooted(_package.Name))
                        {
                            // Skip the root
                            toValidate = toValidate.Substring(Path.GetPathRoot(_package.Name).Length);
                        }

                        if (toValidate.IndexOfAny(Path.GetInvalidFileNameChars().Where(c => c != '\\').ToArray <char>()) != -1)
                        {
                            return("The name contains invalid characters.");
                        }
                    }
                    catch (Exception e)
                    {
                        return(e.Message);
                    }

                    // Check for name duplicates
                    if (NameHelpers.IsDuplicated(
                            _package.Name,
                            ProjectViewModel.Current.ManualPackagingInfo.Packages.Select(p => p.Name),
                            StringComparison.OrdinalIgnoreCase))
                    {
                        return("Package name is duplicated.");
                    }
                }

                return(null);
            }
        }