fork download
  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. //
  5. // Changes to this file may cause incorrect behavior and will be lost if
  6. // the code is regenerated.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9.  
  10. using System;
  11. using System.Collections.Generic;
  12. using Windows.UI.Xaml.Markup;
  13. using Windows.UI.Xaml;
  14. using Application2.XamlTypeInfo;
  15.  
  16. namespace Application2
  17. {
  18. public partial class App : IXamlMetadataProvider
  19. {
  20. private XamlTypeInfoProvider _provider;
  21.  
  22. public IXamlType GetXamlType(String typeName)
  23. {
  24. if(_provider == null)
  25. {
  26. _provider = new XamlTypeInfoProvider();
  27. }
  28. return _provider.GetXamlTypeByName(typeName);
  29. }
  30.  
  31. public XmlnsDefinition[] GetXmlnsDefinitions()
  32. {
  33. return new XmlnsDefinition[0];
  34. }
  35. }
  36. }
  37.  
  38. namespace Application2.XamlTypeInfo
  39. {
  40. internal partial class XamlTypeInfoProvider
  41. {
  42. public IXamlType GetXamlTypeByName(string typeName)
  43. {
  44. if (String.IsNullOrEmpty(typeName))
  45. {
  46. return null;
  47. }
  48. IXamlType xamlType;
  49. if (_xamlTypes.TryGetValue(typeName, out xamlType))
  50. {
  51. return xamlType;
  52. }
  53. xamlType = CreateXamlType(typeName);
  54. if (xamlType != null)
  55. {
  56. _xamlTypes.Add(typeName, xamlType);
  57. }
  58. return xamlType;
  59. }
  60.  
  61. public IXamlMember GetMemberByLongName(string longMemberName)
  62. {
  63. if (String.IsNullOrEmpty(longMemberName))
  64. {
  65. return null;
  66. }
  67. IXamlMember xamlMember;
  68. if (_xamlMembers.TryGetValue(longMemberName, out xamlMember))
  69. {
  70. return xamlMember;
  71. }
  72. xamlMember = CreateXamlMember(longMemberName);
  73. if (xamlMember != null)
  74. {
  75. _xamlMembers.Add(longMemberName, xamlMember);
  76. }
  77. return xamlMember;
  78. }
  79.  
  80. Dictionary<string, IXamlType> _xamlTypes = new Dictionary<string, IXamlType>();
  81. Dictionary<string, IXamlMember> _xamlMembers = new Dictionary<string, IXamlMember>();
  82.  
  83.  
  84. private object Activate_0_MainPage() { return new Application2.MainPage(); }
  85.  
  86.  
  87.  
  88. private IXamlType CreateXamlType(string typeName)
  89. {
  90. XamlSystemBaseType xamlType = null;
  91. XamlUserType userType;
  92.  
  93. switch (typeName)
  94. {
  95. case "Windows.UI.Xaml.Controls.UserControl":
  96. xamlType = new XamlSystemBaseType(typeName, typeof(Windows.UI.Xaml.Controls.UserControl));
  97. break;
  98.  
  99. case "Application2.MainPage":
  100. userType = new XamlUserType(this, typeName, typeof(Application2.MainPage), GetXamlTypeByName("Windows.UI.Xaml.Controls.UserControl"));
  101. userType.Activator = Activate_0_MainPage;
  102. xamlType = userType;
  103. break;
  104. }
  105. return xamlType;
  106. }
  107.  
  108.  
  109.  
  110. private IXamlMember CreateXamlMember(string longMemberName)
  111. {
  112. XamlMember xamlMember = null;
  113. // No Local Properties
  114. return xamlMember;
  115. }
  116.  
  117. }
  118.  
  119. internal class XamlSystemBaseType : IXamlType
  120. {
  121. string _fullName;
  122. Type _underlyingType;
  123.  
  124. public XamlSystemBaseType(string fullName, Type underlyingType)
  125. {
  126. _fullName = fullName;
  127. _underlyingType = underlyingType;
  128. }
  129.  
  130. virtual public bool IsSystemType { get { return true; } }
  131. public string FullName { get { return _fullName; } }
  132.  
  133. public string Name
  134. {
  135. get
  136. {
  137. int idx = _fullName.LastIndexOf('.');
  138. if (idx == -1)
  139. {
  140. return _fullName;
  141. }
  142. return _fullName.Substring(idx + 1);
  143. }
  144. }
  145.  
  146. public Type UnderlyingType
  147. {
  148. get
  149. {
  150. return _underlyingType;
  151. }
  152. }
  153.  
  154. virtual public IXamlType BaseType { get { throw new NotImplementedException(); } }
  155. virtual public IXamlMember ContentProperty { get { throw new NotImplementedException(); } }
  156. virtual public IXamlMember GetMember(string name) { throw new NotImplementedException(); }
  157. virtual public bool IsArray { get { throw new NotImplementedException(); } }
  158. virtual public bool IsCollection { get { throw new NotImplementedException(); } }
  159. virtual public bool IsConstructible { get { throw new NotImplementedException(); } }
  160. virtual public bool IsDictionary { get { throw new NotImplementedException(); } }
  161. virtual public bool IsMarkupExtension { get { throw new NotImplementedException(); } }
  162. virtual public IXamlType ItemType { get { throw new NotImplementedException(); } }
  163. virtual public IXamlType KeyType { get { throw new NotImplementedException(); } }
  164. virtual public object ActivateInstance() { throw new NotImplementedException(); }
  165. virtual public void AddToMap(object instance, object key, object item) { throw new NotImplementedException(); }
  166. virtual public void AddToVector(object instance, object item) { throw new NotImplementedException(); }
  167. virtual public void RunInitializer() { throw new NotImplementedException(); }
  168. }
  169.  
  170. internal delegate object Activator();
  171. internal delegate void AddToCollection(object instance, object item);
  172. internal delegate void AddToDictionary(object instance, object key, object item);
  173.  
  174. internal class XamlUserType : XamlSystemBaseType
  175. {
  176. XamlTypeInfoProvider _provider;
  177. IXamlType _baseType;
  178. bool _isArray;
  179. bool _isMarkupExtension;
  180.  
  181. string _contentPropertyName;
  182. string _itemTypeName;
  183. string _keyTypeName;
  184. Dictionary<string, string> _memberNames;
  185.  
  186. public XamlUserType(XamlTypeInfoProvider provider, string fullName, Type fullType, IXamlType baseType)
  187. :base(fullName, fullType)
  188. {
  189. _provider = provider;
  190. _baseType = baseType;
  191. }
  192.  
  193. override public bool IsSystemType { get { return false; } }
  194. override public IXamlType BaseType { get { return _baseType; } }
  195.  
  196. public Activator Activator { get; set; }
  197. public AddToCollection CollectionAdd { get; set; }
  198. public AddToDictionary DictionaryAdd { get; set; }
  199.  
  200. public void SetContentPropertyName(string contentPropertyName)
  201. {
  202. _contentPropertyName = contentPropertyName;
  203. }
  204. override public IXamlMember ContentProperty
  205. {
  206. get { return _provider.GetMemberByLongName(_contentPropertyName); }
  207. }
  208.  
  209. public void SetIsArray() { _isArray = true; }
  210. override public bool IsArray { get { return _isArray; } }
  211.  
  212. override public bool IsCollection { get { return (CollectionAdd != null); } }
  213. override public bool IsConstructible { get { return (Activator != null); } }
  214. override public bool IsDictionary { get { return (DictionaryAdd != null); } }
  215.  
  216. public void SetIsMarkupExtension() { _isMarkupExtension = true; }
  217. override public bool IsMarkupExtension { get { return _isMarkupExtension; } }
  218.  
  219. public void SetItemTypeName(string itemTypeName)
  220. {
  221. _itemTypeName = itemTypeName;
  222. }
  223. override public IXamlType ItemType
  224. {
  225. get { return _provider.GetXamlTypeByName(_itemTypeName); }
  226. }
  227.  
  228. public void SetKeyTypeName(string keyTypeName)
  229. {
  230. _keyTypeName = keyTypeName;
  231. }
  232. override public IXamlType KeyType
  233. {
  234. get { return _provider.GetXamlTypeByName(_keyTypeName); }
  235. }
  236.  
  237. public void AddMemberName(string shortName, string longName)
  238. {
  239. if(_memberNames == null)
  240. {
  241. _memberNames = new Dictionary<string,string>();
  242. }
  243. _memberNames.Add(shortName, longName);
  244. }
  245.  
  246. override public IXamlMember GetMember(string name)
  247. {
  248. if (_memberNames == null)
  249. {
  250. return null;
  251. }
  252. string longName;
  253. if (_memberNames.TryGetValue(name, out longName))
  254. {
  255. return _provider.GetMemberByLongName(longName);
  256. }
  257. return null;
  258. }
  259.  
  260. override public object ActivateInstance()
  261. {
  262. return Activator();
  263. }
  264.  
  265. override public void AddToMap(object instance, object key, object item)
  266. {
  267. DictionaryAdd(instance, key, item);
  268. }
  269.  
  270. override public void AddToVector(object instance, object item)
  271. {
  272. CollectionAdd(instance, item);
  273. }
  274.  
  275. override public void RunInitializer()
  276. {
  277. System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(UnderlyingType.TypeHandle);
  278. }
  279. }
  280.  
  281. internal delegate object Getter(object instance);
  282. internal delegate void Setter(object instance, object value);
  283.  
  284. internal class XamlMember : IXamlMember
  285. {
  286. XamlTypeInfoProvider _provider;
  287. string _name;
  288. bool _isAttachable;
  289. bool _isDependencyProperty;
  290. bool _isReadOnly;
  291.  
  292. string _typeName;
  293. string _targetTypeName;
  294.  
  295. public XamlMember(XamlTypeInfoProvider provider, string name, string typeName)
  296. {
  297. _name = name;
  298. _typeName = typeName;
  299. _provider = provider;
  300. }
  301.  
  302. public string Name { get { return _name; } }
  303.  
  304. public IXamlType Type
  305. {
  306. get { return _provider.GetXamlTypeByName(_typeName); }
  307. }
  308.  
  309. public void SetTargetTypeName(String targetTypeName)
  310. {
  311. _targetTypeName = targetTypeName;
  312. }
  313. public IXamlType TargetType
  314. {
  315. get { return _provider.GetXamlTypeByName(_targetTypeName); }
  316. }
  317.  
  318. public void SetIsAttachable() { _isAttachable = true; }
  319. public bool IsAttachable { get { return _isAttachable; } }
  320.  
  321. public void SetIsDependencyProperty() { _isDependencyProperty = true; }
  322. public bool IsDependencyProperty { get { return _isDependencyProperty; } }
  323.  
  324. public void SetIsReadOnly() { _isReadOnly = true; }
  325. public bool IsReadOnly { get { return _isReadOnly; } }
  326.  
  327. public Getter Getter { get; set; }
  328. public object GetValue(object instance)
  329. {
  330. if (Getter != null)
  331. return Getter(instance);
  332. else
  333. throw new InvalidOperationException("GetValue");
  334. }
  335.  
  336. public Setter Setter { get; set; }
  337. public void SetValue(object instance, object value)
  338. {
  339. if (Setter != null)
  340. Setter(instance, value);
  341. else
  342. throw new InvalidOperationException("SetValue");
  343. }
  344. }
  345. }
  346.  
  347.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty