本文整理汇总了C#中Script.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Script.GetType方法的具体用法?C# Script.GetType怎么用?C# Script.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Script
的用法示例。
在下文中一共展示了Script.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mechanics_UnitKilled
void Mechanics_UnitKilled(Unit obj, Unit perp, Script script)
{
if(Units.IsInGroup(obj))
{
if (Ability != null && Ability.IsAssignableFrom(script.GetType()))
KilledWithAbilityScript.TryStartPerform();
else
{
if(KilledWithOtherAbilityScript != null)
KilledWithOtherAbilityScript.TryStartPerform();
}
nUsed++;
if (NUses >= 0 && nUsed >= NUses)
TryEndPerform(false);
}
}
示例2: EntityScriptReference
public EntityScriptReference(Script script)
{
Id = script.Id;
Entity = script.Entity;
ScriptType = script.GetType();
}
示例3: Populate
public void Populate(Script script)
{
foreach (ScriptProperty scriptProperty in this.scriptProperties.Values)
script.GetType().GetField(scriptProperty.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(script, scriptProperty.Value);
}
示例4: Merge
public void Merge(Script script)
{
Dictionary<ScriptPropertyKey, FieldInfo> dictionary1 = new Dictionary<ScriptPropertyKey, FieldInfo>();
Dictionary<string, FieldInfo> dictionary2 = new Dictionary<string, FieldInfo>();
foreach (FieldInfo fieldInfo in script.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if ((fieldInfo.FieldType.IsValueType || fieldInfo.FieldType.IsEnum || fieldInfo.FieldType == typeof(string)) && fieldInfo.GetCustomAttributes(typeof(ParameterAttribute), true).Length > 0)
{
dictionary1.Add(new ScriptPropertyKey(fieldInfo.Name, fieldInfo.FieldType), fieldInfo);
if (fieldInfo.FieldType.IsEnum)
dictionary2[fieldInfo.Name] = fieldInfo;
}
}
List<ScriptPropertyKey> list = new List<ScriptPropertyKey>();
foreach (ScriptPropertyKey key in this.scriptProperties.Keys)
{
if (!dictionary1.ContainsKey(key))
list.Add(key);
}
foreach (ScriptPropertyKey key in list)
{
ScriptProperty scriptProperty = this.scriptProperties[key];
if ((scriptProperty.Type == (Type)null || scriptProperty.Type.IsEnum) && dictionary2.ContainsKey(scriptProperty.Name))
{
FieldInfo fieldInfo = dictionary2[scriptProperty.Name];
if (fieldInfo != (FieldInfo)null && Enum.IsDefined(fieldInfo.FieldType, scriptProperty.Value.ToString()))
{
scriptProperty.Type = fieldInfo.FieldType;
scriptProperty.Value = Enum.Parse(fieldInfo.FieldType, scriptProperty.Value.ToString());
this.scriptProperties.Add(new ScriptPropertyKey(scriptProperty.Name, scriptProperty.Type), scriptProperty);
}
}
this.scriptProperties.Remove(key);
}
foreach (KeyValuePair<ScriptPropertyKey, FieldInfo> keyValuePair in dictionary1)
{
ScriptProperty scriptProperty;
if (this.scriptProperties.ContainsKey(keyValuePair.Key))
{
scriptProperty = this.scriptProperties[keyValuePair.Key];
}
else
{
scriptProperty = this.CreateProperty(keyValuePair.Value, script);
this.scriptProperties.Add(new ScriptPropertyKey(scriptProperty.Name, scriptProperty.Type), scriptProperty);
}
this.UpdateValue(scriptProperty, keyValuePair.Value.GetValue(script));
this.UpdateAttributes(keyValuePair.Value, scriptProperty);
}
}
示例5: Generate
public void Generate(ScriptContext context, TextWriter codeStream, Script script, GeneratorOptions options)
{
Compiler.AddHeaders("using XS = " + typeof(Script).Namespace + ";");
ScriptContext sv = new ScriptContext();
sv["main"]= ((options & GeneratorOptions.CreateMain) != 0) ? genMain() : string.Empty;
sv["assembly"] = genAssemblyInfo(context, script, options);
sv["namespace"] = Namespace;
sv["class"] = Class;
sv["src"] = script.Location;
sv["date"] = DateTime.Now.ToString();
sv["version"] = context.CoreVersion.ToString();
sv["script"] = Compiler.GetTypeName(script.GetType());
sv["callIsolation"] = Compiler.GetTypeName(typeof (CallIsolation));
sv["iscriptaction"] = Compiler.GetTypeName(typeof (IScriptAction));
sv["usings"] = Compiler.GenerateFileHeader(true,false,false);
sv["headers"] = Compiler.GenerateFileHeader(false,true,false);
sv["context"] = Compiler.GetTypeName(context.GetType());
using (StringWriter swCode = new StringWriter())
using (StringWriter swSnippets = new StringWriter())
using (new ScriptContextScope(context))
{
Generator c = new Generator(Compiler, swCode, swSnippets, options);
c.GenerateObjectCode(script, "_script", 3);
sv["snippets-code"] = swSnippets.ToString();
sv["script-code"] = swCode.ToString();
}
using (MemoryStream ms = AppDomainLoader.TryLoadResourceStream("XSharper.Embedded.Source.SourceTemplate"))
using (var sr = new StreamReader(ms))
codeStream.Write(sv.ExpandStr(sr.ReadToEnd()));
}