Skip to content

Commit da2adae

Browse files
chore(internal): remove unnecessary internal aliasing
1 parent 1529f4f commit da2adae

File tree

66 files changed

+554
-996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+554
-996
lines changed

src/Scrapegraphai/HttpException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
using System;
12
using System.Diagnostics.CodeAnalysis;
23
using System.Net;
3-
using System = System;
44

55
namespace Scrapegraphai;
66

7-
public sealed class HttpException : System::Exception
7+
public sealed class HttpException : Exception
88
{
99
public required HttpStatusCode? StatusCode { get; set; }
1010
public required string ResponseBody { get; set; }
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
using Crawl = Scrapegraphai.Services.Crawl;
2-
using Credits = Scrapegraphai.Services.Credits;
3-
using Feedback = Scrapegraphai.Services.Feedback;
4-
using GenerateSchema = Scrapegraphai.Services.GenerateSchema;
5-
using Healthz = Scrapegraphai.Services.Healthz;
6-
using Http = System.Net.Http;
7-
using Markdownify = Scrapegraphai.Services.Markdownify;
8-
using Searchscraper = Scrapegraphai.Services.Searchscraper;
9-
using Smartscraper = Scrapegraphai.Services.Smartscraper;
10-
using System = System;
11-
using Validate = Scrapegraphai.Services.Validate;
1+
using System;
2+
using System.Net.Http;
3+
using Scrapegraphai.Services.Crawl;
4+
using Scrapegraphai.Services.Credits;
5+
using Scrapegraphai.Services.Feedback;
6+
using Scrapegraphai.Services.GenerateSchema;
7+
using Scrapegraphai.Services.Healthz;
8+
using Scrapegraphai.Services.Markdownify;
9+
using Scrapegraphai.Services.Searchscraper;
10+
using Scrapegraphai.Services.Smartscraper;
11+
using Scrapegraphai.Services.Validate;
1212

1313
namespace Scrapegraphai;
1414

1515
public interface IScrapegraphaiClient
1616
{
17-
Http::HttpClient HttpClient { get; init; }
17+
HttpClient HttpClient { get; init; }
1818

19-
System::Uri BaseUrl { get; init; }
19+
Uri BaseUrl { get; init; }
2020

2121
/// <summary>
2222
/// API key for authentication
2323
/// </summary>
2424
string APIKey { get; init; }
2525

26-
Smartscraper::ISmartscraperService Smartscraper { get; }
26+
ISmartscraperService Smartscraper { get; }
2727

28-
Markdownify::IMarkdownifyService Markdownify { get; }
28+
IMarkdownifyService Markdownify { get; }
2929

30-
Searchscraper::ISearchscraperService Searchscraper { get; }
30+
ISearchscraperService Searchscraper { get; }
3131

32-
GenerateSchema::IGenerateSchemaService GenerateSchema { get; }
32+
IGenerateSchemaService GenerateSchema { get; }
3333

34-
Crawl::ICrawlService Crawl { get; }
34+
ICrawlService Crawl { get; }
3535

36-
Credits::ICreditService Credits { get; }
36+
ICreditService Credits { get; }
3737

38-
Validate::IValidateService Validate { get; }
38+
IValidateService Validate { get; }
3939

40-
Feedback::IFeedbackService Feedback { get; }
40+
IFeedbackService Feedback { get; }
4141

42-
Healthz::IHealthzService Healthz { get; }
42+
IHealthzService Healthz { get; }
4343
}

src/Scrapegraphai/JsonConverters.cs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,48 @@
1+
using System;
12
using System.Collections.Generic;
3+
using System.Text.Json;
24
using System.Text.Json.Serialization;
3-
using Json = System.Text.Json;
4-
using System = System;
55

66
namespace Scrapegraphai;
77

88
sealed class ModelConverter<TModel> : JsonConverter<TModel>
99
where TModel : ModelBase, IFromRaw<TModel>
1010
{
1111
public override TModel? Read(
12-
ref Json::Utf8JsonReader reader,
13-
System::Type _typeToConvert,
14-
Json::JsonSerializerOptions options
12+
ref Utf8JsonReader reader,
13+
Type _typeToConvert,
14+
JsonSerializerOptions options
1515
)
1616
{
17-
Dictionary<string, Json::JsonElement>? properties = Json::JsonSerializer.Deserialize<
18-
Dictionary<string, Json::JsonElement>
17+
Dictionary<string, JsonElement>? properties = JsonSerializer.Deserialize<
18+
Dictionary<string, JsonElement>
1919
>(ref reader, options);
2020
if (properties == null)
2121
return null;
2222

2323
return TModel.FromRawUnchecked(properties);
2424
}
2525

26-
public override void Write(
27-
Json::Utf8JsonWriter writer,
28-
TModel value,
29-
Json::JsonSerializerOptions options
30-
)
26+
public override void Write(Utf8JsonWriter writer, TModel value, JsonSerializerOptions options)
3127
{
32-
Json::JsonSerializer.Serialize(writer, value.Properties, options);
28+
JsonSerializer.Serialize(writer, value.Properties, options);
3329
}
3430
}
3531

3632
sealed class EnumConverter<TEnum, TValue> : JsonConverter<TEnum>
3733
where TEnum : IEnum<TEnum, TValue>
3834
{
3935
public override TEnum Read(
40-
ref Json::Utf8JsonReader reader,
41-
System::Type _typeToConvert,
42-
Json::JsonSerializerOptions options
36+
ref Utf8JsonReader reader,
37+
Type _typeToConvert,
38+
JsonSerializerOptions options
4339
)
4440
{
45-
return TEnum.FromRaw(Json::JsonSerializer.Deserialize<TValue>(ref reader, options)!);
41+
return TEnum.FromRaw(JsonSerializer.Deserialize<TValue>(ref reader, options)!);
4642
}
4743

48-
public override void Write(
49-
Json::Utf8JsonWriter writer,
50-
TEnum value,
51-
Json::JsonSerializerOptions options
52-
)
44+
public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options)
5345
{
54-
Json::JsonSerializer.Serialize(writer, value.Raw(), options);
46+
JsonSerializer.Serialize(writer, value.Raw(), options);
5547
}
5648
}

src/Scrapegraphai/ModelBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
using System.Collections.Generic;
2-
using Json = System.Text.Json;
2+
using System.Text.Json;
33

44
namespace Scrapegraphai;
55

66
public abstract record class ModelBase
77
{
8-
public Dictionary<string, Json::JsonElement> Properties { get; set; } = [];
8+
public Dictionary<string, JsonElement> Properties { get; set; } = [];
99

10-
internal static readonly Json::JsonSerializerOptions SerializerOptions = new();
10+
internal static readonly JsonSerializerOptions SerializerOptions = new();
1111

12-
static readonly Json::JsonSerializerOptions _toStringSerializerOptions = new(SerializerOptions)
12+
static readonly JsonSerializerOptions _toStringSerializerOptions = new(SerializerOptions)
1313
{
1414
WriteIndented = true,
1515
};
1616

1717
public sealed override string? ToString()
1818
{
19-
return Json::JsonSerializer.Serialize(this.Properties, _toStringSerializerOptions);
19+
return JsonSerializer.Serialize(this.Properties, _toStringSerializerOptions);
2020
}
2121

2222
public abstract void Validate();
2323
}
2424

2525
interface IFromRaw<T>
2626
{
27-
static abstract T FromRawUnchecked(Dictionary<string, Json::JsonElement> properties);
27+
static abstract T FromRawUnchecked(Dictionary<string, JsonElement> properties);
2828
}
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1+
using System;
12
using System.Net.Http;
2-
using Scrapegraphai = Scrapegraphai;
3-
using System = System;
43

54
namespace Scrapegraphai.Models.Crawl;
65

76
/// <summary>
87
/// Retrieve the status and results of a crawling job
98
/// </summary>
10-
public sealed record class CrawlRetrieveResultsParams : Scrapegraphai::ParamsBase
9+
public sealed record class CrawlRetrieveResultsParams : ParamsBase
1110
{
1211
public required string TaskID;
1312

14-
public override System::Uri Url(Scrapegraphai::IScrapegraphaiClient client)
13+
public override Uri Url(IScrapegraphaiClient client)
1514
{
16-
return new System::UriBuilder(
15+
return new UriBuilder(
1716
client.BaseUrl.ToString().TrimEnd('/') + string.Format("/crawl/{0}", this.TaskID)
1817
)
1918
{
2019
Query = this.QueryString(client),
2120
}.Uri;
2221
}
2322

24-
public void AddHeadersToRequest(
25-
HttpRequestMessage request,
26-
Scrapegraphai::IScrapegraphaiClient client
27-
)
23+
public void AddHeadersToRequest(HttpRequestMessage request, IScrapegraphaiClient client)
2824
{
29-
Scrapegraphai::ParamsBase.AddDefaultHeaders(request, client);
25+
ParamsBase.AddDefaultHeaders(request, client);
3026
foreach (var item in this.HeaderProperties)
3127
{
32-
Scrapegraphai::ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value);
28+
ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value);
3329
}
3430
}
3531
}

src/Scrapegraphai/Models/Crawl/CrawlRetrieveResultsResponse.cs

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,53 @@
11
using System.Collections.Generic;
22
using System.Diagnostics.CodeAnalysis;
3+
using System.Text.Json;
34
using System.Text.Json.Serialization;
4-
using CrawlRetrieveResultsResponseProperties = Scrapegraphai.Models.Crawl.CrawlRetrieveResultsResponseProperties;
5-
using Json = System.Text.Json;
6-
using Scrapegraphai = Scrapegraphai;
5+
using Scrapegraphai.Models.Crawl.CrawlRetrieveResultsResponseProperties;
76

87
namespace Scrapegraphai.Models.Crawl;
98

10-
[JsonConverter(typeof(Scrapegraphai::ModelConverter<CrawlRetrieveResultsResponse>))]
9+
[JsonConverter(typeof(ModelConverter<CrawlRetrieveResultsResponse>))]
1110
public sealed record class CrawlRetrieveResultsResponse
12-
: Scrapegraphai::ModelBase,
13-
Scrapegraphai::IFromRaw<CrawlRetrieveResultsResponse>
11+
: ModelBase,
12+
IFromRaw<CrawlRetrieveResultsResponse>
1413
{
1514
/// <summary>
1615
/// Successful crawl results
1716
/// </summary>
18-
public CrawlRetrieveResultsResponseProperties::Result? Result
17+
public Result? Result
1918
{
2019
get
2120
{
22-
if (!this.Properties.TryGetValue("result", out Json::JsonElement element))
21+
if (!this.Properties.TryGetValue("result", out JsonElement element))
2322
return null;
2423

25-
return Json::JsonSerializer.Deserialize<CrawlRetrieveResultsResponseProperties::Result?>(
26-
element,
27-
Scrapegraphai::ModelBase.SerializerOptions
28-
);
24+
return JsonSerializer.Deserialize<Result?>(element, ModelBase.SerializerOptions);
2925
}
30-
set { this.Properties["result"] = Json::JsonSerializer.SerializeToElement(value); }
26+
set { this.Properties["result"] = JsonSerializer.SerializeToElement(value); }
3127
}
3228

33-
public CrawlRetrieveResultsResponseProperties::Status? Status
29+
public Status? Status
3430
{
3531
get
3632
{
37-
if (!this.Properties.TryGetValue("status", out Json::JsonElement element))
33+
if (!this.Properties.TryGetValue("status", out JsonElement element))
3834
return null;
3935

40-
return Json::JsonSerializer.Deserialize<CrawlRetrieveResultsResponseProperties::Status?>(
41-
element,
42-
Scrapegraphai::ModelBase.SerializerOptions
43-
);
36+
return JsonSerializer.Deserialize<Status?>(element, ModelBase.SerializerOptions);
4437
}
45-
set { this.Properties["status"] = Json::JsonSerializer.SerializeToElement(value); }
38+
set { this.Properties["status"] = JsonSerializer.SerializeToElement(value); }
4639
}
4740

4841
public string? TaskID
4942
{
5043
get
5144
{
52-
if (!this.Properties.TryGetValue("task_id", out Json::JsonElement element))
45+
if (!this.Properties.TryGetValue("task_id", out JsonElement element))
5346
return null;
5447

55-
return Json::JsonSerializer.Deserialize<string?>(
56-
element,
57-
Scrapegraphai::ModelBase.SerializerOptions
58-
);
48+
return JsonSerializer.Deserialize<string?>(element, ModelBase.SerializerOptions);
5949
}
60-
set { this.Properties["task_id"] = Json::JsonSerializer.SerializeToElement(value); }
50+
set { this.Properties["task_id"] = JsonSerializer.SerializeToElement(value); }
6151
}
6252

6353
/// <summary>
@@ -67,15 +57,12 @@ public string? Traceback
6757
{
6858
get
6959
{
70-
if (!this.Properties.TryGetValue("traceback", out Json::JsonElement element))
60+
if (!this.Properties.TryGetValue("traceback", out JsonElement element))
7161
return null;
7262

73-
return Json::JsonSerializer.Deserialize<string?>(
74-
element,
75-
Scrapegraphai::ModelBase.SerializerOptions
76-
);
63+
return JsonSerializer.Deserialize<string?>(element, ModelBase.SerializerOptions);
7764
}
78-
set { this.Properties["traceback"] = Json::JsonSerializer.SerializeToElement(value); }
65+
set { this.Properties["traceback"] = JsonSerializer.SerializeToElement(value); }
7966
}
8067

8168
public override void Validate()
@@ -90,14 +77,14 @@ public CrawlRetrieveResultsResponse() { }
9077

9178
#pragma warning disable CS8618
9279
[SetsRequiredMembers]
93-
CrawlRetrieveResultsResponse(Dictionary<string, Json::JsonElement> properties)
80+
CrawlRetrieveResultsResponse(Dictionary<string, JsonElement> properties)
9481
{
9582
Properties = properties;
9683
}
9784
#pragma warning restore CS8618
9885

9986
public static CrawlRetrieveResultsResponse FromRawUnchecked(
100-
Dictionary<string, Json::JsonElement> properties
87+
Dictionary<string, JsonElement> properties
10188
)
10289
{
10390
return new(properties);

0 commit comments

Comments
 (0)