Codemaru 1.0.0.0
QR 코드, 모바일 랜딩 페이지, vCard 연락처 저장과 명함 디자인을 한 화면에서 제공하는 디지털 명함 서비스입니다.
로딩중...
검색중...
일치하는것 없음
Codemaru.Services.CardProfileImporter 클래스 참조sealed

더 자세히 ...

Public 멤버 함수

CardProfile ImportVCard (string content, CardProfile template)

정적 Private 멤버 함수

static Dictionary< string, List< string > > ReadVCardValues (string content)
static List< string > UnfoldLines (string content)
static string DecodeValue (string keyPart, string rawValue)
static string DecodePhoto (string keyPart, string rawValue)
static Encoding GetCharset (string keyPart)
static string DecodeQuotedPrintable (string value, Encoding encoding)
static bool IsHex (char value)
static string UnescapeVCard (string value)
static string ParseName (string value)
static string ParseAddress (string value)
static string First (Dictionary< string, List< string > > values, string key)
static string Join (Dictionary< string, List< string > > values, string key)
static string Coalesce (params string?[] values)

상세한 설명

Card Profile Importer 기능과 관련 상태를 캡슐화합니다.

CardProfileImporter.cs 파일의 14 번째 라인에서 정의되었습니다.

멤버 함수 문서화

◆ Coalesce()

string Codemaru.Services.CardProfileImporter.Coalesce ( params string?[] values)
inlinestaticprivate

Coalesce 작업을 수행합니다.

매개변수
valuesvalues에 사용할 string?[] 값입니다.
반환값
Coalesce 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 641 번째 라인에서 정의되었습니다.

642 {
643 return values.FirstOrDefault(static value => !string.IsNullOrWhiteSpace(value))?.Trim() ?? string.Empty;
644 }

다음에 의해서 참조됨 : ImportVCard().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DecodePhoto()

string Codemaru.Services.CardProfileImporter.DecodePhoto ( string keyPart,
string rawValue )
inlinestaticprivate

Decode Photo 작업을 수행합니다.

매개변수
keyPartkey Part에 사용할 string 값입니다.
rawValueraw Value에 사용할 string 값입니다.
반환값
Decode Photo 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 279 번째 라인에서 정의되었습니다.

280 {
281 if (rawValue.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
282 {
283 return rawValue.Trim();
284 }
285
286 var base64 = new string(rawValue.Where(static c => !char.IsWhiteSpace(c)).ToArray());
287 if (base64.Length == 0)
288 {
289 return string.Empty;
290 }
291
292 var type = "png";
293 if (keyPart.Contains("JPEG", StringComparison.OrdinalIgnoreCase) ||
294 keyPart.Contains("JPG", StringComparison.OrdinalIgnoreCase))
295 {
296 type = "jpeg";
297 }
298 else if (keyPart.Contains("SVG", StringComparison.OrdinalIgnoreCase))
299 {
300 type = "svg+xml";
301 }
302 else if (keyPart.Contains("WEBP", StringComparison.OrdinalIgnoreCase))
303 {
304 type = "webp";
305 }
306
307 return $"data:image/{type};base64,{base64}";
308 }

다음에 의해서 참조됨 : ReadVCardValues().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DecodeQuotedPrintable()

string Codemaru.Services.CardProfileImporter.DecodeQuotedPrintable ( string value,
Encoding encoding )
inlinestaticprivate

Decode Quoted Printable 작업을 수행합니다.

매개변수
value적용할 값입니다.
encodingencoding에 사용할 Encoding 값입니다.
반환값
Decode Quoted Printable 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 387 번째 라인에서 정의되었습니다.

388 {
389 var bytes = new List<byte>();
390 for (var i = 0; i < value.Length; i++)
391 {
392 if (value[i] == '=' && i + 2 < value.Length &&
393 IsHex(value[i + 1]) && IsHex(value[i + 2]))
394 {
395 bytes.Add(Convert.ToByte(value.Substring(i + 1, 2), 16));
396 i += 2;
397 }
398 else
399 {
400 bytes.Add((byte)value[i]);
401 }
402 }
403
404 return encoding.GetString(bytes.ToArray());
405 }

다음을 참조함 : IsHex().

다음에 의해서 참조됨 : DecodeValue().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DecodeValue()

string Codemaru.Services.CardProfileImporter.DecodeValue ( string keyPart,
string rawValue )
inlinestaticprivate

Decode Value 작업을 수행합니다.

매개변수
keyPartkey Part에 사용할 string 값입니다.
rawValueraw Value에 사용할 string 값입니다.
반환값
Decode Value 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 236 번째 라인에서 정의되었습니다.

237 {
238 var value = rawValue;
239 if (keyPart.Contains("ENCODING=QUOTED-PRINTABLE", StringComparison.OrdinalIgnoreCase))
240 {
241 value = DecodeQuotedPrintable(rawValue, GetCharset(keyPart));
242 }
243
244 return UnescapeVCard(value).Trim();
245 }

다음을 참조함 : DecodeQuotedPrintable(), GetCharset(), UnescapeVCard().

다음에 의해서 참조됨 : ReadVCardValues().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ First()

string Codemaru.Services.CardProfileImporter.First ( Dictionary< string, List< string > > values,
string key )
inlinestaticprivate

First 작업을 수행합니다.

매개변수
valuesvalues에 사용할 Dictionary<string, List<string>> 값입니다.
keykey에 사용할 string 값입니다.
반환값
First 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 573 번째 라인에서 정의되었습니다.

574 {
575 return values.TryGetValue(key, out var list) ? list.FirstOrDefault() ?? string.Empty : string.Empty;
576 }

다음에 의해서 참조됨 : ImportVCard().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetCharset()

Encoding Codemaru.Services.CardProfileImporter.GetCharset ( string keyPart)
inlinestaticprivate

Charset 값을 가져옵니다.

매개변수
keyPartkey Part에 사용할 string 값입니다.
반환값
Get Charset 작업에서 생성한 Encoding 결과입니다.

CardProfileImporter.cs 파일의 334 번째 라인에서 정의되었습니다.

335 {
336 var parts = keyPart.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
337 var charsetPart = parts.FirstOrDefault(part => part.StartsWith("CHARSET=", StringComparison.OrdinalIgnoreCase));
338 var charset = charsetPart?.Split('=', 2)[1].Trim('"');
339 if (string.IsNullOrWhiteSpace(charset))
340 {
341 return Encoding.UTF8;
342 }
343
344 try
345 {
346 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
347 return Encoding.GetEncoding(charset);
348 }
349 catch
350 {
351 return Encoding.UTF8;
352 }
353 }

다음에 의해서 참조됨 : DecodeValue().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ImportVCard()

CardProfile Codemaru.Services.CardProfileImporter.ImportVCard ( string content,
CardProfile template )
inline

Import V Card 작업을 수행합니다.

매개변수
contentcontent에 사용할 string 값입니다.
templatetemplate에 사용할 CardProfile 값입니다.
반환값
Import V Card 작업에서 생성한 CardProfile 결과입니다.

CardProfileImporter.cs 파일의 48 번째 라인에서 정의되었습니다.

49 {
50 var values = ReadVCardValues(content);
51 var name = First(values, "FN");
52 if (string.IsNullOrWhiteSpace(name))
53 {
54 name = ParseName(First(values, "N"));
55 }
56
57 var company = First(values, "ORG");
58 var title = First(values, "TITLE");
59 var email = Join(values, "EMAIL");
60 var phone = Join(values, "TEL");
61 var address = ParseAddress(First(values, "ADR"));
62 var url = First(values, "URL");
63 var note = First(values, "NOTE");
64 var photo = First(values, "PHOTO");
65 var brand = Coalesce(company, template.BackBrand, template.Brand);
66
67 return template with
68 {
69 Brand = brand,
70 BackBrand = brand,
71 Tagline = string.IsNullOrWhiteSpace(title) ? template.Tagline : title,
72 BackTagline = string.IsNullOrWhiteSpace(company) ? template.BackTagline : company,
73 Name = Coalesce(name, template.Name),
74 Role = Coalesce(title, template.Role),
75 Email = Coalesce(email, template.Email),
76 Phone = Coalesce(phone, template.Phone),
77 Address = Coalesce(address, template.Address),
78 Website = Coalesce(url, template.Website),
79 ShortBio = Coalesce(note, template.ShortBio),
80 LandingDescription = Coalesce(note, template.LandingDescription),
81 VCardNote = Coalesce(note, template.VCardNote),
82 LogoImageDataUrl = string.IsNullOrWhiteSpace(photo) ? template.LogoImageDataUrl : photo,
83 ImportedFrontImageDataUrl = null,
84 ImportedBackImageDataUrl = null,
85 IncludePhoneInVCard = !string.IsNullOrWhiteSpace(phone) || template.IncludePhoneInVCard,
86 IncludeAddressInVCard = !string.IsNullOrWhiteSpace(address) || template.IncludeAddressInVCard
87 };
88 }

다음을 참조함 : Codemaru.Models.CardProfile(), Coalesce(), First(), Join(), ParseAddress(), ParseName(), ReadVCardValues().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ IsHex()

bool Codemaru.Services.CardProfileImporter.IsHex ( char value)
inlinestaticprivate

Is Hex 조건을 확인합니다.

매개변수
value적용할 값입니다.
반환값
Is Hex 조건이 충족되면 true이고, 그렇지 않으면 false입니다.

CardProfileImporter.cs 파일의 431 번째 라인에서 정의되었습니다.

432 {
433 return (value >= '0' && value <= '9') ||
434 (value >= 'A' && value <= 'F') ||
435 (value >= 'a' && value <= 'f');
436 }

다음에 의해서 참조됨 : DecodeQuotedPrintable().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ Join()

string Codemaru.Services.CardProfileImporter.Join ( Dictionary< string, List< string > > values,
string key )
inlinestaticprivate

Join 작업을 수행합니다.

매개변수
valuesvalues에 사용할 Dictionary<string, List<string>> 값입니다.
keykey에 사용할 string 값입니다.
반환값
Join 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 610 번째 라인에서 정의되었습니다.

611 {
612 return values.TryGetValue(key, out var list)
613 ? string.Join(Environment.NewLine, list.Where(static value => !string.IsNullOrWhiteSpace(value)))
614 : string.Empty;
615 }

다음에 의해서 참조됨 : ImportVCard().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ParseAddress()

string Codemaru.Services.CardProfileImporter.ParseAddress ( string value)
inlinestaticprivate

Parse Address 작업을 수행합니다.

매개변수
value적용할 값입니다.
반환값
Parse Address 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 530 번째 라인에서 정의되었습니다.

531 {
532 if (string.IsNullOrWhiteSpace(value))
533 {
534 return string.Empty;
535 }
536
537 var parts = value.Split(';');
538 return string.Join(" ", parts.Skip(2).Where(static part => !string.IsNullOrWhiteSpace(part))).Trim();
539 }

다음에 의해서 참조됨 : ImportVCard().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ParseName()

string Codemaru.Services.CardProfileImporter.ParseName ( string value)
inlinestaticprivate

Parse Name 작업을 수행합니다.

매개변수
value적용할 값입니다.
반환값
Parse Name 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 495 번째 라인에서 정의되었습니다.

496 {
497 if (string.IsNullOrWhiteSpace(value))
498 {
499 return string.Empty;
500 }
501
502 var parts = value.Split(';');
503 return string.Join(" ", parts.Take(2).Reverse().Where(static part => !string.IsNullOrWhiteSpace(part))).Trim();
504 }

다음에 의해서 참조됨 : ImportVCard().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ReadVCardValues()

Dictionary< string, List< string > > Codemaru.Services.CardProfileImporter.ReadVCardValues ( string content)
inlinestaticprivate

V Card Values 데이터를 읽습니다.

매개변수
contentcontent에 사용할 string 값입니다.
반환값
Read V Card Values 작업에서 생성한 Dictionary<string, List<string>> 결과입니다.

CardProfileImporter.cs 파일의 114 번째 라인에서 정의되었습니다.

115 {
116 var values = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
117 var lines = UnfoldLines(content);
118
119 foreach (var line in lines)
120 {
121 var colon = line.IndexOf(':', StringComparison.Ordinal);
122 if (colon <= 0)
123 {
124 continue;
125 }
126
127 var keyPart = line[..colon];
128 var rawValue = line[(colon + 1)..];
129 var key = keyPart.Split(';', 2)[0].Trim();
130 if (string.IsNullOrWhiteSpace(key))
131 {
132 continue;
133 }
134
135 var value = DecodeValue(keyPart, rawValue);
136 if (key.Equals("PHOTO", StringComparison.OrdinalIgnoreCase))
137 {
138 value = DecodePhoto(keyPart, rawValue);
139 }
140
141 if (string.IsNullOrWhiteSpace(value))
142 {
143 continue;
144 }
145
146 if (!values.TryGetValue(key, out var list))
147 {
148 list = new List<string>();
149 values[key] = list;
150 }
151
152 list.Add(value);
153 }
154
155 return values;
156 }

다음을 참조함 : DecodePhoto(), DecodeValue(), UnfoldLines().

다음에 의해서 참조됨 : ImportVCard().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ UnescapeVCard()

string Codemaru.Services.CardProfileImporter.UnescapeVCard ( string value)
inlinestaticprivate

Unescape V Card 작업을 수행합니다.

매개변수
value적용할 값입니다.
반환값
Unescape V Card 작업에서 생성한 string 결과입니다.

CardProfileImporter.cs 파일의 462 번째 라인에서 정의되었습니다.

463 {
464 return value
465 .Replace("\\n", Environment.NewLine, StringComparison.OrdinalIgnoreCase)
466 .Replace("\\;", ";", StringComparison.Ordinal)
467 .Replace("\\,", ",", StringComparison.Ordinal)
468 .Replace("\\\\", "\\", StringComparison.Ordinal);
469 }

다음에 의해서 참조됨 : DecodeValue().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ UnfoldLines()

List< string > Codemaru.Services.CardProfileImporter.UnfoldLines ( string content)
inlinestaticprivate

Unfold Lines 작업을 수행합니다.

매개변수
contentcontent에 사용할 string 값입니다.
반환값
Unfold Lines 작업에서 생성한 List<string> 결과입니다.

CardProfileImporter.cs 파일의 182 번째 라인에서 정의되었습니다.

183 {
184 var normalized = content
185 .Replace("\r\n", "\n", StringComparison.Ordinal)
186 .Replace('\r', '\n');
187 var lines = new List<string>();
188
189 foreach (var line in normalized.Split('\n'))
190 {
191 if ((line.StartsWith(' ') || line.StartsWith('\t')) && lines.Count > 0)
192 {
193 lines[^1] += line[1..];
194 }
195 else
196 {
197 lines.Add(line);
198 }
199 }
200
201 return lines;
202 }

다음에 의해서 참조됨 : ReadVCardValues().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: