Esempio n. 1
0
        static CompletionDataList GetPageAttributeValues(AspNetAppProject project, FilePath fromFile, string attribute)
        {
            var list = new CompletionDataList();

            switch (attribute.ToLowerInvariant())
            {
            //
            //boolean, default to false
            //
            case "async":
            case "aspcompat":
            case "explicit":           // useful for VB only. set to true in machine.config
            case "maintainscrollpositiononpostback":
            case "linepragmas":        //actually not sure if this defaults true or false
            case "smartnavigation":
            case "strict":             //VB ONLY
            case "trace":
                SimpleList.AddBoolean(list, false);
                break;

            //
            //boolean, default to true
            //
            case "autoeventwireup":
            case "buffer":
            case "enableeventvalidation":
            case "enablesessionstate":
            case "enabletheming":
            case "enableviewstate":
            case "enableviewstatemac":
            case "validaterequest":             //enabled in machine.config
            case "debug":
                SimpleList.AddBoolean(list, true);
                break;

            //
            //specialised hard value list completions
            //
            case "codepage":
                list.AddRange(from e in Encoding.GetEncodings() select e.CodePage.ToString());
                list.DefaultCompletionString = Encoding.UTF8.CodePage.ToString();
                break;

            case "compilationmode":
                SimpleList.AddEnum(list, System.Web.UI.CompilationMode.Always);
                break;

            case "culture":
                list.AddRange(from c in CultureInfo.GetCultures(CultureTypes.AllCultures) select c.Name);
                list.DefaultCompletionString = CultureInfo.CurrentCulture.Name;
                break;

            case "lcid":
                //  locale ID, MUTUALLY EXCLUSIVE with Culture
                list.AddRange(from c in CultureInfo.GetCultures(CultureTypes.AllCultures)
                              select c.LCID.ToString());
                list.DefaultCompletionString = CultureInfo.CurrentCulture.LCID.ToString();
                break;

            case "responseencoding":
                list.AddRange(from e in Encoding.GetEncodings() select e.Name);
                list.DefaultCompletionString = Encoding.UTF8.EncodingName;
                break;

            case "tracemode":
                list.Add("SortByTime");
                list.Add("SortByCategory");
                list.DefaultCompletionString = "SortByTime";
                break;

            case "transaction":
                list.Add("Disabled");
                list.Add("NotSupported");
                list.Add("Required");
                list.Add("RequiresNew");
                list.DefaultCompletionString = "Disabled";
                break;

            case "viewstateencryptionmode":
                SimpleList.AddEnum(list, ViewStateEncryptionMode.Auto);
                break;

            case "warninglevel":
                list.AddRange(new string[] { "0", "1", "2", "3", "4" });
                list.DefaultCompletionString = "0";
                break;

            case "masterpagefile":
                return(project != null
                                        ? MonoDevelop.Html.PathCompletion.GetPathCompletion(project, "*.master", fromFile,
                                                                                            x => "~/" + x.ProjectVirtualPath.ToString().Replace(System.IO.Path.PathSeparator, '/'))
                                        : null);

            //
            //we can probably complete these using info from the project, but not yet
            //

            /*
             * case "CodeFile":
             *      //source file to compile for codebehind on server
             * case "ContentType":
             *      //string, HTTP MIME content-type
             * case "CodeFileBaseClass":
             *      // known base class for the partial classes, so code generator knows not
             *      //to redefine fields to ignore members in partial class
             * case "ErrorPage":
             *      // string, URL
             * case "Inherits":
             *      //  IType : Page. defaults to namespace from ClassName
             * case "Language":
             *      //  string, any available .NET language
             * case "Src":
             *      //  string, extra source code for page
             * case "StyleSheetTheme":
             *      //  theme ID, can be overridden by controls
             * case "Theme":
             *      //  theme identifier, overrides controls' themes
             * case "UICulture":
             *      //  string, valid UI culture
             */

            //
            //we're not likely to suggest anything for these:
            //

            /*
             * case "AsyncTimeOut":
             *      // int in seconds, default 45
             * case "ClassName":
             *      //string, .NET name, default namespace ASP
             * case "ClientTarget":
             *      //string, user agent
             * case "CodeBehind":
             *      //valid but IGNORE. VS-only
             * case "CompilerOptions":
             *      //string, list of compiler switches
             * case "Description":
             *      // string, pointless
             * case "TargetSchema":
             *      //  schema to validate page content. IGNORED, so rather pointless
             * case "Title":
             *      //  string for <title>
             */
            default:
                return(null);
            }

            return(list.Count > 0? list : null);
        }