private static void LoadProperties(XElement xElement, PropertiesCollection propertiesDictionary) { XElement parent = xElement.Elements().FirstOrDefault(x => x.Name.LocalName == XmlNames.Properties); if (parent != null) { IEnumerable <XElement> properties = parent.Elements(); foreach (XElement property in properties) { string key = property.Attribute(XmlNames.Key)?.Value; if (!string.IsNullOrEmpty(key)) { if (property.HasElements) { var valueElements = property.Elements().Where(x => x.Name.LocalName == XmlNames.Value); if (!propertiesDictionary.ContainsKey(key)) { propertiesDictionary.Add(key, valueElements.Select(x => Json.Deserialize(x.Value))); } } else { string value = property.Value; if (!propertiesDictionary.ContainsKey(key)) { propertiesDictionary.Add(key, Json.Deserialize(value)); } } } } } }
public void AddWithOnePropertyDidNotExistsReturnsTrue() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); // Act var added = propertiesCollection.Add("Movie.Id Movie.Title"); // Assert Assert.True(added); }
public void AddWithSinglePropertyThatAlreadyExistsReturnsFalse() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); // Act var added = propertiesCollection.Add("Movie.Id"); // Assert Assert.False(added); }
public void ToStringWithMultiplePropertiesAddedReturnsPropertiesSeparatedByCommas() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); propertiesCollection.Add("Movie.Title"); // Act var propertiesCollectionAsString = propertiesCollection.ToString(); // Assert Assert.Equal("Movie.Id,Movie.Title", propertiesCollectionAsString); }
public void AddWithAllPropertiesAlreadyExistedReturnsFalse() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); propertiesCollection.Add("Movie.Title"); // Act var added = propertiesCollection.Add("Movie.Id Movie.Title"); // Assert Assert.False(added); }
private PropertiesCollection GetProperties(string target, SvnRevision asOfRevision, bool recurse) { try { PropertiesCollection result = new PropertiesCollection(); Collection <SvnPropertyListEventArgs> output; SvnPropertyListArgs args = new SvnPropertyListArgs(); args.Revision = asOfRevision; args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children; client.GetPropertyList(new Uri(target), args, out output); foreach (SvnPropertyListEventArgs eventArgs in output) { Dictionary <string, string> properties = new Dictionary <string, string>(eventArgs.Properties.Count); foreach (SvnPropertyValue value in eventArgs.Properties) { properties.Add(value.Key, value.StringValue); } result.Add(eventArgs.Path, properties); } return(result); } catch (Exception ex) { OnError(ex); } return(null); }
/// <summary> /// Prepares the procedure parameters needed to call the MySQL procedure. /// </summary> private void PrepareParameters() { _dbProcedure.InitializeParameters(); foreach (var dataTypeAndParameterTuple in _dbProcedure.Parameters) { var dataType = dataTypeAndParameterTuple.Item1; var parameter = dataTypeAndParameterTuple.Item2; var customProperty = new CustomProperty(parameter.ParameterName, parameter.Value, parameter.IsReadOnly(), true) { Description = string.Format("Direction: {0}, Data Type: {1}", parameter.Direction, dataType) }; _procedureParamsProperties.Add(customProperty); } FieldInfo fi = ParametersPropertyGrid.GetType().GetField("gridView", BindingFlags.NonPublic | BindingFlags.Instance); object gridViewRef = fi != null?fi.GetValue(ParametersPropertyGrid) : ParametersPropertyGrid; Type gridViewType = gridViewRef.GetType(); MethodInfo mi = gridViewType.GetMethod("MoveSplitterTo", BindingFlags.NonPublic | BindingFlags.Instance); int gridColWidth = (int)Math.Truncate(ParametersPropertyGrid.Width * 0.4); mi.Invoke(gridViewRef, new object[] { gridColWidth }); ParametersPropertyGrid.Refresh(); }
public PropertyEmitter CreateProperty(String name, PropertyAttributes attributes, Type propertyType) { PropertyEmitter propEmitter = new PropertyEmitter(this, name, attributes, propertyType); properties.Add(propEmitter); return(propEmitter); }
private void ActiveDocument_ActiveSegmentChanged(object sender, EventArgs e) { PropertiesCollection.Clear(); var doc = sender as Document; var segment = doc?.ActiveSegmentPair; var contexts = segment?.GetParagraphUnitProperties().Contexts; if (contexts?.Contexts?.Count > 0) { foreach (var context in contexts.Contexts) { var color = context.DisplayColor; var sdiModel = new DsiModel { DisplayName = context.DisplayName, Description = context.Description, Code = context.DisplayCode, }; if (color.Name == "0") // it doesn't have a color set { sdiModel.RowColor = "White"; } else { sdiModel.RowColor = "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2"); } PropertiesCollection.Add(sdiModel); } } }
public PropertyEmitter CreateProperty(string name, PropertyAttributes attributes, Type propertyType, Type[] arguments) { var propEmitter = new PropertyEmitter(this, name, attributes, propertyType, arguments); properties.Add(propEmitter); return(propEmitter); }
public void AddWithSinglePropertyIgnoresWhiteSpace() { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add(" Movie.Id "); // Assert Assert.True(propertiesCollection.Contains("Movie.Id")); }
public void AddWithWhiteSpaceStringWillNotAddAnyProperties(string whiteSpaceProperty) { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add(whiteSpaceProperty); // Assert Assert.Equal(0, propertiesCollection.Count); }
public void AddWithNullInstanceThrowsArgumentNullException() { // Arrange string collection = null; var propertiesCollection = new PropertiesCollection(); // Act // Assert Assert.Throws <ArgumentNullException>(() => propertiesCollection.Add(collection)); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var dataList = serializer.Deserialize <List <PropertyData> >(reader); var collection = new PropertiesCollection(); foreach (var el in dataList) { collection.Add(el.Name, el.Value); } return(collection); }
public void AddWithSinglePropertyAddsThatProperty() { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add("Movie.Id"); // Assert Assert.True(propertiesCollection.Contains("Movie.Id")); }
public void AddWillExtractAllPropertiesFromTheStringAndAddThemIndividually(string properties) { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add(properties); // Assert Assert.True(propertiesCollection.Contains("Movie.Id")); Assert.True(propertiesCollection.Contains("Movie.Title")); }
public void ToStringWithSinglePropertyAddedReturnsThatProperty() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); // Act var propertiesCollectionAsString = propertiesCollection.ToString(); // Assert Assert.Equal("Movie.Id", propertiesCollectionAsString); }
private bool AddThreadProperties( GitPullRequestCommentThread thread, GitPullRequestIterationChanges changes, IIssue issue, int iterationId, string commentSource) { thread.NotNull(nameof(thread)); changes.NotNull(nameof(changes)); issue.NotNull(nameof(issue)); var properties = new PropertiesCollection(); if (issue.AffectedFileRelativePath != null) { if (this.tfsPullRequest.CodeReviewId > 0) { var changeTrackingId = this.TryGetCodeFlowChangeTrackingId(changes, issue.AffectedFileRelativePath); if (changeTrackingId < 0) { // Don't post comment if we couldn't determine the change. return(false); } AddCodeFlowProperties(issue, iterationId, changeTrackingId, properties); } else { throw new NotSupportedException("Legacy code reviews are not supported."); } } // A VSTS UI extension will recognize this and format the comments differently. properties.Add("CodeAnalysisThreadType", "CodeAnalysisIssue"); thread.Properties = properties; // Add a custom property to be able to distinguish all comments created this way. thread.SetCommentSource(commentSource); // Add a custom property to be able to return issue message from existing threads, // without any formatting done by this addin, back to Cake.Issues.PullRequests. thread.SetIssueMessage(issue.Message); return(true); }
private static void AddCodeFlowProperties( IIssue issue, int iterationId, int changeTrackingId, PropertiesCollection properties) { issue.NotNull(nameof(issue)); properties.NotNull(nameof(properties)); properties.Add("Microsoft.VisualStudio.Services.CodeReview.ItemPath", "/" + issue.AffectedFileRelativePath); properties.Add("Microsoft.VisualStudio.Services.CodeReview.Right.StartLine", issue.Line); properties.Add("Microsoft.VisualStudio.Services.CodeReview.Right.EndLine", issue.Line); properties.Add("Microsoft.VisualStudio.Services.CodeReview.Right.StartOffset", 0); properties.Add("Microsoft.VisualStudio.Services.CodeReview.Right.EndOffset", 1); properties.Add("Microsoft.VisualStudio.Services.CodeReview.FirstComparingIteration", iterationId); properties.Add("Microsoft.VisualStudio.Services.CodeReview.SecondComparingIteration", iterationId); properties.Add("Microsoft.VisualStudio.Services.CodeReview.ChangeTrackingId", changeTrackingId); }
private void ActiveDocument_ActiveSegmentChanged(object sender, EventArgs e) { PropertiesCollection.Clear(); var doc = sender as Document; var segment = doc?.ActiveSegmentPair; var contexts = segment?.GetParagraphUnitProperties().Contexts; if (contexts?.Contexts?.Count > 0) { foreach (var context in contexts.Contexts) { var sdiModel = new SdiModel { DisplayName = context.DisplayName, Description = context.Description, Code = context.DisplayCode }; PropertiesCollection.Add(sdiModel); } } }
async void LoadProperties() { PropertiesCollection.Clear(); var items = Repository.GetProperties(); try { location = await Geolocation.GetLastKnownLocationAsync(); if (location == null) { location = await Geolocation.GetLocationAsync(); } foreach (Property item in items) { PropertyListItem listitem = new PropertyListItem(item); Location currLocation = new Location((double)item.Latitude, (double)item.Longitude); listitem.Distance = Xamarin.Essentials.Location.CalculateDistance(currLocation, location, DistanceUnits.Kilometers); PropertiesCollection.Add(listitem); } } catch (FeatureNotSupportedException fnsEx) { // Handle not supported on device exception } catch (FeatureNotEnabledException fneEx) { // Handle not enabled on device exception } catch (PermissionException pEx) { // Handle permission exception } catch (Exception ex) { // Unable to get location } }
private void LoadProperties() { if (IsBusy) { return; } IsBusy = true; PropertiesCollection.Clear(); try { var properties = Repository.GetProperties(); var items = new List <PropertyListItemViewModel>(); foreach (var property in properties) { var item = new PropertyListItemViewModel(property); if (_currentLocation != null) { item.DistanceInKilometres = _currentLocation.CalculateDistance(property.Latitude, property.Longitude, DistanceUnits.Kilometers); } items.Add(item); } foreach (var item in items.OrderBy(x => x.DistanceInKilometres)) { PropertiesCollection.Add(item); } } finally { IsBusy = false; } }
public void AddWithNullInstanceThrowsArgumentNullException() { // Arrange string collection = null; var propertiesCollection = new PropertiesCollection(); // Act // Assert Assert.Throws<ArgumentNullException>(() => propertiesCollection.Add(collection)); }
internal PropertiesCollection SourceProperties() { var result = new PropertiesCollection(); var properties = new Dictionary<string, string>(); properties.Add("svn:externals", "common svn://svn/repos/Trunk/Common"); properties.Add("svn:mime-type", "you should never see me"); result.Add("svn://svn/repos/Tags/Build/12/Common", properties); properties = new Dictionary<string, string>(); properties.Add("svn:mime-type", "you should never see me"); result.Add("svn://svn/repos/Tags/Build/12/Tool1", properties); return result; }
internal PropertiesCollection ExpectedProperties(int revision) { var result = new PropertiesCollection(); var properties = new Dictionary<string, string>(); properties.Add("svn:externals", "common svn://svn/repos/Trunk/Common@" + revision.ToString()); result.Add("svn://svn/repos/Tags/Build/12/Common", properties); return result; }
private PropertiesCollection GetProperties(string target, SvnRevision asOfRevision, bool recurse) { try { PropertiesCollection result = new PropertiesCollection(); Collection<SvnPropertyListEventArgs> output; SvnPropertyListArgs args = new SvnPropertyListArgs(); args.Revision = asOfRevision; args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children; client.GetPropertyList(new Uri(target), args, out output); foreach (SvnPropertyListEventArgs eventArgs in output) { Dictionary<string, string> properties = new Dictionary<string, string>(eventArgs.Properties.Count); foreach (SvnPropertyValue value in eventArgs.Properties) { properties.Add(value.Key, value.StringValue); } result.Add(eventArgs.Path, properties); } return result; } catch(Exception ex) { OnError(ex); } return null; }
public void ToStringWithMultiplePropertiesAddedReturnsPropertiesSeparatedByCommas() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); propertiesCollection.Add("Movie.Title"); // Act var propertiesCollectionAsString = propertiesCollection.ToString(); // Assert Assert.Equal("Movie.Id,Movie.Title", propertiesCollectionAsString); }
public void AddWithWhiteSpaceStringWillNotAddAnyProperties(string whiteSpaceProperty) { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add(whiteSpaceProperty); // Assert Assert.Equal(0, propertiesCollection.Count); }
public void AddWithAllPropertiesAlreadyExistedReturnsFalse() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); propertiesCollection.Add("Movie.Title"); // Act var added = propertiesCollection.Add("Movie.Id Movie.Title"); // Assert Assert.False(added); }
public void ToStringWithSinglePropertyAddedReturnsThatProperty() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); // Act var propertiesCollectionAsString = propertiesCollection.ToString(); // Assert Assert.Equal("Movie.Id", propertiesCollectionAsString); }
public void AddWithOnePropertyDidNotExistsReturnsTrue() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); // Act var added = propertiesCollection.Add("Movie.Id Movie.Title"); // Assert Assert.True(added); }
public void AddWillExtractAllPropertiesFromTheStringAndAddThemIndividually(string properties) { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add(properties); // Assert Assert.True(propertiesCollection.Contains("Movie.Id")); Assert.True(propertiesCollection.Contains("Movie.Title")); }
public void AddWithSinglePropertyIgnoresWhiteSpace() { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add(" Movie.Id "); // Assert Assert.True(propertiesCollection.Contains("Movie.Id")); }
public void AddWithSinglePropertyThatAlreadyExistsReturnsFalse() { // Arrange var propertiesCollection = new PropertiesCollection(); propertiesCollection.Add("Movie.Id"); // Act var added = propertiesCollection.Add("Movie.Id"); // Assert Assert.False(added); }
public void AddWithSinglePropertyAddsThatProperty() { // Arrange var propertiesCollection = new PropertiesCollection(); // Act propertiesCollection.Add("Movie.Id"); // Assert Assert.True(propertiesCollection.Contains("Movie.Id")); }