public static INameSource Then(this INameSource source, string separator, IIndexGenerator index) { var sources = new List <INameSource> { source, Name.From(index) }; return(new CombinedNameSource(sources, separator)); }
public static INameSource Then(this INameSource source, string separator, params INameSource[] otherSources) { var sources = new List <INameSource> { source }; sources.AddRange(otherSources); return(new CombinedNameSource(sources, separator)); }
public IAstMemberReference Resolve(IAstTypeReference declaringType, string name, INameSource scope) { var resolved = declaringType.ResolveMember(name); if (resolved == null) resolved = ResolveMemberFromScope(name, scope); if (resolved == null) throw new NotImplementedException("MemberResolver: Failed to resolve " + name); return resolved; }
public void SayHelloWorld() { INameSource nameSource = (INameSource)mocks.StrictMock(typeof(INameSource)); Expect.Call(nameSource.CreateName(null, null)).IgnoreArguments(). Do(new NameSourceDelegate(Formal)); mocks.ReplayAll(); string expected = "Hi, my name is Ayende Rahien"; string actual = new Speaker("Ayende", "Rahien", nameSource).Introduce(); Assert.Equal(expected, actual); }
public void SayHelloWorld() { INameSource nameSource = MockRepository.Mock <INameSource>(); nameSource.Expect(x => x.CreateName(null, null)) .IgnoreArguments() .DoInstead(new NameSourceDelegate(Formal)); string expected = "Hi, my name is Ayende Rahien"; string actual = new Speaker("Ayende", "Rahien", nameSource) .Introduce(); Assert.Equal(expected, actual); }
private static IAstMemberReference ResolveMemberFromScope(string name, INameSource scope) { var extensions = scope.ResolveMember(name); if (extensions.Count == 0) return null; if (extensions.Count == 1) return extensions[0]; if (extensions.All(a => a is IAstMethodReference)) return new AstMethodGroup(name, extensions.Cast<IAstMethodReference>().ToArray()); throw new NotImplementedException("MemberResolver: Ambiguous result for " + name); }
public SuffixNameSource(string suffix, INameSource source) { if (string.IsNullOrEmpty(suffix)) { throw new ArgumentNullException(nameof(suffix)); } if (source == null) { throw new ArgumentNullException(nameof(source)); } _suffix = suffix; _source = source; }
public PrefixNameSource(string prefix, INameSource source) { if (string.IsNullOrEmpty(prefix)) { throw new ArgumentNullException(nameof(prefix)); } if (source == null) { throw new ArgumentNullException(nameof(source)); } _prefix = prefix; _source = source; }
public void SayHelloWorld_AAA() { //Arrange INameSource nameSource = MockRepository.GenerateStrictMock <INameSource>(); nameSource.Expect(n => n.CreateName(null, null)).IgnoreArguments(). Do(new NameSourceDelegate(Formal)); //Act string actual = new Speaker("Ayende", "Rahien", nameSource).Introduce(); //Assert string expected = "Hi, my name is Ayende Rahien"; Assert.AreEqual(expected, actual); nameSource.VerifyAllExpectations(); }
public static string GetNext(string name, IEnumerable items) { string rname = null; if (name != null) { int i = name.Length - 1; while (i >= 0 && Char.IsDigit(name[i])) { i--; } name = name.Substring(0, i + 1); rname = name; } int maxId = 0; int maxName = 0; if (items != null) { foreach (object el in items) { if (name != null) { INameSource ns = el as INameSource; if (ns != null && ns.Name.StartsWith(name)) { string sub = ns.Name.Substring(name.Length).Trim(); if (IsDigit(sub)) { int num = Convert.ToInt32(sub); maxName = Math.Max(maxName, num); } } } } } maxId++; maxName++; rname += maxName; return(rname); }
private static IAstMemberReference ResolveMemberFromScope(string name, INameSource scope) { var extensions = scope.ResolveMember(name); if (extensions.Count == 0) { return(null); } if (extensions.Count == 1) { return(extensions[0]); } if (extensions.All(a => a is IAstMethodReference)) { return(new AstMethodGroup(name, extensions.Cast <IAstMethodReference>().ToArray())); } throw new NotImplementedException("MemberResolver: Ambiguous result for " + name); }
private static Duplicate?FirstDuplicate(INameSource source, int cycles) { var results = new Dictionary <string, int>(); foreach (var cycle in Enumerable.Range(0, cycles)) { var name = source.Next(); if (results.ContainsKey(name)) { return(new Duplicate { Value = name, FirstCycle = results[name], LastCycle = cycle }); } results.Add(name, cycle); } return(null); }
public LightProcessor(INameSource[] topLevelNameSources, IProcessingStep[] steps) { this.topLevelNameSources = topLevelNameSources; this.steps = steps.OrderBy(s => s.Stage).ToArray(); }
public Speaker(string firstName, string surname, INameSource nameSource) { _firstName = firstName; _surname = surname; _nameSource = nameSource; }
public Speaker(string firstName, string surname, INameSource nameSource) { this.firstName = firstName; this.surname = surname; this.nameSource = nameSource; }
public IAstMemberReference Resolve(IAstTypeReference declaringType, string name, INameSource scope) { var resolved = declaringType.ResolveMember(name); if (resolved == null) { resolved = ResolveMemberFromScope(name, scope); } if (resolved == null) { throw new NotImplementedException("MemberResolver: Failed to resolve " + name); } return(resolved); }
public void Add(INameSource source) { this.sources.Add(source); }
public static INameSource WithSuffix(this INameSource source, string suffix) => new SuffixNameSource(suffix, source);
public static INameSource WithPrefix(this INameSource source, string prefix) => new PrefixNameSource(prefix, source);
public static INameSource Or(this INameSource source, INameSource otherSource) => new OneOfNameSource(new List <INameSource> { source, otherSource });
public LightProcessor(INameSource[] topLevelNameSources, IEnumerable<IProcessingStep> allSteps) { this.topLevelNameSources = topLevelNameSources; this.allSteps = allSteps.OrderBy(s => s.Stage).ToArray(); }