static void Main(string[] args) { ConsoleApp app = new ConsoleApp(); app.LogInfo(); IConsoleInfo consoleInfo = app; consoleInfo.Display(); IDisplayInfo displayInfo = app; displayInfo.Display(); //Generic interface usage Calculator calc = new Calculator(); calc.AddObject(10, 5); //Integer values 10 and 5 are boxed into an object when passed. It will print 15 calc.Add(10, 5); //It will call generic method with integer parameters and print 15. calc.Add("Hello", "World"); //It will call generic method with string parameters and print HelloWorld //Passing strings to AddObject method will still compile, //but it will throw an InvalidCastException at runtime calc.AddObject("Hello", "World"); Console.Read(); }
public void InitPreview(CharacterInfoPreviewPanel t, IDisplayInfo b) { infoText = t; buff = b; buffName.text = b.GetName(); }
void CreateLabel(IDisplayInfo item, Transform region) { BuffDisplayWrapper i = Instantiate <BuffDisplayWrapper>(buffPrefab, region); i.InitPreview(characterInfoPreviewPanel, item); buffDisplay.Add(i); }
private static UIElement GetTextBlock(IDisplayInfo displayInfo) { return(new TextBlock { Text = displayInfo.Title + " " + displayInfo.ControlType.ProgrammaticName, IsEnabled = displayInfo.IsWritable }); }
public void InitPanel(IDisplayInfo skill) { this.skill = skill; text.text = skill.GetHotbarDescription(); gameObject.SetActive(true); }
public void TestAttributes() { CommandInterpreter ci = new CommandInterpreter(new TestCommands()); IOption option = ci.Options[0]; //[Option("Other")] Assert.AreEqual("Other", option.DisplayName); Assert.AreEqual(typeof(int), option.Type); //[AliasName("alias")] //[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")] Assert.AreEqual(2, option.AllNames.Length); Assert.IsTrue(new List <string>(option.AllNames).Contains("Other")); Assert.IsTrue(new List <string>(option.AllNames).Contains("alias")); //[System.ComponentModel.Description("description")] Assert.AreEqual("description", option.Description); //[System.ComponentModel.Category("category")] Assert.AreEqual("category", option.Category); //[System.ComponentModel.Browsable(false)] Assert.AreEqual(false, option.Visible); //[System.ComponentModel.DefaultValue(-1)] Assert.AreEqual(-1, option.Value); { CommandFilterAttribute a = new CommandFilterAttribute(); Assert.IsFalse(a.Visible); a.Visible = true; Assert.IsFalse(a.Visible); } { CommandAttribute a = new CommandAttribute(); a.DisplayName = "test"; a.AliasNames = new string[] { "alias" }; Assert.AreEqual("test,alias", String.Join(",", a.AllNames)); IDisplayInfo di = a; di.Help(); //no-op } { AllArgumentsAttribute a = new AllArgumentsAttribute(); Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType()); } }
private static UIElement GetComboBox(IDisplayInfo displayInfo) { var comboBox = new ComboBox { IsEnabled = displayInfo.IsWritable }; if (displayInfo.ChoiceElements != null) { foreach (var choiceElement in displayInfo.ChoiceElements) { comboBox.Items.Add(new ListBoxItem() { Content = choiceElement }); } } return(comboBox); }
public static void Init(IDisplayInfo displayInfo) { Get = displayInfo; System.Diagnostics.Debug.WriteLine(string.Format("DisplayInfo.Init {0}x{1} ({2}x)", Width, Height, Scale)); }
public static UIElement ToUIElement(this IDisplayInfo displayInfo) { return(_uiElementRetrievers[displayInfo.ControlType](displayInfo)); }
private void ShowHelpFor(IDisplayInfo[] items) { Dictionary<string, List<IDisplayInfo>> found = new Dictionary<string, List<IDisplayInfo>>(StringComparer.OrdinalIgnoreCase); foreach (IDisplayInfo item in items) { if (!item.Visible) continue; List<IDisplayInfo> list; string group = item is Option ? "Options" : "Commands"/*item.Category*/; if (!found.TryGetValue(group, out list)) found.Add(group, list = new List<IDisplayInfo>()); if (!list.Contains(item)) list.Add(item); } List<string> categories = new List<string>(found.Keys); categories.Sort(); foreach (string cat in categories) { System.Console.Out.WriteLine("{0}:", cat); found[cat].Sort(new OrderByName<IDisplayInfo>()); int indent = 6; foreach (IDisplayInfo info in found[cat]) { if (info.DisplayName.Length > indent) indent = info.DisplayName.Length; } string fmt = " {0," + indent + "}: {1}"; foreach (IDisplayInfo info in found[cat]) { System.Console.Out.WriteLine(fmt, info.DisplayName.ToUpper(), info.Description); } System.Console.WriteLine(); } }
/// <summary> /// Can be overridden to control or rewrite help output /// </summary> protected virtual void ShowHelp(IDisplayInfo[] items) { if (items.Length == 1) items[0].Help(); else ShowHelpFor(items); }
public void InitButton(IDisplayInfo skill, SkillTooltipPanel panel) { this.currSkill = skill; this.panel = panel; }