本文整理汇总了C#中Behaviac.Design.MethodDef类的典型用法代码示例。如果您正苦于以下问题:C# MethodDef类的具体用法?C# MethodDef怎么用?C# MethodDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodDef类属于Behaviac.Design命名空间,在下文中一共展示了MethodDef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCode
public static string GenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, bool isRefParam, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
{
if (property.IsPar || property.IsCustomized)
return ParInfoCsExporter.GenerateCode(property, isRefParam, stream, indent, typename, var, caller);
string agentName = GetGenerateAgentName(property, var, caller);
string prop = GetProperty(property, arrayIndexElement, stream, indent, var, caller);
if (!property.IsReadonly)
{
if (setValue == null)
{
if (!string.IsNullOrEmpty(var))
{
if (string.IsNullOrEmpty(typename))
{
stream.WriteLine("{0}{1} = {2};", indent, var, prop);
}
else
{
string nativeType = DataCsExporter.GetPropertyNativeType(property, arrayIndexElement);
stream.WriteLine("{0}{1} {2} = {3};", indent, nativeType, var, prop);
}
}
}
else
{
string propBasicName = property.BasicName.Replace("[]", "");
stream.WriteLine("{0}AgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, setValue);
}
}
return prop;
}
示例2: MetaMethodDialog
public MetaMethodDialog(AgentType agent, MethodDef method, MemberType memberType)
{
InitializeComponent();
this.Owner = MainWindow.Instance;
this.metaMethodPanel.Initialize(true, agent, method, memberType);
}
示例3: ResetMembers
public override bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method = null, PropertyDef property = null)
{
bool bReset = false;
if (this._frames != null)
{
bReset |= this._frames.ResetMembers(check, agentType, clear, method, property);
}
bReset |= base.ResetMembers(check, agentType, clear, method, property);
return bReset;
}
示例4: GetProperty
public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string var, string caller)
{
string agentName = GetGenerateAgentName(property, var, caller);
if (property.Owner != Behaviac.Design.VariableDef.kSelf)
{
string instanceName = property.Owner.Replace("::", ".");
stream.WriteLine("{0}behaviac.Agent {1} = behaviac.Utils.GetParentAgent(pAgent, \"{2}\");", indent, agentName, instanceName);
stream.WriteLine("{0}Debug.Check({1} != null || Utils.IsStaticClass(\"{2}\"));", indent, agentName, instanceName);
}
string prop = getProperty(property, arrayIndexElement, agentName, stream, indent);
return prop;
}
示例5: PostGenerateCode
public static void PostGenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
{
if (property.IsPar || property.IsCustomized)
{
ParInfoCsExporter.PostGenerateCode(property, arrayIndexElement, stream, indent, typename, var, caller);
return;
}
if (!property.IsReadonly)
{
string agentName = GetGenerateAgentName(property, var, caller);
string prop = setValue;
if (property.Owner != Behaviac.Design.VariableDef.kSelf)
{
stream.WriteLine("{0}behaviac.Agent {1} = behaviac.Agent.GetInstance(\"{2}\", pAgent.GetContextId());", indent, agentName, property.Owner.Replace("::", "."));
stream.WriteLine("{0}Debug.Check({1} != null);", indent, agentName);
}
string propBasicName = property.BasicName.Replace("[]", "");
if (setValue != null)
{
stream.WriteLine("{0}AgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, prop);
}
else
{
prop = getProperty(property, arrayIndexElement, agentName, stream, indent);
}
uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);
stream.WriteLine("{0}Debug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
if (string.IsNullOrEmpty(typename))
{
typename = property.NativeType;
}
typename = DataCsExporter.GetGeneratedNativeType(typename);
stream.WriteLine("{0}{1}.SetVariable<{2}>(\"{3}\", {4}, {5}u);", indent, agentName, typename, property.BasicName, prop, id);
}
}
示例6: GenerateCode
public static string GenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, bool isRefParam, StreamWriter stream, string indent, string typename, string var, string caller)
{
if (property.IsPar || property.IsCustomized)
return ParInfoCppExporter.GenerateCode(property, isRefParam, stream, indent, typename, var, caller);
string prop = GetProperty(property, arrayIndexElement, stream, indent, var, caller);
if (!string.IsNullOrEmpty(var))
{
if (string.IsNullOrEmpty(typename))
{
stream.WriteLine("{0}{1} = {2};", indent, var, prop);
}
else
{
stream.WriteLine("{0}{1} {2} = {3};", indent, DataCppExporter.GetGeneratedNativeType(property.NativeType), var, prop);
}
}
return prop;
}
示例7: LoadCustomMembers
//.........这里部分代码省略.........
if (string.IsNullOrEmpty(classname))
{ classname = agent.AgentTypeName; }
string propDisp = GetAttribute(propNode, "disp");
if (string.IsNullOrEmpty(propDisp))
{ propDisp = propName; }
string propDesc = GetAttribute(propNode, "desc");
PropertyDef prop = new PropertyDef(agent, type, classname, propName, propDisp, propDesc);
prop.IsStatic = bStatic;
prop.IsPublic = bPublic;
prop.IsReadonly = bReadonly;
string defaultValue = GetAttribute(propNode, "defaultvalue");
if (!string.IsNullOrEmpty(defaultValue)) {
prop.Variable = new VariableDef(null);
Plugin.InvokeTypeParser(result, type, defaultValue, (object value) => prop.Variable.Value = value, null);
}
agent.AddProperty(prop);
}
}
} else if (bbNode.Name == "methods") {
foreach(XmlNode methodNode in bbNode) {
if (methodNode.Name == "method") {
string methodName = GetAttribute(methodNode, "name");
Type returnType = Plugin.GetTypeFromName(GetAttribute(methodNode, "returntype"));
string isStatic = GetAttribute(methodNode, "static");
bool bStatic = false;
if (!string.IsNullOrEmpty(isStatic) && isStatic == "true")
{ bStatic = true; }
string isPublic = GetAttribute(methodNode, "public");
bool bPublic = false;
if (string.IsNullOrEmpty(isPublic) || isPublic == "true")
{ bPublic = true; }
string classname = GetAttribute(methodNode, "classname");
if (string.IsNullOrEmpty(classname))
{ classname = agent.AgentTypeName; }
string methodDisp = GetAttribute(methodNode, "disp");
if (string.IsNullOrEmpty(methodDisp))
{ methodDisp = methodName; }
string methodDesc = GetAttribute(methodNode, "desc");
bool istask = (GetAttribute(methodNode, "istask") == "true");
//bool isevent = (GetAttribute(methodNode, "isevent") == "true");
MemberType memberType = MemberType.Method;
if (istask) {
memberType = MemberType.Task;
}
methodName = string.Format("{0}::{1}", agent.AgentTypeName, methodName);
MethodDef method = new MethodDef(agent, memberType, classname, methodName, methodDisp, methodDesc, "", returnType);
method.IsStatic = bStatic;
method.IsPublic = bPublic;
agent.AddMethod(method);
foreach(XmlNode paramNode in methodNode) {
string paramName = GetAttribute(paramNode, "name");
Type paramType = Plugin.GetTypeFromName(GetAttribute(paramNode, "type"));
bool isOut = (GetAttribute(paramNode, "isout") == "true");
bool isRef = (GetAttribute(paramNode, "isref") == "true");
string nativeType = Plugin.GetNativeTypeName(paramType);
string paramDisp = GetAttribute(paramNode, "disp");
if (string.IsNullOrEmpty(paramDisp))
{ paramDisp = paramName; }
string paramDesc = GetAttribute(paramNode, "desc");
MethodDef.Param param = new MethodDef.Param(paramName, paramType, nativeType, paramDisp, paramDesc);
param.IsOut = isOut;
param.IsRef = isRef;
method.Params.Add(param);
}
}
}
}
}
}
}
}
示例8: getPrefixString
private string getPrefixString(MethodDef m)
{
if (m != null)
{
if (m.IsChangeableType)
return (m.ReturnType == typeof(object)) ? Empty_Type_Str : Changeable_Type_Str;
if (m.IsCustomized)
return Customized_Str;
}
return Member_Str;
}
示例9: GetProperty
public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent)
{
string retStr = string.Empty;
if (property != null)
{
string typename = DataCppExporter.GetGeneratedNativeType(property.NativeType);
if (!typename.EndsWith("*") && Plugin.IsRefType(property.Type))
{
typename += "*";
}
if (property.IsArrayElement && !typename.StartsWith("behaviac::vector<"))
{
typename = string.Format("behaviac::vector<{0} >", typename);
}
string propBasicName = property.BasicName.Replace("[]", "");
uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);
stream.WriteLine("{0}BEHAVIAC_ASSERT(behaviac::MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
retStr = string.Format("({0}&)pAgent->GetVariable<{0} >({1}u)", typename, id);
}
return retStr;
}
示例10: GetProperty
public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent)
{
string retStr = string.Empty;
if (property != null)
{
string typename = DataCsExporter.GetGeneratedNativeType(property.NativeType);
if (property.IsArrayElement && !typename.StartsWith("List<"))
{
typename = string.Format("List<{0}>", typename);
}
string propBasicName = property.BasicName.Replace("[]", "");
uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);
//stream.WriteLine("{0}Debug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
retStr = string.Format("({0})pAgent.GetVariable({1}u)", typename, id);
}
return retStr;
}
示例11: checkMembersInWorkspace
private bool checkMembersInWorkspace(AgentType agentType, bool clear, MethodDef method, PropertyDef property)
{
foreach(Nodes.BehaviorNode behavior in getAllBehaviors(property)) {
if (behavior != null && behavior is Nodes.Node) {
bool bReset = ((Nodes.Node)behavior).ResetMembers(true, agentType, clear, method, property);
if (bReset)
return DialogResult.Yes == MessageBox.Show(Resources.ModifyMemberWarning, Resources.Warning, MessageBoxButtons.YesNo);
}
}
return true;
}
示例12: ResetMembers
public bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method, PropertyDef property)
{
bool bReset = false;
if (method != null)
{
if (method.OldName == this.Name)
{
bReset = true;
if (!check)
{
this.CopyFrom(method);
}
}
}
else if (property != null)
{
foreach (MethodDef.Param param in this.Params)
{
if (param.Value is VariableDef)
{
VariableDef var = param.Value as VariableDef;
bReset |= var.ResetMembers(check, agentType, clear, property);
}
else if (param.Value is ParInfo)
{
ParInfo par = param.Value as ParInfo;
if (property.IsPar && (property.OldName == par.Name ||
!property.IsArrayElement && par.IsArrayElement && (property.OldName + "[]") == par.Name))
{
if (clear || this.ShouldBeCleared(agentType))
{
bReset = true;
if (!check)
{ param.Value = Plugin.DefaultValue(param.Type); }
}
else
{
bReset = true;
if (!check)
{
bool isArrayElement = par.IsArrayElement;
par.CopyFrom(property);
if (isArrayElement)
{ par.SetArrayElement(property); }
}
}
}
}
}
}
return bReset;
}
示例13: GetProperty
public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string var, string caller)
{
string agentName = GetGenerateAgentName(property, var, caller);
if (property.Owner != Behaviac.Design.VariableDef.kSelf)
{
stream.WriteLine("{0}Agent* {1} = Agent::GetInstance(pAgent, \"{2}\");", indent, agentName, property.Owner);
stream.WriteLine("{0}BEHAVIAC_ASSERT({1});", indent, agentName);
}
string prop = getProperty(property, arrayIndexElement, agentName, stream, indent);
return prop;
}
示例14: MethodDef
public MethodDef(MethodDef other)
{
CopyFrom(other);
}
示例15: GetPropertyBasicName
public static string GetPropertyBasicName(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement)
{
string propName = property.BasicName;
if (property != null && property.IsArrayElement && arrayIndexElement != null)
{
propName = propName.Replace("[]", "");
}
return propName;
}