Ejemplo n.º 1
0
Archivo: Mode.cs Proyecto: hww/VARP2
 public Mode(Mode parentMode, string name, string help = null, KeyMap keyMap = null)
 {
     this.parentMode = parentMode;
     this.name       = name;
     this.help       = help;
     this.keyMap     = keyMap;
 }
Ejemplo n.º 2
0
Archivo: KeyMap.cs Proyecto: hww/VARP2
        public virtual bool Define([NotNull] int[] sequence, object value)
        {
            if (sequence == null)
            {
                throw new ArgumentNullException("sequence");
            }

            var curentMap = this;
            var lastIndex = sequence.Length - 1;

            for (var i = 0; i < sequence.Length; i++)
            {
                var key = sequence[i];
                var tmp = curentMap.GetLocal(key); // do not alow defaults
                if (tmp == null)
                {
                    // there is no this binding
                    // N.B. Do not look at the parent one!
                    if (i == lastIndex)
                    {
                        // the curentMap is the target map and it does not have definition
                        curentMap.SetLocal(key, value);
                        return(true);
                    }
                    else
                    {
                        // the curentMap is the map in the sequence and it does not have definition
                        var newMap = new KeyMap();
                        curentMap.SetLocal(key, newMap);
                        curentMap = newMap;
                    }
                }
                else
                {
                    // we found binding in curentMap
                    if (i == lastIndex)
                    {
                        // curentMap is target map, it has binding but we have to redefine it
                        curentMap.SetLocal(key, value);
                    }
                    else
                    {
                        // the curentMap is the map in the sequence and it has definition
                        var map = tmp.value as KeyMap;
                        if (map != null)
                        {
                            curentMap = map;
                        }
                        else
                        {
                            throw new Exception(string.Format("Expect KeyMap at '{0}' found: '{1}' in: '{2}'", sequence[i], tmp, sequence));
                        }
                    }
                }
            }
            throw new Exception("We can\'t be here");
        }
Ejemplo n.º 3
0
Archivo: KeyMap.cs Proyecto: hww/VARP2
 /// <summary>
 /// Create empty keymap based on parent keymap
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="title"></param>
 public KeyMap([NotNull] KeyMap parent, string title = null)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     this.title  = title;
     this.parent = parent;
     items       = new List <KeyMapItem>();
 }
Ejemplo n.º 4
0
Archivo: KeyMap.cs Proyecto: hww/VARP2
 public virtual void CopyTo(KeyMap other)
 {
     other.title  = title;
     other.title  = help;
     other.parent = parent;
     foreach (var item in items)
     {
         other.SetLocal(item.key, item.value);
     }
 }
Ejemplo n.º 5
0
Archivo: KeyMap.cs Proyecto: hww/VARP2
 /// <summary>
 /// Create empty keymap based on parent keymap
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="title"></param>
 public FullKeymap([NotNull] KeyMap parent, string title = null) : base(parent, title)
 {
 }
Ejemplo n.º 6
0
Archivo: KeyMap.cs Proyecto: hww/VARP2
 public KeyMap(KeyMap parent, string title, string help = null) : this(parent, title)
 {
     this.title = help;
 }
Ejemplo n.º 7
0
Archivo: Mode.cs Proyecto: hww/VARP2
 public Mode(string name, string help = null, KeyMap keyMap = null)
 {
     this.name   = name;
     this.help   = help;
     this.keyMap = keyMap;
 }
Ejemplo n.º 8
0
 private ReadLine(Mode parentMode, string name, string help = null, KeyMap keyMap = null)
     : base(parentMode, name, help, keyMap)
 {
     Initialize();
 }
Ejemplo n.º 9
0
 private ReadLine(string name, string help = null, KeyMap keyMap = null) : base(name, help, keyMap)
 {
     Initialize();
 }