using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.MachineStudio.Common.Notifications;
namespace Tango.MachineStudio.DB.ViewModels
{
public class MediaConditionsViewVM : DbTableViewModel<MediaCondition>
{
public MediaConditionsViewVM(INotificationProvider notification) : base(notification)
{
}
}
}
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace Tango.Scripting.Editors.Intellisense
{
public static class Utils
{
public static String DotNetFrameworkDocsFolder = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X";
private static Dictionary<Assembly, XmlDocument> _assemblies_docs_cache;
static Utils()
{
_assemblies_docs_cache = new Dictionary<Assembly, XmlDocument>();
}
public static void LoadKnownTypeDocs(KnownType knownType)
{
XmlDocument xmlDoc = null;
if (_assemblies_docs_cache.ContainsKey(knownType.Type.Assembly))
{
xmlDoc = _assemblies_docs_cache[knownType.Type.Assembly];
}
if (xmlDoc == null)
{
String dllPath = knownType.Type.Assembly.Location;
string docuPath = dllPath.Substring(0, dllPath.LastIndexOf(".")) + ".XML";
if (File.Exists(docuPath))
{
xmlDoc = new XmlDocument();
xmlDoc.Load(docuPath);
}
else if (File.Exists(System.IO.Path.Combine(DotNetFrameworkDocsFolder, System.IO.Path.GetFileName(docuPath))))
{
xmlDoc = new XmlDocument();
xmlDoc.Load(System.IO.Path.Combine(DotNetFrameworkDocsFolder, System.IO.Path.GetFileName(docuPath)));
}
if (xmlDoc != null)
{
_assemblies_docs_cache.Add(knownType.Type.Assembly, xmlDoc);
}
}
if (xmlDoc == null)
{
xmlDoc = new XmlDocument();
}
//Load Type Summary
{
string path = "T:" + knownType.Type.FullName;
XmlNode xmlDocuOfType = xmlDoc.SelectSingleNode("//member[starts-with(@name, '" + path + "')]");
if (xmlDocuOfType != null)
{
XmlNode summaryNode = xmlDocuOfType.SelectSingleNode("summary");
knownType.Summary = summaryNode.InnerText;
}
}
//Load Constructors...
{
string path = "M:" + knownType.Type.FullName + ".#ctor";
var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
for (int i = 0; i < knownType.Constructors.Count; i++)
{
var constructor = knownType.Constructors[i];
XmlNode cDoc = null;
if (i < docNodes.Count)
{
cDoc = docNodes[i];
}
constructor.Summary = cDoc != null ? cDoc.SelectSingleNode("summary").InnerXml : $"Initializes a new instance of {knownType.FriendlyName}.";
var parameters = constructor.Parameters.ToList();
var parametersNodes = cDoc != null ? cDoc.SelectNodes("param").OfType<XmlNode>().ToList() : new List<XmlNode>();
for (int j = 0; j < parameters.Count; j++)
{
var parameter = parameters[j];
XmlNode pNode = null;
if (j < parametersNodes.Count)
{
pNode = parametersNodes[j];
}
parameter.Description = pNode != null ? pNode.InnerText : null;
}
}
}
//Load Methods...
{
string path = "M:" + knownType.Type.FullName;
var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
for (int i = 0; i < knownType.Methods.Count; i++)
{
var method = knownType.Methods[i];
XmlNode mDoc = null;
mDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(knownType.Type.Name + "." + method.Name));
method.Summary = mDoc != null ? mDoc.SelectSingleNode("summary").InnerXml.Remove("(<see cref=\".:)|(\" \\/>)") : "No documentation";
var parameters = method.Parameters.ToList();
var parametersNodes = mDoc != null ? mDoc.SelectNodes("param").OfType<XmlNode>().ToList() : new List<XmlNode>();
bool isLinq = knownType.Type == typeof(Enumerable);
for (int j = 0; j < parameters.Count; j++)
{
var parameter = parameters[j];
XmlNode pNode = null;
if (j < parametersNodes.Count)
{
pNode = parametersNodes[j];
}
parameter.Description = pNode != null ? pNode.InnerText.Remove("(<see cref=\".:)|(\" \\/>)") : null;
}
}
}
//Load Properties
{
string path = "P:" + knownType.Type.FullName;
var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
for (int i = 0; i < knownType.Properties.Count; i++)
{
var property = knownType.Properties[i];
var pDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(knownType.Type.Name + "." + property.Name));
if (pDoc != null)
{
var summaryNode = pDoc.SelectSingleNode("summary");
property.Summary = summaryNode != null ? summaryNode.InnerXml : "No documentation";
}
}
}
//Load Enum Values
{
if (knownType.Type.IsEnum)
{
for (int i = 0; i < knownType.Fields.Count; i++)
{
var field = knownType.Fields[i];
var pDoc = xmlDoc.SelectSingleNode("//member[starts-with(@name, '" + $"F:{knownType.Type.FullName}.{field.Name}" + "')]");
if (pDoc != null)
{
var summaryNode = pDoc.SelectSingleNode("summary");
field.Summary = summaryNode != null ? summaryNode.InnerXml : "No documentation";
}
}
}
}
}
}
}