private void SetInitialMutableValue()
        {
            var userFacingAbsKey = MutableField.AbsoluteKey;

            switch (MutableField.SchemaSource)
            {
            case SchemaSource.Mutable:
                SetSelectedMutableText("Local Payload" + (userFacingAbsKey.Length == 0 ? "" : ".") + userFacingAbsKey);
                break;

            case SchemaSource.Global:
                SetSelectedMutableText("Global Payload" + (userFacingAbsKey.Length == 0 ? "" : ".") + userFacingAbsKey);
                break;
            }

            var segmentCount = MutableField.AbsoluteKey.Count(c => c.Equals('.')) + 2;

            GetComponent <LayoutElement>().preferredHeight = segmentCount * 16;

            SchemaProvider.CacheSchema();
            bool fieldValid;

            try
            {
                fieldValid = MutableField.ValidateKey(SchemaProvider.Schema);
            }
            catch (NullReferenceException)
            {
                fieldValid = false;
            }
            SchemaProvider.UnCacheSchema();

            IndicateError = !fieldValid;
        }
Beispiel #2
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var extantDataField = new MutableField <T> {
                AbsoluteKey = PerElementAbsoluteKey.GetFirstValue(payload.Data)
            };

            bool valueAssigned = false;

            foreach (var entries in BoundsList.GetEntries(payload.Data))
            {
                var boundsList = BoundsList.GetValue(entries);

                foreach (var bound in boundsList)
                {
                    var useExtantValue = extantDataField.ValidateKey(bound.Data);

                    if (useExtantValue)
                    {
                        DefaultableField.SetValue(
                            extantDataField.GetLastKeyValue(bound.Data), payload.Data);
                        valueAssigned = true;
                    }
                    if (valueAssigned)
                    {
                        break;
                    }
                }
                if (valueAssigned)
                {
                    break;
                }
            }

            if (!valueAssigned)
            {
                DefaultableField.SetValue(DefaultValue.GetFirstValue(payload.Data), payload.Data);
            }

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
        //private void HandleGlobalParameterSelected( MutableBoxMutableItemBehaviour item )
        //{
        //    IndicateGlobalValue(item);
        //
        //    ShowItemDropDown = false;
        //}

        private void IndicateMutableValue(MutableBoxMutableItemBehaviour item)
        {
            SetSelectedMutableText(item.UserFacingAbsoluteKey);

            var segmentCount = item.UserFacingAbsoluteKey.Count(c => c.Equals('.')) + 1;

            GetComponent <LayoutElement>().preferredHeight = segmentCount * 16;

            UndoLord.Instance.Push(new MutableFieldChange(this, MutableField, item.UserFacingAbsoluteKey));

            // ArraySuffix never leaves this class!
            var arrayFreeText = item.AbsoluteKey.Replace(ArraySuffix, "");

            SchemaProvider.CacheSchema();
            MutableField.AbsoluteKey = arrayFreeText;

            MutableField.SchemaSource = item.SchemaSource;

            //////
            //MutableField.UseMutableValue = !item.useCachedData?
            //////

            //MutableField.UseMutableData = true;

            bool fieldValid;

            try
            {
                fieldValid = MutableField.ValidateKey(SchemaProvider.Schema);
            }
            catch (NullReferenceException)
            {
                fieldValid = false;
            }
            SchemaProvider.UnCacheSchema();

            IndicateError = !fieldValid;

            SwitchDisplayToMutableValue();

            //ShowItemDropDown = false;
        }
Beispiel #4
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            PayloadData = payload.Data;
            CacheSchema(); var extantDataField = new MutableField <T> {
                AbsoluteKey = PerElementAbsoluteKey.GetFirstValue(payload.Data)
            };

            bool valueAssigned = false;

            var boundsList = Expression.ResolveExpression(ChainView.Instance.Chain.RootBoundingBoxes);

            foreach (var bound in boundsList)
            {
                var useExtantValue = extantDataField.ValidateKey(bound.Data);

                if (useExtantValue)
                {
                    DefaultableField.SetValue(
                        extantDataField.GetLastKeyValue(bound.Data), payload.Data);
                    valueAssigned = true;
                }
                if (valueAssigned)
                {
                    break;
                }
            }

            if (!valueAssigned)
            {
                DefaultableField.SetValue(GetDefaultValue(payload.Data), payload.Data);
            }

            UnCacheSchema();

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
        public void DoUndo(bool toLiteral, string value)
        {
            if (LiteralValueDisplayPanel.activeInHierarchy != toLiteral)
            {
                if (toLiteral)
                {
                    SwitchDisplayToLiteralValue();
                }
                else
                {
                    SwitchDisplayToMutableValue();
                }
            }

            if (toLiteral)
            {
                LiteralValueInputFieldComponent.text = value;

                object result = null;

                var success = value.StringToValueOfType(Type, ref result);

                if (success)
                {
                    IndicateError = !MutableField.SetLiteralValueAsObject(result);
                }
            }
            else //This was a Mutable
            {
                var segmentCount = value.Count(c => c.Equals('.')) + 1;
                GetComponent <LayoutElement>().preferredHeight = segmentCount * 16;

                SetSelectedMutableText(value);

                var schemaSource = value.StartsWith("Local") ? SchemaSource.Mutable : SchemaSource.Global;
                value = value.Substring(value.IndexOf(".", StringComparison.CurrentCulture) + 1);

                // ArraySuffix never leaves this class!
                var arrayFreeText = value.Replace(ArraySuffix, "");

                SchemaProvider.CacheSchema();
                MutableField.AbsoluteKey = arrayFreeText;

                MutableField.SchemaSource = schemaSource;

                bool fieldValid;

                try
                {
                    fieldValid = MutableField.ValidateKey(SchemaProvider.Schema);
                }
                catch (NullReferenceException)
                {
                    fieldValid = false;
                }
                SchemaProvider.UnCacheSchema();

                IndicateError = !fieldValid;

                SwitchDisplayToMutableValue();
            }
        }