Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Fixed a problem that caused a hard crash when certain model propertie…
Browse files Browse the repository at this point in the history
…s were changed under certain conditions (See #38)
  • Loading branch information
msawczyn committed Nov 30, 2018
1 parent 5e881c5 commit 595b829
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 65 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
1.2.6.19
- Fixed code generation issue where class and enum directory overrides were being ignored (See https://github.com/msawczyn/EFDesigner/issues/36)
- Fixed a problem that caused a hard crash when certain model properties were changed under certain conditions (See https://github.com/msawczyn/EFDesigner/issues/38)

1.2.6.18
- Fixed issue #35, Concurrency mode: optimistic auto generated Timestamp property (See https://github.com/msawczyn/EFDesigner/issues/35)
Expand Down
Binary file modified dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Microsoft.VisualStudio.Modeling.Diagrams;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using Microsoft.VisualStudio.Modeling.Diagrams;

namespace Sawczyn.EFDesigner.EFModel
{
Expand All @@ -21,24 +21,24 @@ public class SourceMultiplicityTypeConverter : MultiplicityTypeConverter
/// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
AssociationConnector connector = context?.Instance as AssociationConnector;
Association association = context.Instance as Association;

if (connector != null)
{
Association association = PresentationViewsSubject.GetSubject(connector) as Association;
if (association == null && context.Instance is AssociationConnector connector)
association = PresentationViewsSubject.GetSubject(connector) as Association;

if (destinationType == typeof(string) && association != null && value is Multiplicity)
switch ((Multiplicity)value)
{
case Multiplicity.One:
return $"1 (One {association.Source.Name})";
//case Multiplicity.OneMany:
// return $"1..* (Collection of one or more {association.Source.Name})";
case Multiplicity.ZeroMany:
return $"* (Collection of {association.Source.Name})";
case Multiplicity.ZeroOne:
return $"0..1 (Zero or one of {association.Source.Name})";
}
if (destinationType == typeof(string) && association != null && value is Multiplicity multiplicity)
{
switch (multiplicity)
{
case Multiplicity.One:
return $"1 (One {association.Source.Name})";
//case Multiplicity.OneMany:
// return $"1..* (Collection of one or more {association.Source.Name})";
case Multiplicity.ZeroMany:
return $"* (Collection of {association.Source.Name})";
case Multiplicity.ZeroOne:
return $"0..1 (Zero or one of {association.Source.Name})";
}
}

return base.ConvertTo(context, culture, value, destinationType);
Expand All @@ -59,20 +59,21 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
/// </param>
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
AssociationConnector connector = context.Instance as AssociationConnector;
if (connector == null) return new StandardValuesCollection(new string[0]);
Association association = context.Instance as Association;

if (association == null && context.Instance is AssociationConnector connector)
association = PresentationViewsSubject.GetSubject(connector) as Association;

Association association = PresentationViewsSubject.GetSubject(connector) as Association;
if (association == null)
return new StandardValuesCollection(new string[0]);

List<string> result = new List<string>
{
$"* (Collection of {association.Source.Name})",
//$"1..* (Collection of one or more {association.Source.Name})",
$"0..1 (Zero or one of {association.Source.Name})",
$"1 (One {association.Source.Name})"
};
{
$"* (Collection of {association.Source.Name})",
//$"1..* (Collection of one or more {association.Source.Name})",
$"0..1 (Zero or one of {association.Source.Name})",
$"1 (One {association.Source.Name})"
};
return new StandardValuesCollection(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Microsoft.VisualStudio.Modeling.Diagrams;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using Microsoft.VisualStudio.Modeling.Diagrams;

namespace Sawczyn.EFDesigner.EFModel
{
Expand All @@ -21,24 +21,24 @@ public class TargetMultiplicityTypeConverter : MultiplicityTypeConverter
/// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
AssociationConnector connector = context?.Instance as AssociationConnector;
Association association = context.Instance as Association;

if (connector != null)
{
Association association = PresentationViewsSubject.GetSubject(connector) as Association;
if (association == null && context.Instance is AssociationConnector connector)
association = PresentationViewsSubject.GetSubject(connector) as Association;

if (destinationType == typeof(string) && association != null && value is Multiplicity)
switch ((Multiplicity)value)
{
case Multiplicity.One:
return $"1 (One {association.Target.Name})";
//case Multiplicity.OneMany:
// return $"1..* (Collection of one or more {association.Target.Name})";
case Multiplicity.ZeroMany:
return $"* (Collection of {association.Target.Name})";
case Multiplicity.ZeroOne:
return $"0..1 (Zero or one of {association.Target.Name})";
}
if (destinationType == typeof(string) && association != null && value is Multiplicity multiplicity)
{
switch (multiplicity)
{
case Multiplicity.One:
return $"1 (One {association.Target.Name})";
//case Multiplicity.OneMany:
// return $"1..* (Collection of one or more {association.Target.Name})";
case Multiplicity.ZeroMany:
return $"* (Collection of {association.Target.Name})";
case Multiplicity.ZeroOne:
return $"0..1 (Zero or one of {association.Target.Name})";
}
}

return base.ConvertTo(context, culture, value, destinationType);
Expand All @@ -59,29 +59,22 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
/// </param>
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
StandardValuesCollection noResult = new StandardValuesCollection(new string[0]);
Association association = context.Instance as Association;

try
{
AssociationConnector connector = context.Instance as AssociationConnector;
Association association = PresentationViewsSubject.GetSubject(connector) as Association;
if (association == null)
return new StandardValuesCollection(new string[0]);
if (association == null && context.Instance is AssociationConnector connector)
association = PresentationViewsSubject.GetSubject(connector) as Association;

List<string> result = new List<string>
{
$"* (Collection of {association.Target.Name})",
//$"1..* (Collection of one or more {association.Target.Name})",
$"0..1 (Zero or one of {association.Target.Name})",
$"1 (One {association.Target.Name})"
};
return new StandardValuesCollection(result);
}
catch (Exception e)
{
}
if (association == null)
return new StandardValuesCollection(new string[0]);

return noResult;
List<string> result = new List<string>
{
$"* (Collection of {association.Target.Name})",
//$"1..* (Collection of one or more {association.Target.Name})",
$"0..1 (Zero or one of {association.Target.Name})",
$"1 (One {association.Target.Name})"
};
return new StandardValuesCollection(result);
}
}
}

0 comments on commit 595b829

Please sign in to comment.