diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/PointMarkupSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/PointMarkupSerializer.cs index 7a2fdb5..b41b661 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/PointMarkupSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/PointMarkupSerializer.cs @@ -16,25 +16,21 @@ protected internal override bool CanSerializeToString(WorkflowMarkupSerializatio protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj) { - List properties = new List(); + List properties = []; if (obj is Point) { properties.Add(typeof(Point).GetProperty("X")); properties.Add(typeof(Point).GetProperty("Y")); } - return properties.ToArray(); + return [.. properties]; } protected internal override string SerializeToString(WorkflowMarkupSerializationManager serializationManager, object value) { - string convertedValue = String.Empty; - TypeConverter converter = TypeDescriptor.GetConverter(value); - if (converter != null && converter.CanConvertTo(typeof(string))) - convertedValue = converter.ConvertTo(value, typeof(string)) as string; - else - convertedValue = base.SerializeToString(serializationManager, value); - return convertedValue; + return converter != null && converter.CanConvertTo(typeof(string)) + ? converter.ConvertTo(value, typeof(string)) as string + : base.SerializeToString(serializationManager, value); } protected internal override object DeserializeFromString(WorkflowMarkupSerializationManager serializationManager, Type propertyType, string value) @@ -45,10 +41,9 @@ protected internal override object DeserializeFromString(WorkflowMarkupSerializa if (!String.IsNullOrWhiteSpace(pointValue)) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(Point)); - if (converter != null && converter.CanConvertFrom(typeof(string)) && !IsValidCompactAttributeFormat(pointValue)) - point = converter.ConvertFrom(value); - else - point = base.SerializeToString(serializationManager, value); + point = converter != null && converter.CanConvertFrom(typeof(string)) && !IsValidCompactAttributeFormat(pointValue) + ? converter.ConvertFrom(value) + : base.SerializeToString(serializationManager, value); } return point; diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/SizeMarkupSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/SizeMarkupSerializer.cs index a026fb1..515eebf 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/SizeMarkupSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Design/SizeMarkupSerializer.cs @@ -16,25 +16,21 @@ protected internal override bool CanSerializeToString(WorkflowMarkupSerializatio protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj) { - List properties = new List(); + List properties = []; if (obj is Size) { properties.Add(typeof(Size).GetProperty("Width")); properties.Add(typeof(Size).GetProperty("Height")); } - return properties.ToArray(); + return [.. properties]; } protected internal override string SerializeToString(WorkflowMarkupSerializationManager serializationManager, object value) { - string convertedValue = String.Empty; - TypeConverter converter = TypeDescriptor.GetConverter(value); - if (converter != null && converter.CanConvertTo(typeof(string))) - convertedValue = converter.ConvertTo(value, typeof(string)) as string; - else - convertedValue = base.SerializeToString(serializationManager, value); - return convertedValue; + return converter != null && converter.CanConvertTo(typeof(string)) + ? converter.ConvertTo(value, typeof(string)) as string + : base.SerializeToString(serializationManager, value); } protected internal override object DeserializeFromString(WorkflowMarkupSerializationManager serializationManager, Type propertyType, string value) @@ -45,10 +41,9 @@ protected internal override object DeserializeFromString(WorkflowMarkupSerializa if (!String.IsNullOrWhiteSpace(sizeValue)) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(Size)); - if (converter != null && converter.CanConvertFrom(typeof(string)) && !IsValidCompactAttributeFormat(sizeValue)) - size = converter.ConvertFrom(value); - else - size = base.SerializeToString(serializationManager, value); + size = converter != null && converter.CanConvertFrom(typeof(string)) && !IsValidCompactAttributeFormat(sizeValue) + ? converter.ConvertFrom(value) + : base.SerializeToString(serializationManager, value); } return size; diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/CodeTypeReferenceSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/CodeTypeReferenceSerializer.cs index 150746d..d283eb1 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/CodeTypeReferenceSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/CodeTypeReferenceSerializer.cs @@ -28,7 +28,7 @@ protected internal override string SerializeToString(WorkflowMarkupSerialization if (value == null) throw new ArgumentNullException("value"); - if (!(value is CodeTypeReference reference)) + if (value is not CodeTypeReference reference) return string.Empty; // make the typename as best we can, and try to get the fully qualified name @@ -55,15 +55,9 @@ protected internal override string SerializeToString(WorkflowMarkupSerialization // to make sure that writers (such as Xoml) are given types that exist in the target framework // This makes it the job of the rules designer or rules validator to not call the Xoml stack // with types that do not exist in the target framework - if (string.IsNullOrEmpty(assemblyFullName)) - { - typeName = type.AssemblyQualifiedName; - } - else - { - typeName = string.Format(CultureInfo.InvariantCulture, "{0}, {1}", type.FullName, assemblyFullName); - } - return typeName; + return string.IsNullOrEmpty(assemblyFullName) + ? type.AssemblyQualifiedName + : string.Format(CultureInfo.InvariantCulture, "{0}, {1}", type.FullName, assemblyFullName); } protected internal override object DeserializeFromString(WorkflowMarkupSerializationManager serializationManager, Type propertyType, string value) diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/ExtendedPropertyInfo.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/ExtendedPropertyInfo.cs index 055cd55..940ef57 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/ExtendedPropertyInfo.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/ExtendedPropertyInfo.cs @@ -105,10 +105,9 @@ public override MethodInfo GetSetMethod(bool nonPublic) public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { - if (OnGetValue != null) - return OnGetValue(this, obj); - else - return null; + return OnGetValue != null + ? OnGetValue(this, obj) + : null; } public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) @@ -119,10 +118,9 @@ public override void SetValue(object obj, object value, BindingFlags invokeAttr, public XmlQualifiedName GetXmlQualifiedName(WorkflowMarkupSerializationManager managerLocal, out string prefix) { prefix = String.Empty; - if (OnGetXmlQualifiedName != null) - return OnGetXmlQualifiedName(this, managerLocal, out prefix); - else - return null; + return OnGetXmlQualifiedName != null + ? OnGetXmlQualifiedName(this, managerLocal, out prefix) + : null; } public override ParameterInfo[] GetIndexParameters() diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/StringCollectionMarkupSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/StringCollectionMarkupSerializer.cs index 0d3f4dc..1d4f5d5 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/StringCollectionMarkupSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/StringCollectionMarkupSerializer.cs @@ -45,10 +45,9 @@ protected internal override object DeserializeFromString(WorkflowMarkupSerializa // ICollection or its derivative, special case! (A synchronization // handle cannot begin with a * because it won't be a language independent // identifier :) ) - if (IsValidCompactAttributeFormat(value)) - return DeserializeFromCompactFormat(serializationManager, serializationManager.WorkflowMarkupStack[typeof(XmlReader)] as XmlReader, value); - else - return SynchronizationHandlesTypeConverter.UnStringify(value); + return IsValidCompactAttributeFormat(value) + ? DeserializeFromCompactFormat(serializationManager, serializationManager.WorkflowMarkupStack[typeof(XmlReader)] as XmlReader, value) + : SynchronizationHandlesTypeConverter.UnStringify(value); } } } diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializationManager.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializationManager.cs index 5b9f89e..783c864 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializationManager.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializationManager.cs @@ -285,10 +285,9 @@ public virtual Type GetType(string typeName) } typeName = typeName.Trim(); - if (assembly != null) - type = assembly.GetType(typeName, false); - else - type = Type.GetType(fullyQualifiedTypeName, false); + type = assembly != null + ? assembly.GetType(typeName, false) + : Type.GetType(fullyQualifiedTypeName, false); } return type; } diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs index 84676ed..7f87cd2 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs @@ -537,10 +537,9 @@ internal void SerializeContents(WorkflowMarkupSerializationManager serialization else { TypeConverter typeConverter = TypeDescriptor.GetConverter(obj.GetType()); - if (typeConverter != null && typeConverter.CanConvertTo(typeof(string))) - stringValue = typeConverter.ConvertTo(null, CultureInfo.InvariantCulture, obj, typeof(string)) as string; - else - stringValue = Convert.ToString(obj, CultureInfo.InvariantCulture); + stringValue = typeConverter != null && typeConverter.CanConvertTo(typeof(string)) + ? typeConverter.ConvertTo(null, CultureInfo.InvariantCulture, obj, typeof(string)) as string + : Convert.ToString(obj, CultureInfo.InvariantCulture); } writer.WriteValue(stringValue); @@ -1212,10 +1211,9 @@ internal static WorkflowMarkupSerializationException CreateSerializationError(st if (string.IsNullOrEmpty(errorMsg)) errorMsg = e?.Message ?? string.Empty; - if (reader is IXmlLineInfo xmlLineInfo) - return new WorkflowMarkupSerializationException(errorMsg, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition); - else - return new WorkflowMarkupSerializationException(errorMsg, 0, 0); + return reader is IXmlLineInfo xmlLineInfo + ? new WorkflowMarkupSerializationException(errorMsg, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition) + : new WorkflowMarkupSerializationException(errorMsg, 0, 0); } #endregion @@ -2071,12 +2069,9 @@ internal PropertyInfo Property internal object GetContents() { - object value; - if (this.contentProperty != null) - value = this.contentProperty.GetValue(this.parentObject, null); - else - value = this.parentObjectSerializer.GetChildren(this.serializationManager, this.parentObject); - return value; + return this.contentProperty != null + ? this.contentProperty.GetValue(this.parentObject, null) + : this.parentObjectSerializer.GetChildren(this.serializationManager, this.parentObject); } internal void SetContents(IList contents) diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializerMapping.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializerMapping.cs index 812d827..2ae99df 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializerMapping.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializerMapping.cs @@ -196,10 +196,9 @@ internal static void GetMappingsFromXmlNamespace(WorkflowMarkupSerializationMana string assemblyName = String.Empty; if (serializationManager.LocalAssembly != assembly) { - if (xmlnsDefinition.AssemblyName != null && xmlnsDefinition.AssemblyName.Trim().Length > 0) - assemblyName = xmlnsDefinition.AssemblyName; - else - assemblyName = assembly.FullName; + assemblyName = xmlnsDefinition.AssemblyName != null && xmlnsDefinition.AssemblyName.Trim().Length > 0 + ? xmlnsDefinition.AssemblyName + : assembly.FullName; } if (xmlnsDefinition.XmlNamespace.Equals(xmlNamespace, StringComparison.Ordinal)) @@ -287,14 +286,9 @@ private static string GetAssemblyName(Type type) { // // Handle DesignTimeType - if (type.Assembly == null) - { - return string.Empty; - } - else - { - return type.Assembly.FullName; - } + return type.Assembly == null + ? string.Empty + : type.Assembly.FullName; } //Format for the xmlnamespace: clr-namespace:[Namespace][;Assembly=[AssemblyName]] diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/XamlInterfaces.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/XamlInterfaces.cs index 127e7d7..0104271 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/XamlInterfaces.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/XamlInterfaces.cs @@ -174,10 +174,9 @@ public override object ProvideValue(IServiceProvider provider) return type; // To Support types whose assembly is not available, we need to still resolve the clr namespace - if (manager.XmlNamespaceBasedMappings.TryGetValue(reader.LookupNamespace(prefix), out List xmlnsMappings) && xmlnsMappings != null && xmlnsMappings.Count > 0) - return xmlnsMappings[0].ClrNamespace + "." + typename; - else - return typename; + return manager.XmlNamespaceBasedMappings.TryGetValue(reader.LookupNamespace(prefix), out List xmlnsMappings) && xmlnsMappings != null && xmlnsMappings.Count > 0 + ? xmlnsMappings[0].ClrNamespace + "." + typename + : typename; } type = manager.GetType(new XmlQualifiedName(typename, reader.LookupNamespace(string.Empty))); diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/SR.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/SR.cs index cb0f4b7..e313d31 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/SR.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/SR.cs @@ -110,14 +110,9 @@ internal static string GetString(CultureInfo culture, string name, params object return null; string res = sys.resources.GetString(name, culture); System.Diagnostics.Debug.Assert(res != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { name })); - if (args != null && args.Length > 0) - { - return string.Format(CultureInfo.CurrentCulture, res, args); - } - else - { - return res; - } + return args != null && args.Length > 0 + ? string.Format(CultureInfo.CurrentCulture, res, args) + : res; } internal static string GetString(string name)