public static bool StartsWith <T1>([NotNull] this IStructure structure, [CanBeNull] out T1 obj1) where T1 : ZilObject { if (structure.HasLengthAtLeast(1) && structure.GetFirst() is T1 elem1) { obj1 = elem1; return(true); } obj1 = default; return(false); }
public static bool StartsWith <T1, T2>([NotNull] this IStructure structure, [CanBeNull] out T1 obj1, [CanBeNull] out T2 obj2) where T1 : ZilObject where T2 : ZilObject { if (structure.HasLengthAtLeast(2) && structure[0] is T1 elem1 && structure[1] is T2 elem2) { obj1 = elem1; obj2 = elem2; return(true); } obj1 = default; obj2 = default; return(false); }
public static bool StartsWith <T1, T2, T3, T4>([NotNull] this IStructure structure, [CanBeNull] out T1 obj1, [CanBeNull] out T2 obj2, [CanBeNull] out T3 obj3, [CanBeNull] out T4 obj4) where T1 : ZilObject where T2 : ZilObject where T3 : ZilObject where T4 : ZilObject { if (structure.HasLengthAtLeast(4) && structure[0] is T1 elem1 && structure[1] is T2 elem2 && structure[2] is T3 elem3 && structure[3] is T4 elem4) { obj1 = elem1; obj2 = elem2; obj3 = elem3; obj4 = elem4; return(true); } obj1 = default; obj2 = default; obj3 = default; obj4 = default; return(false); }