protected override void HandleConfigChange(IDiffSpread<string> configSpread)
        {
            FCount = 0;
            List<string> invalidPins = FPins.Keys.ToList();
            var formular = new MessageFormular(configSpread[0]);

            foreach (string field in formular.Fields)
            {
                bool create = false;

                if (FPins.ContainsKey(field) && FPins[field] != null)
                {
                    invalidPins.Remove(field);

                    if (FTypes.ContainsKey(field))
                    {
                        if (FTypes[field] != formular.GetType(field))
                        {
                            FPins[field].Dispose();
                            FPins[field] = null;
                            create = true;
                        }

                    }
                    else
                    {
                        // key is in FPins, but no type defined. should never happen
                        create = true;
                    }
                }
                else
                {
                    FPins.Add(field, null);
                    create = true;
                }

                if (create)
                {
                    Type type = formular.GetType(field);
                    IOAttribute attr = DefinePin(field, type, formular.GetCount(field)); // each implementation of DynamicPinsNode must create its own InputAttribute or OutputAttribute (
                    Type pinType = typeof(ISpread<>).MakeGenericType((typeof(ISpread<>)).MakeGenericType(type)); // the Pin is always a binsized one
                    FPins[field] = FIOFactory.CreateIOContainer(pinType, attr);

                    FTypes.Add(field, type);
                }
                FCount += 2; // total pincount. always add two to account for data pin and binsize pin
            }
            foreach (string name in invalidPins)
            {
                FPins[name].Dispose();
                FPins.Remove(name);
                FTypes.Remove(name);
            }
        }
Exemple #2
0
 public Message(MessageFormular formular) 
 {
     Address = "vvvv";
     TimeStamp = Time.Time.CurrentTime(); // init with local timezone
     SetConfig(formular);
 }
Exemple #3
0
 public void SetConfig(MessageFormular formular)
 {
     foreach (string field in formular.Fields)
     {
         Data[field] = Bin.New(formular.GetType(field)); // Type
         var count = formular.GetCount(field);
         count = count <= -1 ? 1 : count;
         Data[field].SetCount(count); // Count
     }
 }
        protected override void HandleConfigChange(IDiffSpread<string> configSpread)
        {
            var form = new MessageFormular(configSpread[0]);

            FillEnum(form.Fields.ToArray());
        }
 public MessageFormularChangedEvent(MessageFormular formular) : base()
 {
     this.Formular = formular;
 }