string GetProjectFile(DirectoryInfo dir, DotNetLanguage language)
        {
            string projectFileFilter = String.Empty;

            if (language == DotNetLanguage.VB)
            {
                projectFileFilter = VBProjectFileFilter;
            }
            else if (language == DotNetLanguage.CSharp)
            {
                projectFileFilter = CSharpProjectFileFilter;
            }

            var projectFiles = dir.GetFiles(projectFileFilter, SearchOption.TopDirectoryOnly);

            if (null == projectFiles || projectFiles.Count() == 0)
            {
                if (null != dir.Parent)
                {
                    var projFile = GetProjectFile(dir.Parent, language);
                    return(projFile);
                }
                else
                {
                    return(String.Empty);
                }
            }
            else
            {
                return(projectFiles[0].FullName);
            }
        }
        string GetProjectFile(string codeFile)
        {
            var projFile = String.Empty;

            DotNetLanguage language = DotNetLanguage.Unknown;

            if (codeFile.EndsWith(VBFileExtension))
            {
                language = DotNetLanguage.VB;
            }
            else if (codeFile.EndsWith(CSharpFileExtension))
            {
                language = DotNetLanguage.CSharp;
            }
            else // resx? trdx?
            {
                language = DotNetLanguage.VB;
            }

            var fullName = Path.Combine(RepositoryFolder, codeFile);
            var dirName  = Path.GetDirectoryName(fullName);

            if (Directory.Exists(dirName))
            {
                var dir = new DirectoryInfo(dirName);
                projFile = GetProjectFile(dir, language);
            }
            return(projFile);
        }
 public TestScenario(string scenarioName, DotNetLanguage language, DotNetTemplate template, DotNetActions commands = DotNetActions.None)
 {
     ScenarioName = scenarioName;
     Template     = template;
     Language     = language;
     Commands     = commands;
 }
 public override void CreateUpdateMethod(StringBuilder sb, string updateStatement, DotNetLanguage.MemberInfo primaryKey)
 {
     sb.AppendFormat("Public Sub Update{0}(){4}Dim sb As New StringBuilder(){4}{4}sb.Append(\"UPDATE {0} SET \"){4}{1}{4}sb.Append(\" WHERE {2} = \").Append(obj.{3}).Append(\";\"){4}End Sub{4}{4}",
         ClassName, //0
         updateStatement, //1
         primaryKey.ColumnName, //2
         primaryKey.Property, //3
         Environment.NewLine); //4
 }
        public override void CreateProperty(StringBuilder sb, DotNetLanguage.MemberInfo info)
        {
            //Private Member
            sb.AppendFormat("Private {0} As {1}{2}", info.Member, info.SystemType, LineTerminator);

            if (IncludeWCFTags)
                sb.Append(DataMember);

            //Public Property
            sb.AppendFormat("Public Property {0} As {1}{3}Get{3}Return {2}{3}End Get{3}Set(value As {1}){3}{2} = value{3}End Get{3}End Property", info.Property, info.SystemType, info.Member, Environment.NewLine);
            sb.AppendLine().AppendLine();
        }
Beispiel #6
0
        //args array contains command-line arguments excluding executable
        //executable name is included in c++ args
        static int Main(string[] args)
        {
            Console.WriteLine("--  int  --");
            Console.WriteLine("minimum:" + int.MinValue);
            Console.WriteLine("maximum:" + int.MaxValue);
            Console.WriteLine("length:" + sizeof(int));
            Console.WriteLine();

            Console.WriteLine("--  float  --");
            Console.WriteLine("minimum:" + float.MinValue);
            Console.WriteLine("maximum:" + float.MaxValue);
            Console.WriteLine("length:" + sizeof(float));
            Console.WriteLine();

            //Because a string "modification" is actually a new string creation, you must use
            //caution when you create references to strings. If you create a reference to a string, and then "modify" the original string,
            //the reference will continue to point to the original object instead of the new object that was created when the string was modified. The following code illustrates this behavior:
            string name     = "coder";
            string nameCopy = name;

            //this call creates a new string in memory with both strings combined
            // previous value is still in memory until the garbage collector gets rid of it
            name += " maximus";
            Console.WriteLine("variable nameCopy still holds old value:" + nameCopy);

            Programmer manny = new Programmer();

            manny.Name = "manny";
            DotNetLanguage languageOfPreference = manny.languageOfPreference();

            if (languageOfPreference != DotNetLanguage.CSHARP)
            {
                Console.WriteLine("You know nothing!");
            }


            //asks console user for character input, preventing program from quitting
            Console.ReadLine();

            /*programs' main function can be void or return an int. It could be read by the caller of the program.
             * example: a command-line interface returns error codes that are used to determine the next call in a batch file */
            return(0);
        }
        public override void CreateProperty(StringBuilder sb, DotNetLanguage.MemberInfo info)
        {
            if (_buildOutProperties)
            {
                //Private Member
                sb.AppendFormat("private {0} {1}{2}", info.SystemType, info.Member, LineTerminator);

                if (IncludeWCFTags)
                    sb.Append(DataMember);

                //Public Property
                sb.AppendFormat("public {0} {1}{3}{{{3} get {{ return {2}; }}{3} set {{ {2} = value; }}{3}}} ", info.SystemType, info.Property, info.Member, Environment.NewLine);
            }
            else
            {
                if (IncludeWCFTags)
                    sb.Append(DataMember);

                sb.AppendFormat("{0} {1} {2} {{ get; set; }}", Public, info.SystemType, info.Property);
            }

            sb.AppendLine().AppendLine();
        }
        public static Assembly CreateAssembly(string code, string compilerVersion, DotNetLanguage language, bool compileInMemory, List<string> references, out List<DotNetScriptError> errors, IZeusContext context)
		{
			string tmpDirectory = System.Environment.CurrentDirectory;
			System.Environment.CurrentDirectory = RootFolder;

			Assembly generatedAssembly = null;
			string ext = ".cs", lang = "C#";
			errors = null;

			//Create an instance whichever code provider that is needed
			CodeDomProvider codeProvider = null;

            // string extraParams;
            if (language == DotNetLanguage.VBNet)
            {
                lang = "VB";
                ext = ".vb";
                codeProvider = new VBCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", compilerVersion } });
            }
            else
            {
                codeProvider = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", compilerVersion } });
            }

            //add compiler parameters
            CompilerParameters compilerParams = new CompilerParameters();
            compilerParams.CompilerOptions = "/target:library /optimize"; // + extraParams;
            CompilerResults results = null; 

			// Add References
			if (!references.Contains("mscorlib.dll")) references.Add("mscorlib.dll");
			if (!references.Contains("System.dll")) references.Add("System.dll");
			if (!references.Contains("System.EnterpriseServices.dll")) references.Add("System.EnterpriseServices.dll");
			if (!references.Contains("Zeus.dll")) references.Add("Zeus.dll");
            if (!references.Contains("PluginInterfaces.dll")) references.Add("PluginInterfaces.dll");

            foreach (string reference in Zeus.Configuration.ZeusConfig.Current.TemplateReferences)
            {
                if (!references.Contains(reference)) references.Add(reference);
            }

			foreach (string reference in references) 
			{
				compilerParams.ReferencedAssemblies.Add(reference);
			}

			if (compileInMemory) 
			{
				compilerParams.GenerateExecutable = false;
				compilerParams.IncludeDebugInformation = false;
				compilerParams.GenerateInMemory = true;

                results = codeProvider.CompileAssemblyFromSource(compilerParams, code);
			}
			else 
			{
				string guid = Guid.NewGuid().ToString();
				string assemblyname = DotNetScriptEngine.DEBUG_FILE_PREFIX + guid + ".dll";;
				string codefilename = DotNetScriptEngine.DEBUG_FILE_PREFIX + guid + ext;
				
				StreamWriter writer = File.CreateText(codefilename);
				writer.Write(code);
				writer.Flush();
				writer.Close();

				compilerParams.GenerateExecutable = false;
				compilerParams.IncludeDebugInformation = true;
				compilerParams.GenerateInMemory = false;
				compilerParams.OutputAssembly = assemblyname;

                results = codeProvider.CompileAssemblyFromFile(compilerParams, codefilename);
			}

			//Do we have any compiler errors
			if (results.Errors.HasErrors)
			{
                errors = new List<DotNetScriptError>();
				foreach (CompilerError compileError in results.Errors) 
				{
					errors.Add(new DotNetScriptError(compileError, context));
				}
			}
			else 
			{
				//get a hold of the actual assembly that was generated
				generatedAssembly = results.CompiledAssembly;
			}

			System.Environment.CurrentDirectory = tmpDirectory;

			//return the assembly
			return generatedAssembly;
		}
        public static Assembly CreateAssembly(string code, string compilerVersion, DotNetLanguage language, bool compileInMemory, List <string> references, out List <DotNetScriptError> errors, IZeusContext context)
        {
            string tmpDirectory = System.Environment.CurrentDirectory;

            System.Environment.CurrentDirectory = RootFolder;

            Assembly generatedAssembly = null;
            string   ext = ".cs", lang = "C#";

            errors = null;

            //Create an instance whichever code provider that is needed
            CodeDomProvider codeProvider = null;

            // string extraParams;
            if (language == DotNetLanguage.VBNet)
            {
                lang         = "VB";
                ext          = ".vb";
                codeProvider = new VBCodeProvider(new Dictionary <string, string>()
                {
                    { "CompilerVersion", compilerVersion }
                });
            }
            else
            {
                codeProvider = new CSharpCodeProvider(new Dictionary <string, string>()
                {
                    { "CompilerVersion", compilerVersion }
                });
            }

            //add compiler parameters
            CompilerParameters compilerParams = new CompilerParameters();

            compilerParams.CompilerOptions = "/target:library /optimize"; // + extraParams;
            CompilerResults results = null;

            // Add References
            if (!references.Contains("mscorlib.dll"))
            {
                references.Add("mscorlib.dll");
            }
            if (!references.Contains("System.dll"))
            {
                references.Add("System.dll");
            }
            if (!references.Contains("System.EnterpriseServices.dll"))
            {
                references.Add("System.EnterpriseServices.dll");
            }
            if (!references.Contains("Zeus.dll"))
            {
                references.Add("Zeus.dll");
            }
            if (!references.Contains("PluginInterfaces.dll"))
            {
                references.Add("PluginInterfaces.dll");
            }

            foreach (string reference in Zeus.Configuration.ZeusConfig.Current.TemplateReferences)
            {
                if (!references.Contains(reference))
                {
                    references.Add(reference);
                }
            }

            foreach (string reference in references)
            {
                compilerParams.ReferencedAssemblies.Add(reference);
            }

            if (compileInMemory)
            {
                compilerParams.GenerateExecutable      = false;
                compilerParams.IncludeDebugInformation = false;
                compilerParams.GenerateInMemory        = true;

                results = codeProvider.CompileAssemblyFromSource(compilerParams, code);
            }
            else
            {
                string guid         = Guid.NewGuid().ToString();
                string assemblyname = DotNetScriptEngine.DEBUG_FILE_PREFIX + guid + ".dll";;
                string codefilename = DotNetScriptEngine.DEBUG_FILE_PREFIX + guid + ext;

                StreamWriter writer = File.CreateText(codefilename);
                writer.Write(code);
                writer.Flush();
                writer.Close();

                compilerParams.GenerateExecutable      = false;
                compilerParams.IncludeDebugInformation = true;
                compilerParams.GenerateInMemory        = false;
                compilerParams.OutputAssembly          = assemblyname;

                results = codeProvider.CompileAssemblyFromFile(compilerParams, codefilename);
            }

            //Do we have any compiler errors
            if (results.Errors.HasErrors)
            {
                errors = new List <DotNetScriptError>();
                foreach (CompilerError compileError in results.Errors)
                {
                    errors.Add(new DotNetScriptError(compileError, context));
                }
            }
            else
            {
                //get a hold of the actual assembly that was generated
                generatedAssembly = results.CompiledAssembly;
            }

            System.Environment.CurrentDirectory = tmpDirectory;

            //return the assembly
            return(generatedAssembly);
        }
        protected bool LoadAssembly(IZeusContext context)
        {
            bool     assemblyLoaded         = false;
            bool     cacheAssembly          = (_codeSegment.ITemplate.SourceType == ZeusConstants.SourceTypes.COMPILED);
            Assembly newAssembly            = null;
            List <DotNetScriptError> errors = null;

            if ((cacheAssembly) && (_codeSegment.CachedAssembly != null))
            {
                newAssembly = this._codeSegment.CachedAssembly;
            }
            else
            {
                this._compiledInMemory = true;

                List <string> references = new List <string>();
                List <string> namespaces = new List <string>();

                CompilerVersion = Zeus.Configuration.ZeusConfig.Current.CompilerVersion;

                string[] array;
                foreach (object obj in _codeSegment.ExtraData)
                {
                    if (obj is String[])
                    {
                        array = (string[])obj;
                        if ((array.Length == 2) && (array[0] == DotNetScriptEngine.DLLREF))
                        {
                            if (!references.Contains(array[1]))
                            {
                                references.Add(array[1]);
                            }
                        }
                        if ((array.Length == 2) && (array[0] == DotNetScriptEngine.DEBUG))
                        {
                            this._compiledInMemory = false;
                        }
                        if ((array.Length == 2) && (array[0] == DotNetScriptEngine.VERSION))
                        {
                            this.CompilerVersion = array[1];
                        }
                    }
                }
                foreach (string reference in _engine.BuildDLLNames(context))
                {
                    if (!references.Contains(reference))
                    {
                        references.Add(reference);
                    }
                }

                if (cacheAssembly)
                {
                    _compiledInMemory = false;
                }

                DotNetLanguage lang = (_codeSegment.Language == ZeusConstants.Languages.CSHARP) ? DotNetLanguage.CSharp : DotNetLanguage.VBNet;
                newAssembly = CreateAssembly(_codeSegment.Code, CompilerVersion, lang, _compiledInMemory, references, out errors, context);

                if (cacheAssembly && (newAssembly != null))
                {
                    _codeSegment.CachedAssembly = newAssembly;
                }
            }

            if (errors != null)
            {
                foreach (DotNetScriptError error in errors)
                {
                    this.AddError(error);
                }
            }
            else
            {
                this._assemblyStack.Push(newAssembly);
                assemblyLoaded = true;
            }

            return(assemblyLoaded);
        }
        /// <summary>
        /// The main internal method that orchestrates the code generation for the provided parameters
        /// </summary>
        /// <returns>The generated class code as a StringBuilder</returns>
        private static StringBuilder GenerateClass(DotNetLanguage motif, ClassParameters parameters)
        {
            ClassParameters p = parameters;

            StringBuilder sb = new StringBuilder(),
                          sbColumns = new StringBuilder(),
                          sbProperties = new StringBuilder(),
                          sbObjectGen = new StringBuilder(),
                          sbUpdate = new StringBuilder(),
                          sbInsert = new StringBuilder();

            string tableName, primaryKey, sqlQuery;

            if (p.SourceType == SourceTypeEnum.TableName)
            {
                tableName = p.ClassSource;
                primaryKey = GetPrimaryKeyColumn(p.ConnectionString, tableName);
                sqlQuery = "SELECT TOP 1 * FROM " + p.ClassSource;
            }
            else
            {
                tableName = null;
                primaryKey = null;
                sqlQuery = p.ClassSource;
            }

            DataTable dt = GetSchema(p.ConnectionString, sqlQuery);

            DotNetLanguage.MemberInfo info = null;

            //Using Statements
            sb.Append(motif.Using).Append(" System").Append(motif.LineTerminator);
            sb.Append(motif.Using).Append(" System.Collections.Generic").Append(motif.LineTerminator);
            sb.Append(motif.Using).Append(" System.Data").Append(motif.LineTerminator);
            sb.Append(motif.Using).Append(" System.Text").Append(motif.LineTerminator);

            if (motif.IncludeWCFTags)
                sb.Append(motif.Using).Append(" System.Runtime.Serialization").Append(motif.LineTerminator);

            sb.Append(Environment.NewLine);

            //Open the Namespace
            if (parameters.IncludeNamespace)
                sb.Append(motif.OpenNamespace);

            //Add the [DataContract] attribute
            if (motif.IncludeWCFTags)
                sb.Append(motif.DataContract);

            //Open the Class
            sb.Append(motif.OpenClass);
            sb.Append(motif.EmptyConstructor);
            sb.Append(motif.CreateRegion("Properties"));

            //Data Collection and Property Generation
            foreach (DataColumn dc in dt.Columns)
            {
                info = new DotNetLanguage.MemberInfo(dc, p.LanguageType, p.MemberPrefix);

                //DataColumn as Property
                motif.CreateProperty(sbProperties, info);

                //Object Generation Code
                sbObjectGen.Append("obj.").Append(info.Property).Append(" = ").Append(info.ConvertTo).Append(motif.DataRowGet("dr", dc.ColumnName)).Append(")").Append(motif.LineTerminator);

                //I don't remember why I did any of this:
                if (tableName != null && info.ColumnName != primaryKey)
                {
                    //Column CSV
                    sbColumns.Append(dc.ColumnName).Append(", ");

                    //Update Statement Code
                    sbUpdate.Append("sb.Append(\"").Append(dc.ColumnName).Append("\").Append(\" = \").Append(").Append(info.StringValue).Append(").Append(\",\")").Append(motif.LineTerminator);

                    //Insert Statement Code
                    sbInsert.Append("sb.Append(").Append(info.StringValue).Append(").Append(\",\")").Append(motif.LineTerminator);
                }
            }

            //This section can only be performed if this is a single table that this code is being generated from.
            //Virtual Tables do not qualify because they won't have primary keys
            if (tableName != null)
            {
                //Trim the trailing patterns from these
                TrimEnd(sbColumns, "\",\" ");
                TrimEnd(sbUpdate, ".Append(\",\")" + motif.LineTerminator);
                TrimEnd(sbInsert, ".Append(\",\")" + motif.LineTerminator);
            }

            //Append the Class Private Members and Public Properties
            sb.Append(sbProperties);
            sb.Append(motif.EndRegion);

            //Object Generation Method
            motif.CreateObjectGenerationMethod(sb, sbObjectGen.ToString());

            if (tableName != null)
            {
                //Update Method
                if (dt.Columns[primaryKey] != null)
                    motif.CreateUpdateMethod(sb, sbUpdate.ToString(), new DotNetLanguage.MemberInfo(dt.Columns[primaryKey], p.LanguageType, p.MemberPrefix));

                //Insert Method
                motif.CreateInsertMethod(sb, sbColumns.ToString(), sbInsert.ToString());

                //AddString Methods
                motif.CreateAddStringMethods(sb);
            }

            sb.Append(motif.CloseClass);

            if (parameters.IncludeNamespace)
                sb.Append(motif.CloseNamespace);

            return sb;
        }
 public static string ToCliName(this DotNetLanguage language) => language switch
 {
        /// <summary>
        /// Provides the core functionality to show an IntelliPrompt member list based on the current context in a <see cref="SyntaxEditor"/>.
        /// </summary>
        /// <param name="language">The <see cref="DotNetLanguage"/> to use for quick info formatting.</param>
        /// <param name="syntaxEditor">The <see cref="SyntaxEditor"/> that will display the IntelliPrompt member list.</param>
        /// <param name="completeWord">Whether to complete the word.</param>
        /// <returns>
        /// <c>true</c> if an auto-complete occurred or if a IntelliPrompt member list is displayed; otherwise, <c>false</c>.
        /// </returns>
        internal bool ShowIntelliPromptMemberList(DotNetLanguage language, SyntaxEditor syntaxEditor, SyntaxEditor toEditor, bool completeWord, string parameterName)
        {
            // Try and ensure the compilation unit is up-to-date
            SemanticParserService.WaitForParse(SemanticParserServiceRequest.GetParseHashKey(syntaxEditor.Document, syntaxEditor.Document));

            // Get the context
            //DotNetContext context = this.GetContext(syntaxEditor, syntaxEditor.Caret.Offset, true, false);
            DotNetContext context = this.GetContext(syntaxEditor, syntaxEditor.Document.GetText(LineTerminator.Newline).Length - 1, true, false);

            // Initialize the member list
            IntelliPromptMemberList memberList = toEditor.IntelliPrompt.MemberList;// syntaxEditor.IntelliPrompt.MemberList;

            memberList.ResetAllowedCharacters();
            memberList.Clear();
            memberList.ImageList = SyntaxEditor.ReflectionImageList;
            memberList.Context   = context;

            // GFH
            if (completeWord && context.InitializationTextRange.StartOffset >= 0)
            {
                string partialWord = syntaxEditor.Document.GetText(LineTerminator.Newline).Substring(context.InitializationTextRange.StartOffset, context.InitializationTextRange.Length);

                if (parameterName.StartsWith(partialWord))
                {
                    memberList.Add(new IntelliPromptMemberListItem(parameterName, (int)ActiproSoftware.Products.SyntaxEditor.IconResource.PrivateProperty));
                }
            }

            // Get the member list items
            Hashtable memberListItemHashtable = new Hashtable();

            switch (context.Type)
            {
            case DotNetContextType.AnyCode:
                // Fill with everything
                if (context.ProjectResolver != null)
                {
                    // Fill with child namespace names in the global and imported namespaces
                    //context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, null);
                    //foreach (string namespaceName in context.ImportedNamespaces)
                    //    context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, namespaceName);

                    //// Fill with the types in the global and imported namespaces
                    //context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, null, DomBindingFlags.Default, true);
                    //foreach (string namespaceName in context.ImportedNamespaces)
                    //    context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, namespaceName, DomBindingFlags.Default, true);

                    // Fill with static members of parent types
                    if ((context.TypeDeclarationNode != null) && (context.TypeDeclarationNode.DeclaringType is IDomType))
                    {
                        context.ProjectResolver.AddMemberListItemsForDeclaringTypeMembers(memberListItemHashtable, context.TypeDeclarationNode, (IDomType)context.TypeDeclarationNode.DeclaringType, DomBindingFlags.Static | DomBindingFlags.AllAccessTypes);
                    }

                    // Fill with nested types
                    if (context.TypeDeclarationNode != null)
                    {
                        context.ProjectResolver.AddMemberListItemsForNestedTypes(memberListItemHashtable, context.TypeDeclarationNode, context.TypeDeclarationNode, DomBindingFlags.Default, true);
                    }

                    // Fill with members if in a member (pay attention to if member is instance or static)
                    if (context.TypeDeclarationNode != null)
                    {
                        if (context.MemberDeclarationNode != null)
                        {
                            if (!((IDomMember)context.MemberDeclarationNode).IsStatic)
                            {
                                // Fill with extension methods
                                context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                              context.TypeDeclarationNode, DomBindingFlags.Instance |
                                                                                              context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                            }

                            // Fill with members
                            context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode, context.TypeDeclarationNode,
                                                                                 (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) |
                                                                                 DomBindingFlags.Static | (((IDomMember)context.MemberDeclarationNode).IsStatic ? DomBindingFlags.None : DomBindingFlags.Instance) |
                                                                                 context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                        }
                        else
                        {
                            // Not within a member so fill with static members
                            context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode, context.TypeDeclarationNode,
                                                                                 (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Static |
                                                                                 context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                        }
                    }

                    // Fill with variables defined in the scope
                    context.ProjectResolver.AddMemberListItemsForVariables(memberListItemHashtable, context);

                    // Fill with language keywords
                    //this.AddKeywordMemberListItems(memberListItemHashtable);

                    // Fill with code snippets
                    if (this.CodeSnippetsEnabled)
                    {
                        context.ProjectResolver.AddMemberListItemsForCodeSnippets(memberListItemHashtable);
                    }
                }
                break;

            case DotNetContextType.BaseAccess:
                // If the context is in an instance member declaration...
                if ((context.ProjectResolver != null) && (context.MemberDeclarationNode != null) && (!((IDomMember)context.MemberDeclarationNode).IsStatic))
                {
                    if (context.TargetItem.Type == DotNetContextItemType.Base)
                    {
                        // Fill with extension methods
                        context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                      (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Instance |
                                                                                      context.AdditionalBindingFlags | DomBindingFlags.Public | DomBindingFlags.Family | DomBindingFlags.Assembly);

                        // Fill with instance type members
                        context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                             (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                             context.AdditionalBindingFlags | DomBindingFlags.Public | DomBindingFlags.Family | DomBindingFlags.Assembly);
                    }
                }
                break;

            case DotNetContextType.DocumentationCommentTag:
                // Add tags
                if (context.ProjectResolver != null)
                {
                    context.ProjectResolver.AddMemberListItemsForDocumentationComments(memberListItemHashtable, context,
                                                                                       (syntaxEditor.Caret.Offset > 0) && (syntaxEditor.Document[syntaxEditor.Caret.Offset - 1] != '<'));
                }
                break;

            case DotNetContextType.AsType:
            case DotNetContextType.IsTypeOfType:
            case DotNetContextType.TryCastType:
            case DotNetContextType.TypeOfType:
                if (context.ProjectResolver != null)
                {
                    if (context.TargetItem != null)
                    {
                        switch (context.TargetItem.Type)
                        {
                        case DotNetContextItemType.Namespace:
                        case DotNetContextItemType.NamespaceAlias:
                            // Fill with child namespaces and types
                            context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, context.TargetItem.ResolvedInfo.ToString());
                            context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, context.TargetItem.ResolvedInfo.ToString(), DomBindingFlags.Default, false);
                            break;

                        case DotNetContextItemType.Type:
                            // Fill with nested types
                            context.ProjectResolver.AddMemberListItemsForNestedTypes(memberListItemHashtable, context.TypeDeclarationNode, (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Default, false);
                            break;
                        }
                    }
                    else
                    {
                        // VB requires New added for As specifications
                        if ((context.Type == DotNetContextType.AsType) && (language == DotNetLanguage.VB))
                        {
                            memberListItemHashtable["New"] = new IntelliPromptMemberListItem("New", (int)ActiproSoftware.Products.SyntaxEditor.IconResource.Keyword);
                        }

                        // Fill with native types
                        context.ProjectResolver.AddMemberListItemsForNativeTypes(language, memberListItemHashtable, context);

                        // Fill with child namespace names in the global and imported namespaces
                        context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, null);
                        foreach (string namespaceName in context.ImportedNamespaces)
                        {
                            context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, namespaceName);
                        }

                        // Fill with the types in the imported namespaces
                        context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, null, DomBindingFlags.Default, false);
                        foreach (string namespaceName in context.ImportedNamespaces)
                        {
                            context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, namespaceName, DomBindingFlags.Default, false);
                        }

                        // Fill with nested types
                        if (context.TypeDeclarationNode != null)
                        {
                            context.ProjectResolver.AddMemberListItemsForNestedTypes(memberListItemHashtable, context.TypeDeclarationNode, context.TypeDeclarationNode, DomBindingFlags.Default, true);
                        }
                    }
                }
                break;

            case DotNetContextType.NamespaceTypeOrMember:
                if (context.ProjectResolver != null)
                {
                    switch (context.TargetItem.Type)
                    {
                    case DotNetContextItemType.Namespace:
                    case DotNetContextItemType.NamespaceAlias:
                        // Fill with child namespaces and types
                        context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, context.TargetItem.ResolvedInfo.ToString());
                        context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, context.TargetItem.ResolvedInfo.ToString(), DomBindingFlags.Default, false);
                        break;

                    case DotNetContextItemType.Constant:
                    case DotNetContextItemType.Type:
                        // Add nested types
                        if (context.TargetItem.ResolvedInfo is IDomType)
                        {
                            // Fill with nested types
                            context.ProjectResolver.AddMemberListItemsForNestedTypes(memberListItemHashtable, context.TypeDeclarationNode, (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Default, false);
                        }

                        // If the context is in a type declaration...
                        if (context.TypeDeclarationNode != null)
                        {
                            // Fill with static type members
                            context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                                 (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Static |
                                                                                 context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                        }
                        break;

                    case DotNetContextItemType.Member:
                        // If the context is in a type declaration...
                        if (context.TypeDeclarationNode != null)
                        {
                            // Fill with instance type members of member return type
                            IDomType type = context.ProjectResolver.ConstructAndResolveContextItemMemberReturnType(context, context.Items.Length - 1);
                            if (type != null)
                            {
                                // Fill with extension methods
                                context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                              type, DomBindingFlags.Instance | context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);

                                // Fill with instance type members
                                context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                                     type, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                                     context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                            }
                        }
                        break;

                    case DotNetContextItemType.ArrayItem:
                    case DotNetContextItemType.Parameter:
                    case DotNetContextItemType.Variable:
                        // If the context is in a member declaration...
                        if (context.MemberDeclarationNode != null)
                        {
                            // Fill with extension methods
                            context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                          (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Instance |
                                                                                          context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);

                            // Fill with instance type members
                            context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                                 (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                                 context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                        }
                        break;
                    }
                }
                break;

            case DotNetContextType.NativeType:
                // If the context is in a member declaration...
                if ((context.ProjectResolver != null) && (context.TypeDeclarationNode != null))
                {
                    if (context.TargetItem.Type == DotNetContextItemType.Type)
                    {
                        // Fill with static type members
                        context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                             (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Static |
                                                                             context.AdditionalBindingFlags | DomBindingFlags.Public);
                    }
                }
                break;

            case DotNetContextType.NewObjectDeclaration:
                if ((context.ProjectResolver != null) && (context.TypeDeclarationNode != null))
                {
                    if (context.TargetItem == null)
                    {
                        // Fill with child namespace names in the global and imported namespaces
                        context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, null);
                        foreach (string namespaceName in context.ImportedNamespaces)
                        {
                            context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, namespaceName);
                        }

                        // Fill with the creatable types in the global and imported namespaces
                        context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, null, DomBindingFlags.Default | DomBindingFlags.HasConstructor, false);
                        foreach (string namespaceName in context.ImportedNamespaces)
                        {
                            context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, namespaceName, DomBindingFlags.Default | DomBindingFlags.HasConstructor, false);
                        }

                        // Fill with the creatable nested types
                        context.ProjectResolver.AddMemberListItemsForNestedTypes(memberListItemHashtable, context.TypeDeclarationNode, context.TypeDeclarationNode, DomBindingFlags.Default | DomBindingFlags.HasConstructor, true);
                    }
                    else
                    {
                        switch (context.TargetItem.Type)
                        {
                        case DotNetContextItemType.Namespace:
                        case DotNetContextItemType.NamespaceAlias:
                            // Fill with child namespaces and creatable types
                            context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable, context.TargetItem.ResolvedInfo.ToString());
                            context.ProjectResolver.AddMemberListItemsForTypes(memberListItemHashtable, context.TypeDeclarationNode, context.TargetItem.ResolvedInfo.ToString(), DomBindingFlags.Default | DomBindingFlags.HasConstructor, false);
                            break;

                        case DotNetContextItemType.Type:
                            // Fill with the creatable nested types
                            context.ProjectResolver.AddMemberListItemsForNestedTypes(memberListItemHashtable, context.TypeDeclarationNode, (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Default | DomBindingFlags.HasConstructor, false);

                            // Fill with extension methods
                            context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                          (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Instance | context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);

                            // Fill with instance type members
                            context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                                 (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                                 context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                            break;
                        }
                    }
                }
                break;

            case DotNetContextType.ThisAccess:
                // If the context is in an instance member declaration...
                if ((context.ProjectResolver != null) && (context.MemberDeclarationNode != null) && (!((IDomMember)context.MemberDeclarationNode).IsStatic))
                {
                    if (context.TargetItem.Type == DotNetContextItemType.This)
                    {
                        // Fill with extension methods
                        context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                      (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Instance |
                                                                                      context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);

                        // Fill with instance type members
                        context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                             (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                             context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                    }
                }
                break;

            case DotNetContextType.BaseMemberAccess:
            case DotNetContextType.ThisMemberAccess:
                // If the context is in an instance member declaration...
                if ((context.ProjectResolver != null) && (context.MemberDeclarationNode != null) && (!((IDomMember)context.MemberDeclarationNode).IsStatic))
                {
                    // Fill with instance type members of member return type
                    IDomType type = null;
                    if (context.TargetItem.ResolvedInfo is IDomType)
                    {
                        type = (IDomType)context.TargetItem.ResolvedInfo;
                    }
                    else
                    {
                        type = context.ProjectResolver.ConstructAndResolveContextItemMemberReturnType(context, context.Items.Length - 1);
                    }

                    if (type != null)
                    {
                        // Fill with extension methods
                        context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                      type, DomBindingFlags.Instance | context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);

                        // Fill with instance type members
                        context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                             type, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                             context.AdditionalBindingFlags | DomBindingFlags.AllAccessTypes);
                    }
                }
                break;

            case DotNetContextType.StringLiteral:
                // If the context is in a member declaration...
                if (context.ProjectResolver != null)
                {
                    if (context.TargetItem.Type == DotNetContextItemType.StringLiteral)
                    {
                        // Fill with extension methods
                        context.ProjectResolver.AddMemberListItemsForExtensionMethods(memberListItemHashtable, context,
                                                                                      (IDomType)context.TargetItem.ResolvedInfo, DomBindingFlags.Instance |
                                                                                      context.AdditionalBindingFlags | DomBindingFlags.Public);

                        // Fill with string instance type members
                        context.ProjectResolver.AddMemberListItemsForMembers(memberListItemHashtable, context.TypeDeclarationNode,
                                                                             (IDomType)context.TargetItem.ResolvedInfo, (this.LanguageType == DotNetLanguage.CSharp ? DomBindingFlags.ExcludeIndexers : DomBindingFlags.None) | DomBindingFlags.Instance |
                                                                             context.AdditionalBindingFlags | DomBindingFlags.Public);
                    }
                }
                break;

            case DotNetContextType.UsingDeclaration:
                // Fill with namespaces
                if (context.ProjectResolver != null)
                {
                    context.ProjectResolver.AddMemberListItemsForChildNamespaces(memberListItemHashtable,
                                                                                 (context.TargetItem != null ? context.TargetItem.ResolvedInfo.ToString() : String.Empty));
                }
                break;
            }

            // Pre-filter the member list
            this.OnSyntaxEditorIntelliPromptMemberListPreFilter(syntaxEditor,
                                                                new IntelliPromptMemberListPreFilterEventArgs(syntaxEditor, context, memberListItemHashtable));

            // Add items
            if (memberListItemHashtable.Count > 0)
            {
                IntelliPromptMemberListItem[] items = new IntelliPromptMemberListItem[memberListItemHashtable.Count];
                memberListItemHashtable.Values.CopyTo(items, 0);
                memberList.AddRange(items);
            }

            // Show the list
            if (memberList.Count > 0)
            {
                if (context.InitializationTextRange.IsDeleted)
                {
                    memberList.Show();
                }
                else if (completeWord)
                {
                    memberList.CompleteWord(toEditor.Caret.Offset - context.InitializationTextRange.Length, context.InitializationTextRange.Length);
                    //memberList.CompleteWord(context.InitializationTextRange.StartOffset, context.InitializationTextRange.Length);
                }
                else
                {
                    memberList.Show(toEditor.Caret.Offset, context.InitializationTextRange.Length);
                    //memberList.Show(context.InitializationTextRange.StartOffset, context.InitializationTextRange.Length);
                }
                return(true);
            }
            else if (memberList.Visible)
            {
                memberList.Abort();
            }

            return(false);
        }