/// <summary>
 /// Initializes a new instance of the <see cref="VirtualContainer"/> class.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="content">The content.</param>
 public VirtualContainer(VirtualContainerLevel level, Container content)
 {
     this.Level = level;
     this.Type = ContentType.VICONTAINER;
     this.Content = this.GenerateContentList();
     this.Content[0] = content;
     this.POH = new POH();
     this.Pointer = string.Empty;
 }
        public void SentData(Dictionary<StreamData,string> dataToSent)
        {
            Dictionary<int, IFrame> outputData = new Dictionary<int, IFrame>();
            foreach (StreamData stream in dataToSent.Keys)
            {
                if (!Streams.Contains(stream))
                {
                    //TODO można rzucać wyjątek
                    continue;
                }

                if (!outputData.ContainsKey(stream.Port))
                {
                    outputData.Add(stream.Port, new Frame(stream.Stm));
                }

                //TODO ewentualne dzielenie danych
                Container content = new Container(dataToSent[stream]);
                VirtualContainer vc = new VirtualContainer(stream.VcLevel, content);
                outputData[stream.Port].SetVirtualContainer(stream.VcLevel, stream.HigherPath, stream.LowerPath, vc);
            }

            Ttf.PassDataToInterfaces(outputData);
        }
 /// <summary>
 /// Sets the content.
 /// </summary>
 /// <param name="container">The container.</param>
 public void SetContent(Container container)
 {
     this.Content[0] = container;
 }
示例#4
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;
     }
 }