Exemplo n.º 1
0
    public SolutionGraph(IEnumerable<Solution> solutions)
    {
        _allNugets = new Lazy<IEnumerable<NugetSpec>>(() => _solutions.SelectMany(x => x.PublishedNugets).ToList());

            solutions.Each(s => _solutions[s.Name] = s);
            solutions.Each(s => s.DetermineDependencies(FindNugetSpec));

            _orderedSolutions = new Lazy<IList<Solution>>(() =>
            {
                var graph = new DependencyGraph<Solution>(s => s.Name, s => s.SolutionDependencies().Select(x => x.Name));
                solutions.Each(graph.RegisterItem);
                return graph.Ordered().ToList();
            });
    }
Exemplo n.º 2
0
        public SerializationContext Create(IEnumerable <DataRepository> dataRepositories = null, IEnumerable <IWithId> externalReferences = null)
        {
            var projectRetriever = _container.Resolve <IPKSimProjectRetriever>();
            var project          = projectRetriever.Current;

            //do not use the pksim repository since we need to register the deserialized object afterwards
            //this repository is only used to resolve the references
            var withIdRepository = new WithIdRepository();

            externalReferences?.Each(withIdRepository.Register);

            var allRepositories = new List <DataRepository>();

            if (project != null)
            {
                allRepositories.AddRange(project.All <IndividualSimulation>()
                                         .Where(s => s.HasResults)
                                         .Select(s => s.DataRepository)
                                         .Union(project.AllObservedData));
            }

            if (dataRepositories != null)
            {
                allRepositories.AddRange(dataRepositories);
            }

            allRepositories.Each(withIdRepository.Register);

            return(SerializationTransaction.Create(_dimensionFactory, _objectBaseFactory, withIdRepository, _cloneManagerForModel, allRepositories));
        }
Exemplo n.º 3
0
 public static FileInclusionPolicy CreateInclusionPolicy(IEnumerable<string> excludes = null, IEnumerable<string> includes = null)
 {
     var policy = new FileInclusionPolicy();
     if (excludes != null) excludes.Each(policy.AddExclude);
     if(includes != null) includes.Each(policy.AddInclude);
     return policy;
 }
        public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
        {
            ReadScriptConfig(FubuMvcPackageFacility.GetApplicationPath(), log);
            packages.Each(p => p.ForFolder(BottleFiles.WebContentFolder, folder => ReadScriptConfig(folder, log)));

            _assets.CompileDependencies(log);
        }
        public static Type GenerateType(Type baseType, IEnumerable<Type> interfaceTypes)
        {
            var newType = dynamicModule.DefineType(
                Prefix + "." + baseType.GetName(),
                TypeAttributes.AutoLayout | TypeAttributes.Public | TypeAttributes.Class,
                baseType);

            interfaceTypes.Each(interfaceType =>
            {
                newType.AddInterfaceImplementation(interfaceType);
                interfaceType.GetMethods().Each(method =>
                {
                    ImplementInterfaceMethod(newType, method);
                });
            });

            baseType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Each(constructor =>
            {
                switch (constructor.Attributes & MethodAttributes.MemberAccessMask)
                {
                    case MethodAttributes.Family:
                    case MethodAttributes.Public:
                    case MethodAttributes.FamORAssem:
                        ImplementConstructor(newType, constructor);
                        break;
                }
            });

            return newType.CreateType();
        }
Exemplo n.º 6
0
        public FubuMvcContext(IFubuMvcSystem system)
        {
            _system = system;

            _contextualProviders = system.ContextualProviders ?? new IContextualInfoProvider[0];
            _contextualProviders.Each(x => x.Reset());
        }
		public void EachWithFunc( IEnumerable<object> sut )
		{
			var copy = sut.ToList();
			Func<object, bool> action = copy.Remove;
			var results = sut.Each( action );
			Assert.All( results,  b => b.IsFalse( () => { throw new InvalidOperationException( "was not true." ); } ) );
		}
Exemplo n.º 8
0
        public IEnumerable<IActivator> Bootstrap(IPackageLog log)
        {
            _services = _inner.Bootstrap(log).Select(x => new BottleService(x, log));
            _services.Each(x => x.Start());

            return new IActivator[0];
        }
        public ThreadSafeLocaleCache(CultureInfo culture, IEnumerable<LocalString> strings)
        {
            _data = new Dictionary<LocalizationKey, string>();
            strings.Each(s => _data.Add(new LocalizationKey(s.value), s.display));

            _culture = culture;
        }
Exemplo n.º 10
0
        public void Report(IEnumerable<SuiteRunResult> executed)
        {
            var totalPasses = executed.Sum(x => x.Passes);
            var totalFailures = executed.Sum(x => x.Failures);
            var total = totalPasses + totalFailures;

            _output.WriteLine("Loaded: {0}".FormatWith(executed.Select(s => s.Name).Join(", ")));
            _output.WriteLine("  {0} {1} loaded.".FormatWith(
                total,
                "test".Pluralize(total)));
            _output.WriteLine("  {0}/{1} {2} passed ({3} {4}).".FormatWith(
                totalPasses,
                total,
                "test".Pluralize(total),
                totalFailures,
                "failure".Pluralize(totalFailures)));

            if (totalFailures > 0)
                _output.WriteLine("Failures: ");
            executed.Each(suiteResult => suiteResult
                .Results
                .Where(containerResult => containerResult.Results.Any(r => !r.Pass))
                .Each(f =>
                {
                    _output.WriteLine("  {0}.{1} contained {2} failures.".FormatWith(suiteResult.Name, f.Name, f.Failures));
                    f.Results.Where(r => !r.Pass).Each(r => _output.WriteLine("    {0} failed. [{1}]".FormatWith(r.Name, r.Message)));
                }));

            _output.Flush();
        }
		public void Each( IEnumerable<object> sut )
		{
			var count = 0;
			Action<object> action = o => count++;
			sut.Each( action );
			Assert.Equal( sut.Count(), count );
		}
Exemplo n.º 12
0
        public AggregateResult(IEnumerable<GameResult> results)
        {
            _playerToScoreMap = new Dictionary<BotPlayer, int>();
              results.SelectMany(x => x.Players).Each(x => _playerToScoreMap[x] = 0);

              results.Each(result =>
              {
            if (result.IsTie)
            {
              result.Players.Each(player =>
              {
            _playerToScoreMap[player]++;
              });
            }
            else
            {
              _playerToScoreMap[result.Winner] += 3;
            }
              });

              var winners = _playerToScoreMap.GroupBy(x => x.Value).OrderByDescending(x => x.Key).First();

              if (winners.Count() == _playerToScoreMap.Count)
              {
            IsTie = true;
              }
              else
              {
            Winner = winners.First().Key;
              }
        }
        public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
        {
            var provider = new FileSystemVirtualPathProvider();
            HostingEnvironment.RegisterVirtualPathProvider(provider);

            packages.Each(x => x.ForFolder(FubuMvcPackages.WebContentFolder, provider.RegisterContentDirectory));
        }
Exemplo n.º 14
0
 public void Discard(IEnumerable<Card> cards)
 {
     cards.Each(card =>
                    {
                        RemoveCardFromDeck(card);
                        Player.AddToDiscard(card);
                    });
 }
Exemplo n.º 15
0
 public void Draw(IEnumerable<Card> cards)
 {
     cards.Each(card =>
                    {
                        RemoveCardFromDeck(card);
                        Player.AddCardToHand(card);
                    });
 }
Exemplo n.º 16
0
 protected override void applyBufferingToChildSectionLines(IEnumerable<Line> sectionLines, int index)
 {
     if (isSubsequentLine(index))
     {
         var buffer = (Convert.ToChar(9475).ToString() + " ").PadLeft(_tabWidth);
         sectionLines.Each(x => x.Prepend(buffer));
     }
 }
        public void RunAssemblies(IEnumerable<Assembly> assemblies)
        {
            var map = new Dictionary<Assembly, IEnumerable<Context>>();

            assemblies.Each(assembly => map.Add(assembly, _explorer.FindContextsIn(assembly)));

            StartRun(map);
        }
    public void RunAssemblies(IEnumerable<Assembly> assemblies)
    {
      _internalListener.OnRunStart();

      assemblies.Each(x => InternalRunAssembly(x));

      _internalListener.OnRunEnd();
    }
Exemplo n.º 19
0
        public static string Visualize(this IFubuPage page, IEnumerable<BehaviorNode> nodes)
        {
            var builder = new StringBuilder();

            nodes.Each(x => builder.Append(page.Visualize(x)));

            return builder.ToString();
        }
Exemplo n.º 20
0
        public FubuMvcContext(IApplicationUnderTest application, BindingRegistry binding, IEnumerable<IContextualInfoProvider> contextualProviders )
        {
            _application = application;
            _binding = binding;

            _contextualProviders = contextualProviders ?? new IContextualInfoProvider[0];

            _contextualProviders.Each(x => x.Reset());
        }
Exemplo n.º 21
0
 public ServiceGroupTag(string title, IEnumerable<Description> descriptions) : base(Guid.NewGuid().ToString(), title)
 {
     descriptions.Each(x =>
     {
         var titleTag = new HtmlTag("div").AddClass("service-title").Text(x.Title);
         AppendContent(titleTag);
         AppendContent(new DescriptionBodyTag(x));
     });
 }
Exemplo n.º 22
0
 public void Refill(IEnumerable<ScreenAction> actions)
 {
     ContextMenu.Items.Clear();
     actions.Each(x =>
     {
         var item = CommandMenuItem.Build(x);
         ContextMenu.Items.Add(item);
     });
 }
Exemplo n.º 23
0
        public void SendOutgoingMessages(Envelope original, IEnumerable<object> cascadingMessages)
        {
            if (original.AckRequested)
            {
                sendAcknowledgement(original);
            }

            cascadingMessages.Each(o => SendOutgoingMessage(original, o));
        }
Exemplo n.º 24
0
 public static ExecutionResult Merge(this ExecutionResult executionResult, IEnumerable<ValidationFailure> validationFailures, MessageCategory withMessageCategory = MessageCategory.BrokenBusinessRule)
 {
     if (executionResult != null)
     {
         validationFailures.Each(
             x => executionResult.Add(MessageCategory.BrokenBusinessRule, x.ErrorMessage, x.PropertyName));
     }
     return executionResult;
 }
Exemplo n.º 25
0
        public void Create(Guid identity, Guid metadataDefinitionGroupIdentity, string name, IEnumerable<ValueSet> values)
        {
            var aggregate = new Entity(identity,metadataDefinitionGroupIdentity, new EntityName(name));

            if(values != null && values.Any())
                values.Each(x => aggregate.AddMetadataDefinitionValue(x.MetadataDefinitionIdentity, new MetadataDefinitionName(x.Name), DataTypeBuilder.Create(x.DataType), x.Regex, GetValue(x.Values)));

            _repository.Save(aggregate.ToMaybe());
        }
Exemplo n.º 26
0
        public void StartWatching(string physicalPath, IEnumerable<string> folders)
        {
            cleanUpWatchers();

            Console.WriteLine("Listening for file changes at");

            addDirectory(physicalPath);
            folders.Each(addDirectory);
        }
Exemplo n.º 27
0
        public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
        {
            packages.Each(p => p.ForFolder(FubuMvcPackages.WebContentFolder, topFolder =>
            {
                var contentFolder = FileSystem.Combine(topFolder, "content");

                log.Trace("Added folder '{0}' to the package folder list", contentFolder);
                _contents.RegisterDirectory(contentFolder);
            }));
        }
Exemplo n.º 28
0
        public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
        {
            packages.Each(p => p.ForFolder(FubuMvcPackages.WebContentFolder, topFolder =>
            {
                var imagesFolder = Path.Combine(topFolder, "content\\images");

                log.Trace("Added folder '{0}' to the PackagedImageUrl list", imagesFolder);
                _resolver.RegisterDirectory(imagesFolder);
            }));
        }
Exemplo n.º 29
0
        static void ExecuteCommands(IEnumerable<Command> commands)
        {
            int count = 0;
            commands.Each(command =>
                {
                    command.Execute();
                    count++;
                });

            _log.Debug(x => x.Write("{0} command{1} executed", count, (count > 0 ? "s" : "")));
        }
Exemplo n.º 30
0
        public void LogBootstrapperRun(IBootstrapper bootstrapper, IEnumerable<IActivator> activators)
        {
            var provenance = "Loaded by Bootstrapper:  " + bootstrapper;
            var bootstrapperLog = LogFor(bootstrapper);

            activators.Each(a =>
            {
                LogObject(a, provenance);
                bootstrapperLog.AddChild(a);
            });
        }
Exemplo n.º 31
0
        public Transformer(IEnumerable<ITransformHandler> handlers)
        {
            handlers.Each(x => _handlers[x.Key] = x);
            _handlers["inner"] = new InnerTransformHandler(this);

            _handlers.OnMissing = key =>
            {
                throw new ArgumentOutOfRangeException(nameof(key), key,
                    "No transformation handler is available for '" + key + "'");
            };
        }
Exemplo n.º 32
0
 public void Set(IEnumerable <IContent> set)
 {
     try
     {
         var redis      = redisManager.GetClient();
         var redisMovie = redis.As <IContent>();
         set?.Each(x => redisMovie.SetValue(x.ID, x));
         return;
     }
     catch
     {
     }
 }
 public SerializationContext(IDimensionFactory dimensionFactory, IObjectBaseFactory objectFactory,
                             IWithIdRepository withIdRepository, IEnumerable <DataRepository> dataRepositories, ICloneManagerForModel cloneManagerForModel, IContainer container)
 {
     Container            = container;
     StringMap            = new Cache <string, int>();
     IdStringMap          = new Cache <int, string>();
     IdRepository         = withIdRepository;
     DimensionFactory     = dimensionFactory;
     ObjectFactory        = objectFactory;
     Formulas             = new FormulaCache();
     _modelReferenceCache = new ModelReferenceCache(withIdRepository, cloneManagerForModel);
     _dataReferenceCache  = new DataReferenceCache(withIdRepository);
     _dataRepositories    = new List <DataRepository>();
     dataRepositories?.Each(AddRepository);
 }
 public void AddNodes(IEnumerable <ITreeNode> nodesToAdd)
 {
     removeHandlers();
     _treeGroups.DoWithinBatchUpdate(() => nodesToAdd.Each(_treeGroups.AddNode));
     addHandlers();
 }
 public void RemoveNodes(IEnumerable <ITreeNode> nodesToDelete)
 {
     removeHandlers();
     _treeGroups.DoWithinBatchUpdate(() => nodesToDelete.Each(RemoveNode));
     addHandlers();
 }
Exemplo n.º 36
0
 public void Activate(IEnumerable <IPackageInfo> packages, IPackageLog log)
 {
     packages.Each(p => p.ForFolder(BottleFiles.WebContentFolder, folder => ReadSparkConfig(p.Name, folder, log)));
     ReadSparkConfig(FubuSparkConstants.HostOrigin, FubuMvcPackageFacility.GetApplicationPath(), log);
 }
Exemplo n.º 37
0
 public void AppendRange(IEnumerable <TValue> values)
 {
     values.Each(x => Append(x));
 }
Exemplo n.º 38
0
        public static JsonObject CreateJwtPayload(
            IAuthSession session, string issuer, TimeSpan expireIn,
            string audience                  = null,
            IEnumerable <string> roles       = null,
            IEnumerable <string> permissions = null)
        {
            var now        = DateTime.UtcNow;
            var jwtPayload = new JsonObject
            {
                { "iss", issuer },
                { "sub", session.UserAuthId },
                { "iat", now.ToUnixTime().ToString() },
                { "exp", now.Add(expireIn).ToUnixTime().ToString() },
            };

            if (audience != null)
            {
                jwtPayload["aud"] = audience;
            }

            if (!string.IsNullOrEmpty(session.Email))
            {
                jwtPayload["email"] = session.Email;
            }
            if (!string.IsNullOrEmpty(session.FirstName))
            {
                jwtPayload["given_name"] = session.FirstName;
            }
            if (!string.IsNullOrEmpty(session.LastName))
            {
                jwtPayload["family_name"] = session.LastName;
            }
            if (!string.IsNullOrEmpty(session.DisplayName))
            {
                jwtPayload["name"] = session.DisplayName;
            }

            if (!string.IsNullOrEmpty(session.UserName))
            {
                jwtPayload["preferred_username"] = session.UserName;
            }
            else if (!string.IsNullOrEmpty(session.UserAuthName) && !session.UserAuthName.Contains("@"))
            {
                jwtPayload["preferred_username"] = session.UserAuthName;
            }

            var profileUrl = session.GetProfileUrl();

            if (profileUrl != null && profileUrl != AuthMetadataProvider.DefaultNoProfileImgUrl)
            {
                jwtPayload["picture"] = profileUrl;
            }

            var combinedRoles = new List <string>(session.Roles.Safe());
            var combinedPerms = new List <string>(session.Permissions.Safe());

            roles.Each(x => combinedRoles.AddIfNotExists(x));
            permissions.Each(x => combinedPerms.AddIfNotExists(x));

            if (combinedRoles.Count > 0)
            {
                jwtPayload["roles"] = combinedRoles.ToJson();
            }

            if (combinedPerms.Count > 0)
            {
                jwtPayload["perms"] = combinedPerms.ToJson();
            }

            return(jwtPayload);
        }
Exemplo n.º 39
0
 public void AddRange(IEnumerable <IBusinessRule> rulesToAdd)
 {
     rulesToAdd.Each(Add);
 }
 /// <summary>
 ///    to initialize the serialization FormulaCache of a building block with its FormulaCache (which may contain unused
 ///    formulas)
 /// </summary>
 public void AddFormulasToCache(IEnumerable <IFormula> formulas)
 {
     formulas?.Each(f => AddFormulaToCache(f));
 }
Exemplo n.º 41
0
 /// <summary>
 ///     Force Marten to create document mappings for all the given document types
 /// </summary>
 /// <param name="documentTypes"></param>
 public void RegisterDocumentTypes(IEnumerable <Type> documentTypes)
 {
     documentTypes.Each(RegisterDocumentType);
 }
Exemplo n.º 42
0
 /// <summary>
 /// Appends a sequence of items to an existing list
 /// </summary>
 /// <typeparam name="T">The type of the items in the list</typeparam>
 /// <param name="list">The list to modify</param>
 /// <param name="items">The sequence of items to add to the list</param>
 /// <returns></returns>
 public static IList <T> AddRange <T>(this IList <T> list, IEnumerable <T> items)
 {
     items.Each(list.Add);
     return(list);
 }
Exemplo n.º 43
0
 public void AddRange(IEnumerable <ObjectDef> items)
 {
     items.Each(Add);
 }
Exemplo n.º 44
0
 /// <summary>
 /// Writes a sequence of fields to the CSV file. This will
 /// ignore any need to quote and ignore the
 /// <see cref="CsvConfiguration.QuoteAllFields"/>
 /// and just quote based on the shouldQuote
 /// parameter.
 /// When all fields are written for a row,
 /// <see cref="CsvWriter.NextRow" /> must be called
 /// to complete writing of the current row.
 /// </summary>
 /// <param name="fields">The fields to write.</param>
 /// <param name="shouldQuote">True to quote the fields, otherwise false.</param>
 public virtual void WriteFields(IEnumerable <string> fields, bool shouldQuote)
 {
     Guard.NotNull(fields, nameof(fields));
     fields.Each(x => WriteField(x, shouldQuote));
 }
Exemplo n.º 45
0
 public virtual void AddObserverSetMappings(IEnumerable <ObserverSetMapping> observerSetMappings) => observerSetMappings.Each(AddObserverSetMapping);
Exemplo n.º 46
0
 public void RemoveOwnershipFromThisNode(IEnumerable <Uri> subjects)
 {
     _persistence.Alter(_graph.NodeId, node => subjects.Each(node.RemoveOwnership));
 }
Exemplo n.º 47
0
 /* ----------------------------------------------------------------- */
 ///
 /// Add
 ///
 /// <summary>
 /// Adds the Page object to be rendered.
 /// </summary>
 ///
 /// <param name="items">Page collection.</param>
 ///
 /* ----------------------------------------------------------------- */
 public void Add(IEnumerable <Page> items) => items.Each(e => _inner.Add(this.NewItem(Count, e)));
Exemplo n.º 48
0
 public void RemoveOwnershipFromNode(string nodeId, IEnumerable <Uri> subjects)
 {
     _persistence.Alter(nodeId, node => subjects.Each(node.RemoveOwnership));
 }
 public TaskHealthAssignmentPlanner(IEnumerable <Uri> permanentTasks)
 {
     _permanentTasks = permanentTasks;
     _permanentTasks.Each(x => _status.FillDefault(x));
 }
Exemplo n.º 50
0
 public InterceptorChainBuilder Use(IEnumerable <Type> interceptorTypes)
 {
     interceptorTypes.Each((type, index) => this.Use(type, index));
     return(this);
 }
Exemplo n.º 51
0
        public void AppendRange(IEnumerable <TValue> values, Func <TValue, object> idSelector)
        {
            Guard.NotNull(idSelector, nameof(idSelector));

            values.Each(x => Append(x, idSelector(x)));
        }
Exemplo n.º 52
0
        public void AddRoutes(IEnumerable <string> paths)
        {
            paths.Each(x => _matches.Add(x.Substring(1), x));

            _routes.Add(new Route("{controller}", new StubRouteHandler()));
        }
Exemplo n.º 53
0
 public void AddEventTypes(IEnumerable <Type> types)
 {
     types.Each(AddEventType);
 }
 static void InvokeAll(this IEnumerable <Action> actions)
 {
     actions.Each(x => x());
 }
Exemplo n.º 55
0
 public virtual void Delete(IEnumerable <object> key)
 {
     key.Each(u => Delete(u));
 }
Exemplo n.º 56
0
 private void RecalculateNemesis(IEnumerable <int> playerIdsThatNeedNewNemesis, ApplicationUser currentUser)
 {
     playerIdsThatNeedNewNemesis.Each(x => _nemesisRecalculator.RecalculateNemesis(x, currentUser, _dataContext));
 }
Exemplo n.º 57
0
 private void RecalculateChampions(IEnumerable <int> gameDefinitionIds, ApplicationUser currentUser)
 {
     gameDefinitionIds.Each(x => _championRecalculator.RecalculateChampion(x, currentUser, _dataContext));
 }
Exemplo n.º 58
0
 public void AddDataRepositories(IEnumerable <ModelDataRepository> dataRepositories)
 {
     dataRepositories?.Each(AddDataRepository);
 }
Exemplo n.º 59
0
 /// <summary>
 /// Writes a sequence of fields to the CSV file. The fields
 /// may get quotes added to it.
 /// When all fields are written for a row,
 /// <see cref="CsvWriter.NextRow" /> must be called
 /// to complete writing of the current row.
 /// </summary>
 /// <param name="fields">The fields to write.</param>
 public virtual void WriteFields(IEnumerable <string> fields)
 {
     Guard.NotNull(fields, nameof(fields));
     fields.Each(x => WriteField(x));
 }
Exemplo n.º 60
0
 public PathCache <TEntity> For(IEnumerable <TEntity> entities)
 {
     entities?.Each(Add);
     return(this);
 }