|
|
|
|
|
// <copyright file="FrmTiQuDiZhiFenCeng.cs" company="jindongfang">
|
|
|
|
|
|
// Copyright (c) jindongfang. All rights reserved.
|
|
|
|
|
|
// </copyright>
|
|
|
|
|
|
|
|
|
|
|
|
using DevExpress.XtraGrid.Columns;
|
|
|
|
|
|
using Fk.Utils;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Dynamic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using WorkData;
|
|
|
|
|
|
using WorkData.Entity;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WellWorkDataUI.CustomControls
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Class FrmTiQuDiZhiFenCeng.
|
|
|
|
|
|
/// Implements the <see cref="DevExpress.XtraEditors.XtraForm" />
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <seealso cref="DevExpress.XtraEditors.XtraForm" />
|
|
|
|
|
|
public partial class FrmTiQuDiZhiFenCeng : DevExpress.XtraEditors.XtraForm
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The list layer
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private List<string> listLayer = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The model list
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private ModelList modelList = new ModelList();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// NeedRefresh
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool NeedRefresh { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="FrmTiQuDiZhiFenCeng"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public FrmTiQuDiZhiFenCeng()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnQueryChuceng_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> lstCw = new List<string>();
|
|
|
|
|
|
var list_sycw = await DBHelp.NewDb.Queryable<CcsjSyhd>().GroupBy(o => o.CW).Select(x => x.CW).ToListAsync();
|
|
|
|
|
|
var list_yxcw = await DBHelp.NewDb.Queryable<CcsjYxhd>().GroupBy(o => o.CW).Select(x => x.CW).ToListAsync();
|
|
|
|
|
|
var list_kxdcw = await DBHelp.NewDb.Queryable<CcsjKxd>().GroupBy(o => o.CW).Select(x => x.CW).ToListAsync();
|
|
|
|
|
|
var list_stlcw = await DBHelp.NewDb.Queryable<CcsjStl>().GroupBy(o => o.CW).Select(x => x.CW).ToListAsync();
|
|
|
|
|
|
var list_bhdcw = await DBHelp.NewDb.Queryable<CcsjBhd>().GroupBy(o => o.CW).Select(x => x.CW).ToListAsync();
|
|
|
|
|
|
lstCw.AddRange(list_sycw);
|
|
|
|
|
|
lstCw.AddRange(list_yxcw);
|
|
|
|
|
|
lstCw.AddRange(list_kxdcw);
|
|
|
|
|
|
lstCw.AddRange(list_stlcw);
|
|
|
|
|
|
lstCw.AddRange(list_bhdcw);
|
|
|
|
|
|
this.SetLayers(lstCw);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnQueryFenceng_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = await DBHelp.NewDb.Queryable<InterpretDrillWellLayered>()
|
|
|
|
|
|
.Select(o => o.CW)
|
|
|
|
|
|
.Distinct()
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
this.SetLayers(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetLayers(List<string> list)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.listLayer.Clear();
|
|
|
|
|
|
this.listLayer.AddRange(list.Where(o => !string.IsNullOrWhiteSpace(o)));
|
|
|
|
|
|
|
|
|
|
|
|
this.listBoxControl1.DataSource = null;
|
|
|
|
|
|
this.listBoxControl1.DataSource = this.listLayer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnGenerate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.modelList.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
//@"(?<lv0>[a-zA-Z])",
|
|
|
|
|
|
// @"(?<lv1>\d|[MDCLXVI]+|[\u2160-\u2183]+)",
|
|
|
|
|
|
// @"(?<lv2>\d+\+\d+|\d+)",
|
|
|
|
|
|
// @"(?<lv3>[a-zA-Z])",
|
|
|
|
|
|
// @"(?<lv4>[a-zA-Z])",
|
|
|
|
|
|
string[] regexArray = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
@"(?<lv0>[a-zA-Z])",
|
|
|
|
|
|
@"(?<lv1>\d|[MDCLXVI]+|[\u2160-\u2183]+)",
|
|
|
|
|
|
@"(?<lv2>[a-zA-Z]|\d+)",
|
|
|
|
|
|
@"(?<lv3>-\d+)",
|
|
|
|
|
|
@"(?<lv4>[a-zA-Z])",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var regex_lv4 = new Regex(string.Concat(regexArray), RegexOptions.Compiled);
|
|
|
|
|
|
var regex_lv3 = new Regex(string.Concat(regexArray.Take(4).ToArray()), RegexOptions.Compiled);
|
|
|
|
|
|
var regex_lv2 = new Regex(string.Concat(regexArray.Take(3).ToArray()), RegexOptions.Compiled);
|
|
|
|
|
|
var regex_lv1 = new Regex(string.Concat(regexArray.Take(2).ToArray()), RegexOptions.Compiled);
|
|
|
|
|
|
var regex_lv0 = new Regex(string.Concat(regexArray.Take(1).ToArray()), RegexOptions.Compiled);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in this.listLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
var m = regex_lv4.Match(item);
|
|
|
|
|
|
if (m.Groups.Count <= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
m = regex_lv3.Match(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m.Groups.Count <= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
m = regex_lv2.Match(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m.Groups.Count <= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
m = regex_lv1.Match(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m.Groups.Count <= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
m = regex_lv0.Match(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var lv0 = m.Groups["lv0"]?.Value;
|
|
|
|
|
|
var lv1 = m.Groups["lv1"]?.Value;
|
|
|
|
|
|
var lv2 = m.Groups["lv2"]?.Value;
|
|
|
|
|
|
var lv3 = m.Groups["lv3"]?.Value;
|
|
|
|
|
|
var lv4 = m.Groups["lv4"]?.Value;
|
|
|
|
|
|
|
|
|
|
|
|
var tmp = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
m.Groups["lv0"]?.Value,
|
|
|
|
|
|
m.Groups["lv1"]?.Value,
|
|
|
|
|
|
m.Groups["lv2"]?.Value,
|
|
|
|
|
|
m.Groups["lv3"]?.Value,
|
|
|
|
|
|
m.Groups["lv4"]?.Value,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var real = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
lv0,
|
|
|
|
|
|
lv0 + lv1,
|
|
|
|
|
|
lv0 + lv1 + lv2,
|
|
|
|
|
|
lv0 + lv1 + lv2 + lv3,
|
|
|
|
|
|
lv0 + lv1 + lv2 + lv3 + lv4,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tmp.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(tmp[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic model = this.modelList.FirstOrDefault(o =>
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int j = 0; j < i; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (o.Level(j) != real[j])
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var text = o.Level(i);
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(text) && text != real[i])
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (model == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
model = new Model();
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j <= i; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
model[$"Level{j}"] = real[j];
|
|
|
|
|
|
model[$"Tmp{j}"] = tmp[j];
|
|
|
|
|
|
model.MaxLevel = Math.Max(model.MaxLevel, j);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.modelList.Add(model);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
model[$"Level{i}"] = real[i];
|
|
|
|
|
|
model[$"Tmp{i}"] = tmp[i];
|
|
|
|
|
|
model.MaxLevel = Math.Max(model.MaxLevel, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取层级
|
|
|
|
|
|
this.gridViewMain.Columns.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= this.modelList.MaxLevel; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GridColumn col = this.gridViewMain.Columns.Add();
|
|
|
|
|
|
col.Caption = $"{NumberConverter.NumToChinese(i + 1)}级分层";
|
|
|
|
|
|
col.FieldName = $"Level{i}";
|
|
|
|
|
|
col.Visible = true;
|
|
|
|
|
|
col.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.modelList.Sort(Model.Comprare);
|
|
|
|
|
|
|
|
|
|
|
|
this.gridControl1.DataSource = this.modelList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnGenerateOne_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.modelList.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in this.listLayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic model = this.modelList.FirstOrDefault(o => o.Level(0) == item);
|
|
|
|
|
|
|
|
|
|
|
|
if (model == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
model = new Model();
|
|
|
|
|
|
|
|
|
|
|
|
model[$"Level0"] = item;
|
|
|
|
|
|
model[$"Tmp0"] = item;
|
|
|
|
|
|
|
|
|
|
|
|
this.modelList.Add(model);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.gridViewMain.Columns.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= this.modelList.MaxLevel; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GridColumn col = this.gridViewMain.Columns.Add();
|
|
|
|
|
|
col.Caption = $"{NumberConverter.NumToChinese(i + 1)}级分层";
|
|
|
|
|
|
col.FieldName = $"Level{i}";
|
|
|
|
|
|
col.Visible = true;
|
|
|
|
|
|
col.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.modelList.Sort(Model.Comprare);
|
|
|
|
|
|
|
|
|
|
|
|
this.gridControl1.DataSource = this.modelList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (MessageBox.Show("是否提取到地址分层并覆盖已有分层数据?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
await DBHelp.NewDb.UseTranAsync(async db =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await db.Deleteable<GeologicalStratification>().ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
var list = new List<GeologicalStratification>();
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, GeologicalStratification> dict = new Dictionary<string, GeologicalStratification>();
|
|
|
|
|
|
|
|
|
|
|
|
int nLine = 0;
|
|
|
|
|
|
foreach (dynamic item in this.modelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var listTmp = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= item.MaxLevel; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
listTmp.Add(item[$"Level{i}"]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string[] arr = listTmp.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
GeologicalStratification parent = null;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < arr.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
GeologicalStratification cur = null;
|
|
|
|
|
|
string key = $"{arr[i]}-{i}";
|
|
|
|
|
|
|
|
|
|
|
|
if (dict.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
cur = dict[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
cur = new GeologicalStratification()
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = GetNextId(list),
|
|
|
|
|
|
Code = arr[i],
|
|
|
|
|
|
Level = i,
|
|
|
|
|
|
Order = nLine,
|
|
|
|
|
|
ParentID = parent?.ID ?? -1,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
dict[key] = cur;
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(cur);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
parent = cur;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nLine++;
|
|
|
|
|
|
}
|
|
|
|
|
|
await db.Insertable(list).ExecuteCommandAsync();
|
|
|
|
|
|
});
|
|
|
|
|
|
await DataHelp.LoadGeoLayer(); //更新当前工区变量
|
|
|
|
|
|
MessageBox.Show("提取成功!");
|
|
|
|
|
|
this.NeedRefresh = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GetNextId(List<GeologicalStratification> list)
|
|
|
|
|
|
{
|
|
|
|
|
|
return list.Count > 0 ? list.Max(o => o.ID) + 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The model.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private class Model : DynamicObject
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly Dictionary<string, object> dynamicProperties = new Dictionary<string, object>();
|
|
|
|
|
|
public int MaxLevel { get; set; } = 0;
|
|
|
|
|
|
public string Level(int level)
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic m = this;
|
|
|
|
|
|
return m[$"Level{level}"];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool TrySetMember(SetMemberBinder binder, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.dynamicProperties[binder.Name] = value;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!this.dynamicProperties.TryGetValue(binder.Name, out result))
|
|
|
|
|
|
{
|
|
|
|
|
|
result = string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> GetDynamicMemberNames()
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.dynamicProperties.Keys;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
string key = (string)indexes[0];
|
|
|
|
|
|
|
|
|
|
|
|
this.dynamicProperties[key] = value;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
|
|
|
|
|
|
{
|
|
|
|
|
|
string key = (string)indexes[0];
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.dynamicProperties.TryGetValue(key, out result))
|
|
|
|
|
|
{
|
|
|
|
|
|
result = string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Comprares the specified a.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="a">a.</param>
|
|
|
|
|
|
/// <param name="b">The b.</param>
|
|
|
|
|
|
/// <returns>System.Int32.</returns>
|
|
|
|
|
|
public static int Comprare(Model a, Model b)
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic lhs = a;
|
|
|
|
|
|
dynamic rhs = b;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string tmp1 = lhs[$"Tmp{i}"]?.ToString() ?? string.Empty;
|
|
|
|
|
|
string tmp2 = rhs[$"Tmp{i}"]?.ToString() ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
tmp1 = tmp1.Replace("+", ".");
|
|
|
|
|
|
tmp2 = tmp2.Replace("+", ".");
|
|
|
|
|
|
|
|
|
|
|
|
int v = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (double.TryParse(tmp1, out var d1) && double.TryParse(tmp2, out var d2))
|
|
|
|
|
|
{
|
|
|
|
|
|
v = Comparer<double>.Default.Compare(d1, d2);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
v = string.Compare(tmp1, tmp2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (v != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return v;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private class ModelList : List<Model>, ITypedList
|
|
|
|
|
|
{
|
|
|
|
|
|
public int MaxLevel { get; set; } = 4;
|
|
|
|
|
|
|
|
|
|
|
|
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<PropertyDescriptor> descriptors = new List<PropertyDescriptor>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= this.MaxLevel; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
descriptors.Add(new MyDynamicPropertyDescriptor($"Level{i}", typeof(string)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new PropertyDescriptorCollection(descriptors.ToArray());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string GetListName(PropertyDescriptor[] listAccessors)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private class MyDynamicPropertyDescriptor : PropertyDescriptor
|
|
|
|
|
|
{
|
|
|
|
|
|
public MyDynamicPropertyDescriptor(string name, Type type)
|
|
|
|
|
|
: base(name, null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Type = type;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Type Type { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IsReadOnly => false;
|
|
|
|
|
|
public override Type PropertyType => this.Type;
|
|
|
|
|
|
public override Type ComponentType => typeof(Model);
|
|
|
|
|
|
|
|
|
|
|
|
public override bool CanResetValue(object component) => throw new NotImplementedException();
|
|
|
|
|
|
public override void ResetValue(object component) => throw new NotImplementedException();
|
|
|
|
|
|
public override bool ShouldSerializeValue(object component) => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
|
|
public override object GetValue(object component)
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic model = component as Model;
|
|
|
|
|
|
|
|
|
|
|
|
return model[this.Name];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetValue(object component, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
dynamic model = component as Model;
|
|
|
|
|
|
|
|
|
|
|
|
model[this.Name] = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|