public void Setup(IEnumerable<Type> typesToRegister, IEnumerable<Type> viewModelTypesToRegister) { typesToRegister.Apply(container.Register); viewModelTypesToRegister.Apply(container.Register); this.viewModelTypes = new HashSet<Type>(viewModelTypesToRegister); }
public IDictionary<string, object> ModuleConfig(IEnumerable<ModuleData> modules) { var moduleConfig = new Dictionary<string, object>(); modules.Apply(module => moduleConfig[module.Name] = module.Config()); var container = new Dictionary<string, object>(); container["remoteModuleConfig"] = moduleConfig; return container; }
public Directives Directives(IEnumerable <GraphQLDirective> directives) { var target = new Directives(); directives?.Apply(d => { var dir = new Directive(Name(d.Name)).WithLocation(d, _body); dir.Arguments = Arguments(d.Arguments); target.Add(dir); }); return(target); }
private static void Draw( Graphics graphics, Rectangle canvasRectangle, Func<IEnumerable<SizeF>, Rectangle, IEnumerable<Rectangle>> arrangeRectangles, IEnumerable<WordModel> wordModels, String fontName) { var wordsData = wordModels.Apply( models => arrangeRectangles(models.Select(model => GetWordSize(graphics, model, fontName)), canvasRectangle), (model, rect) => Tuple.Create(model.Word, new Font(fontName, model.Size), rect)); DrawWords(graphics, wordsData); }
protected InMemoryDatabaseTestFixtureBase(IEnumerable<Assembly> assemblies) { Configuration = new Configuration() .SetProperty(NHibernate.Cfg.Environment.ReleaseConnections, "on_close") .SetProperty(NHibernate.Cfg.Environment.Dialect, typeof(SQLiteDialect).AssemblyQualifiedName) .SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, typeof(SQLite20Driver).AssemblyQualifiedName) .SetProperty(NHibernate.Cfg.Environment.ConnectionString, "data source=:memory:") .SetProperty(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass, typeof(ProxyFactoryFactory).AssemblyQualifiedName); assemblies.Apply(assembly => Configuration.AddAssembly(assembly)); SessionFactory = Configuration.BuildSessionFactory(); }
public IEnumerable <IAuthorizationPolicy> GetPolicies(IEnumerable <string> policies) { var found = new List <IAuthorizationPolicy>(); policies?.Apply(name => { if (_policies.ContainsKey(name)) { found.Add(_policies[name]); } }); return(found); }
public Packet(CarnetNumber number, State state, DateTime date, Association association, DeliveryMode deliveryMode, Invoice invoice, DeliveryNote deliveryNote, User user, string comments, string reference, PacketType type, Clause31Insurer c31Insurer, IEnumerable<Carnet> carnets) : base(number) { Carnets = new List<Carnet>(Contract.Required(carnets, "carnets")); this.State = state; this.Date = date; this.Association = association; this.DeliveryMode = deliveryMode; this.Invoice = invoice; this.User = user; this.Comments = comments; this.Reference = reference; this.Type = type; this.Clause31Insurer = c31Insurer; carnets.Apply(carnet => carnet.Packet = this); }
/// <summary> /// Given an invalid input string and a list of valid options, returns a filtered /// list of valid options sorted based on their similarity with the input. /// </summary> public static string[] SuggestionList(string input, IEnumerable <string> options) { if (options == null) { return(empty); } var optionsByDistance = new Dictionary <string, int>(); var inputThreshold = input.Length / 2; options?.Apply(t => { var distance = DamerauLevenshteinDistance(input, t, inputThreshold); var threshold = Math.Max(inputThreshold, Math.Max(t.Length / 2, 1)); if (distance <= threshold) { optionsByDistance[t] = distance; } }); return(optionsByDistance.OrderBy(x => x.Value).Select(x => x.Key).ToArray()); }
public async Task<bool> ZippAsync(IEnumerable<string> iText, string iFileName, string iPassword) { CheckArguments(iText, iFileName); SevenZipCompressor sevenZipCompressor = new SevenZipCompressor() { DirectoryStructure = true, EncryptHeaders = true, DefaultItemName = "Default.txt" }; try { using (var instream = new MemoryStream()) { using (var streamwriter = new StreamWriter(instream)) { iText.Apply(t => streamwriter.WriteLine(t)); await streamwriter.FlushAsync(); instream.Position = 0; using (Stream outstream = File.Create(iFileName)) { await sevenZipCompressor.CompressStreamAnsync(instream, outstream, iPassword); } } } } catch (Exception e) { Trace.WriteLine(string.Format("Problem zipping a text: {0}", e)); return false; } return true; }
/// <summary> /// Removes the range. /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="source">The items.</param> /// <param name="collection">The collection.</param> public static void RemoveRange <TSource>(this ObservableCollection <TSource> source, IEnumerable <TSource> collection) { // Remove range from local items collection.Apply(p => source.Remove(p)); }
private void AddAlbum(IEnumerable<IAlbum> Al) { Al.Apply(al => _PlayList.AddAlbum(al)); }
/// <summary>Adds the given types to this profile.</summary> /// <param name="types">The collection of types to add to this profile.</param> public void Add(IEnumerable<Type> types) { types.Apply(type => Add(type)); }
private void _removeChildrenFromContainer(IReactContainerComponent container, IEnumerable<IReactComponent> children) { if (children == null) { return; } children.Apply(container.RemoveView); }
private Dictionary<string, IEnumerable<Field>> CollectFields( ExecutionContext context, GraphType type, IEnumerable<Selection> selections, Dictionary<string, IEnumerable<Field>> fields ) { if( fields == null ) { fields = new Dictionary<string, IEnumerable<Field>>(); } selections.Apply( selection => { if( selection.Field != null ) { if( !ShouldIncludeNode( context, selection.Field.Directives ) ) { return; } string name = selection.Field.Alias ?? selection.Field.Name; if( !fields.ContainsKey( name ) ) { fields[name] = Enumerable.Empty<Field>(); } fields[name] = fields[name].Append( selection.Field ); } else if( selection.Fragment != null ) { FragmentSpread fragmentSpread = selection.Fragment as FragmentSpread; if( fragmentSpread != null ) { if( !ShouldIncludeNode( context, fragmentSpread.Directives ) ) { return; } FragmentDefinition fragment = context.Fragments.FindFragmentDefinition( fragmentSpread.Name ); if( !ShouldIncludeNode( context, fragment.Directives ) || !DoesFragmentConditionMatch( context, fragment, type ) ) { return; } CollectFields( context, type, fragment.Selections, fields ); } InlineFragment inlineFragment = selection.Fragment as InlineFragment; if( inlineFragment != null ) { if( !ShouldIncludeNode( context, inlineFragment.Directives ) || !DoesFragmentConditionMatch( context, inlineFragment, type ) ) { return; } CollectFields( context, type, inlineFragment.Selections, fields ); } } } ); return fields; }
void OnGUI() { if (_prefabs == null || _repository == null) { _repository = new ComponentRepository(); _currentSceneScroll = Vector2.zero; _prefabs = PrefabInfo.GetAllPrefabs(_repository); } if (GUILayout.Button("転送")) { _prefabs.Forward(); _prefabs.Apply(); _prefabs = null; return; } GUILayout.Label("プレハブのコンポーネントの転送の可否:"); _currentSceneScroll = GUILayout.BeginScrollView(_currentSceneScroll); foreach (var prefab in _prefabs) { GUILayout.BeginHorizontal(); GUILayout.Label("", _width100); GUILayout.Label(prefab.Name); GUILayout.EndHorizontal(); foreach (var obj in prefab.GameObjects) { if (!obj.DllComponents.Any()) { continue; } var message = obj.DllComponents.All(x => x.HasForwarder) ? "転送可能" : "不可"; GUILayout.BeginHorizontal(); GUILayout.Label("", _width100); GUILayout.Label(obj.Target.name, _width100); GUILayout.Label(message); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("", _width200); var valid = string.Join(", ", obj.DllComponents.Where(x => x.HasForwarder).Select(x => x.DllType.Name).ToArray()); GUILayout.Label("可能: " + valid); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("", _width200); var invalid = string.Join(", ", obj.DllComponents.Where(x => !x.HasForwarder).Select(x => x.DllType.Name).ToArray()); GUILayout.Label("不可: " + invalid); GUILayout.EndHorizontal(); GUILayout.Space(4); } } GUILayout.EndScrollView(); }
public CompositeLog(IEnumerable<ILog> loggers) { loggers.Apply(_loggers.Add); }
public void RegisterTypes(IEnumerable <IGraphType> types) { types.Apply(t => _types[t.Name] = t); }
public void Compose(CompositionBatch batch) { tasks.Apply(s => s.Compose(batch)); }
public static double[] Add(this IEnumerable <double> collection, double added) { return(collection.Apply(item => item + added).ToArray()); }
public static double[] Add(this IEnumerable <double> collection, IEnumerable <double> other) { return(collection.Apply(other, (item, otherItem) => item + otherItem).ToArray()); }
public static double[] Multiply(this IEnumerable <double> collection, double multiplier) { return(collection.Apply(item => item * multiplier).ToArray()); }
private IEnumerable<Tag> Transform(IEnumerable<Tag> tags) { var newTags = new List<Tag>(); tags.Apply(tag => { _tagTransformers.Apply(t => { if(t.Matches(tag)) tag = t.Transform(tag); }); newTags.Add(tag); }); return newTags; }
public ComplexSubpath(IEnumerable<Vector2> vectors) { vectors.Apply(i => _vectors.Add(i)); }
public void ReplaceText(IEnumerable<TextTag> tags) { _textView.BeginInvokeOnMainThread(() => { var defaultSettings = new DefaultSettings(); var defaultColor = _highlightSettings.Get(HighlightKeys.Default).Color; //textView.TextStorage.BeginEditing(); _textView.TextStorage.SetString("".CreateString(defaultColor.ToNSColor())); tags.Apply(tag => { var color = !string.IsNullOrWhiteSpace(tag.Color) ? tag.Color : defaultColor; var font = tag.Mono ? defaultSettings.MonoFont : defaultSettings.Font; _textView.TextStorage.Append(tag.Text.CreateString(color.ToNSColor(), font)); }); //textView.TextStorage.EndEditing(); }); }
/// <summary> /// Clear the elements provided /// </summary> /// <param name="elements"></param> /// <returns></returns> public IActionProvider Clear(IEnumerable <IWebElement> elements) { elements.Apply(e => e.Clear()); return(_actionProvider); }
public static IEnumerable <Leaf> BoldItalic(IEnumerable <Leaf> leaves) { return(leaves.Apply(e => e.Style.Set(StyleKeys.FontWeight, Text.FontWeight.BoldItalic))); }
protected override void RegisterForTypes(IEnumerable <Type> itemTypes) { itemTypes.Apply(RegisterForType); }
/// <summary> /// Removes the range. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="items">The items.</param> /// <param name="collection">The collection.</param> public static void RemoveRange <T>(this IList <T> items, IEnumerable <T> collection) { // Remove range from local items collection.Apply(p => items.Remove(p)); }
static public float Execute(this IEnumerable <Signal> item, float input) { return(item.Apply(input, (i, s) => s.Execute(i))); }
private void _purgeChildrenFromRegistry(IDictionary<long, IReactComponent> registry, IEnumerable<IReactComponent> children) { if (children == null) { return; } children.Apply(child => { Debug.Assert(!child.IsReactRootView(), "Root views should not be unregistered"); registry[child.ReactTag.Value] = null; }); }
public void Add(TResult dto) { if (dto == null) { throw new ArgumentNullException(nameof(dto)); } var entity = Map(dto); _rules.Apply(entity, DataAction.Add); _dbSet.Add(entity); Map(entity, dto); }
private static DataSeriesBox show(String title, IEnumerable<double> x, IEnumerable<double>[] series, bool time = false) { return show(title, x.ToArray(), series.Apply(y => y.ToArray()), time); }
private void UpdateBindings(IEnumerable<IAction> actions) { if (Execute.InDesignMode) { return; } var parentWindow = this.GetWindow(); if (parentWindow == null) { Logger.Instance.Warn("WindowKeyBinding defined with no window in the visual hierachy."); return; } var currentBindings = parentWindow.InputBindings; if (_bindings != null) { _bindings.Apply(b => currentBindings.Remove(b.KeyBinding)); } if (actions != null) { //We don't want to create new ones every time this is iterated over. _bindings = ActionKeyBinding.From(actions).ToList(); _bindings.Apply(a => currentBindings.Add(a.KeyBinding)); } else { _bindings = null; } }
/// <summary>Adds all applicable types from the given assemblies into this profile.</summary> /// <param name="assemblies">The collection of assemblies that contain the types to add.</param> public void Add(IEnumerable<Assembly> assemblies) { assemblies.Apply(asm => Add(asm)); }
/// <summary> /// Applies the supplied function to each element in the input sequence /// </summary> /// <typeparam name="T">The input sequence item type</typeparam> /// <typeparam name="S">The output sequence item type</typeparam> /// <param name="seq">The sequence to transform</param> /// <param name="f">The transformation function</param> /// <returns></returns> public static IReadOnlyList <S> map <T, S>(IEnumerable <T> seq, Func <T, S> f) => seq.Apply(f);
/// <summary> /// Adds the range. /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="items">The items.</param> /// <param name="collection">The collection.</param> public static void AddRange <TSource>(this IList <TSource> items, IEnumerable <TSource> collection) { // Add range to local items collection.Apply(items.Add); }
private void _fillPlatformsList(IEnumerable<PlatformInfo> pis) { if (pis.Count() > 0) { pis.Apply(p => listPlatforms.Items.Add(new PlatformListItem(p))); listPlatforms.Items[0].Selected = true; } }
internal void Fire(IEnumerable<NotifyCollectionChangedEventArgs> arguments, bool Sync) { NotifyCollectionChangedEventHandler Event = _Event; if (Event == null) return; foreach (NotifyCollectionChangedEventHandler del in Event.GetInvocationList()) { Dispatcher dip = del.GetDispatcher(); Action CallNotifyCollectionChangedEventHandler = () => { arguments.Apply(ar => del(_Owner, ar)); }; // If the subscriber is a DispatcherObject and different thread if (dip != null && ((!Sync) || dip.CheckAccess() == false)) { //// If the subscriber is a DispatcherObject and different thread // Invoke handler in the target dispatcher's thread if (Sync) dip.Invoke(DispatcherPriority.DataBind, CallNotifyCollectionChangedEventHandler); else dip.BeginInvoke(DispatcherPriority.DataBind, CallNotifyCollectionChangedEventHandler); } else { if (Sync) CallNotifyCollectionChangedEventHandler(); else CallNotifyCollectionChangedEventHandler.BeginInvoke(null, null); } } }
public void InitWithProfiles( IEnumerable<Profile> profiles, IServiceLocator services, AppSettings settings, IProfileLoader profileLoader, IAppSettingsLoader appSettingsLoader, Action complete) { _services = services; _appSettings = settings; _profileLoader = profileLoader; _appSettingsLoader = appSettingsLoader; _complete = complete; Profiles.Content.As<NSMutableArray>().RemoveAllObjects(); int idx = -1; profiles.Apply((p, i) => { if(string.Equals(settings.Profile, p.Name)){ idx = i; } Profiles.AddObject(ProfileInfo.For(p)); }); Profiles.SelectionIndex = idx; }