static void Main(string[] args) { int n = 42; object o = n; // Boxing Console.WriteLine($"1) n={n}, o={o}"); int m = (int)o; // Unboxing Console.WriteLine($"2) m={m}"); // value of o? n = 5; Console.WriteLine($"3) n={n}, o={o}"); // and now? S s = new S() { Name = "Klaus" }; Console.WriteLine($"4) s.Name={s.Name}"); INameable si = s; Console.WriteLine($"5) si.Name={si.Name}"); s.Name = "Hans"; Console.WriteLine($"6) s.Name={s.Name}, si.Name={si.Name}"); }
private static string GetTooltipForMember(IMember currentMember, INameable element) { var type = "(unknown type)"; var scope = "(unknown scope)"; try { if (element is IMember) { var member = element as IMember; scope = member.Parent == currentMember ? "(local)" : member.GetScopeDescription(); type = element.GetType().Name; } else if (element is Variable) { var variable = element as Variable; type = variable.TypeString; scope = variable.Member.GetType().Name + " " + variable.Member.Name; } } catch (Exception e) { Log.Error("Error getting type/scope for element " + element.Name + " while generating tooltip", e); } return(type + ", in " + scope); }
internal void Attach(string objectType, INameable editedObject) { EditedObject = editedObject; ObjectTypeLabel.Text = $"{objectType}:"; ObjectNameLabel.Text = EditedObject.GetName(); }
public void GetInfo(object item, ItemInfo info) { IListable listable = item.As <IListable>(); if (listable != null) { listable.GetInfo(info); return; } IResource resource = item.As <IResource>(); if (resource != null && !item.Is <Game>()) { info.Label = Path.GetFileName(resource.Uri.LocalPath); info.ImageIndex = info.GetImageList().Images.IndexOfKey(Sce.Atf.Resources.ResourceImage); return; } // If the object has a name use it as the label (overriding whatever may have been set previously) INameable nameable = Adapters.As <INameable>(item); if (nameable != null) { info.Label = nameable.Name; } }
public void Show(INameable nameable) { this.nameable = nameable; showing = true; rect = new Rectangle((1280 / 2) - 250, 720/2, 500, 200); }
static void AddCurrentlyLoadedInstructionSet() { #region Add the per-object InstructionSets // When the InstructionSet is created from the InstructionSetSave, a scene must be passed // so that the instructions can be hooked up correctly. List <InstructionSet> instructionSetList = InstructionSetSaveList.ToInstructionSetList(EditorData.BlockingScene); for (int i = 0; i < InstructionSetSaveList.InstructionSetSaves.Count; i++) { string objectName = InstructionSetSaveList.InstructionSetSaves[i].Target; INameable target = EditorData.BlockingScene.FindByName(objectName); if (target == null) { //EditorData.GlobalInstructionSets.Add(instructionSetList[i]); } else { // The dictionary is already populated with the instruction sets EditorData.ObjectInstructionSets[target] = instructionSetList[i]; } } #endregion #region Add the AnimationSequences EditorData.GlobalInstructionSets = InstructionSetSaveList.ToAnimationSequenceList(instructionSetList); #endregion }
private void CreateAnalysisReport(DateTime renderBegins, IDirective directive) { if (!Configurations.Xeora.Application.Main.PrintAnalysis) { return; } string analysisOutput = directive switch { INameable nameable => $"{directive.UniqueId} - {nameable.DirectiveId}", IHasBind hasBind => $"{directive.UniqueId} - {hasBind.Bind}", _ => directive.UniqueId }; double totalMs = DateTime.Now.Subtract(renderBegins).TotalMilliseconds; this._Mother.AnalysisBulk.AddOrUpdate( directive.Type, new Tuple <int, double>(1, totalMs), (k, v) => new Tuple <int, double>(v.Item1 + 1, v.Item2 + totalMs)); Basics.Console.Push( $"analysed - {directive.GetType().Name}", $"{totalMs}ms {{{analysisOutput}}}", string.Empty, false, groupId: Helpers.Context.UniqueId, type: totalMs > Configurations.Xeora.Application.Main.AnalysisThreshold ? Basics.Console.Type.Warn: Basics.Console.Type.Info); }
public string Name(INameable nameable) { // use a custom namespace if defined var custom = nameable as ICustomizable; return(custom?.Namespace ?? nameable.Name.ToCamelCase()); }
static void Main(string[] args) { int n = 42; object o = n; // Boxing Console.WriteLine($"1) n={n}, o={o}"); //n=42, o=42 int m = (int)o; // Unboxing Console.WriteLine($"2) m={m}"); //m = 42 // value of o? o wird nicht geändert n = 5; Console.WriteLine($"3) n={n}, o={o}"); //Wirkliche benutzung S s = new S() { Name = "Klaus" }; Console.WriteLine($"4) s.Name={s.Name}"); INameable si = s; Console.WriteLine($"5) si.Name={si.Name}"); // auch Klaus s.Name = "Hans"; Console.WriteLine($"6) s.Name={s.Name}, si.Name={si.Name}"); // si bleibt beim alten, weil es boxed ist }
public void AddAsSharedResourceWithContainer(INameable resourceToAdd, string initialName = null, bool askUser = true) { if (!_isInitialized) { throw new Exception(); } IResourcesAddingViewModel resourcesAddingViewModel = _container.Resolve <IResourcesAddingViewModel>(); IResourceViewModel resourceViewModel = _resourceViewModelGettingFunc(); resourceViewModel.RelatedEditorItemViewModel = resourceToAdd; if (initialName != null) { resourceViewModel.Name = initialName; } else { resourceViewModel.Name = resourceToAdd.Name; } resourcesAddingViewModel.ResourceWithName = resourceViewModel; if (askUser) { _applicationGlobalCommands.ShowWindowModal(() => new ResourcesAddingWindow(), resourcesAddingViewModel); } else { resourcesAddingViewModel.IsResourceAdded = true; } if (resourcesAddingViewModel.IsResourceAdded) { _resourceViewModelsInContainers.Add(resourceViewModel); } UpdateResourcesViewModelCollection(); }
private void DoubleClickAnimationSequenceListBox(Window callingWindow) { object highlightedObject = mAnimationSequenceListBox.GetFirstHighlightedObject(); if (highlightedObject != null) { if (highlightedObject is AnimationSequence) { // Any logic here? } else if (highlightedObject is TimedKeyframeList) { // Find the object that this references and select it. TimedKeyframeList asTimedKeyframeList = highlightedObject as TimedKeyframeList; INameable target = EditorData.BlockingScene.FindByName(asTimedKeyframeList.TargetName); if (target is Sprite) { EditorData.EditorLogic.SelectObject <Sprite>(target as Sprite, EditorData.EditorLogic.CurrentSprites); } // else other types GuiData.TimeLineWindow.InstructionMode = InstructionMode.Current; EditorData.EditorLogic.CurrentKeyframeList = asTimedKeyframeList.KeyframeList; } } }
public CombatActor(INameable name, IStats stats, IDamageable damageable, IDamageDealer dealer) { Name = name; Target = null; Stats = stats; Damageable = damageable; DamageDealer = dealer; }
public static void ToString_NameIsEmpty_ReturnsClassName(INameable nameable) { // Arrange // Act var result = nameable.ToString(); // Assert Assert.AreEqual(nameable.GetType().Name, result); }
public void SetName(object item, string name) { INameable nameable = item.As <INameable>(); if (nameable != null && !string.IsNullOrEmpty(name)) { nameable.Name = name; } }
protected void Process(INameable nameable, MemberInfo info) { if (!nameable.IsNameSpecified) { if (info == null) throw new ConventionException("Cannot apply the naming convention. No member specified.", nameable); nameable.Name = DetermineNameFromMember(info); } }
static void Main(string[] args) { Dictionary <string, INameable> inhabitants = new Dictionary <string, INameable>(); int count = int.Parse(Console.ReadLine()); for (int counter = 0; counter < count; counter++) { string[] inhabitantInfo = Console.ReadLine().Split(); switch (inhabitantInfo.Length) { case 4: string name = inhabitantInfo[0]; int age = int.Parse(inhabitantInfo[1]); string id = inhabitantInfo[2]; string birthdate = inhabitantInfo[3]; INameable citizen = new Citizen(name, age, id, birthdate); inhabitants.Add(name, citizen); break; case 3: name = inhabitantInfo[0]; age = int.Parse(inhabitantInfo[1]); string group = inhabitantInfo[2]; INameable rebel = new Rebel(name, age, group); inhabitants.Add(name, rebel); break; } } int foodBougth = 0; string personName; while ((personName = Console.ReadLine()) != "End") { if (inhabitants.ContainsKey(personName) == false) { continue; } INameable person = inhabitants[personName]; switch (person.GetType().Name) { case "Citizen": foodBougth += 10; break; case "Rebel": foodBougth += 5; break; } } Console.WriteLine(foodBougth); }
public string GetName(object item) { INameable nameable = item.As <INameable>(); if (nameable != null) { return(nameable.Name); } return(null); }
public static void ToString_NameIsNotEmpty_ReturnsName(INameable nameable) { //// Arrange //nameable.Name = "TestName"; //// Act //var result = nameable.ToString(); //// Assert //Assert.AreEqual(nameable.Name, result); }
public static string Print(INameable nameable) { string result = nameable.Name; if (nameable.GetType().IsDefined(typeof(FancyAttribute), false)) { result = $"*** {nameable.Name}"; } return(result); }
public void UpdateSharedResource(INameable resourceToAdd) { var existing = _deviceSharedResources.SharedResources.FirstOrDefault(nameable => nameable.Name == resourceToAdd.Name); if (existing != null) { _deviceSharedResources.SharedResources.Remove(existing); } _deviceSharedResources.SharedResources.Add(resourceToAdd); UpdateResourcesViewModelCollection(); }
public static void AddKeyframeToGlobalInstrutionSet(Window callingWindow) { KeyframeList keyframeList = ((KeyframeListSelectionWindow)callingWindow).SelectedKeyframeList; INameable targetNameable = ((KeyframeListSelectionWindow)callingWindow).SelectedNameable; TimedKeyframeList timedKeyframeList = new TimedKeyframeList(keyframeList, targetNameable.Name); timedKeyframeList.TimeToExecute = GuiData.TimeLineWindow.CurrentValue; // Add the selected KeyframeList to the Global InstructionSet EditorData.EditorLogic.CurrentAnimationSequence.Add(timedKeyframeList); }
public static bool IsNameUnique <T>(INameable nameable, IList <T> listToCheckAgainst) where T : INameable { for (int i = 0; i < listToCheckAgainst.Count; i++) { INameable nameableToCheckAgainst = listToCheckAgainst[i]; if (nameable != nameableToCheckAgainst && nameable.Name == nameableToCheckAgainst.Name) { return(false); } } return(true); }
/// <summary> /// Called on label edited event /// </summary> /// <param name="e">Event args</param> protected virtual void OnNodeLabelEdited(TreeControl.NodeEventArgs e) { INameable nameable = e.Node.Tag.As <INameable>(); if (nameable != null) { ITransactionContext transactionContext = Adapters.As <ITransactionContext>(m_treeControlAdapter.TreeView); transactionContext.DoTransaction( delegate { nameable.Name = e.Node.Label; }, Localizer.Localize("Edit Label")); } }
public void Interface() { ISession s = OpenSession(); object id = s.Save(new BasicNameable()); s.Flush(); s.Close(); s = OpenSession(); INameable n = (INameable)s.Load(typeof(INameable), id); s.Delete(n); s.Flush(); s.Close(); }
public async Task InterfaceAsync() { ISession s = OpenSession(); object id = await(s.SaveAsync(new BasicNameable())); await(s.FlushAsync()); s.Close(); s = OpenSession(); INameable n = (INameable)await(s.LoadAsync(typeof(INameable), id)); await(s.DeleteAsync(n)); await(s.FlushAsync()); s.Close(); }
/// <summary> /// Initializes a new instance of the <see cref="RoboCup.AtHome.CommandGenerator.Token"/> class. /// </summary> /// <param name="key">The original substring in the taks prototype string.</param> /// <param name="value">The replacement object for the wildcard represented by this Token.</param> /// <param name="metadata">Additional metadata to add (e.g. from the grammar /// or the taks prototype string).</param> public Token(string key, INameable value, IEnumerable <string> metadata) { this.key = key; this.value = value; this.metadata = new List <string>(); IMetadatable imvalue = value as IMetadatable; if (imvalue != null) { this.metadata.AddRange(imvalue.Metadata); } if (metadata != null) { this.metadata.AddRange(metadata); } }
public InstructionSet ToInstructionSet(FlatRedBall.Scene scene) { InstructionSet instructionSet = new InstructionSet(); instructionSet.Name = this.Target; INameable nameable = null; foreach (KeyframeListSave keyframeList in Instructions) { KeyframeList keyframes = new KeyframeList(); keyframes.Name = keyframeList.Name; instructionSet.Add(keyframes); foreach (KeyframeSave keyframe in keyframeList.SceneKeyframes) { InstructionList list = new InstructionList(); list.Name = keyframe.Name; keyframes.Add(list); foreach (InstructionSave instructionSave in keyframe.InstructionSaves) { if (nameable == null || nameable.Name != instructionSave.TargetName) { // We don't have a nameable yet, or the current instruction is // not modifying the one referenced by nameable. nameable = scene.Sprites.FindByName(instructionSave.TargetName); if (nameable == null) { nameable = scene.SpriteFrames.FindByName(instructionSave.TargetName); } } if (nameable == null) { throw new NullReferenceException("Could not find an object of instance " + instructionSave.Type + " with the name " + instructionSave.TargetName); } list.Add(instructionSave.ToInstruction(nameable)); } } } return(instructionSet); }
private void BaseListUserControl_Filter(object sender, FilterEventArgs e) { INameable nameable = e.Item as INameable; if (nameable != null) { if (FilterControl.IsEmpty || nameable.DisplayName.ToLower().Contains(FilterControl.Text.ToLower())) { e.Accepted = true; } else { e.Accepted = false; } } else { e.Accepted = true; } }
private void Init() { if (m_game != null) { return; } NativeObjectAdapter curLevel = GameEngine.GetGameLevel(); try { // create new document by creating a Dom node of the root type defined by the schema DomNode rootNode = new DomNode(m_schemaLoader.GameType, m_schemaLoader.GameRootElement); INameable nameable = rootNode.As <INameable>(); nameable.Name = "Game"; NativeObjectAdapter gameLevel = rootNode.Cast <NativeObjectAdapter>(); GameEngine.CreateObject(gameLevel); GameEngine.SetGameLevel(gameLevel); gameLevel.UpdateNativeOjbect(); NativeGameWorldAdapter gworld = rootNode.Cast <NativeGameWorldAdapter>(); m_game = rootNode.Cast <IGame>(); IGameObjectFolder rootFolder = m_game.RootGameObjectFolder; m_renderSurface.Game = m_game; m_renderSurface.GameEngineProxy = m_gameEngine; } finally { GameEngine.SetGameLevel(curLevel); } m_mainWindow.Closed += delegate { GameEngine.DestroyObject(m_game.Cast <NativeObjectAdapter>()); m_renderSurface.Dispose(); }; }
public void AddAsSharedResource(INameable resourceModelToAdd, bool askUser) { if (!_isInitialized) { throw new Exception(); } IResourcesAddingViewModel resourcesAddingViewModel = _container.Resolve <IResourcesAddingViewModel>(); resourcesAddingViewModel.ResourceWithName = resourceModelToAdd; if (askUser) { _applicationGlobalCommands.ShowWindowModal(() => new ResourcesAddingWindow(), resourcesAddingViewModel); } else { resourcesAddingViewModel.IsResourceAdded = true; } if (resourcesAddingViewModel.IsResourceAdded) { _deviceSharedResources.SharedResources.Add(resourceModelToAdd); } UpdateResourcesViewModelCollection(); }
private void Init() { NativeObjectAdapter curLevel = GameEngine.GetGameLevel(); try { // create new document by creating a Dom node of the root type defined by the schema DomNode rootNode = new DomNode(m_schemaLoader.GameType, m_schemaLoader.GameRootElement); INameable nameable = rootNode.Cast <INameable>(); nameable.Name = "ThumbnailGenerator"; NativeObjectAdapter gameLevel = rootNode.Cast <NativeObjectAdapter>(); GameEngine.CreateObject(gameLevel); GameEngine.SetGameLevel(gameLevel); gameLevel.UpdateNativeOjbect(); NativeGameWorldAdapter gworld = rootNode.Cast <NativeGameWorldAdapter>(); m_game = rootNode.Cast <IGame>(); IGameObjectFolder rootFolder = m_game.RootGameObjectFolder; m_renderSurface = new TextureRenderSurface(96, 96); m_renderState = new RenderState(); m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows; } finally { GameEngine.SetGameLevel(curLevel); } m_mainWindow.Closed += delegate { GameEngine.DestroyObject(m_game.Cast <NativeObjectAdapter>()); m_renderSurface.Dispose(); m_renderState.Dispose(); }; }
public static void FilterINameableListBox(this FrameworkElement element, string filter) { for (int i = 0; i != VisualTreeHelper.GetChildrenCount(element); i += 1) { FrameworkElement child = VisualTreeHelper.GetChild(element, i) as FrameworkElement; if (child != null) { if (child is ListBoxItem) { child.Visibility = Visibility.Visible; if (filter != "") { INameable ctx = (INameable)child.DataContext; if (!ctx.Name.ToLower().Contains(filter.ToLower())) child.Visibility = Visibility.Collapsed; } } else { child.FilterINameableListBox(filter); } } } }
private void scene_OnNameChanged(INameable sender, string oldName) { this.TabText = sender.Name; }
static int CompareScreenSaves(INameable firstScreenSave, INameable secondScreenSave) { return firstScreenSave.Name.CompareTo(secondScreenSave.Name); }
public int Compare(INameable x, INameable y) { return x.Name.CompareTo(y.Name); }
private string GetLogHeader(INameable obj) { return "[" + GetTimeWithMilliseconds() + "]" + "(" + obj.Name + ")"; }