internal Name() { LastName = FirstName = MiddleName = Prefix = Suffix = ReadOnlyCollectionConverter.Empty(); }
internal Address() { #pragma warning disable CS0618 // Typ oder Element ist veraltet PostOfficeBox = ExtendedAddress = #pragma warning restore CS0618 // Typ oder Element ist veraltet Street = Locality = Region = PostalCode = Country = ReadOnlyCollectionConverter.Empty(); }
internal Name(string vCardValue, VcfDeserializationInfo info, VCdVersion version) { Debug.Assert(vCardValue != null); StringBuilder builder = info.Builder; ValueSplitter semicolonSplitter = info.SemiColonSplitter; ValueSplitter commaSplitter = info.CommaSplitter; semicolonSplitter.ValueString = vCardValue; int index = 0; foreach (var s in semicolonSplitter) { switch (index++) { case LAST_NAME: { if (s.Length == 0) { LastName = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } LastName = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case FIRST_NAME: { if (s.Length == 0) { FirstName = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } FirstName = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case MIDDLE_NAME: { if (s.Length == 0) { MiddleName = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } MiddleName = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case PREFIX: { if (s.Length == 0) { Prefix = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } Prefix = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case SUFFIX: { if (s.Length == 0) { Suffix = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } Suffix = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } } //switch } //foreach // Wenn die VCF-Datei fehlerhaft ist, könnten Properties null sein: FirstName ??= ReadOnlyCollectionConverter.Empty(); LastName ??= ReadOnlyCollectionConverter.Empty(); MiddleName ??= ReadOnlyCollectionConverter.Empty(); Prefix ??= ReadOnlyCollectionConverter.Empty(); Suffix ??= ReadOnlyCollectionConverter.Empty(); }
internal Address(string vCardValue, VcfDeserializationInfo info, VCdVersion version) { Debug.Assert(vCardValue != null); StringBuilder builder = info.Builder; ValueSplitter semicolonSplitter = info.SemiColonSplitter; ValueSplitter commaSplitter = info.CommaSplitter; int index = 0; semicolonSplitter.ValueString = vCardValue; foreach (var s in semicolonSplitter) { switch (index++) { #pragma warning disable CS0618 // Typ oder Element ist veraltet case POST_OFFICE_BOX: { if (s.Length == 0) { PostOfficeBox = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } PostOfficeBox = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case EXTENDED_ADDRESS: { if (s.Length == 0) { ExtendedAddress = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } ExtendedAddress = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } #pragma warning restore CS0618 // Typ oder Element ist veraltet case STREET: { if (s.Length == 0) { Street = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } Street = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case LOCALITY: { if (s.Length == 0) { Locality = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } Locality = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case REGION: { if (s.Length == 0) { Region = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } Region = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case POSTAL_CODE: { if (s.Length == 0) { PostalCode = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } PostalCode = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } case COUNTRY: { if (s.Length == 0) { Country = ReadOnlyCollectionConverter.Empty(); } else { var list = new List <string>(); commaSplitter.ValueString = s; foreach (var item in commaSplitter) { list.Add(item.UnMask(builder, version)); } Country = ReadOnlyCollectionConverter.ToReadOnlyCollection(list); } break; } default: break; } //switch } //foreach // Wenn die VCF-Datei fehlerhaft ist, könnten Properties null sein: #pragma warning disable CS0618 // Typ oder Element ist veraltet PostOfficeBox ??= ReadOnlyCollectionConverter.Empty(); ExtendedAddress ??= ReadOnlyCollectionConverter.Empty(); #pragma warning restore CS0618 // Typ oder Element ist veraltet Street ??= ReadOnlyCollectionConverter.Empty(); Locality ??= ReadOnlyCollectionConverter.Empty(); Region ??= ReadOnlyCollectionConverter.Empty(); PostalCode ??= ReadOnlyCollectionConverter.Empty(); Country ??= ReadOnlyCollectionConverter.Empty(); }