本文整理汇总了C#中DataStore.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# DataStore.Initialize方法的具体用法?C# DataStore.Initialize怎么用?C# DataStore.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStore
的用法示例。
在下文中一共展示了DataStore.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareRegistration
internal void PrepareRegistration(Registration registration)
{
Debug.Assert(
getters.All(
k => k.GetType().BaseType != null && k.GetType().BaseType.GetGenericArguments().Length == 1));
Func<ResourceGetter, Type> provType =
k =>
{
var t = k.GetType().Construct(k2 => k2.BaseType != typeof (ResourceGetter), k2 => k2.BaseType);
return t.Last().BaseType.GetGenericArguments().First();
};
Func<ResourcePoster, Type> wrType =
k =>
{
var t = k.GetType().Construct(k2 => k2.BaseType != typeof (ResourcePoster), k2 => k2.BaseType);
return t.Last().BaseType.GetGenericArguments().First();
};
//все известны кастомные получатели-писатели заполняем сразу. Потом добавим по умолчанию кому надо.
_providers = getters.Where(k =>_settingsHolder.Settings.ActivationSwitchMatch(k.Metadata,_settingsHolder.Provider))
.GroupBy(k => provType(k.Value))
.Select(k=>k.First().Value)
.ToDictionary(provType);
_posters = writers.Where(k => _settingsHolder.Settings.ActivationSwitchMatch(k.Metadata, _settingsHolder.Provider))
.GroupBy(k => wrType(k.Value))
.Select(k => k.First().Value)
.ToDictionary(wrType);
var type = registration.ResourceType;
var provider = _providers.ContainsKey(type)
? _providers[type]
: GetDefaultGetter(type);
var poster = _posters.ContainsKey(type)
? _posters[type]
: !registration.IsCacheData
? GetDefaultWriter(type)
: null;
Debug.Assert(provider != null);
Debug.Assert(poster != null || registration.IsCacheData);
var store = new DataStore(registration.ResourceName, provider, poster, _servicesPackage);
_container.Container.ComposeExportedValue(store);
store.Initialize(registration.IsCacheData,registration.CollectRareItems);
if (registration.IsSecuritized)
_securityManager.RegisterSecuritizedType(type);
_stores.Add(type,store);
}