private static T GetAttribute <T>(this NewElement element, Func <WebconProxy.Attribute, bool> selector) where T : WebconProxy.Attribute { var attributes = new List <WebconProxy.Attribute>(); attributes.AddRange(element.BoolAttributes); attributes.AddRange(element.ChooseAttributes); attributes.AddRange(element.CommentAttributes); attributes.AddRange(element.DateTimeAttributes); attributes.AddRange(element.DecimalAttributes); attributes.AddRange(element.HyperLinkAttributes); attributes.AddRange(element.IntegerAttributes); attributes.AddRange(element.PeopleAttributes); attributes.AddRange(element.PickerAttributes); attributes.AddRange(element.SubElementAttributes); attributes.AddRange(element.TextAttributes); attributes.AddRange(element.TreeAttributes); var att = attributes.FirstOrDefault(selector); if (att == null) { throw new MissingFieldException(); } return(att as T); }
public DownloadManager() { DeleteCommand = new DeleteCommand(); DeleteCommand.Subscriber += DeleteItemsEventhandler; NewCommand = new NewElement(); }
public void SetValue_WhenNoFieldWithGivenId_ShouldThrowFieldNotFoundException() { NewElement element = InitializeEmptyNewElement(); int nonExistingId = 15; Assert.ThrowsAny <FieldNotFoundException>(() => { element.SetValue(nonExistingId, 150); }); }
internal static T GetAttributeByName <T>(this NewElement element, string fieldName) where T : WebconProxy.Attribute { try { return(GetAttribute <T>(element, (a) => a.FieldName == fieldName)); } catch (MissingFieldException) { throw new FieldNotFoundException($"Could not find webcon attribute with name \"{fieldName}\""); } }
internal static T GetAttributeById <T>(this NewElement element, int id) where T : WebconProxy.Attribute { try { return(GetAttribute <T>(element, (a) => a.Id == id)); } catch (MissingFieldException) { throw new FieldNotFoundException($"Could not find webcon attribute with id: ({id})"); } }
public void GivenCommentAttributeWithId_WhenSearchingById_ShouldNotThrow() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); int id = 5; var att = new CommentAttribute() { Id = id }; element.CommentAttributes.Add(att); Action a = () => AttributesMapper.GetAttributeById <CommentAttribute>(element, id); a.Should().NotThrow <FieldNotFoundException>(); }
public void GivenCommentAttributeWithName_WhenSearchingByName_ShouldNotThrow() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); string fieldName = "WFD_Comment1"; var att = new CommentAttribute() { FieldName = fieldName }; element.CommentAttributes.Add(att); Action a = () => AttributesMapper.GetAttributeByName <CommentAttribute>(element, fieldName); a.Should().NotThrow <FieldNotFoundException>(); }
public void GivenCommentAttributeWithName_WhenSearchingByName_ShouldBeSameAsTheAddedOne() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); string fieldName = "WFD_Comment1"; var att = new CommentAttribute() { FieldName = fieldName }; element.CommentAttributes.Add(att); var foundAttribute = AttributesMapper.GetAttributeByName <CommentAttribute>(element, fieldName); foundAttribute.Should().Be(att); }
public void GivenCommentAttributeWithId_WhenSearchingById_ShouldBeSameAsTheAddedOne() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); int id = 5; var att = new CommentAttribute() { Id = id }; element.CommentAttributes.Add(att); var foundAttribute = AttributesMapper.GetAttributeById <CommentAttribute>(element, id); foundAttribute.Should().Be(att); }
public void SetValue_SetsBooleanAttribute() { NewElement element = InitializeEmptyNewElement(); int id = 15; var att = new BoolAttribute() { Id = id }; element.BoolAttributes.Add(att); bool value = true; element.SetValue(id, value); Assert.Equal(value, att.Value); }
public void SetValue_SetsDecimalAttribute() { NewElement element = InitializeEmptyNewElement(); int id = 15; var att = new DecimalAttribute() { Id = id }; element.DecimalAttributes.Add(att); decimal value = 15.15m; element.SetValue(id, value); Assert.Equal(value, att.Value); }
public void SetValue_SetsDateTimeAttribute() { NewElement element = InitializeEmptyNewElement(); int id = 15; var att = new DateTimeAttribute() { Id = id }; element.DateTimeAttributes.Add(att); DateTime value = DateTime.Now; element.SetValue(id, value); Assert.Equal(value, att.Value); }
public void SetValue_SetsStringAttribute() { NewElement element = InitializeEmptyNewElement(); int id = 15; var att = new TextAttribute() { Id = id }; element.TextAttributes.Add(att); string value = "test string"; element.SetValue(id, value); Assert.Equal(value, att.Value); }
public void SetValue_SetsIntegerAttribute() { NewElement element = InitializeEmptyNewElement(); int id = 15; var att = new IntegerAttribute() { Id = id }; element.IntegerAttributes.Add(att); int value = 150; element.SetValue(id, value); Assert.Equal(value, att.Value); }
public void AddComment_AddsComment() { NewElement element = InitializeEmptyNewElement(); int id = 15; var att = new CommentAttribute() { Id = id }; att.Value = new Comments(); element.CommentAttributes.Add(att); string value = "test string"; element.AddComment(id, value); Assert.Equal(value, att.Value.NewComment); }
// ------------------------------------------------------------------------ public void PressLeftButton() { if (Input.GetMouseButtonDown(0)) { isPressed = true; timer = 0; NewElement = GetObjectFromCursor(); } if (timer > clickTime && NewElement.IsNotNull() && isPressed && currentMode == InputMode.Properties) { Debug.Log("It is in drag mode now!!!"); SetMode(InputMode.Drag); } if (!Input.GetMouseButtonUp(0) && !Input.GetMouseButtonUp(2)) { return; } HandleClick(NewElement); isPressed = false; }
public static NewElement InitializeEmptyNewElement(NewElement element = null) { if (element == null) { element = new NewElement(); } element.BoolAttributes = new List <BoolAttribute>(); element.ChooseAttributes = new List <ChooseAttribute>(); element.DateTimeAttributes = new List <DateTimeAttribute>(); element.DecimalAttributes = new List <DecimalAttribute>(); element.HyperLinkAttributes = new List <HyperLinkAttribute>(); element.IntegerAttributes = new List <IntegerAttribute>(); element.PeopleAttributes = new List <PeopleAttribute>(); element.PickerAttributes = new List <PickerAttribute>(); element.SubElementAttributes = new List <SubelementAttribute>(); element.TextAttributes = new List <TextAttribute>(); element.TreeAttributes = new List <TreeAttribute>(); element.CommentAttributes = new List <CommentAttribute>(); return(element); }
public static void SetValue(this NewElement element, int id, string value) => GetAttributeById <TextAttribute>(element, id).Value = value;
/*Cliquer sur le Bouton de Création d'un nouvel élément (Lieu, Seigneur...)*/ private void newElemClick(object sender, RoutedEventArgs e) { NewElement element = new NewElement(); this.NavigationService.Navigate(element); }
public static void SetValue(this NewElement element, int id, bool value) => GetAttributeById <BoolAttribute>(element, id).Value = value;
public static void SetValue(this NewElement element, int id, DateTime value) => GetAttributeById <DateTimeAttribute>(element, id).Value = value;
public static void SetValue(this NewElement element, int id, decimal value) => GetAttributeById <DecimalAttribute>(element, id).Value = value;
public static void AddComment(this NewElement element, int id, string value) => GetAttributeById <CommentAttribute>(element, id).Value.NewComment = value;
public static void SetValue(this NewElement element, int id, int value) => GetAttributeById <IntegerAttribute>(element, id).Value = value;