本文整理汇总了C#中Globals.AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Globals.AddProperty方法的具体用法?C# Globals.AddProperty怎么用?C# Globals.AddProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Globals
的用法示例。
在下文中一共展示了Globals.AddProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
protected void Parse(StringReader rdr, DepthScanner scanner, Globals globals)
{
int currentLine = 0;
ParseNamespace(rdr, globals, scanner, ref currentLine, false);
// Resolve incomplete names
foreach (string key in globals.GetPropertyNames())
{
TypeInfo t = globals.GetProperty(key, true) as TypeInfo;
if (t != null)
{
if (!t.IsComplete)
globals.AddProperty(key, globals.GetTypeInfo(t.Name), -1, "");
if (t is TemplateInst)
{
TemplateInst ti = t as TemplateInst;
if (!ti.WrappedType.IsComplete)
ti.WrappedType = globals.GetTypeInfo(ti.WrappedType.Name);
}
}
}
foreach (FunctionInfo f in globals.GetFunctions(null, true))
{
f.ResolveIncompletion(globals);
}
foreach (TypeInfo type in globals.TypeInfo)
{
type.ResolveIncompletion(globals);
}
}
示例2: ParseNamespace
//.........这里部分代码省略.........
{
int abstractIdx = Array.IndexOf(tokens, "abstract");
int sharedIdx = Array.IndexOf(tokens, "shared");
int templateIdx = Array.IndexOf(tokens, "template");
int mixinIdx = Array.IndexOf(tokens, "mixin");
int finalIdx = Array.IndexOf(tokens, "final");
int classTermIdx = Math.Max(abstractIdx, Math.Max(sharedIdx, Math.Max(templateIdx, Math.Max(mixinIdx, finalIdx)))) + 1;
bool isInterface = tokens[classTermIdx].Equals("interface");
if (templateIdx != -1)
{
//Resolve template type?
}
string className = tokens[classTermIdx + 1];
TypeInfo ti = new TypeInfo { Name = className,
IsTemplate = templateIdx != -1, IsShared = sharedIdx != -1,
IsAbstract = abstractIdx != -1, IsMixin = mixinIdx != -1,
IsInterface = isInterface,
SourceLine = lineNumber, SourceFile = defName };
// Get any baseclasses, baseclass must appear first
for (int i = classTermIdx + 2; i < tokens.Length; ++i)
{
string baseName = tokens[i];
if (globals.ContainsTypeInfo(baseName.Replace(",","")))
ti.BaseTypes.Add(globals.GetTypeInfo(baseName.Replace(",","")));
}
ParseClass(rdr, globals, scanner, ti, ref currentLine);
globals.AddTypeInfo(className, ti);
}
else if (tokens[0].ToLower().Equals("namespace")) // Namespace
{
string nsName = tokens[1];
Globals namespaceGlobals = null;
if (globals.ContainsNamespace(nsName)) // Check if the namespace has been encountered before
namespaceGlobals = globals.GetNamespace(nsName);
else
namespaceGlobals = new Globals(false);
namespaceGlobals.Parent = globals;
ParseNamespace(rdr, namespaceGlobals, scanner, ref currentLine, true);
namespaceGlobals.Name = nsName;
globals.AddNamespace(nsName, namespaceGlobals);
}
else if (tokens[0].ToLower().Equals("enum")) // Enumeration
{
ParseEnum(line, rdr, globals, ref currentLine);
}
else
{
if (ResemblesFunction(line)) // Global/namespace function
{
try
{
FunctionInfo fi = _parseFunction(rdr, line, globals, lineNumber, defName);
if (fi != null)
globals.AddFunction(fi);
}
catch (Exception ex) { }
}
else if (ResemblesProperty(line, globals)) // Global/namespace property
{
string[] parts = l.Replace(";", "").Split(BREAKCHARS);
// Globals can't be private/protected
int constIdx = Array.IndexOf(parts, "const");
int uniformIdx = Array.IndexOf(parts, "uniform");
int termIdx = Math.Max(constIdx, uniformIdx) + 1;
if (parts[termIdx].Contains('<'))
{
string templateType = parts[termIdx].Substring(0, parts[termIdx].IndexOf('<'));
string containedType = parts[termIdx].Extract('<', '>');
TypeInfo wrapped = globals.GetTypeInfo(containedType);
TemplateInst ti = new TemplateInst() { Name = templateType, IsTemplate = true, WrappedType = wrapped != null ? wrapped : new TypeInfo { Name = containedType, IsComplete = false, SourceLine = lineNumber, SourceFile = defName } };
globals.AddProperty(parts[termIdx + 1], ti, lineNumber, defName);
//if (constIdx != -1)
// globals.ReadonlyProperties.Add(tokens[termIdx + 1]);
}
else
{
string pname = parts[termIdx].EndsWith("@") ? parts[termIdx].Substring(0, parts[termIdx].Length - 1) : parts[termIdx]; //handle
if (pname.Length == 0)
continue;
TypeInfo pType = null;
if (globals.ContainsTypeInfo(pname))
pType = globals.GetTypeInfo(pname);
if (pType == null)
{ //create temp type to resolve later
pType = new TypeInfo() { Name = pname, IsComplete = false, SourceLine = lineNumber, SourceFile = defName };
}
globals.AddProperty(parts[termIdx + 1], pType, lineNumber, defName);
//if (constIdx != -1)
// globals.ReadonlyProperties.Add(tokens[termIdx + 1]);
}
}
}
}
}