public string CreateBrowseUrl(int pageNum) { var finalUrl = Url.Replace("{platform}", Platform); finalUrl = finalUrl.Replace("{accessibilityFilter}", AccessibilityFilter.ToString()); finalUrl = finalUrl.Replace("{channel}", ((int)Channel).ToString()); finalUrl = finalUrl.Replace("{category}", Category.ToString()); finalUrl = finalUrl.Replace("{language}", "0"); finalUrl = finalUrl.Replace("{country}", Country); finalUrl = finalUrl.Replace("{locale}", "en-US"); finalUrl = finalUrl.Replace("{pageNum}", pageNum.ToString()); return(finalUrl); }
/// <summary> /// Return a JSON-representation of this object. /// </summary> /// <param name="CustomPullEVSEDataRequestSerializer">A delegate to customize the serialization of PullEVSEDataRequest responses.</param> /// <param name="CustomGeoCoordinatesSerializer">A delegate to serialize custom geo coordinates JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <PullEVSEDataRequest> CustomPullEVSEDataRequestSerializer = null, CustomJObjectSerializerDelegate <GeoCoordinates> CustomGeoCoordinatesSerializer = null) { var JSON = JSONObject.Create( new JProperty("ProviderID", ProviderId.ToString()), new JProperty("GeoCoordinatesResponseFormat", GeoCoordinatesResponseFormat.AsString()), LastCall.HasValue ? new JProperty("LastCall", LastCall.Value.ToIso8601()) : null, OperatorIdFilter.SafeAny() ? new JProperty("OperatorIds", new JArray(OperatorIdFilter.Select(operatorId => operatorId.ToString()))) : null, CountryCodeFilter.SafeAny() ? new JProperty("CountryCodes", new JArray(CountryCodeFilter.Select(countryCode => countryCode.Alpha3Code))) : null, AccessibilityFilter.SafeAny() ? new JProperty("Accessibility", new JArray(AccessibilityFilter.Select(accessibility => accessibility.AsString()))) : null, AuthenticationModeFilter.SafeAny() ? new JProperty("AuthenticationModes", new JArray(AuthenticationModeFilter.Select(authenticationMode => authenticationMode.AsString()))) : null, CalibrationLawDataAvailabilityFilter.SafeAny() ? new JProperty("CalibrationLawDataAvailability", new JArray(CalibrationLawDataAvailabilityFilter.Select(calibrationLawDataAvailability => calibrationLawDataAvailability.AsString()))) : null, IsHubjectCompatibleFilter.HasValue ? new JProperty("IsHubjectCompatible", IsHubjectCompatibleFilter.Value) : null, IsOpen24HoursFilter.HasValue ? new JProperty("IsOpen24Hours", IsOpen24HoursFilter.Value) : null, RenewableEnergyFilter.HasValue ? new JProperty("RenewableEnergy", RenewableEnergyFilter.Value) : null, SearchCenter.HasValue && DistanceKM.HasValue ? new JProperty("SearchCenter", new JObject( new JProperty("GeoCoordinates", SearchCenter.Value.ToJSON(CustomGeoCoordinatesSerializer)), new JProperty("Radius", DistanceKM.Value) )) : null, CustomData != null ? new JProperty("CustomData", CustomData) : null ); return(CustomPullEVSEDataRequestSerializer != null ? CustomPullEVSEDataRequestSerializer(this, JSON) : JSON); }
public static AccessibilityFilter GetValidAccessibilityFilter( MemberDeclarationListSelection selectedMembers, SemanticModel semanticModel, CancellationToken cancellationToken = default(CancellationToken)) { if (selectedMembers.Count < 2) { return(AccessibilityFilter.None); } ImmutableArray <Accessibility> avaiableAccessibilities = AvailableAccessibilities; var all = AccessibilityFilter.None; AccessibilityFilter valid = AccessibilityFilter.Public | AccessibilityFilter.Internal | AccessibilityFilter.Protected | AccessibilityFilter.Private; foreach (MemberDeclarationSyntax member in selectedMembers) { Accessibility accessibility = SyntaxAccessibility.GetExplicitAccessibility(member); if (accessibility == Accessibility.NotApplicable) { accessibility = SyntaxAccessibility.GetDefaultExplicitAccessibility(member); if (accessibility == Accessibility.NotApplicable) { return(AccessibilityFilter.None); } } switch (accessibility) { case Accessibility.Private: case Accessibility.Protected: case Accessibility.ProtectedAndInternal: case Accessibility.ProtectedOrInternal: case Accessibility.Internal: case Accessibility.Public: { all |= accessibility.GetAccessibilityFilter(); break; } default: { Debug.Fail(accessibility.ToString()); return(AccessibilityFilter.None); } } ModifierListInfo modifiersInfo = SyntaxInfo.ModifierListInfo(member); if (modifiersInfo.Modifiers.ContainsAny( SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) { valid &= ~AccessibilityFilter.Private; } if (modifiersInfo.IsOverride && IsBaseDeclarationWithoutSource(member, semanticModel, cancellationToken)) { switch (accessibility) { case Accessibility.Private: case Accessibility.Protected: case Accessibility.Internal: case Accessibility.Public: { valid &= accessibility.GetAccessibilityFilter(); if (valid == AccessibilityFilter.None) { return(AccessibilityFilter.None); } avaiableAccessibilities = _accessibilityArrayMap[accessibility]; continue; } default: { return(AccessibilityFilter.None); } } } foreach (Accessibility accessibility2 in avaiableAccessibilities) { if (accessibility != accessibility2 && !SyntaxAccessibility.IsValidAccessibility(member, accessibility2, ignoreOverride: true)) { valid &= ~accessibility2.GetAccessibilityFilter(); if (valid == AccessibilityFilter.None) { return(AccessibilityFilter.None); } } } } switch (all) { case AccessibilityFilter.Private: case AccessibilityFilter.Protected: case AccessibilityFilter.Internal: case AccessibilityFilter.Public: { valid &= ~all; break; } } return(valid); }
public static async Task ComputeRefactoringAsync(RefactoringContext context, MemberDeclarationListSelection selectedMembers) { if (context.IsRefactoringEnabled(RefactoringIdentifiers.ChangeAccessibility) && !selectedMembers.Parent.IsKind(SyntaxKind.InterfaceDeclaration)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); AccessibilityFilter validAccessibilities = ChangeAccessibilityAnalysis.GetValidAccessibilityFilter(selectedMembers, semanticModel, context.CancellationToken); if (validAccessibilities != AccessibilityFilter.None) { bool canHaveMultipleDeclarations = CanHaveMultipleDeclarations(); TryRegisterRefactoring(validAccessibilities, Accessibility.Public, canHaveMultipleDeclarations); TryRegisterRefactoring(validAccessibilities, Accessibility.Internal, canHaveMultipleDeclarations); TryRegisterRefactoring(validAccessibilities, Accessibility.Protected, canHaveMultipleDeclarations); TryRegisterRefactoring(validAccessibilities, Accessibility.Private, canHaveMultipleDeclarations); } } if (context.IsAnyRefactoringEnabled( RefactoringIdentifiers.ConvertBlockBodyToExpressionBody, RefactoringIdentifiers.ConvertExpressionBodyToBlockBody)) { ConvertBodyAndExpressionBodyRefactoring.ComputeRefactoring(context, selectedMembers); } if (context.IsRefactoringEnabled(RefactoringIdentifiers.InitializeFieldFromConstructor) && !selectedMembers.Parent.IsKind(SyntaxKind.InterfaceDeclaration)) { InitializeFieldFromConstructorRefactoring.ComputeRefactoring(context, selectedMembers); } if (context.IsRefactoringEnabled(RefactoringIdentifiers.AddEmptyLineBetweenDeclarations)) { AddEmptyLineBetweenDeclarationsRefactoring.ComputeRefactoring(context, selectedMembers); } void TryRegisterRefactoring(AccessibilityFilter accessibilities, Accessibility accessibility, bool canHaveMultipleDeclarations) { if ((accessibilities & accessibility.GetAccessibilityFilter()) != 0) { if (canHaveMultipleDeclarations) { context.RegisterRefactoring( ChangeAccessibilityRefactoring.GetTitle(accessibility), async cancellationToken => { SemanticModel semanticModel = await context.Document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); return(await ChangeAccessibilityRefactoring.RefactorAsync(context.Document.Solution(), selectedMembers, accessibility, semanticModel, cancellationToken).ConfigureAwait(false)); }, _accessiblityIdentifierMap[accessibility]); } else { context.RegisterRefactoring( ChangeAccessibilityRefactoring.GetTitle(accessibility), cancellationToken => ChangeAccessibilityRefactoring.RefactorAsync(context.Document, selectedMembers, accessibility, cancellationToken), EquivalenceKey.Join(RefactoringIdentifiers.ChangeAccessibility, accessibility.ToString())); } } } bool CanHaveMultipleDeclarations() { foreach (MemberDeclarationSyntax member in selectedMembers) { switch (member.Kind()) { case SyntaxKind.ClassDeclaration: { if (((ClassDeclarationSyntax)member).Modifiers.Contains(SyntaxKind.PartialKeyword)) { return(true); } break; } case SyntaxKind.InterfaceDeclaration: { if (((InterfaceDeclarationSyntax)member).Modifiers.Contains(SyntaxKind.PartialKeyword)) { return(true); } break; } case SyntaxKind.RecordDeclaration: { if (((RecordDeclarationSyntax)member).Modifiers.Contains(SyntaxKind.PartialKeyword)) { return(true); } break; } case SyntaxKind.StructDeclaration: { if (((StructDeclarationSyntax)member).Modifiers.Contains(SyntaxKind.PartialKeyword)) { return(true); } break; } case SyntaxKind.MethodDeclaration: { if (((MethodDeclarationSyntax)member).Modifiers.ContainsAny(SyntaxKind.PartialKeyword, SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) { return(true); } break; } case SyntaxKind.PropertyDeclaration: { if (((PropertyDeclarationSyntax)member).Modifiers.ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) { return(true); } break; } case SyntaxKind.IndexerDeclaration: { if (((IndexerDeclarationSyntax)member).Modifiers.ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) { return(true); } break; } case SyntaxKind.EventDeclaration: { if (((EventDeclarationSyntax)member).Modifiers.ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) { return(true); } break; } case SyntaxKind.EventFieldDeclaration: { if (((EventFieldDeclarationSyntax)member).Modifiers.ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) { return(true); } break; } } } return(false); } }