private static void AddFiles(Project project, ProjectItems items, Document currentDoc) { foreach (ProjectItem subItem in items) { if (currentDoc == subItem) { continue; } if (subItem.Kind == PhysicalFolderKind || subItem.Kind == VirtualFolderKind) { AddFiles(project, subItem.ProjectItems, currentDoc); } else if (subItem.Kind == PhysicalFileKind) { if (subItem.Name.EndsWith(".cs")) // HACK: Gotta be a better way to know if it's C#. { for (short i = 0; i < subItem.FileCount; i++) { string path = subItem.FileNames[i]; if (path == currentDoc.FullName) { continue; } project.Sources.Add(Either <FileInfo, string> .A(new FileInfo(path))); } } } } }
public void Either4_Fold() { Action a = () => {}; Either <Action, object, string, Type> e = Either <Action, object, string, Type> .A(a); Assert.AreEqual(a, e.Fold(v => v, v => null, v => null, v => null)); e = Either <Action, object, string, Type> .D(typeof(object)); Assert.AreEqual(typeof(object), e.Fold(v => null, v => null, v => null, v => v)); }
public void Either3_Fold() { Action a = () => {}; Either <Action, object, string> e = Either <Action, object, string> .A(a); Assert.AreEqual(a, e.Fold(v => v, v => null, v => null)); e = Either <Action, object, string> .C("foo"); Assert.AreEqual("foo", e.Fold(v => null, v => null, v => v)); }
public void Either2_Fold() { Action a = () => {}; Either <Action, object> e = Either <Action, object> .A(a); Assert.AreEqual(a, e.Fold(v => v, v => null)); e = Either <Action, object> .B("foo"); Assert.AreEqual("foo", e.Fold(v => null, v => v.ToString())); }
public void Either2_Fold_b_Null() { Func <Action, int> a = x => 42; Func <object, int> b = null; var e = Either <Action, object> .A(() => {}); AssertException <ArgumentNullException> (() => e.Fold(a, b)); e = Either <Action, object> .B(new object()); AssertException <ArgumentNullException> (() => e.Fold(a, b)); }
public void Either2_Fold_a_Null() { Func <Action, int> a = null; Func <object, int> b = x => Convert.ToInt32(x); var e = Either <Action, object> .A(() => {}); AssertException <ArgumentNullException> (() => e.Fold(a, b)); e = Either <Action, object> .B(new object()); AssertException <ArgumentNullException> (() => e.Fold(a, b)); }
public void Either3_Fold_c_Null() { Func <Action, int> a = x => 42; Func <object, int> b = x => Convert.ToInt32(x); Func <string, int> c = null; var e = Either <Action, object, string> .A(() => {}); AssertException <ArgumentNullException> (() => e.Fold(a, b, c)); e = Either <Action, object, string> .B(new object()); AssertException <ArgumentNullException> (() => e.Fold(a, b, c)); e = Either <Action, object, string> .C("foo"); AssertException <ArgumentNullException> (() => e.Fold(a, b, c)); }
public void Either4_Fold_d_Null() { Func <Action, int> a = x => 42; Func <object, int> b = x => Convert.ToInt32(x); Func <string, int> c = x => Convert.ToInt32(x); Func <Type, int> d = null; var e = Either <Action, object, string, Type> .A(() => {}); AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d)); e = Either <Action, object, string, Type> .B(new object()); AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d)); e = Either <Action, object, string, Type> .C("foo"); AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d)); e = Either <Action, object, string, Type> .D(typeof(object)); AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d)); }
/// <summary> /// Instruments the supplied code to call the <see cref="Hook"/> methods. /// </summary> /// <param name="code">The code to instrument.</param> /// <param name="submissionId">The submission ID.</param> /// <returns>A task for a <see cref="string"/> representing the instrumented code.</returns> /// <seealso cref="Hook.CreateSubmission"/> public static Task <Either <string, Error> > Instrument(string code, int submissionId) { if (code == null) { throw new ArgumentNullException("code"); } return(Task <Either <string, Error> > .Factory.StartNew(s => { SyntaxTree tree = SyntaxTree.Parse((string)s); InstrumentingRewriter rewriter = new InstrumentingRewriter(submissionId); tree.AcceptVisitor(rewriter); Error error = tree.Errors.FirstOrDefault(e => e.ErrorType == ErrorType.Error); if (error != null) { return Either <string, Error> .B(error); } return Either <string, Error> .A(tree.GetText()); }, code)); }
private Either <CachedSequence <T>, IEnumerator <T> > Either(CachedSequence <T> tail) { return(Either <CachedSequence <T>, IEnumerator <T> > .A(tail)); }
protected override Either <Action, object, string> CreateValueX() { return(Either <Action, object, string> .A(() => {})); }
public void Either4_A_ValueNull() { Either <Action, object, string, Type> .A(null); }
public void Either3_A_ValueNull() { Either <Action, object, string> .A(null); }
public void Either2_A_ValueNull() { Either <Action, object> .A(null); }