105 lines
3.6 KiB
C#
105 lines
3.6 KiB
C#
|
|
using System;
|
|
using System.Xml;
|
|
using System.Configuration;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
namespace Ease.Core.Utility
|
|
{
|
|
//public abstract class ConfigElementTemplate<ElementT>
|
|
// where ElementT : ConfigElementTemplate<ElementT>, new()
|
|
//{
|
|
// protected XmlNamespaceManager _nm;
|
|
// protected static ElementT GetConfig(string section)
|
|
// {
|
|
// return new ElementT(); //#### (ElementT)ConfigurationManager.GetSection(section);
|
|
// }
|
|
// //object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
|
|
// //{
|
|
// // try
|
|
// // {
|
|
// // _nm = new XmlNamespaceManager(section.OwnerDocument.NameTable);
|
|
// // _nm.AddNamespace("_cfg_", section.NamespaceURI);
|
|
|
|
// // Parse(section as XmlElement);
|
|
// // return this;
|
|
// // }
|
|
// // catch (ConfigurationErrorsException)
|
|
// // {
|
|
// // throw;
|
|
// // }
|
|
// // catch (Exception e)
|
|
// // {
|
|
// // throw new ConfigurationErrorsException(e.Message, e, section);
|
|
// // }
|
|
// //}
|
|
|
|
// protected void CheckRequiredAttributes(XmlElement node, params string[] attributes)
|
|
// {
|
|
// foreach (string attribute in attributes)
|
|
// {
|
|
// //####
|
|
// //if (!node.HasAttribute(attribute))
|
|
// // throw new ConfigurationErrorsException("Required Attribute: " + attribute + " is missing", node);
|
|
// }
|
|
// }
|
|
|
|
// //protected void RaiseError(XmlElement node, string message, params object[] args)
|
|
// //{
|
|
// // throw new ConfigurationErrorsException(string.Format(message, args), node);
|
|
// //}
|
|
|
|
// protected List<ChildT> ReadChildren<ChildT>(XmlElement node, string name)
|
|
// where ChildT : ConfigChildElementTemplate<ChildT, ElementT>, new()
|
|
// {
|
|
// List<ChildT> list = new List<ChildT>();
|
|
// AddChildren<ChildT>(node, name, list);
|
|
// return list;
|
|
// }
|
|
|
|
// protected void AddChildren<ChildT>(XmlElement node, string name, IList<ChildT> list)
|
|
// where ChildT : ConfigChildElementTemplate<ChildT, ElementT>, new()
|
|
// {
|
|
// foreach (XmlElement childNode in node.SelectNodes("_cfg_:" + name, _nm))
|
|
// {
|
|
// ChildT child = new ChildT();
|
|
// child._nm = _nm;
|
|
// child.Parent = (ElementT)this;
|
|
|
|
// try
|
|
// {
|
|
// child.Parse(childNode);
|
|
// }
|
|
// //####
|
|
// //catch (ConfigurationException)
|
|
// //{
|
|
// // throw;
|
|
// //}
|
|
// catch (Exception e)
|
|
// {
|
|
// //####
|
|
// //throw new ConfigurationErrorsException(e.Message, e, childNode);
|
|
// }
|
|
|
|
// list.Add(child);
|
|
// }
|
|
// }
|
|
|
|
// protected abstract void Parse(XmlElement node);
|
|
//}
|
|
|
|
//public abstract class ConfigChildElementTemplate<ElementT, ParentT> : ConfigElementTemplate<ElementT>
|
|
// where ElementT : ConfigChildElementTemplate<ElementT, ParentT>, new()
|
|
// where ParentT : ConfigElementTemplate<ParentT>, new()
|
|
//{
|
|
// protected ParentT _parent;
|
|
// public ParentT Parent
|
|
// {
|
|
// get { return _parent; }
|
|
// internal set { _parent = value; }
|
|
// }
|
|
//}
|
|
}
|