本文整理汇总了C#中IEnumerable.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.Apply方法的具体用法?C# IEnumerable.Apply怎么用?C# IEnumerable.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.Apply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup(IEnumerable<Type> typesToRegister, IEnumerable<Type> viewModelTypesToRegister)
{
typesToRegister.Apply(container.Register);
viewModelTypesToRegister.Apply(container.Register);
this.viewModelTypes = new HashSet<Type>(viewModelTypesToRegister);
}
示例2: ModuleConfig
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;
}
示例3: Draw
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);
}
示例4: InMemoryDatabaseTestFixtureBase
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();
}
示例5: Packet
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);
}
示例6: ZippAsync
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;
}
示例7: _purgeChildrenFromRegistry
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;
});
}
示例8: CollectFields
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;
}
示例9: AddAlbum
private void AddAlbum(IEnumerable<IAlbum> Al)
{
Al.Apply(al => _PlayList.AddAlbum(al));
}
示例10: Add
/// <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));
}
示例11: UpdateBindings
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;
}
}
示例12: ComplexSubpath
public ComplexSubpath(IEnumerable<Vector2> vectors)
{
vectors.Apply(i => _vectors.Add(i));
}
示例13: InitWithProfiles
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;
}
示例14: Transform
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;
}
示例15: _removeChildrenFromContainer
private void _removeChildrenFromContainer(IReactContainerComponent container, IEnumerable<IReactComponent> children)
{
if (children == null)
{
return;
}
children.Apply(container.RemoveView);
}