@@ -830,14 +830,6 @@ private bool ParseArgumentList(ArgumentInfo info, string[] strs, object destinat
830
830
continue ;
831
831
}
832
832
833
- if ( arg . IsSubComponentItemType )
834
- {
835
- hadError |= ! arg . SetValue ( this , ref values [ arg . Index ] , value , tag , destination ) ;
836
- if ( ! IsCurlyGroup ( value ) && i + 1 < strs . Length && IsCurlyGroup ( strs [ i + 1 ] ) )
837
- hadError |= ! arg . SetValue ( this , ref values [ arg . Index ] , strs [ ++ i ] , "" , destination ) ;
838
- continue ;
839
- }
840
-
841
833
if ( arg . IsCustomItemType )
842
834
{
843
835
hadError |= ! arg . SetValue ( this , ref values [ arg . Index ] , value , tag , destination ) ;
@@ -1395,7 +1387,6 @@ public sealed class Arg
1395
1387
public bool IsDefault { get { return _arg . IsDefault ; } }
1396
1388
public bool IsHidden { get { return _arg . IsHidden ; } }
1397
1389
public bool IsCollection { get { return _arg . IsCollection ; } }
1398
- public bool IsSubComponentItemType { get { return _arg . IsSubComponentItemType ; } }
1399
1390
public bool IsTaggedCollection { get { return _arg . IsTaggedCollection ; } }
1400
1391
// Used for help and composing settings strings.
1401
1392
public object DefaultValue { get { return _arg . DefaultValue ; } }
@@ -1486,12 +1477,6 @@ private static string TypeToString(Type type)
1486
1477
bldr . Append ( ']' ) ;
1487
1478
return bldr . ToString ( ) ;
1488
1479
}
1489
- else if ( type . IsGenericEx ( typeof ( SubComponent < , > ) ) )
1490
- {
1491
- var genArgs = type . GetGenericTypeArgumentsEx ( ) ;
1492
- Contracts . Assert ( Utils . Size ( genArgs ) == 2 ) ;
1493
- return $ "{ ComponentCatalog . SignatureToString ( genArgs [ 1 ] ) } ⇒ { genArgs [ 0 ] . Name } ";
1494
- }
1495
1480
else
1496
1481
return type . Name ;
1497
1482
}
@@ -1574,7 +1559,6 @@ private sealed class Argument
1574
1559
public readonly bool IsDefault ;
1575
1560
public readonly bool IsHidden ;
1576
1561
public readonly bool IsCollection ;
1577
- public readonly bool IsSubComponentItemType ;
1578
1562
public readonly bool IsTaggedCollection ;
1579
1563
public readonly bool IsComponentFactory ;
1580
1564
@@ -1629,9 +1613,7 @@ public Argument(int index, string name, string[] nicks, object defaults, Argumen
1629
1613
if ( defaults != null && ! IsRequired )
1630
1614
DefaultValue = field . GetValue ( defaults ) ;
1631
1615
1632
- if ( typeof ( SubComponent ) . IsAssignableFrom ( ItemValueType ) )
1633
- IsSubComponentItemType = true ;
1634
- else if ( typeof ( IComponentFactory ) . IsAssignableFrom ( ItemValueType ) )
1616
+ if ( typeof ( IComponentFactory ) . IsAssignableFrom ( ItemValueType ) )
1635
1617
IsComponentFactory = true ;
1636
1618
else if ( ! IsValidItemType ( ItemValueType ) )
1637
1619
{
@@ -1658,7 +1640,6 @@ public Argument(int index, string name, string[] nicks, object defaults, Argumen
1658
1640
}
1659
1641
1660
1642
Contracts . Check ( ! IsCollection || AllowMultiple , "Collection arguments must allow multiple" ) ;
1661
- Contracts . Check ( ! IsSingleSubComponent || AllowMultiple , "SubComponent arguments must allow multiple" ) ;
1662
1643
Contracts . Check ( ! Unique || IsCollection , "Unique only applicable to collection arguments" ) ;
1663
1644
}
1664
1645
@@ -1681,42 +1662,15 @@ public bool Finish(CmdParser owner, ArgValue val, object destination)
1681
1662
{
1682
1663
// Make sure all collections have a non-null.
1683
1664
// REVIEW: Should we really do this? Or should all code be able to handle null arrays?
1684
- // Should we also set null strings to ""? SubComponent?
1665
+ // Should we also set null strings to ""?
1685
1666
if ( IsCollection && Field . GetValue ( destination ) == null )
1686
1667
Field . SetValue ( destination , Array . CreateInstance ( ItemType , 0 ) ) ;
1687
1668
return ReportMissingRequiredArgument ( owner , val ) ;
1688
1669
}
1689
1670
1690
1671
var values = val . Values ;
1691
1672
bool error = false ;
1692
- if ( IsSingleSubComponent )
1693
- {
1694
- bool haveKind = false ;
1695
- var com = SubComponent . Create ( ItemType ) ;
1696
- for ( int i = 0 ; i < Utils . Size ( values ) ; )
1697
- {
1698
- string str = ( string ) values [ i ] . Value ;
1699
- if ( str . StartsWith ( "{" ) )
1700
- {
1701
- i ++ ;
1702
- continue ;
1703
- }
1704
- if ( haveKind )
1705
- {
1706
- owner . Report ( "Duplicate component kind for argument {0}" , LongName ) ;
1707
- error = true ;
1708
- }
1709
- com . Kind = str ;
1710
- haveKind = true ;
1711
- values . RemoveAt ( i ) ;
1712
- }
1713
-
1714
- if ( Utils . Size ( values ) > 0 )
1715
- com . Settings = values . Select ( x => ( string ) x . Value ) . ToArray ( ) ;
1716
-
1717
- Field . SetValue ( destination , com ) ;
1718
- }
1719
- else if ( IsSingleComponentFactory )
1673
+ if ( IsSingleComponentFactory )
1720
1674
{
1721
1675
bool haveName = false ;
1722
1676
string name = null ;
@@ -1758,53 +1712,6 @@ public bool Finish(CmdParser owner, ArgValue val, object destination)
1758
1712
error = true ;
1759
1713
}
1760
1714
}
1761
- else if ( IsMultiSubComponent )
1762
- {
1763
- // REVIEW: the kind should not be separated from settings: everything related
1764
- // to one item should go into one value, not multiple values
1765
- if ( IsTaggedCollection )
1766
- {
1767
- // Tagged collection of SubComponents
1768
- var comList = new List < KeyValuePair < string , SubComponent > > ( ) ;
1769
-
1770
- for ( int i = 0 ; i < Utils . Size ( values ) ; )
1771
- {
1772
- var com = SubComponent . Create ( ItemValueType ) ;
1773
- string tag = values [ i ] . Key ;
1774
- com . Kind = ( string ) values [ i ++ ] . Value ;
1775
- if ( i < values . Count && IsCurlyGroup ( ( string ) values [ i ] . Value ) && string . IsNullOrEmpty ( values [ i ] . Key ) )
1776
- com . Settings = new string [ ] { ( string ) values [ i ++ ] . Value } ;
1777
- comList . Add ( new KeyValuePair < string , SubComponent > ( tag , com ) ) ;
1778
- }
1779
-
1780
- var arr = Array . CreateInstance ( ItemType , comList . Count ) ;
1781
- for ( int i = 0 ; i < arr . Length ; i ++ )
1782
- {
1783
- var kvp = Activator . CreateInstance ( ItemType , comList [ i ] . Key , comList [ i ] . Value ) ;
1784
- arr . SetValue ( kvp , i ) ;
1785
- }
1786
-
1787
- Field . SetValue ( destination , arr ) ;
1788
- }
1789
- else
1790
- {
1791
- // Collection of SubComponents
1792
- var comList = new List < SubComponent > ( ) ;
1793
- for ( int i = 0 ; i < Utils . Size ( values ) ; )
1794
- {
1795
- var com = SubComponent . Create ( ItemValueType ) ;
1796
- com . Kind = ( string ) values [ i ++ ] . Value ;
1797
- if ( i < values . Count && IsCurlyGroup ( ( string ) values [ i ] . Value ) )
1798
- com . Settings = new string [ ] { ( string ) values [ i ++ ] . Value } ;
1799
- comList . Add ( com ) ;
1800
- }
1801
-
1802
- var arr = Array . CreateInstance ( ItemValueType , comList . Count ) ;
1803
- for ( int i = 0 ; i < arr . Length ; i ++ )
1804
- arr . SetValue ( comList [ i ] , i ) ;
1805
- Field . SetValue ( destination , arr ) ;
1806
- }
1807
- }
1808
1715
else if ( IsMultiComponentFactory )
1809
1716
{
1810
1717
// REVIEW: the kind should not be separated from settings: everything related
@@ -1951,7 +1858,7 @@ public bool SetValue(CmdParser owner, ref ArgValue val, string value, string tag
1951
1858
}
1952
1859
val . Values . Add ( new KeyValuePair < string , object > ( tag , newValue ) ) ;
1953
1860
}
1954
- else if ( IsSingleSubComponent || IsComponentFactory )
1861
+ else if ( IsComponentFactory )
1955
1862
{
1956
1863
Contracts . Assert ( newValue is string || newValue == null ) ;
1957
1864
Contracts . Assert ( ( string ) newValue != "" ) ;
@@ -1994,14 +1901,12 @@ private bool ParseValue(CmdParser owner, string data, out object value)
1994
1901
return true ;
1995
1902
if ( type == typeof ( string ) )
1996
1903
return true ;
1997
- if ( IsSubComponentItemType )
1998
- return true ;
1999
1904
2000
1905
ReportBadArgumentValue ( owner , data ) ;
2001
1906
return false ;
2002
1907
}
2003
1908
2004
- if ( IsSubComponentItemType || IsComponentFactory )
1909
+ if ( IsComponentFactory )
2005
1910
{
2006
1911
value = data ;
2007
1912
return true ;
@@ -2471,8 +2376,6 @@ public string GetSyntaxHelp()
2471
2376
bldr . Append ( "=<guid>" ) ;
2472
2377
else if ( type == typeof ( System . DateTime ) )
2473
2378
bldr . Append ( "=<datetime>" ) ;
2474
- else if ( IsSubComponentItemType )
2475
- bldr . Append ( "=<name>{<options>}" ) ;
2476
2379
else if ( IsComponentFactory )
2477
2380
bldr . Append ( "=<name>{<options>}" ) ;
2478
2381
else if ( IsCustomItemType )
@@ -2512,14 +2415,6 @@ public bool Unique {
2512
2415
get { return 0 != ( Kind & ArgumentType . Unique ) ; }
2513
2416
}
2514
2417
2515
- public bool IsSingleSubComponent {
2516
- get { return IsSubComponentItemType && ! Field . FieldType . IsArray ; }
2517
- }
2518
-
2519
- public bool IsMultiSubComponent {
2520
- get { return IsSubComponentItemType && Field . FieldType . IsArray ; }
2521
- }
2522
-
2523
2418
public bool IsSingleComponentFactory
2524
2419
{
2525
2420
get { return IsComponentFactory && ! Field . FieldType . IsArray ; }
0 commit comments