当前位置: 首页>>代码示例>>C#>>正文


C# IDictionary.ReadValue方法代码示例

本文整理汇总了C#中IDictionary.ReadValue方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.ReadValue方法的具体用法?C# IDictionary.ReadValue怎么用?C# IDictionary.ReadValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDictionary的用法示例。


在下文中一共展示了IDictionary.ReadValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

        /// <summary>
        /// Converts the provided dictionary into an object of the specified type.
        /// </summary>
        /// <param name="dictionary">An <see cref="T:System.Collections.Generic.IDictionary`2" /> instance of property data stored as name/value pairs.</param>
        /// <returns>
        /// The deserialized object.
        /// </returns>
        /// <exception cref="ArgumentNullException">dictionary</exception>
        public GameInfo Deserialize(IDictionary<string, object> dictionary)
        {
            if (dictionary == null)
                throw new ArgumentNullException("dictionary");

            GameInfo info = new GameInfo();

            info.Hero = dictionary.ReadValue<string>("Hero");
            info.Child = dictionary.ReadValue<string>("Child");
            info.IsHeroQuest = dictionary.ReadValue<bool>("IsHeroQuest");
            info.IsLinkedGame = dictionary.ReadValue<bool>("IsLinkedGame");
            info.WasGivenFreeRing = dictionary.ReadValue<bool>("WasGivenFreeRing");
            info.GameID = dictionary.ReadValue<short>("GameID");
            info.Rings = (Rings)dictionary.ReadValue<long>("Rings");
            info.Game = dictionary.ReadValue<Game>("Game");
            info.Animal = dictionary.ReadValue<Animal>("Animal");
            info.Behavior = dictionary.ReadValue<ChildBehavior>("Behavior");

            return info;
        }
开发者ID:kabili207,项目名称:zora-sharp,代码行数:28,代码来源:GameInfoJsonConverter.cs

示例2: Deserialize

        /// <summary>
        /// Converts the provided dictionary into an object of the specified type.
        /// </summary>
        /// <param name="dictionary">An <see cref="T:System.Collections.Generic.IDictionary`2" /> instance of property data stored as name/value pairs.</param>
        /// <param name="type">The type of the resulting object.</param>
        /// <param name="serializer">The <see cref="T:System.Web.Script.Serialization.JavaScriptSerializer" /> instance.</param>
        /// <returns>
        /// The deserialized object.
        /// </returns>
        /// <exception cref="ArgumentNullException">dictionary</exception>
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary == null)
                throw new ArgumentNullException("dictionary");
            if (type != typeof(GameInfo))
                return null;

            GameInfo info = new GameInfo();

            info.Hero = dictionary.ReadValue<string>("Hero");
            info.Child = dictionary.ReadValue<string>("Child");
            info.IsHeroQuest = dictionary.ReadValue<bool>("IsHeroQuest");
            info.IsLinkedGame = dictionary.ReadValue<bool>("IsLinkedGame");
            info.GameID = dictionary.ReadValue<short>("GameID");
            info.Rings = (Rings)dictionary.ReadValue<long>("Rings");
            info.Game = dictionary.ReadValue<Game>("Game");
            info.Animal = dictionary.ReadValue<Animal>("Animal");
            info.Behavior = dictionary.ReadValue<ChildBehavior>("Behavior");

            return info;
        }
开发者ID:Chibiyima,项目名称:oracle-hack,代码行数:31,代码来源:GameInfoJsonConverter.cs

示例3: ReadExportDefinition

        public static ExportDefinition ReadExportDefinition(ComposablePartDefinition owner, IDictionary<string, object> cache)
        {
            Assumes.NotNull(owner);
            Assumes.NotNull(cache);

            LazyMemberInfo exportingMemberInfo = new LazyMemberInfo(
                cache.ReadValue<MemberTypes>(AttributedCacheServices.CacheKeys.MemberType, MemberTypes.TypeInfo),
                cache.ReadLazyAccessors(ReflectionModelServices.GetPartType(owner)));
                

            return ReflectionModelServices.CreateExportDefinition(
                exportingMemberInfo,
                cache.ReadContractName(),
                cache.ReadLazyMetadata(),
                owner as ICompositionElement);
        }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:16,代码来源:CompositionCacheServices.cs

示例4: ReadImportDefinition

        public static ContractBasedImportDefinition ReadImportDefinition(ComposablePartDefinition owner, IDictionary<string, object> cache)
        {
            Assumes.NotNull(owner);
            Assumes.NotNull(cache);
  
            Lazy<Type> partType = ReflectionModelServices.GetPartType(owner);
            ICompositionElement origin = owner as ICompositionElement;
            if (cache.ReadValue<string>(AttributedCacheServices.CacheKeys.ImportType) == AttributedCacheServices.ImportTypes.Parameter)
            {
                return ReflectionModelServices.CreateImportDefinition(
                    cache.ReadLazyParameter(partType),
                    cache.ReadContractName(),
                    cache.ReadValue<string>(AttributedCacheServices.CacheKeys.RequiredTypeIdentity),
                    cache.ReadRequiredMetadata(),
                    cache.ReadValue<ImportCardinality>(AttributedCacheServices.CacheKeys.Cardinality, ImportCardinality.ExactlyOne),
                    cache.ReadValue<CreationPolicy>(AttributedCacheServices.CacheKeys.RequiredCreationPolicy, CreationPolicy.Any),
                    origin);
            }
            else
            {
                LazyMemberInfo importingMemberInfo = new LazyMemberInfo(
                    cache.ReadValue<MemberTypes>(AttributedCacheServices.CacheKeys.MemberType, MemberTypes.Property),
                    cache.ReadLazyAccessors(partType));

                return ReflectionModelServices.CreateImportDefinition(
                    importingMemberInfo,
                    cache.ReadContractName(),
                    cache.ReadValue<string>(AttributedCacheServices.CacheKeys.RequiredTypeIdentity),
                    cache.ReadRequiredMetadata(),
                    cache.ReadValue<ImportCardinality>(AttributedCacheServices.CacheKeys.Cardinality, ImportCardinality.ExactlyOne),
                    cache.ReadValue<bool>(AttributedCacheServices.CacheKeys.IsRecomposable, false),
                    cache.ReadValue<CreationPolicy>(AttributedCacheServices.CacheKeys.RequiredCreationPolicy, CreationPolicy.Any),
                    origin);
            }
        }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:35,代码来源:CompositionCacheServices.cs

示例5: ReadPartDefinition

        public static ComposablePartDefinition ReadPartDefinition(IDictionary<string, object> cache, Func<ComposablePartDefinition, IEnumerable<ImportDefinition>> importsCreator, Func<ComposablePartDefinition, IEnumerable<ExportDefinition>> exportsCreator, Func<Assembly> assemblyLoader)
        {
            Assumes.NotNull(cache);

            Lazy<Type> partType = cache.ReadLazyTypeForPart(assemblyLoader);

            ComposablePartDefinition part = null;
            part = ReflectionModelServices.CreatePartDefinition(
                partType,
                cache.ReadValue<bool>(AttributedCacheServices.CacheKeys.IsDisposalRequired, false),
                LazyServices.MakeLazy(() => importsCreator(part)),
                LazyServices.MakeLazy(() => exportsCreator(part)),
                cache.ReadLazyMetadata(),
                null);

            return part;
        }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:17,代码来源:CompositionCacheServices.cs

示例6: LoadSettings

        /// <summary>
        /// Loads gadget settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadSettings(IDictionary<string, string> settings)
        {
            base.LoadSettings(settings);

            if (settings == null)
                return;

            using (new AutoSaveSuppressor(this))
            {
                _settings = settings;
                SelectedProcess = settings.ReadValue(SelectedProcessKey, string.Empty);
                SelectedFilter = settings.ReadValue(SelectedFilterKey, string.Empty);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:18,代码来源:BaseProcessGadgetViewModel.cs

示例7: LoadSettings

        /// <summary>
        /// The load settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public override void LoadSettings(IDictionary<string, string> settings)
        {
            base.LoadSettings(settings);

            if (settings == null)
                return;

            var descriptor = FilterDescriptor.GetFilterList(settings.ReadValue(MerticFilter, string.Empty));

            if (descriptor == null)
                return;

            Gadget.FilterList.AddRange(descriptor);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:18,代码来源:ProcessMetricsGadgetChartTabViewModel.cs

示例8: LoadSettings

        /// <summary>
        /// Loads gadget settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadSettings(IDictionary<string, string> settings)
        {
            base.LoadSettings(settings);

            if (settings == null)
                return;

            using (new AutoSaveSuppressor(this))
            {
                SelectedKPIs = settings.ReadValue(SelectedKPIKey, string.Empty).Split(';').SelectMany(x => KPIs.Where(kpi => kpi.Kpi.Guid.ToString() == x).Select(y => y.Kpi)).ToList();

                foreach (var kpi in SelectedKPIs.Select(kpi => KPIs.FirstOrDefault(x => x.Kpi.Guid == kpi.Guid)).Where(kpiSelectorViewModel => kpiSelectorViewModel != null))
                    kpi.IsSelected = true;
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:19,代码来源:ProcessKpiListGadgetViewModel.cs

示例9: LoadProcessDependentSettings

        /// <summary>
        /// Loads process-dependent settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadProcessDependentSettings(IDictionary<string, string> settings)
        {
            base.LoadProcessDependentSettings(settings);

            using (new AutoSaveSuppressor(this))
            {
                var kpisGuid = settings.ReadValue(SelectedKPIKey, string.Empty);
                foreach (var kpi in KPIs)
                    kpi.IsSelected = false;

                foreach (var kpi in kpisGuid.Split(';').Select(guid => KPIs.FirstOrDefault(x => x.Kpi.Guid.ToString() == guid)).Where(kpi => kpi != null))
                    kpi.IsSelected = true;

                SelectedKPIs = KPIs.Where(x => x.IsSelected).Select(x => x.Kpi).ToList();

                if (SelectedTab != null)
                    SelectedTab.RefreshView();

                SetupSubTitle();
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:25,代码来源:ProcessKpiListGadgetViewModel.cs

示例10: LoadProcessDependentSettings

        /// <summary>
        /// Loads process-dependent settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadProcessDependentSettings(IDictionary<string, string> settings)
        {
            base.LoadProcessDependentSettings(settings);

            using (new AutoSaveSuppressor(this))
            {
                var metricGuid = settings.ReadValue(SelectedMetricKey, string.Empty);
                SelectedMetric = Metrics.FirstOrDefault(x => x.Guid.ToString() == metricGuid);

                var filterName = settings.ReadValue(SelectedFilterKey, string.Empty);
                SelectedFilter = Filters.FirstOrDefault(x => x.Name == filterName);

                var filterDef = settings.ReadValue(ProcessedFilterKey, string.Empty);
                if (!string.IsNullOrWhiteSpace(filterDef))
                    PopulateUdp(filterDef);

                SetupSubTitle();

                if (SelectedTab != null)
                    SelectedTab.RefreshView();
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:26,代码来源:ProcessMetricsGadgetViewModel.cs

示例11: LoadSettings

        /// <summary>
        /// Loads gadget settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadSettings(IDictionary<string, string> settings)
        {
            base.LoadSettings(settings);

            if (settings == null)
                return;

            using (new AutoSaveSuppressor(this))
            {
                ChartType = settings.ReadValue(ChartTypeKey, GadgetChartTypes.Column);

                var selectedMetricGuid = settings.ReadValue(SelectedMetricKey, Guid.Empty);
                SelectedMetric = Metrics.FirstOrDefault(m => m.Guid.Equals(selectedMetricGuid));

                var filterName = settings.ReadValue(SelectedFilterKey, string.Empty);
                SelectedFilter = Filters.FirstOrDefault(x => x.Name == filterName);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:22,代码来源:ProcessMetricsGadgetViewModel.cs

示例12: LoadProcessDependentSettings

        /// <summary>
        /// Loads process-dependent settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadProcessDependentSettings(IDictionary<string, string> settings)
        {
            base.LoadProcessDependentSettings(settings);

            using (new AutoSaveSuppressor(this))
            {
                var kpiGuid = settings.ReadValue(SelectedKPIKey, string.Empty);
                SelectedKPI = KPIs.FirstOrDefault(x => x.Guid.ToString() == kpiGuid);

                SetupSubTitle();

                if (SelectedTab != null)
                    SelectedTab.RefreshView();
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:19,代码来源:ProcessKpiGaugeGadgetViewModel.cs

示例13: LoadSettings

        /// <summary>
        /// Loads gadget settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadSettings(IDictionary<string, string> settings)
        {
            base.LoadSettings(settings);

            if (settings == null)
                return;

            using (new AutoSaveSuppressor(this))
                SelectedKPI = KPIs.FirstOrDefault(kpi => kpi.Guid.ToString() == settings.ReadValue(SelectedKPIKey, string.Empty));
        }
开发者ID:mparsin,项目名称:Elements,代码行数:14,代码来源:ProcessKpiGaugeGadgetViewModel.cs

示例14: LoadProcessDependentSettings

        /// <summary>
        /// Loads process-dependent settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadProcessDependentSettings(IDictionary<string, string> settings)
        {
            base.LoadProcessDependentSettings(settings);

            using (new AutoSaveSuppressor(this))
            {
                var filterMode = settings.ReadValue(SelectedFilterModeKey, string.Empty);
                FilterType selectedFilterMode;
                SelectedFilterMode = Enum.TryParse(filterMode, out selectedFilterMode) ? selectedFilterMode : FilterType.NoFilter;

                var filterDefinition = settings.ReadValue(ProcessedFilterKey, string.Empty);
                if (!string.IsNullOrWhiteSpace(filterDefinition))
                    _processedFilter = FilterDescriptor.FromJSON(filterDefinition);

                var filter = settings.ReadValue(ChosenFilterKey, string.Empty);
                if (CommonFilterList != null)
                    ChosenFilter = CommonFilterList.FirstOrDefault(x => x.Name == filter);

                bool useDefaultLayout;
                if (Boolean.TryParse(settings.ReadValue(UseDefaultLayoutKey, string.Empty), out useDefaultLayout))
                {
                    UseDefaultLayout = useDefaultLayout;
                }

                if (!ShouldUseDefaultLayout() && LayoutList != null)
                {
                    int layoutId;
                    if (Int32.TryParse(settings.ReadValue(SelectedLayoutKey, string.Empty), out layoutId))
                    {
                        SetSelectedLayout(LayoutList.FirstOrDefault(x => x.Id == layoutId));
                    }

                    int origLayoutId;
                    if (Int32.TryParse(settings.ReadValue(OriginalSelectedLayoutKey, string.Empty), out origLayoutId))
                    {
                        _originalSelectedLayout = LayoutList.FirstOrDefault(x => x.Id == origLayoutId);
                    }
                }

                if (SelectedLayout == null)
                        SetDefaultLayout();

                SetupSubTitle();

                if (SelectedTab != null)
                    SelectedTab.RefreshView();
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:52,代码来源:ProcessSearchGridGadgetViewModel.cs


注:本文中的IDictionary.ReadValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。