示例#1
0
        private void OnConfig(IDiffSpread <string> spread)
        {
            if (!SkippedFirst)
            {
                // usually just the Default of the pin, any saved data will come next
                SkippedFirst = true;
                return;
                // default of the pin already mimmicks default Formular for this node
            }

            var formular = Formular;

            formular.Require(RequireEnum.None);

            if (FFormularSelection.IsAnyInvalid())
            {
                formular.Name = MessageFormular.DYNAMIC;
            }
            else
            {
                formular.Name = FFormularSelection[0].Name;
            }

            // overwrite fiels that occur in FConfig
            var config = new MessageFormular(MessageFormular.DYNAMIC, FConfig[0]);

            foreach (var field in config.FieldDescriptors)
            {
                formular[field.Name] = field;
            }

            Formular = formular;
        }
示例#2
0
        protected virtual void OnSelectFormular(IDiffSpread <EnumEntry> spread)
        {
            if (FFormularSelection.IsAnyInvalid() || string.IsNullOrWhiteSpace(FFormularSelection[0].Name))
            {
                FLogger.Log(LogType.Warning, "[\"" + this.GetType().Name + "\"] - Select a Formular. ID = " + PluginHost.GetNodePath(false));
                return;
            }

            var formularName = FFormularSelection[0].Name;

            if (Formular.Name == formularName)
            {
                return;
            }

            if (formularName != MessageFormular.DYNAMIC)
            {
                Formular = RetrieveAdoptedFormular(formularName);
            }
            else
            {
                // fallback to what's been known to the node
                // so a switch to DYNAMIC keeps the old entries (but makes them editable)
                Formular.Name = MessageFormular.DYNAMIC;
                Formular      = Formular;
            }
        }
        protected override void FillEnum(IEnumerable <string> fields)
        {
            var special = new string[] { "Topic", "TimeStamp" };

            var comparable = Enumerable.Empty <string>();

            if (!FFormularSelection.IsAnyInvalid())
            {
                comparable = from fieldName in fields
                             where !FFormularSelection.IsAnyInvalid()
                             let type = MessageFormularRegistry.Context[FFormularSelection[0].Name]?[fieldName]?.Type
                                        where type != null
                                        where type.IsPrimitive || type == typeof(string) || type is IComparable
                                        select fieldName;
            }

            var enums = special.Concat(comparable).ToArray();

            EnumManager.UpdateEnum(EnumName, enums.First(), enums);
        }
示例#4
0
        /// <summary>
        /// This will be called when a Formular is changed in the registry, to make all affected nodes comply with potential re-configuration
        /// </summary>
        /// <param name="sender">Usually Context</param>
        /// <param name="e">Contains the new Formular</param>
        protected virtual void FormularRemotelyChanged(MessageFormularRegistry sender, MessageFormular formular)
        {
            if (FFormularSelection.IsAnyInvalid())
            {
                return;                                     // before and during first frame input pins might not be valid yet
            }
            if (formular.IsDynamic)
            {
                return;
            }

            if (FFormularSelection[0] == formular.Name)
            {
                formular = RetrieveAdoptedFormular(formular.Name);
                if (!CustomizeFormular)
                {
                    formular.Require(RequireEnum.All);                     // always add all.
                }
                Formular = formular;
            }
        }