本文整理汇总了C#中ISettingsSection.GetOrCreateSection方法的典型用法代码示例。如果您正苦于以下问题:C# ISettingsSection.GetOrCreateSection方法的具体用法?C# ISettingsSection.GetOrCreateSection怎么用?C# ISettingsSection.GetOrCreateSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISettingsSection
的用法示例。
在下文中一共展示了ISettingsSection.GetOrCreateSection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public MainWindowControlState Read(ISettingsSection section) {
HorizontalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT));
VerticalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(VERTICALCONTENT_SECT));
foreach (var twSect in section.SectionsWithName(TOOLWINDOWUI_SECT)) {
var state = ToolWindowUIState.TryDeserialize(twSect);
if (state == null)
continue;
switch (state.Location) {
case AppToolWindowLocation.Left: LeftState = state; break;
case AppToolWindowLocation.Right: RightState = state; break;
case AppToolWindowLocation.Top: TopState = state; break;
case AppToolWindowLocation.Bottom: BottomState = state; break;
}
}
foreach (var locSect in section.SectionsWithName(LOCATION_SECT)) {
var guid = locSect.Attribute<Guid?>(LOCATION_GUID_ATTR);
var loc = locSect.Attribute<AppToolWindowLocation?>(LOCATION_ATTR);
if (guid == null || loc == null)
continue;
if (!IsValid(loc.Value))
continue;
SavedLocations[guid.Value] = loc.Value;
}
return this;
}
示例2: Save
public void Save(ISettingsSection section) {
section.Attribute(NAME_ATTR, Name);
section.Attribute(INDEX_ATTR, Index);
section.Attribute(ISHORIZONTAL_ATTR, IsHorizontal);
if (StackedContentState != null)
StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), StackedContentState);
foreach (var stg in TabGroups)
stg.Save(section.CreateSection(TABGROUP_SECTION));
}
示例3: Load
public static SerializedTabGroupWindow Load(ISettingsSection section) {
var name = section.Attribute<string>(NAME_ATTR) ?? MAIN_NAME;
int index = section.Attribute<int?>(INDEX_ATTR) ?? -1;
bool isHorizontal = section.Attribute<bool?>(ISHORIZONTAL_ATTR) ?? false;
var stackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION));
var tgw = new SerializedTabGroupWindow(name, index, isHorizontal, stackedContentState);
foreach (var tgSection in section.SectionsWithName(TABGROUP_SECTION))
tgw.TabGroups.Add(SerializedTabGroup.Load(tgSection));
return tgw;
}
示例4: Write
public void Write(ISettingsSection section) {
Debug.Assert(HorizontalContentState != null && VerticalContentState != null);
if (HorizontalContentState != null)
StackedContentStateSerializer.Serialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT), HorizontalContentState);
if (VerticalContentState != null)
StackedContentStateSerializer.Serialize(section.GetOrCreateSection(VERTICALCONTENT_SECT), VerticalContentState);
Debug.Assert(LeftState != null && RightState != null && TopState != null && BottomState != null);
if (LeftState != null)
ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), LeftState);
if (RightState != null)
ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), RightState);
if (TopState != null)
ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), TopState);
if (BottomState != null)
ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), BottomState);
foreach (var kv in SavedLocations) {
var sect = section.CreateSection(LOCATION_SECT);
sect.Attribute(LOCATION_GUID_ATTR, kv.Key);
sect.Attribute(LOCATION_ATTR, kv.Value);
}
}
示例5: TryDeserialize
public static ToolWindowUIState TryDeserialize(ISettingsSection section)
{
var location = section.Attribute<AppToolWindowLocation?>(LOCATION_ATTR);
int? index = section.Attribute<int?>(INDEX_ATTR);
bool? isHorizontal = section.Attribute<bool?>(ISHORIZONTAL_ATTR);
if (location == null || index == null || isHorizontal == null)
return null;
var state = new ToolWindowUIState();
state.Location = location.Value;
state.Index = index.Value;
state.IsHorizontal = isHorizontal.Value;
foreach (var sect in section.SectionsWithName(GROUP_SECT)) {
var content = ToolWindowGroupState.TryDeserialize(sect);
if (content == null)
return null;
state.Groups.Add(content);
}
state.StackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION));
if (state.StackedContentState == null)
return null;
return state;
}
示例6: Serialize
public static void Serialize(ISettingsSection section, ToolWindowUIState state)
{
section.Attribute(LOCATION_ATTR, state.Location);
section.Attribute(INDEX_ATTR, state.Index);
section.Attribute(ISHORIZONTAL_ATTR, state.IsHorizontal);
foreach (var content in state.Groups)
ToolWindowGroupState.Serialize(section.CreateSection(GROUP_SECT), content);
Debug.Assert(state.StackedContentState != null);
if (state.StackedContentState != null)
StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), state.StackedContentState);
}