Skip to content

Commit aa309e6

Browse files
committed
Fix Net40 Compile
1 parent cfe0da3 commit aa309e6

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/Shared/HandyControl_Shared/HandyControls/Attach/BrushAttach.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows;
1+
#if !NET40
2+
using System.Windows;
23
using System.Windows.Media;
34
using HandyControl.Tools;
45

@@ -52,3 +53,4 @@ public static void SetColorCorrectionFactor(DependencyObject obj, double value)
5253
obj.SetValue(ColorCorrectionFactorProperty, value);
5354
}
5455
}
56+
#endif

src/Shared/HandyControl_Shared/HandyControls/Tools/Helper/ApplicationHelper.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ public static void StartProfileOptimization(string CachePath = null)
103103
ProfileOptimization.SetProfileRoot(CachePath);
104104
ProfileOptimization.StartProfile("Profile");
105105
}
106+
107+
108+
/// <summary>
109+
/// Retrieves an enumeration value from a string representation. It requires the generic type to be an enum.
110+
/// </summary>
111+
/// <typeparam name="TEnum">The generic type must be an enumeration type to convert the string into its corresponding enum value.</typeparam>
112+
/// <param name="text">The string representation of the enumeration value to be converted.</param>
113+
/// <returns>The corresponding enumeration value of the specified type.</returns>
114+
/// <exception cref="InvalidOperationException">Thrown when the generic type parameter is not an enumeration.</exception>
115+
public static TEnum GetEnum<TEnum>(string text) where TEnum : struct
116+
{
117+
return !typeof(TEnum).GetTypeInfo().IsEnum
118+
? throw new InvalidOperationException("Generic parameter 'TEnum' must be an enum.")
119+
: (TEnum) Enum.Parse(typeof(TEnum), text);
120+
}
106121
#endif
107122

108123
/// <summary>
@@ -151,19 +166,5 @@ public static string GetExecutablePathNative()
151166
InteropMethods.GetModuleFileName(IntPtr.Zero, sb, MAX_PATH);
152167
return sb.ToString();
153168
}
154-
155-
/// <summary>
156-
/// Retrieves an enumeration value from a string representation. It requires the generic type to be an enum.
157-
/// </summary>
158-
/// <typeparam name="TEnum">The generic type must be an enumeration type to convert the string into its corresponding enum value.</typeparam>
159-
/// <param name="text">The string representation of the enumeration value to be converted.</param>
160-
/// <returns>The corresponding enumeration value of the specified type.</returns>
161-
/// <exception cref="InvalidOperationException">Thrown when the generic type parameter is not an enumeration.</exception>
162-
public static TEnum GetEnum<TEnum>(string text) where TEnum : struct
163-
{
164-
return !typeof(TEnum).GetTypeInfo().IsEnum
165-
? throw new InvalidOperationException("Generic parameter 'TEnum' must be an enum.")
166-
: (TEnum) Enum.Parse(typeof(TEnum), text);
167-
}
168169
}
169170

src/Shared/HandyControl_Shared/HandyControls/Tools/Helper/Github Update/UpdateHelperJsonContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
#if !NET40
2+
using System.Collections.Generic;
23
using System.Text.Json.Serialization;
34

45
namespace HandyControl.Tools;
@@ -8,3 +9,4 @@ namespace HandyControl.Tools;
89
internal partial class UpdateHelperJsonContext : JsonSerializerContext
910
{
1011
}
12+
#endif

src/Shared/HandyControl_Shared/HandyControls/Tools/Markup/ColorBrightnessExtension.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
#if !NET40
2+
using System;
23
using System.Windows.Markup;
34
using System.Windows.Media;
45

@@ -44,3 +45,4 @@ public override object ProvideValue(IServiceProvider serviceProvider)
4445
: ColorHelper.DarkenColor(Color, -(float) CorrectionFactor);
4546
}
4647
}
48+
#endif

0 commit comments

Comments
 (0)