Beispiel #1
0
 public SrvsFile(MsgFileLocation filename)
 {
     msgfilelocation = filename;
     //read in srv file
     string[] lines = File.ReadAllLines(filename.Path);
     classname = filename.basename;
     Namespace += "." + filename.package;
     Name = filename.package + "." + filename.basename;
     //def is the list of all lines in the file
     def = new List<string>();
     int mid = 0;
     bool found = false;
     List<string> request = new List<string>(), response = new List<string>();
     //Search through for the "---" separator between request and response
     for (; mid < lines.Length; mid++)
     {
         lines[mid] = lines[mid].Replace("\"", "\\\"");
         if (lines[mid].Contains('#'))
         {
             lines[mid] = lines[mid].Substring(0, lines[mid].IndexOf('#'));
         }
         lines[mid] = lines[mid].Trim();
         if (lines[mid].Length == 0)
         {
             continue;
         }
         def.Add(lines[mid]);
         if (lines[mid].Contains("---"))
         {
             found = true;
             continue;
         }
         if (found)
             response.Add(lines[mid]);
         else
             request.Add(lines[mid]);
     }
     //treat request and response like 2 message files, each with a partial definition and extra stuff tagged on to the classname
     Request = new MsgsFile(new MsgFileLocation(filename.Path.Replace(".srv",".msg"), filename.searchroot), true, request, "\t");
     Response = new MsgsFile(new MsgFileLocation(filename.Path.Replace(".srv", ".msg"), filename.searchroot), false, response, "\t");
 }
        public override bool Equals(object obj)
        {
            MsgFileLocation other = obj as MsgFileLocation;

            return(other != null && string.Equals(other.package, package) && string.Equals(other.basename, basename));
        }
Beispiel #3
0
        public MsgsFile(MsgFileLocation filename, string extraindent)
        {
            msgfilelocation = filename;
            if (resolver == null)
                resolver = new Dictionary<string, Dictionary<string,List<ResolvedMsg>>>();
            if (!filename.Path.Contains(".msg"))
                throw new Exception("" + filename + " IS NOT A VALID MSG FILE!");
            classname = filename.basename;
            Package = filename.package;
            //Parse for the Namespace
            Namespace += "." + filename.package;
            Name = filename.package + "." + classname;
            Namespace = Namespace.Trim('.');
            if (!resolver.Keys.Contains(Package))
                resolver.Add(Package, new Dictionary<string, List<ResolvedMsg>>());
            if (!resolver[Package].ContainsKey(classname))
                resolver[Package].Add(classname, new List<ResolvedMsg> { new ResolvedMsg{OtherType = Namespace + "." + classname, Definer = this} });
            else
                resolver[Package][classname].Add(new ResolvedMsg{OtherType = Namespace + "." + classname, Definer = this});
            List<string> lines = new List<string>(File.ReadAllLines(filename.Path));
            lines = lines.Where(st => (!st.Contains('#') || st.Split('#')[0].Length != 0)).ToList();
            for (int i = 0; i < lines.Count; i++)
                lines[i] = lines[i].Split('#')[0].Trim();
            //lines = lines.Where((st) => (st.Length > 0)).ToList();

            lines.ForEach(s =>
                              {
                                  if (s.Contains('#') && s.Split('#')[0].Length != 0)
                                      s = s.Split('#')[0];
                                  if (s.Contains('#'))
                                      s = "";
                              });
            lines = lines.Where(st => (st.Length > 0)).ToList();


            def = new List<string>();
            for (int i = 0; i < lines.Count; i++)
            {
                def.Add(lines[i]);
                SingleType test = KnownStuff.WhatItIs(this, lines[i], extraindent);
                if (test != null)
                    Stuff.Add(test);
            }
        }
Beispiel #4
0
 public MsgsFile(MsgFileLocation filename)
     : this(filename, "")
 {
 }
Beispiel #5
0
     MsgsFile(MsgFileLocation filename, bool isrequest, List<string> lines, string extraindent)
 {
     msgfilelocation = filename;
     if (resolver == null)
         resolver = new Dictionary<string, Dictionary<string, List<ResolvedMsg>>>();
     serviceMessageType = isrequest ? ServiceMessageType.Request : ServiceMessageType.Response;
     //Parse The file name to get the classname;
     classname = filename.basename;
     //Parse for the Namespace
     Namespace += "." + filename.package;
     Name = filename.package + "." + classname;
     classname += (isrequest ? "Request" : "Response");
     Namespace = Namespace.Trim('.');
     Package = filename.package;
     if (!resolver.Keys.Contains(Package))
         resolver.Add(Package, new Dictionary<string, List<ResolvedMsg>>());
     if (!resolver[Package].ContainsKey(classname))
         resolver[Package].Add(classname, new List<ResolvedMsg> { new ResolvedMsg { OtherType = Namespace + "." + classname, Definer = this } });
     else
         resolver[Package][classname].Add(new ResolvedMsg { OtherType = Namespace + "." + classname, Definer = this });
     def = new List<string>();
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i].Trim().Length == 0)
         {
             continue;
         }
         def.Add(lines[i]);
         SingleType test = KnownStuff.WhatItIs(this, lines[i], extraindent);
         if (test != null)
             Stuff.Add(test);
     }
 }
Beispiel #6
0
 public MsgsFile(MsgFileLocation filename, bool isrequest, List<string> lines)
     : this(filename, isrequest, lines, "")
 {
 }