예제 #1
0
파일: Header.cs 프로젝트: Ziolass/TSST-15Z
 /// <summary>
 /// Initializes a new instance of the <see cref="Header"/> class.
 /// </summary>
 /// <param name="header">The header.</param>
 public Header(Header header)
 {
     this.Checksum = header.Checksum;
     this.EOW = header.EOW;
     this.DCC = header.DCC;
     this.Type = ContentType.HEADER;
 }
예제 #2
0
 /// <summary>
 /// Evaluates the content. Read JSON object create IContent
 /// </summary>
 /// <param name="content">The content.</param>
 /// <returns></returns>
 private static IContent EvaluateContent(JObject content)
 {
     try
     {
         if (FrameBuilder.isVirtualContainer(content["Type"])) //VirtualContainer
         {
             //Create new VC with level from JSON file
             VirtualContainer newVC = new VirtualContainer(FrameBuilder.getVCLevel(content["Level"]));
             newVC.Pointer = content["Pointer"].ToString();
             newVC.POH = (POH)FrameBuilder.EvaluateContent((JObject)content["POH"]);
             if (FrameBuilder.isJArray(content["Content"]))
             {
                 newVC.Content = FrameBuilder.evaluateContents((JArray)content["Content"]);
             }
             else //There is no value Content of VC is null
             {
                 newVC.Content = null;
             }
             return newVC;
         }
         else if (FrameBuilder.isContainer(content["Type"]))
         {
             Container newContainer = new Container(content["Content"].ToString());
             return newContainer;
         }
         else if (FrameBuilder.isHeader(content["Type"]))
         {
             string checksum = content["Checksum"].ToString();
             string eow = content["EOW"].ToString();
             string dcc = content["DCC"].ToString();
             Header newHeader = new Header(checksum, eow, dcc);
             return newHeader;
         }
         else if (FrameBuilder.isPOH(content["Type"]))
         {
             SignalLabelType signalType = FrameBuilder.getSignalType(content["SignalLabel"]);
             POH poh = new POH(signalType);
             return poh;
         }
         else return null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return null;
     }
 }