static ClassInstancesAssembly() { try { #if COREFX13 // We can't go looking for types, so let's settle for what's in lang-ext Types = typeof(ClassInstancesAssembly).GetTypeInfo().Assembly.DefinedTypes.Freeze(); #else Types = (from nam in GetAssemblies().Freeze() where nam != null && nam.Name != "mscorlib" && !nam.Name.StartsWith("System.") && !nam.Name.StartsWith("Microsoft.") let asm = SafeLoadAsm(nam) where asm != null from typ in asm.GetTypes() where typ != null && !typ.FullName.StartsWith("<") && !typ.FullName.Contains("+<") select typ.GetTypeInfo()) .Freeze(); #endif Structs = Types.Filter(t => t?.IsValueType ?? false); AllClassInstances = Structs.Filter(t => t?.ImplementedInterfaces?.Exists(i => i == typeof(Typeclass)) ?? false); ClassInstances = new Map <OrdTypeInfo, TypeInfo, Set <OrdTypeInfo, TypeInfo> >(); foreach (var ci in AllClassInstances) { var typeClasses = ci?.ImplementedInterfaces ?.Filter(i => typeof(Typeclass).GetTypeInfo().IsAssignableFrom(i.GetTypeInfo())) ?.Map(t => t.GetTypeInfo()) ?.Freeze() ?? Lst <TypeInfo> .Empty; ClassInstances = typeClasses.Fold(ClassInstances, (s, x) => s.AddOrUpdate(x, Some: cis => cis.AddOrUpdate(ci), None: () => Set <OrdTypeInfo, TypeInfo>(ci))); } } catch (Exception e) { Error = e; } }
private static bool CheckSecDiag(Lst <Move> board, Move lastMove) { if (lastMove.MovePosition.row + lastMove.MovePosition.col != 3 - 1) { return(false); } return(match(isMovedBy(board, lastMove), Some: by => board.Filter(m => m.MovePosition.row + m.MovePosition.col == 3 - 1).Count(m => m.MovedBy == by) == 3, None: () => false)); }
private Lst <DependencyNode> Mark(DependencyNode node, Lst <DependencyNode> sorted) { if (node.SortMark != SortMark.Unmarked) { return(sorted); } node.SortMark = SortMark.Temporary; var result = _nodes.Filter(node.DependsOn).Fold(sorted, (s, n) => Mark(n, s)); node.SortMark = SortMark.Permanent; return(node + result); }
public Model(string nameSpace, TypeDef type) { Namespace = nameSpace; Type = type; Document = type.Document; Methods = type.Members.Filter(m => m is MethodDef) .Map(m => m as MethodDef) .Filter(t => type.Type == TypeDefTag.Interface || t.Visibility == Vis.Public || t.Visibility == Vis.Protected) .OrderBy(t => t.Name.ToString()) .Freeze(); Ctors = Methods.Filter(m => m.Type.Name.ToString() == "ctor").Freeze(); Props = type.Members.Filter(m => m is PropDef) .Map(m => m as PropDef) .Filter(t => type.Type == TypeDefTag.Interface || t.Visibility == Vis.Public || t.Visibility == Vis.Protected) .OrderBy(t => t.Name.ToString()) .Freeze(); Fields = type.Members.Filter(m => m is FieldDef) .Map(m => m as FieldDef) .Filter(t => t.Visibility == Vis.Public || t.Visibility == Vis.Protected) .OrderBy(t => t.Name.ToString()) .Freeze(); Methods = type.Members.Filter(m => m is MethodDef) .Map(m => m as MethodDef) .Filter(t => type.Type == TypeDefTag.Interface || t.Visibility == Vis.Public || t.Visibility == Vis.Protected) .Filter(m => m.Type.Name.ToString() != "ctor") .OrderBy(t => t.Name.ToString()) .Freeze(); Enums = type.Members.Filter(m => m is EnumDef) .Map(m => m as EnumDef) .Filter(t => t.Visibility == Vis.Public) .OrderBy(t => t.Name.ToString()) .Freeze(); Delegates = type.Members.Filter(m => m is DelegateDef) .Map(m => m as DelegateDef) .Filter(t => t.Visibility == Vis.Public) .OrderBy(t => t.Name.ToString()) .Freeze(); }
public override string ToString() => $"error at {Pos}: " + (Tag == ParserErrorTag.Unexpect ? $"unexpected {Msg}" : Tag == ParserErrorTag.SysUnexpect ? $"unexpected {Msg}" : Tag == ParserErrorTag.Message ? Msg : Tag == ParserErrorTag.Expect ? $"unexpected {Msg}, {FormatExpects(Expected.Filter(x => !String.IsNullOrEmpty(x)).Distinct().Freeze())}" : "unknown error");
public DocumentComments(Lst <Tag> tags) { Summary = tags.Filter(t => t.Name == "summary").HeadOrNone(); Returns = tags.Filter(t => t.Name == "returns").HeadOrNone(); Remarks = tags.Filter(t => t.Name == "remarks"); TypeParams = tags.Filter(t => t.Name == "typeparam"); Params = tags.Filter(t => t.Name == "param"); Examples = tags.Filter(t => t.Name == "example"); Exceptions = tags.Filter(t => t.Name == "exception"); Permissions = tags.Filter(t => t.Name == "permission"); Includes = tags.Filter(t => t.Name == "include"); Completionlists = tags.Filter(t => t.Name == "completionlist"); Seealsos = tags.Filter(t => t.Name == "seealso"); Sees = tags.Filter(t => t.Name == "see"); }
public Option <DocAttr> Attr(string name) => Attrs.Filter(x => x.Name == name).HeadOrNone();
private static bool CheckRow(Lst <Move> board, Move lastMove) { return(match(isMovedBy(board, lastMove), Some: by => board.Filter(m => m.MovePosition.col == lastMove.MovePosition.col).Count(m => m.MovedBy == by) == 3, None: () => false)); }
public string ToStringNoPosition() => (Tag == ParserErrorTag.Unexpect ? $"unexpected {Msg}" : Tag == ParserErrorTag.SysUnexpect ? $"unexpected {Msg}" : Tag == ParserErrorTag.Message ? Msg : Tag == ParserErrorTag.Expect ? $"unexpected {Msg}, {FormatExpects(Expected.Filter(x => !String.IsNullOrEmpty(x)).Distinct().Freeze())}" : "unknown error");