Exemplo n.º 1
0
        public void Test1()
        {
            var rule = new ConditionRule
            {
                Condition = new AllMatch
                {
                    Conditions =
                    {
                        new CustomerAge     {
                            From = 10
                        },
                        new False(),
                        new ProductQuantity {
                            To = 50
                        },
                        new OrderDate       {
                            From = DateTime.Today
                        }
                    }
                }
            };

            var xaml = SimpleXamlSerializer.ToXaml(rule);

            Debug.Print(XElement.Parse(xaml).ToString());
        }
Exemplo n.º 2
0
        public SampleRuleViewModel()
        {
            m_data = SimpleXamlSerializer.ToXaml(SampleRules.GetOrCreateSampleRule());

            CopyCommand           = new RelayCommand(() => Clipboard.SetText(Data), () => !string.IsNullOrEmpty(Data));
            PasteCommand          = new RelayCommand(() => Data = Clipboard.GetText(), Clipboard.ContainsText);
            LoadDefaultCommand    = new RelayCommand(() => LoadDefault());
            ToggleEditModeCommand = new RelayCommand(() => IsInEditMode = !IsInEditMode);
            SetEditModeCommand    = new RelayCommand <bool>(x => IsInEditMode = x);
            ApplyEditTextCommand  = new RelayCommand(() => ApplyEditText());
            ApplyGraphCommand     = new RelayCommand(() => ApplyGraph(), () => IsGraphChanged);
            RevertGraphCommand    = new RelayCommand(() => Designer = null, () => IsGraphChanged);
            SaveCommand           = new RelayCommand(() => Save(), () => IsModified);
        }
Exemplo n.º 3
0
        public void ApplyGraph(bool isAutoApply = false)
        {
            if (m_designer == null || !IsGraphChanged)
            {
                return;
            }

            m_isAutoApplyMode = isAutoApply;
            try
            {
                AsText = SimpleXamlSerializer.ToXaml(Designer.Model.Value);
            }
            finally
            {
                m_isAutoApplyMode = false;
            }

            IsInEditMode   = false;
            IsGraphChanged = false;
            Changed();
        }
Exemplo n.º 4
0
        public RuleDesigner(string xaml)
        {
            var rule = string.IsNullOrEmpty(xaml) ? null : SimpleXamlSerializer.FromXaml <Rule>(xaml);

            m_model = RuleModelFactory.CreateModel(rule, m => Changed());
        }
Exemplo n.º 5
0
 private void LoadDefault()
 {
     Data = SimpleXamlSerializer.ToXaml(SampleRules.CreateSampleRule());
     LogInfo("Loaded default sample data.");
 }
Exemplo n.º 6
0
 public static Rule CreateRule(string xaml)
 {
     return(SimpleXamlSerializer.FromXaml <Rule>(xaml));
 }