Example #1
0
        public void Does_Not_Modify_Input()
        {
            var raw = new RawAttribute();

            Assert.AreEqual("MvcContrib.BrailViewEngine.RawAttribute.Transform", raw.TransformMethodName);
            Assert.AreEqual("this & that", RawAttribute.Transform("this & that"));
            Assert.AreEqual("this & that", RawAttribute.Transform((object)"this & that"));
        }
Example #2
0
        public static void LoadSchemaFile(string filePath, List <Entity> allEntities)
        {
            //int count = 0;
            using (System.IO.StreamReader r = new StreamReader(filePath))
            {
                String  json        = r.ReadToEnd();
                var     converter   = new ExpandoObjectConverter();
                dynamic jsonmessage = JsonConvert.DeserializeObject <ExpandoObject>(json, converter);
                JToken  token       = JToken.Parse(json);
                Entity  objEntity   = new Entity();

                foreach (var tempVal in jsonmessage)
                {
                    if (tempVal.Key is "definitions")
                    {
                        foreach (var temp2 in tempVal.Value)
                        {
                            foreach (var tempAttr in temp2)
                            {
                                if (tempAttr.Key is "entityName")
                                {
                                    objEntity.setEntityName(tempAttr.Value.ToString());
                                    objEntity.setEntityId(tempAttr.Value.ToString());
                                }
                                if (tempAttr.Key is "extendsEntity")
                                {
                                    objEntity.setParentEntityName(tempAttr.Value.ToString());
                                }
                                if (tempAttr.Key is "hasAttributes")
                                {
                                    //cast to the attribute class
                                    foreach (var tempMember in tempAttr.Value[0])
                                    {
                                        Console.WriteLine(tempMember.Value.GetType().Name);
                                        foreach (KeyValuePair <string, object> kvp in ((IDictionary <string, object>)tempMember.Value))
                                        {
                                            //string PropertyWithValue = kvp.Key + ": " + kvp.Value.ToString();
                                            if (kvp.Key is "members")
                                            {
                                                //use automapper to map the attributes of member segment
                                                foreach (var temp in ((List <object>)kvp.Value))
                                                {
                                                    RawAttribute result = Mapper.Map <RawAttribute>(temp);
                                                    //Extract Dependencies
                                                    objEntity.dependencyList.AddRange(ExtractDependency(result));
                                                    if (result.displayName is null || result.dataType is null)
                                                    {
                                                        //Console.WriteLine("{0} : {1}", result.displayName, result.dataType);
                                                    }
                                                    else
                                                    {
                                                        objEntity.attributeList.Add(result);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }