粘贴箱: 年足表示機能追加 IndicatorSchema.cs

格式
Plain text
提交日期
2015-01-29 03:05
Publication Period
Unlimited
  1. /*
  2. * Copyright (c) Daisuke OKAJIMA All rights reserved.
  3. *
  4. * $Id$
  5. */
  6. using System;
  7. using System.Collections;
  8. using System.IO;
  9. using System.Text;
  10. using System.Diagnostics;
  11. using System.Drawing;
  12. using System.Windows.Forms;
  13. using Travis.PKI;
  14. using Travis.Storage;
  15. using Zanetti.Parser;
  16. using Zanetti.SystemTrading;
  17. namespace Zanetti.Indicators.Schema
  18. {
  19. internal abstract class SchemaItemBase {
  20. protected string _name;
  21. public abstract string UniqueID { get; }
  22. public string Name {
  23. get {
  24. return _name;
  25. }
  26. }
  27. public abstract void VerifyExpression();
  28. protected static void VerifyExpression(string name, string expression) {
  29. try {
  30. ExpressionConstructor ep = new ExpressionConstructor();
  31. new ZPredicationParser(new StringReader(expression), ep).Parse();
  32. }
  33. catch(Exception ex) {
  34. throw new FormatException(String.Format("{0} 内のexpression\n{1}\nは誤っています。\n{2}", name, expression, ex.Message));
  35. }
  36. }
  37. }
  38. //パラメータ
  39. internal class SchemaParameter {
  40. private SchemaItem _owner;
  41. private int _index;
  42. private string _name;
  43. private double[] _dailyValues;
  44. private string _dailyUnit;
  45. private double[] _weeklyValues;
  46. private string _weeklyUnit;
  47. private double[] _monthlyValues;
  48. private string _monthlyUnit;
  49. private double[] _yearlyValues;
  50. private string _yearlyUnit;
  51. public SchemaParameter(SchemaItem owner, StorageNode definition, StorageNode config) {
  52. _owner = owner;
  53. _index = Int32.Parse(Util.LoadMandatoryAttr(definition, "index"));
  54. _dailyValues = new double[owner.MaxInstanceCount];
  55. _weeklyValues = new double[owner.MaxInstanceCount];
  56. _monthlyValues = new double[owner.MaxInstanceCount];
  57. _yearlyValues = new double[owner.MaxInstanceCount];
  58. if(definition["default"]!=null) { //日足・週足・月足関係ないパラメータ
  59. string unit = Util.LoadMandatoryAttr(definition, "unit");
  60. _dailyUnit = unit;
  61. _weeklyUnit = unit;
  62. _monthlyUnit = unit;
  63. _yearlyUnit = unit;
  64. string def = Util.LoadMandatoryAttr(definition, "default");
  65. FillParams(_dailyValues, config, "d", def);
  66. FillParams(_weeklyValues, config, "w", def);
  67. FillParams(_monthlyValues, config, "m", def);
  68. FillParams(_yearlyValues, config, "y", def);
  69. }
  70. else {
  71. foreach(StorageNode ch in definition.Children) {
  72. if(ch.Name=="name")
  73. _name = ch.TextValue;
  74. else if(ch.Name=="daily") {
  75. _dailyUnit = ch["unit"];
  76. FillParams(_dailyValues, config, "d", ch["default"]);
  77. }
  78. else if(ch.Name=="weekly") {
  79. _weeklyUnit = ch["unit"];
  80. FillParams(_weeklyValues, config, "w", ch["default"]);
  81. }
  82. else if(ch.Name=="monthly") {
  83. _monthlyUnit = ch["unit"];
  84. FillParams(_monthlyValues, config, "m", ch["default"]);
  85. }
  86. else if (ch.Name == "yearly")
  87. {
  88. _yearlyUnit = ch["unit"];
  89. FillParams(_yearlyValues, config, "y", ch["default"]);
  90. }
  91. }
  92. }
  93. }
  94. private void FillParams(double[] dest, StorageNode config, string type, string defaults) {
  95. string[] ds = null;
  96. for(int i=0; i<dest.Length; i++) {
  97. string v = config==null? "" : config.GetValue(String.Format("param_{0}{1}{2}", _index, type, i), "");
  98. if(v.Length==0) {
  99. if(ds==null) ds = defaults.Split(','); //Splitは遅延
  100. if(i<ds.Length) v = ds[i];
  101. }
  102. dest[i] = v.Length==0? 0 : Double.Parse(v);
  103. }
  104. }
  105. public void SaveTo(StorageNode node) {
  106. for(int i=0; i<_dailyValues.Length; i++)
  107. node[String.Format("param_{0}d{1}", _index, i)] = _dailyValues[i].ToString();
  108. for(int i=0; i<_weeklyValues.Length; i++)
  109. node[String.Format("param_{0}w{1}", _index, i)] = _weeklyValues[i].ToString();
  110. for(int i=0; i<_monthlyValues.Length; i++)
  111. node[String.Format("param_{0}m{1}", _index, i)] = _monthlyValues[i].ToString();
  112. for (int i = 0; i < _yearlyValues.Length; i++)
  113. node[String.Format("param_{0}y{1}", _index, i)] = _yearlyValues[i].ToString();
  114. }
  115. public SchemaItem Owner {
  116. get {
  117. return _owner;
  118. }
  119. }
  120. public string Name {
  121. get {
  122. return _name;
  123. }
  124. }
  125. public double[] DailyValues {
  126. get {
  127. return _dailyValues;
  128. }
  129. set {
  130. _dailyValues = value;
  131. }
  132. }
  133. public string DailyUnit {
  134. get {
  135. return _dailyUnit;
  136. }
  137. }
  138. public double[] WeeklyValues {
  139. get {
  140. return _weeklyValues;
  141. }
  142. set {
  143. _weeklyValues = value;
  144. }
  145. }
  146. public string WeeklyUnit {
  147. get {
  148. return _weeklyUnit;
  149. }
  150. }
  151. public double[] MonthlyValues {
  152. get {
  153. return _monthlyValues;
  154. }
  155. set {
  156. _monthlyValues = value;
  157. }
  158. }
  159. public string MonthlyUnit
  160. {
  161. get {
  162. return _monthlyUnit;
  163. }
  164. }
  165. public double[] YearlyValues
  166. {
  167. get
  168. {
  169. return _yearlyValues;
  170. }
  171. set
  172. {
  173. _yearlyValues = value;
  174. }
  175. }
  176. public string YearlyUnit
  177. {
  178. get
  179. {
  180. return _yearlyUnit;
  181. }
  182. }
  183. public int Index
  184. {
  185. get {
  186. return _index;
  187. }
  188. }
  189. /*
  190. public override string UniqueID {
  191. get {
  192. return _owner.UniqueID + "/P" + _index.ToString();
  193. }
  194. }
  195. */
  196. }
  197. //見え方の定義
  198. internal class SchemaAppearance {
  199. private IndicatorAppearance[] _appearances;
  200. private SchemaItem _owner;
  201. public SchemaAppearance(SchemaItem owner, StorageNode definition, StorageNode config) {
  202. _owner = owner;
  203. int c = owner.MaxInstanceCount;
  204. string[] styles = Util.LoadMandatoryAttr(definition, "style").Split(',');
  205. string[] colors = Util.LoadMandatoryAttr(definition, "color").Split(',');
  206. _appearances = new IndicatorAppearance[c];
  207. for(int i=0; i<_appearances.Length; i++) {
  208. string style = config==null? "" : config.GetValue(String.Format("style{0}", i), "");
  209. if(style.Length==0 && styles.Length>i) style = styles[i];
  210. string color = config==null? "" : config.GetValue(String.Format("color{0}", i), "");
  211. if(color.Length==0 && colors.Length>i) color = colors[i];
  212. _appearances[i] = new IndicatorAppearance(IndicatorAppearance.ParseStyle(style), color.Length==0? Color.Empty : Util.ParseColor(color, Color.White));
  213. }
  214. }
  215. public void SaveTo(StorageNode node) {
  216. int i = 0;
  217. foreach(IndicatorAppearance a in _appearances) {
  218. node[String.Format("style{0}", i)] = a.Style.ToString();
  219. node[String.Format("color{0}", i++)] = Util.FormatColor(a.Color);
  220. }
  221. }
  222. public SchemaItem Owner {
  223. get {
  224. return _owner;
  225. }
  226. }
  227. public IndicatorAppearance[] Appearances {
  228. get {
  229. return _appearances;
  230. }
  231. }
  232. /*
  233. public override string UniqueID {
  234. get {
  235. return _owner.UniqueID + "/A";
  236. }
  237. }
  238. */
  239. }
  240. //Indicator/Screening/Validationの項目
  241. internal abstract class SchemaItem : SchemaItemBase {
  242. protected ExtensionKit _owner;
  243. protected string _title;
  244. protected string _headerString;
  245. protected string _description;
  246. protected string _formatString;
  247. protected string _targetBrand;
  248. protected string _relativiseParam;
  249. protected FormatModifier _formatModifier;
  250. protected SchemaAppearance _appearance;
  251. protected ArrayList _parameters;
  252. //protected SchemaItem _paramDependency;
  253. //protected SchemaItem _appearanceDependency;
  254. protected int _maxInstanceCount;
  255. public SchemaItem(ExtensionKit owner, StorageNode definition, StorageNode parent_config) {
  256. _owner = owner;
  257. _parameters = new ArrayList();
  258. _name = Util.LoadMandatoryAttr(definition, "name");
  259. _headerString = "";
  260. _description = "";
  261. _targetBrand = definition["brand"];
  262. _relativiseParam = definition["relativise"];
  263. _maxInstanceCount = Util.ParseInt(definition["count"], 1);
  264. StorageNode config = parent_config==null? null : parent_config.FindChildNode(_name);
  265. ParseFormat(definition);
  266. string d = definition["depends"];
  267. SchemaItem dep = null;
  268. if(d!=null) {
  269. dep = _owner.FindSchemaItemByName(d);
  270. if(dep==null)
  271. throw new FormatException(d + " is not found");
  272. _maxInstanceCount = dep.MaxInstanceCount;
  273. }
  274. foreach(StorageNode e in definition.Children) {
  275. if(e.Name=="param") {
  276. SchemaParameter p = CreateOrFindSchemaParameter(e, config);
  277. while(_parameters.Count<=p.Index) _parameters.Add(null);
  278. _parameters[p.Index] = p;
  279. }
  280. else if(e.Name=="defaultappearance")
  281. _appearance = CreateOrFindSchemaAppearance(e, config);
  282. else if(e.Name=="title")
  283. _title = e.TextValue;
  284. else if(e.Name=="description")
  285. _description = e.TextValue;
  286. else if(e.Name=="header")
  287. _headerString = e.TextValue;
  288. }
  289. //if(_title==null) throw new FormatException(String.Format("titleがないか空の{0}があります。", definition.Name));
  290. if(_headerString==null) throw new FormatException(String.Format("headerがないか空の{0}があります。", definition.Name));
  291. //依存先からの補完
  292. if(dep!=null) {
  293. if(_appearance==null) _appearance = dep.Appearance;
  294. for(int i=0; i<_parameters.Count; i++)
  295. if(_parameters[i]==null) _parameters[i] = dep.GetParameter(i);
  296. while(_parameters.Count<dep.ParameterCount) _parameters.Add(dep.GetParameter(_parameters.Count));
  297. }
  298. }
  299. public void SaveTo(StorageNode node) {
  300. //if(_paramDependency!=null && _appearanceDependency!=null) return;
  301. if(_appearance==null && _parameters.Count==0) return;
  302. StorageNode ch = new StorageNode();
  303. ch.Name = _name;
  304. foreach(SchemaParameter p in _parameters) {
  305. if(p.Owner==this) p.SaveTo(ch);
  306. }
  307. if(_appearance!=null && _appearance.Owner==this) _appearance.SaveTo(ch);
  308. node.AddChild(ch);
  309. }
  310. public ExtensionKit Owner {
  311. get {
  312. return _owner;
  313. }
  314. }
  315. public string Title {
  316. get {
  317. return _title;
  318. }
  319. }
  320. public string HeaderString {
  321. get {
  322. return _headerString;
  323. }
  324. }
  325. public string Description {
  326. get {
  327. return _description;
  328. }
  329. }
  330. public string FormatString {
  331. get {
  332. return _formatString;
  333. }
  334. }
  335. public FormatModifier FormatModifier {
  336. get {
  337. return _formatModifier;
  338. }
  339. }
  340. public string TargetBrand {
  341. get {
  342. return _targetBrand;
  343. }
  344. }
  345. public string RelativiseParam {
  346. get {
  347. return _relativiseParam;
  348. }
  349. }
  350. public int ParameterCount {
  351. get {
  352. //if(_dependsTo!=null)
  353. // return _dependsTo.ParameterCount;
  354. //else
  355. return _parameters.Count;
  356. }
  357. }
  358. public SchemaParameter GetParameter(int index) {
  359. //if(_dependsTo!=null)
  360. // return _dependsTo.GetParameter(index);
  361. //else
  362. return (SchemaParameter)_parameters[index];
  363. }
  364. public IEnumerable Parameters {
  365. get {
  366. //if(_dependsTo!=null)
  367. // return _dependsTo.Parameters;
  368. //else
  369. return _parameters;
  370. }
  371. }
  372. public SchemaAppearance Appearance {
  373. get {
  374. //if(_dependsTo!=null)
  375. // return _dependsTo.Appearance;
  376. //else
  377. return _appearance;
  378. }
  379. set {
  380. _appearance = value;
  381. }
  382. }
  383. public override string UniqueID {
  384. get {
  385. return _owner.ID + ":" + _name;
  386. }
  387. }
  388. public virtual int MaxInstanceCount {
  389. get {
  390. //if(_dependsTo!=null)
  391. // return _dependsTo.MaxInstanceCount;
  392. //else
  393. return _maxInstanceCount;
  394. }
  395. }
  396. public bool OwnsConfig {
  397. get {
  398. bool a = _appearance!=null && _appearance.Owner==this;
  399. if(a) return true;
  400. foreach(SchemaParameter p in _parameters)
  401. if(p.Owner==this) return true;
  402. return false;
  403. }
  404. }
  405. public SchemaParameter[] OwnedParameters {
  406. get {
  407. ArrayList temp = new ArrayList();
  408. foreach(SchemaParameter p in _parameters)
  409. if(p.Owner==this) temp.Add(p);
  410. return (SchemaParameter[])temp.ToArray(typeof(SchemaParameter));
  411. }
  412. }
  413. private void ParseFormat(StorageNode definition) {
  414. string f = definition["format"];
  415. if(f==null) {
  416. _formatString = "F2";
  417. _formatModifier = FormatModifier.Nop;
  418. }
  419. else {
  420. string[] fs = f.Split(',');
  421. if(fs.Length>0) {
  422. _formatString = fs[0];
  423. if(fs.Length>1) _formatModifier = ParseFormatModifier(fs[1]);
  424. }
  425. else
  426. _formatString = "F2";
  427. }
  428. }
  429. private SchemaParameter CreateOrFindSchemaParameter(StorageNode definition, StorageNode config) {
  430. string d = definition["depends"];
  431. if(d==null)
  432. return new SchemaParameter(this, definition, config);
  433. else {
  434. SchemaItem si = _owner.FindSchemaItemByName(d);
  435. if(si==null) throw new FormatException(d + " is not found");
  436. return si.GetParameter(Int32.Parse(definition["index"]));
  437. }
  438. }
  439. public void CollectParameter(ArrayList col) {
  440. foreach(SchemaParameter p in _parameters)
  441. if(p.Owner==this) col.Add(p);
  442. }
  443. public void CollectAppearance(ArrayList col) {
  444. if(_appearance!=null && _appearance.Owner==this) col.Add(_appearance);
  445. }
  446. private SchemaAppearance CreateOrFindSchemaAppearance(StorageNode definition, StorageNode config) {
  447. string d = definition["depends"];
  448. if(d==null)
  449. return new SchemaAppearance(this, definition, config);
  450. else {
  451. SchemaItem si = _owner.FindSchemaItemByName(d);
  452. if(si==null) throw new FormatException(d + " is not found");
  453. return si.Appearance;
  454. }
  455. }
  456. private static FormatModifier ParseFormatModifier(string t) {
  457. if(t=="%")
  458. return FormatModifier.Percent;
  459. else if(t=="100")
  460. return FormatModifier.Mul100;
  461. else
  462. return FormatModifier.Nop;
  463. }
  464. }
  465. //Indicatorを示すスキーマ
  466. internal class SchemaIndicatorItem : SchemaItem {
  467. protected IndicatorTarget _target;
  468. protected IndicatorDisplay _display;
  469. protected string _rawExpression;
  470. protected string _groupName;
  471. public SchemaIndicatorItem(ExtensionKit owner, StorageNode definition, StorageNode parameters) : base(owner, definition, parameters) {
  472. _target = ParseTarget(definition["target"]);
  473. _groupName = definition["group"];
  474. _display = _target==IndicatorTarget.Oscillator? IndicatorDisplay.Normal : ParseDisplay(definition["display"]);
  475. _rawExpression = Util.LoadMandatoryText(definition, "expression");
  476. if(_rawExpression.Length==0)
  477. throw new FormatException("expression is empty");
  478. if(_appearance==null)
  479. throw new FormatException(String.Format("{0}にdefaultappearanceがありません。", _name));
  480. }
  481. public IndicatorTarget Target {
  482. get {
  483. return _target;
  484. }
  485. }
  486. public IndicatorDisplay Display {
  487. get {
  488. return _display;
  489. }
  490. }
  491. public string RawExpression {
  492. get {
  493. return _rawExpression;
  494. }
  495. }
  496. public string GroupName {
  497. get {
  498. return _groupName;
  499. }
  500. }
  501. public override void VerifyExpression() {
  502. VerifyExpression(_name, _rawExpression);
  503. }
  504. private static IndicatorTarget ParseTarget(string value) {
  505. if(value=="price")
  506. return IndicatorTarget.Price;
  507. else if(value=="volume")
  508. return IndicatorTarget.Volume;
  509. else if(value=="oscillator")
  510. return IndicatorTarget.Oscillator;
  511. else
  512. throw new FormatException(String.Format("{0}はtargetの値として正しくありません。", value));
  513. }
  514. private static IndicatorDisplay ParseDisplay(string value) {
  515. if(value=="normal")
  516. return IndicatorDisplay.Normal;
  517. else {
  518. IndicatorDisplay d = IndicatorDisplay.None;
  519. foreach(string t in value.Split('+')) {
  520. if(t=="value")
  521. d |= IndicatorDisplay.Value;
  522. else if(t=="explanation")
  523. d |= IndicatorDisplay.Explanation;
  524. else if(t=="chart")
  525. d |= IndicatorDisplay.Chart;
  526. else
  527. throw new FormatException(String.Format("{0}はdisplayの値として正しくありません。", value));
  528. }
  529. return d;
  530. }
  531. }
  532. }
  533. internal class SchemaScreeningItem : SchemaItem {
  534. protected string _rawExpression;
  535. protected string _rawFilter;
  536. public SchemaScreeningItem(ExtensionKit owner, StorageNode definition, StorageNode parameters) : base(owner, definition, parameters) {
  537. _rawExpression = Util.LoadMandatoryText(definition, "expression");
  538. StorageNode fl = definition.FindChildNode("filter");
  539. _rawFilter = fl==null? "" : fl.TextValue;
  540. if(_rawExpression.Length==0)
  541. throw new FormatException("expression is empty");
  542. }
  543. public string RawExpression {
  544. get {
  545. return _rawExpression;
  546. }
  547. }
  548. public string RawFilter {
  549. get {
  550. return _rawFilter;
  551. }
  552. }
  553. public override void VerifyExpression() {
  554. VerifyExpression(_name, _rawExpression);
  555. if(_rawFilter.Length>0)
  556. VerifyExpression(_name, _rawFilter);
  557. }
  558. }
  559. /* バージョン1形式
  560. * <prediction name="uehige_p">
  561. <title>上ひげ陰線の売り場検証</title>
  562. <description>上ひげ(チャート上のひげの長さが終値の1%以上で判定しています)かつ陰線を出し、
  563. さらにその上ひげで高値を更新したときに空売りをしたと想定して勝率を測定します。</description>
  564. <header>上ひげ陰線かつ{0}高値更新なら空売りで{1}以内に{2}以上下降</header>
  565. <condition>ue_hige() and insen() and (high()==max(high({0})))</condition>
  566. <claim><![CDATA[min(low(0,0-{1})) < close()*(1-{2}/100)]]></claim>
  567. <param index="0" type="positiveInteger" unit="日" default="5"/>
  568. <param index="1" type="positiveInteger" unit="日" default="5"/>
  569. <param index="2" type="positiveInteger" unit="%" default="2"/>
  570. </prediction>
  571. */
  572. internal class SchemaPredictionItem : SchemaItem {
  573. protected string _rawCondition;
  574. protected string _rawClaim;
  575. public SchemaPredictionItem(ExtensionKit owner, StorageNode definition, StorageNode parameters) : base(owner, definition, parameters) {
  576. _rawCondition = Util.LoadMandatoryText(definition, "condition");
  577. _rawClaim = Util.LoadMandatoryText(definition, "claim");
  578. }
  579. public string RawCondition {
  580. get {
  581. return _rawCondition;
  582. }
  583. }
  584. public string RawClaim {
  585. get {
  586. return _rawClaim;
  587. }
  588. }
  589. public override void VerifyExpression() {
  590. VerifyExpression(_name, _rawCondition);
  591. VerifyExpression(_name, _rawClaim);
  592. }
  593. }
  594. internal class SchemaAutoTradingItem : SchemaItem {
  595. protected TradingType _tradingType;
  596. protected string _rawSignal;
  597. protected string _rawExit;
  598. protected string _rawLosscut;
  599. protected EntryType _rawEntryType;
  600. protected string _rawGyakusashine;
  601. public SchemaAutoTradingItem(ExtensionKit owner, StorageNode definition, StorageNode parameters) : base(owner, definition, parameters) {
  602. _tradingType = ParseTradingType(Util.LoadOptionalText(definition, "type", "long"));
  603. _rawSignal = Util.LoadMandatoryText(definition, "signal");
  604. _rawExit = Util.LoadMandatoryText(definition, "exit");
  605. _rawLosscut= Util.LoadMandatoryText(definition, "losscut");
  606. StorageNode entry = definition.FindChildNode("entry");
  607. if(entry==null) {
  608. _rawEntryType = EntryType.TodayClose;
  609. _rawGyakusashine = "";
  610. }
  611. else {
  612. _rawEntryType = ParseEntryType(entry.GetValue("type", ""));
  613. _rawGyakusashine = entry.TextValue;
  614. }
  615. }
  616. public string RawSignal {
  617. get {
  618. return _rawSignal;
  619. }
  620. }
  621. public string RawExit {
  622. get {
  623. return _rawExit;
  624. }
  625. }
  626. public string RawLosscut {
  627. get {
  628. return _rawLosscut;
  629. }
  630. }
  631. public EntryType RawEntryType {
  632. get {
  633. return _rawEntryType;
  634. }
  635. }
  636. public string RawGyakusashine {
  637. get {
  638. return _rawGyakusashine;
  639. }
  640. }
  641. public TradingType TradingType {
  642. get {
  643. return _tradingType;
  644. }
  645. }
  646. public override void VerifyExpression() {
  647. VerifyExpression(_name, _rawSignal);
  648. VerifyExpression(_name, _rawExit);
  649. VerifyExpression(_name, _rawLosscut);
  650. }
  651. private static TradingType ParseTradingType(string t) {
  652. if(t=="Short" || t=="short")
  653. return TradingType.Short;
  654. else if(t=="Long" || t=="long")
  655. return TradingType.Long;
  656. else
  657. throw new FormatException(t + " はTradingTypeの値として不正です。");
  658. }
  659. private static EntryType ParseEntryType(string t) {
  660. t = t.ToLower();
  661. if(t=="tomorrow-open")
  662. return EntryType.TomorrowOpen;
  663. else if(t=="signal-limitorder")
  664. return EntryType.Gyakusashine;
  665. else if(t=="todayclose" || t=="today-close" || t.Length==0) //タイプミスがあったようだ。互換性のためtodayclose, today-closeどちらもOKとする
  666. return EntryType.TodayClose;
  667. else
  668. throw new FormatException(t + " はEntryTypeの値として不正です。");
  669. }
  670. }
  671. internal class SchemaOscillatorGroup {
  672. private string _name;
  673. private string _title;
  674. private ValueRange _type;
  675. public SchemaOscillatorGroup(ExtensionKit parent, StorageNode definition) {
  676. _name = Util.LoadMandatoryAttr(definition, "name");
  677. _title = Util.LoadMandatoryAttr(definition, "title");
  678. _type = ParseValueRange(Util.LoadMandatoryAttr(definition, "type"));
  679. }
  680. public string Name {
  681. get {
  682. return _name;
  683. }
  684. }
  685. public string Title {
  686. get {
  687. return _title;
  688. }
  689. }
  690. public ValueRange Type {
  691. get {
  692. return _type;
  693. }
  694. }
  695. private static ValueRange ParseValueRange(string data) {
  696. if(data=="percent0_1")
  697. return ValueRange.Percent0_1;
  698. else if(data=="percent1_1")
  699. return ValueRange.Percent1_1;
  700. else if(data=="origin0")
  701. return ValueRange.Origin0;
  702. else
  703. return ValueRange.Default;
  704. }
  705. }
  706. internal class SchemaExtensionLibrary : SchemaItemBase {
  707. private ExtensionKit _owner;
  708. private string _expression;
  709. public SchemaExtensionLibrary(ExtensionKit owner, StorageNode definition) {
  710. _owner = owner;
  711. _name = Util.LoadMandatoryAttr(definition, "name");
  712. _expression = Util.LoadMandatoryText(definition, "expression");
  713. }
  714. public string Expression {
  715. get {
  716. return _expression;
  717. }
  718. }
  719. public override string UniqueID {
  720. get {
  721. return _owner.ID + ":"+ _name;
  722. }
  723. }
  724. public override void VerifyExpression() {
  725. VerifyExpression(_name, _expression);
  726. }
  727. }
  728. }
下载 可打印视图

网址

Embed with JavaScript

Embed with iframe

原始文本