Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Marcussen committed Feb 10, 2018
1 parent 8475716 commit 47e2171
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 224 deletions.
59 changes: 46 additions & 13 deletions Types/AppIconFieldType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,53 @@

namespace Build.Shared.Types
{
public class AppIconFieldType : MasterMediaFieldType
public class AppIconFieldType : MediaFieldType
{
private bool _isMaster;
public virtual bool IsMaster { get { return _isMaster; } }

public AppIconFieldType(int value
, string displayName
, ProjectType projectType
, bool isMaster
, int order
, bool isForClient
, bool isProdReady
, bool defaultToDisabled
, AppIconFieldType inheritsFromDefault
, Dictionary<string, string> metadata
, int width)
: base(value, displayName, projectType, FieldHolderType.AppIcon, order, isForClient, isProdReady, defaultToDisabled, metadata, width)
: base(value: value
, displayName: displayName
, projectType: projectType
, fieldHolderType: FieldHolderType.AppIcon
, order: order
, isForClient: isForClient
, isProdReady: isProdReady
, defaultToDisabled: defaultToDisabled
, inheritsFromDefault: inheritsFromDefault
, metadata: metadata
, width: width)
{
_isMaster = isMaster;
}

public class Shared : AppIconFieldType
{
public Shared(int value
, string displayName
, bool isMaster
, int order
, bool isForClient
, bool isProdReady
, bool defaultToDisabled
, AppIconFieldType inheritsFromDefault
, Dictionary<string, string> metadata
, int width)
: base(value, displayName, ProjectType.Shared, isMaster, order, isForClient, isProdReady, defaultToDisabled, metadata, width)
: base(value: value
, displayName: displayName
, projectType: ProjectType.Shared
, order: order
, isForClient: isForClient
, isProdReady: isProdReady
, defaultToDisabled: defaultToDisabled
, inheritsFromDefault: inheritsFromDefault
, metadata: metadata
, width: width)
{
}
}
Expand All @@ -44,14 +59,23 @@ public class Droid : AppIconFieldType
{
public Droid(int value
, string displayName
, bool isMaster
, int order
, bool isForClient
, bool isProdReady
, bool defaultToDisabled
, AppIconFieldType inheritsFromDefault
, Dictionary<string, string> metadata
, int width)
: base(value, displayName, ProjectType.Droid, isMaster, order, isForClient, isProdReady, defaultToDisabled, metadata, width)
: base(value: value
, displayName: displayName
, projectType: ProjectType.Droid
, order: order
, isForClient: isForClient
, isProdReady: isProdReady
, defaultToDisabled: defaultToDisabled
, inheritsFromDefault: inheritsFromDefault
, metadata: metadata
, width: width)
{
}
}
Expand All @@ -60,14 +84,23 @@ public class Ios : AppIconFieldType
{
public Ios(int value
, string displayName
, bool isMaster
, int order
, bool isForClient
, bool isProdReady
, bool defaultToDisabled
, AppIconFieldType inheritsFromDefault
, Dictionary<string, string> metadata
, int width)
: base(value, displayName, ProjectType.Ios, isMaster, order, isForClient, isProdReady, defaultToDisabled, metadata, width)
: base(value: value
, displayName: displayName
, projectType: ProjectType.Ios
, order: order
, isForClient: isForClient
, isProdReady: isProdReady
, defaultToDisabled: defaultToDisabled
, inheritsFromDefault: inheritsFromDefault
, metadata: metadata
, width: width)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion Types/BuildConfigRecordSetFieldType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public BuildConfigRecordSetFieldType(int value
, bool isProdReady
, bool defaultToDisabled
, StringFieldDisplayType fieldDisplayType
, string defaultValue) : base(value, displayName, projectType, FieldHolderType.Packaging, true, order, isForClient, isProdReady, defaultToDisabled, fieldDisplayType, defaultValue)
, string defaultValue) : base(value, displayName, projectType, FieldHolderType.Packaging, order, isForClient, isProdReady, defaultToDisabled, null, fieldDisplayType, defaultValue)
{
}

Expand Down
34 changes: 20 additions & 14 deletions Types/Enumeration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@ private static TEnumeration[] GetEnumerations()
.ToArray();
}

[Conditional("DEBUG")]
public static void TestAll()
{
var enumerations = GetAll();
var possibleDuplicates = enumerations.GroupBy(x => x.Value)
.Select(x => new {
Count = x.Count(),
Value = x.Key
})
.OrderByDescending(x => x.Count);

var duplicates = possibleDuplicates.Where(x => x.Count > 1).ToList();
if (duplicates.Any())
{
var firstDuplicate = duplicates.FirstOrDefault();
throw new Exception($"Duplicated Value found Enumeration Type {enumerations.FirstOrDefault().GetType().FullName} for Value {firstDuplicate.Value}");
}

}
public static IEnumerable<TTypeOut> GetAllOf<TTypeOut>()
{
Type enumerationType = typeof(TEnumeration);
Expand All @@ -98,20 +117,7 @@ public static IEnumerable<TTypeOut> GetAllOf<TTypeOut>()
.Select(info => info.GetValue(null))
.Cast<TTypeOut>();
}

public TEnumeration[] GetAllOfC(Type enumerationType)
{
//Type enumerationType = typeof(t);

Type enumerationTypeOut = typeof(TEnumeration);
return enumerationType
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)
.Where(info => enumerationTypeOut.IsAssignableFrom(info.FieldType))
.Select(info => info.GetValue(null))
.Cast<TEnumeration>()
.ToArray();
}


public override bool Equals(object obj)
{
return Equals(obj as TEnumeration);
Expand Down
Loading

0 comments on commit 47e2171

Please sign in to comment.