Example #1
0
        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;
        }
        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();
        }
Example #5
0
        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);
        }
        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;
        }
Example #7
0
        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;
            });
        }
        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;
        }
 private void AddAlbum(IEnumerable<IAlbum> Al)
 {
     Al.Apply(al => _PlayList.AddAlbum(al));
 }
Example #10
0
 /// <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));
 }
Example #11
0
        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;
            }
        }
 public ComplexSubpath(IEnumerable<Vector2> vectors)
 {
     vectors.Apply(i => _vectors.Add(i));
 }
        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;
        }
Example #14
0
        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;
        }
Example #15
0
        private void _removeChildrenFromContainer(IReactContainerComponent container, IEnumerable<IReactComponent> children)
        {
            if (children == null)
            {
                return;
            }

            children.Apply(container.RemoveView);
        }
Example #16
0
 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);
 }
Example #17
0
 private void _fillPlatformsList(IEnumerable<PlatformInfo> pis) {
    if (pis.Count() > 0) {
       pis.Apply(p => listPlatforms.Items.Add(new PlatformListItem(p)));
       listPlatforms.Items[0].Selected = true;
    }
 }
Example #18
0
 /// <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));
 }
        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();
            });
        }
Example #20
0
 public CompositeLog(IEnumerable<ILog> loggers)
 {
     loggers.Apply(_loggers.Add);
 }
        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);
                }
            }
        }