Skip to content

Commit e1028f9

Browse files
committed
added robust encoders (internal)
1 parent 6c40483 commit e1028f9

10 files changed

+32
-502
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,6 @@ _Pvt_Extensions
234234

235235
# FAKE - F# Make
236236
.fake/
237+
# FAKE - F# Make
238+
.fake/
239+
/Asn1ParserTests

Asn1Parser/Asn1Parser.csproj

+3-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
<Reference Include="System.Numerics" />
4848
</ItemGroup>
4949
<ItemGroup>
50-
<Compile Include="Tree\IAsn1Tree.cs" />
5150
<Compile Include="CLRExtensions\Generics\ObservableList.cs" />
5251
<Compile Include="Asn1Reader.cs" />
5352
<Compile Include="Asn1Class.cs" />
@@ -59,11 +58,6 @@
5958
<Compile Include="EncodingFormat.cs" />
6059
<Compile Include="EncodingType.cs" />
6160
<Compile Include="Properties\AssemblyInfo.cs" />
62-
<Compile Include="Tree\Asn1Tree.cs" />
63-
<Compile Include="Tree\Asn1Node.cs" />
64-
<Compile Include="Tree\GenericAsn1Tree.cs" />
65-
<Compile Include="Tree\IAsn1NodeValue.cs" />
66-
<Compile Include="Tree\InsertNodeOption.cs" />
6761
<Compile Include="Universal\Asn1BitString.cs" />
6862
<Compile Include="Universal\Asn1BmpString.cs" />
6963
<Compile Include="Universal\Asn1GeneralizedTime.cs" />
@@ -83,7 +77,9 @@
8377
<Compile Include="Utils\Strings.cs" />
8478
<Compile Include="Utils\StringUtils.cs" />
8579
</ItemGroup>
86-
<ItemGroup />
80+
<ItemGroup>
81+
<Folder Include="Tree\" />
82+
</ItemGroup>
8783
<ItemGroup>
8884
<Content Include="CompiledDLL\SysadminsLV.Asn1Parser.dll" />
8985
</ItemGroup>

Asn1Parser/Asn1Utils.cs

+21-3
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,25 @@ static String DecodeGeneralizedTime(Asn1Reader asn) {
742742
static String DecodeBMPString(Asn1Reader asn) {
743743
return Encoding.BigEndianUnicode.GetString(asn.RawData, asn.PayloadStartOffset, asn.PayloadLength);
744744
}
745-
#endregion
746-
#endregion
747-
}
745+
#endregion
746+
#region Data type robust encoders
747+
internal static Byte[] EncodeEditValue(String input, Asn1Type tag, Boolean isHex) {
748+
if (isHex) {
749+
return Encode(AsnFormatter.StringToBinary(input, EncodingType.Hex), (Byte)tag);
750+
}
751+
switch (tag) {
752+
case Asn1Type.BIT_STRING:
753+
return null;
754+
case Asn1Type.BMPString:
755+
return null;
756+
case Asn1Type.BOOLEAN:
757+
return null;
758+
case Asn1Type.CHARACTER_STRING:
759+
return null;
760+
}
761+
return null;
762+
}
763+
#endregion
764+
#endregion
765+
}
748766
}

Asn1Parser/CLRExtensions/Generics/ObservableList.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ public ObservableList(Boolean observe) {
5151
/// </summary>
5252
/// <param name="collection">Items to add</param>
5353
public new void AddRange(IEnumerable<T> collection) {
54-
base.AddRange(collection);
55-
var e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, new List<T>(collection));
54+
IEnumerable<T> enumerable = collection as T[] ?? collection.ToArray();
55+
base.AddRange(enumerable);
56+
var e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, new List<T>(enumerable));
5657
OnCollectionChanged(e);
5758
}
5859
/// <summary>
@@ -198,10 +199,8 @@ protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e) {
198199
/// <param name="propertyName">Property name which value is changed.</param>
199200
protected void OnPropertyChanged(String propertyName) {
200201
PropertyChangedEventHandler handler = PropertyChanged;
201-
if (handler != null) {
202-
handler(this, new PropertyChangedEventArgs(propertyName));
203-
}
204-
}
202+
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
203+
}
205204
/// <summary>
206205
/// Occurs when a property value changes.
207206
/// </summary>

Asn1Parser/Tree/Asn1Node.cs

-111
This file was deleted.

Asn1Parser/Tree/Asn1Tree.cs

-50
This file was deleted.

0 commit comments

Comments
 (0)