예제 #1
0
        public void Field_Static()
        {
            FieldDetail fi = ExtractField(Subjects.One, "BasicClass", "_staticField");

            Assert.AreEqual(Status.Present, fi.Status);
            Assert.AreEqual("public static string _staticField", fi.ToString());
        }
예제 #2
0
        public void Field_ReadOnly()
        {
            FieldDetail fi = ExtractField(Subjects.One, "BasicClass", "_readOnlyField");

            Assert.AreEqual(Status.Present, fi.Status);
            Assert.AreEqual("public readonly string _readOnlyField", fi.ToString());
        }
예제 #3
0
        public void Field_Const_String()
        {
            FieldDetail fi = ExtractField(Subjects.One, "BasicClass", "_constString");

            Assert.AreEqual(Status.Present, fi.Status);
            Assert.AreEqual("public const string _constString = \"This is const\"", fi.ToString());
        }
예제 #4
0
        public void Field_Const_Int()
        {
            FieldDetail fi = ExtractField(Subjects.One, "BasicClass", "_constInt");

            Assert.AreEqual(Status.Present, fi.Status);
            Assert.AreEqual("public const int _constInt = 3", fi.ToString());
        }
예제 #5
0
        public void Field_WithAttributes()
        {
            FieldDetail fi = ExtractField(Subjects.One, "BasicClass", "_fieldWithAttribute");

            Assert.AreEqual(Status.Present, fi.Status);
            CheckForAttribute(fi);
        }
예제 #6
0
        protected FieldDetail ExtractField(string assemblyFile, string typeName, string fieldName, DiffConfig config)
        {
            ClassDetail ci = ExtractClass(assemblyFile, typeName, config);

            FieldDetail value = ListOperations.FindOrReturnMissing(ci.FilterChildren <FieldDetail>(), fieldName);

            Log.Verbose("Extracted field : {0}", value);
            return(value);
        }
예제 #7
0
        private void AssertChange(string from, string name, ChangeType change)
        {
            FieldDetail r1 = ExtractField(Subjects.One, from, name);
            FieldDetail r2 = ExtractField(Subjects.Two, from, name);

            Align(r1, r2);

            Assert.AreEqual(change, r1.PerformCompare(r2));
        }
예제 #8
0
        public void SetField(FieldDetail field)
        {
            Console.WriteLine("Searching field {0}", field.fieldName);
            FieldDescListBox.Items[FieldListBox.Items.FindIndex(x => x.Name == field.fieldName)].Select();
            if (field.fieldItems.Count == 0 && field.fieldItemsIndex.Count == 0)
            {
                return;
            }
            var headers = FieldFile.GetFieldFile(field.fieldName, dbFolder).ReadFieldHeaders();
            var indices = headers
                          .Select((item, index) => new { item.name, index })
                          .Where(pair => { return(field.fieldItems.Contains(pair.name)); })
                          .Select(x => x.index)
                          .Concat(field.fieldItemsIndex)
                          .OrderBy(x => x);

            foreach (var idx in indices)
            {
                Console.WriteLine("{0} -> {1}", idx, headers[idx].name);
            }
            SelectFieldItems(indices);
        }
예제 #9
0
        /*
         *  <name>ParamId</name>
         *  <display>Tên thuộc tính</display>
         *  <type>text</type>
         *  <action_link>text</action_link>
         *  <action_style>info</action_style>
         *  <action_type>popup</action_type>
         */
        //public static List<ListField> GetDataFieldForList(string filePath = "")
        //{
        //    try
        //    {
        //        string xmlPath = HttpContext.Current.Server.MapPath(filePath); //Path of the xml script
        //        DataSet ds = new DataSet();//Using dataset to read xml file
        //        ds.ReadXml(xmlPath);
        //        var parms = new List<ListField>();
        //        parms = (from rows in ds.Tables[0].AsEnumerable()
        //                 select new ListField
        //                 {
        //                     name = rows[0].ToString(),
        //                     display = rows[1].ToString(),
        //                     type = rows[2].ToString()
        //                 }).ToList();
        //        return parms;
        //    }
        //    catch (Exception ex)
        //    {
        //        return new List<ListField>();
        //    }
        //}

        public static List <ListField> GetDataFieldForList2(string filePath)
        {
            try
            {
                List <ListField> fields  = new List <ListField>();
                string           xmlPath = HttpContext.Current.Server.MapPath(filePath); //Path of the xml script
                XmlDocument      doc     = new XmlDocument();
                doc.Load(xmlPath);
                //Get and display the last item node.
                XmlElement  root     = doc.DocumentElement;
                XmlNodeList nodeList = root.GetElementsByTagName("datafield");
                if (nodeList != null && nodeList.Count > 0)
                {
                    foreach (XmlNode node in nodeList)
                    {
                        XmlNodeList childs = node.ChildNodes;
                        ListField   field  = new ListField();
                        if (childs != null && childs.Count > 0)
                        {
                            foreach (XmlNode child in childs)
                            {
                                if (child.Name == "index")
                                {
                                    field.index = Convert.ToInt32(child.InnerText.Trim());
                                }
                                if (child.Name == "name")
                                {
                                    field.name = child.InnerText;
                                }
                                if (child.Name == "display")
                                {
                                    field.display = child.InnerText;
                                }
                                if (child.Name == "type")
                                {
                                    field.type = child.InnerText;
                                }
                                if (child.Name == "details")
                                {
                                    if (child.ChildNodes != null && child.ChildNodes.Count > 0)
                                    {
                                        field.Details = new List <FieldDetail>();

                                        foreach (XmlNode detail in child.ChildNodes)
                                        {
                                            FieldDetail fieldDetail = new FieldDetail();
                                            XmlNodeList details     = detail.ChildNodes;
                                            if (details != null && details.Count > 0)
                                            {
                                                foreach (XmlNode childDetail in details)
                                                {
                                                    if (childDetail.Name == "dataBind")
                                                    {
                                                        fieldDetail.dataBind = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "displayBind")
                                                    {
                                                        fieldDetail.displayBind = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "style")
                                                    {
                                                        fieldDetail.style = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "type")
                                                    {
                                                        fieldDetail.type = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "link")
                                                    {
                                                        fieldDetail.link = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "icon")
                                                    {
                                                        fieldDetail.icon = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "message")
                                                    {
                                                        fieldDetail.message = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "jsfunction")
                                                    {
                                                        fieldDetail.jsfunction = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "conditionTarget")
                                                    {
                                                        fieldDetail.conditionTarget = childDetail.InnerText;
                                                    }
                                                    if (childDetail.Name == "conditionValue")
                                                    {
                                                        fieldDetail.conditionValue = childDetail.InnerText;
                                                    }
                                                }
                                                field.Details.Add(fieldDetail);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        fields.Add(field);
                    }
                    return(fields);
                }
            }
            catch (Exception ex)
            {
            }
            return(new List <ListField>());
        }