Inheritance: IIntellisenseFilterOpsTO
Esempio n. 1
0
        public static IList <IDev2DataLanguageIntellisensePart> GenerateIntellisensePartsFromDataList(string dataList)
        {
            DataListIntellisenseBuilder dlib = new DataListIntellisenseBuilder();

            IntellisenseFilterOpsTO ifot = new IntellisenseFilterOpsTO {
                FilterType = enIntellisensePartType.All
            };

            dlib.FilterTO = ifot;

            IList <IDev2DataLanguageIntellisensePart> result = dlib.Generate();

            return(result);
        }
 private IList<IIntellisenseResult> ParseDataLanguageForIntellisense(string transform, string dataList, bool addCompleteParts, IntellisenseFilterOpsTO filterOps, bool isFromIntellisense = false)
 {
     return DataListFactory.CreateLanguageParser().ParseDataLanguageForIntellisense(transform, dataList, addCompleteParts, filterOps, isFromIntellisense);
 }
        public void Check_Scalars_And_Recordsets_Have_Descriptions()
        {
            const string dl = @"<ADL><TestScalar Description=""this is a decription for TestScalar"" /><TestRecset Description=""this is a decription for TestRecset"">
  <TestField Description=""this is a decription for TestField"" />
</TestRecset></ADL>";
            const string payload = "[[";

            IntellisenseFilterOpsTO filterTo = new IntellisenseFilterOpsTO { FilterCondition = "", FilterType = enIntellisensePartType.All };
            IList<IIntellisenseResult> results = ParseDataLanguageForIntellisense(payload, dl, false, filterTo);

            Assert.AreEqual(3, results.Count);
            Assert.AreEqual("this is a decription for TestScalar / Select this variable", results[0].Option.Description);
            Assert.AreEqual("this is a decription for TestRecset / Select this record set", results[1].Option.Description);
            Assert.AreEqual("this is a decription for TestField / Select this record set field", results[2].Option.Description);
        }
        /// <summary>
        /// Generates this instance.
        /// </summary>
        /// <returns></returns>
        public IList <IDev2DataLanguageIntellisensePart> Generate()
        {
            IList <IDev2DataLanguageIntellisensePart> result = new List <IDev2DataLanguageIntellisensePart>();

            XmlDocument xDoc = new XmlDocument();
            // ReSharper disable TooWideLocalVariableScope
            string rawRecsetName;

            // ReSharper restore TooWideLocalVariableScope
            if (FilterTO == null)
            {
                FilterTO = new IntellisenseFilterOpsTO();
            }
            if (FilterTO.FilterCondition != null)
            {
                rawRecsetName = FilterTO.FilterCondition;
                if (rawRecsetName.Contains("[["))
                {
                    rawRecsetName = rawRecsetName.Replace("[[", "");
                }
                if (rawRecsetName.Contains("]]"))
                {
                    rawRecsetName = rawRecsetName.Replace("]]", "");
                }
                if (rawRecsetName.Contains("()"))
                {
                    // ReSharper disable RedundantAssignment
                    rawRecsetName = rawRecsetName.Replace("()", "");
                    // ReSharper restore RedundantAssignment
                }
            }


            if (!string.IsNullOrEmpty(DataList))
            {
                XmlNodeList tmpRootNl = null;

                try
                {
                    xDoc.LoadXml(DataList);
                    tmpRootNl = xDoc.ChildNodes;
                }
                catch (Exception ex)
                {
                    Dev2Logger.Log.Error(ex);
                }

                if (tmpRootNl != null)
                {
                    XmlNodeList nl = tmpRootNl[0].ChildNodes;
                    for (int i = 0; i < nl.Count; i++)
                    {
                        XmlNode tmpNode = nl[i];

                        if (IsValidChildNode(tmpNode))
                        {
                            // it is a record set, make it as such
                            string recordsetName = tmpNode.Name;
                            IList <IDev2DataLanguageIntellisensePart> children = new List <IDev2DataLanguageIntellisensePart>();
                            // now extract child node defs
                            XmlNodeList childNl = tmpNode.ChildNodes;
                            for (int q = 0; q < childNl.Count; q++)
                            {
                                children.Add(DataListFactory.CreateIntellisensePart(childNl[q].Name, ExtractDescription(childNl[q])));
                            }
                            if (FilterTO.FilterType == enIntellisensePartType.All)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                            }
                            if (FilterTO.FilterType == enIntellisensePartType.RecordsetsOnly)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(string.Concat(recordsetName, "()"), ExtractDescription(tmpNode)));
                            }
                            if (FilterTO.FilterType == enIntellisensePartType.RecordsetFields)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                            }
                        }
                        else
                        {
                            // scalar value, make it as such
                            if (FilterTO.FilterType == enIntellisensePartType.All || FilterTO.FilterType == enIntellisensePartType.ScalarsOnly)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(tmpNode.Name, ExtractDescription(tmpNode)));
                            }
                        }
                    }
                }
            }


            return(result);
        }
        public static IList<IDev2DataLanguageIntellisensePart> GenerateIntellisensePartsFromDataList(string dataList, IntellisenseFilterOpsTO fiterTo)
        {
            DataListIntellisenseBuilder dlib = new DataListIntellisenseBuilder { FilterTO = fiterTo, DataList = dataList };

            IList<IDev2DataLanguageIntellisensePart> result = dlib.Generate();

            return result;
        }
        public static IList<IDev2DataLanguageIntellisensePart> GenerateIntellisensePartsFromDataList(string dataList)
        {
            DataListIntellisenseBuilder dlib = new DataListIntellisenseBuilder();

            IntellisenseFilterOpsTO ifot = new IntellisenseFilterOpsTO { FilterType = enIntellisensePartType.All };

            dlib.FilterTO = ifot;

            IList<IDev2DataLanguageIntellisensePart> result = dlib.Generate();

            return result;
        }
Esempio n. 7
0
        public void WhenIValidate()
        {
            IList<IIntellisenseResult> results = new List<IIntellisenseResult>();

            var variable = ScenarioContext.Current.Get<string>("variable");


            var parser = new Dev2DataLanguageParser();

            IntellisenseFilterOpsTO filterTO = new IntellisenseFilterOpsTO { FilterType = enIntellisensePartType.All };

            var datalist = new StringBuilder();
            datalist.Append("<DataList>");

            datalist.Append("<a>");
            datalist.Append("</a>");

            datalist.Append("<b>");
            datalist.Append("</b>");

            datalist.Append("<c>");
            datalist.Append("</c>");

            datalist.Append("<y>");
            datalist.Append("</y>");

            datalist.Append("<d>");
            datalist.Append("</d>");

            datalist.Append("<test>");
            datalist.Append("</test>");

            datalist.Append("<v>");
            datalist.Append("</v>");

            datalist.Append("<var>");
            datalist.Append("</var>");

            datalist.Append("<var1>");
            datalist.Append("</var1>");

            datalist.Append("<rec>");
            datalist.Append("<a/>");
            datalist.Append("<b/>");
            datalist.Append("</rec>");

            datalist.Append("<r>");
            datalist.Append("<a/>");
            datalist.Append("<b/>");
            datalist.Append("</r>");

            datalist.Append("</DataList>");

            var dataList = datalist.ToString();
            var tmpResults = parser.ParseDataLanguageForIntellisense(variable, dataList, true, filterTO, false);
            tmpResults.ToList().ForEach(r =>
            {
                if(r.Type == enIntellisenseResultType.Error)
                {
                    results.Add(r);
                }
            });

            ScenarioContext.Current.Add("results", results);
        }
        /// <summary>
        /// Generates this instance.
        /// </summary>
        /// <returns></returns>
        public IList<IDev2DataLanguageIntellisensePart> Generate()
        {
            IList<IDev2DataLanguageIntellisensePart> result = new List<IDev2DataLanguageIntellisensePart>();

            XmlDocument xDoc = new XmlDocument();
            // ReSharper disable TooWideLocalVariableScope
            string rawRecsetName;
            // ReSharper restore TooWideLocalVariableScope
            if(FilterTO == null)
            {
                FilterTO = new IntellisenseFilterOpsTO();
            }
            if(FilterTO.FilterCondition != null)
            {
                rawRecsetName = FilterTO.FilterCondition;
                if(rawRecsetName.Contains("[["))
                {
                    rawRecsetName = rawRecsetName.Replace("[[", "");
                }
                if(rawRecsetName.Contains("]]"))
                {
                    rawRecsetName = rawRecsetName.Replace("]]", "");
                }
                if(rawRecsetName.Contains("()"))
                {
                    // ReSharper disable RedundantAssignment
                    rawRecsetName = rawRecsetName.Replace("()", "");
                    // ReSharper restore RedundantAssignment
                }
            }


            if(!string.IsNullOrEmpty(DataList))
            {
                XmlNodeList tmpRootNl = null;

                try
                {
                    xDoc.LoadXml(DataList);
                    tmpRootNl = xDoc.ChildNodes;
                }
                catch(Exception ex)
                {
                    Dev2Logger.Log.Error(ex);
                }

                if(tmpRootNl != null)
                {
                    XmlNodeList nl = tmpRootNl[0].ChildNodes;
                    for(int i = 0; i < nl.Count; i++)
                    {
                        XmlNode tmpNode = nl[i];

                        if(IsValidChildNode(tmpNode))
                        {
                            // it is a record set, make it as such
                            string recordsetName = tmpNode.Name;
                            IList<IDev2DataLanguageIntellisensePart> children = new List<IDev2DataLanguageIntellisensePart>();
                            // now extract child node defs
                            XmlNodeList childNl = tmpNode.ChildNodes;
                            for(int q = 0; q < childNl.Count; q++)
                            {
                                children.Add(DataListFactory.CreateIntellisensePart(childNl[q].Name, ExtractDescription(childNl[q])));
                            }
                            if(FilterTO.FilterType == enIntellisensePartType.All)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                            }
                            if(FilterTO.FilterType == enIntellisensePartType.RecordsetsOnly)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(string.Concat(recordsetName, "()"), ExtractDescription(tmpNode)));
                            }
                            if(FilterTO.FilterType == enIntellisensePartType.RecordsetFields)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(recordsetName, ExtractDescription(tmpNode), children));
                            }
                        }
                        else
                        {
                            // scalar value, make it as such
                            if(FilterTO.FilterType == enIntellisensePartType.All || FilterTO.FilterType == enIntellisensePartType.ScalarsOnly)
                            {
                                result.Add(DataListFactory.CreateIntellisensePart(tmpNode.Name, ExtractDescription(tmpNode)));
                            }
                        }
                    }
                }
            }


            return result;
        }
Esempio n. 9
0
        public static IList <IDev2DataLanguageIntellisensePart> GenerateIntellisensePartsFromDataList(string dataList, IntellisenseFilterOpsTO fiterTo)
        {
            DataListIntellisenseBuilder dlib = new DataListIntellisenseBuilder {
                FilterTO = fiterTo, DataList = dataList
            };

            IList <IDev2DataLanguageIntellisensePart> result = dlib.Generate();

            return(result);
        }