public void Init() { Influences = new InfluenceTable(); if (levelUpKindID == null || levelUpKindID.Count == 0) { levelUpKindID = new List <int>(); } else { } titleInfluence = -1; // morphToKindId = -1; AICreateArchitectureConditionWeight = new Dictionary <Condition, float>(); AIUpgradeArchitectureConditionWeight = new Dictionary <Condition, float>(); AIUpgradeLeaderConditionWeight = new Dictionary <Condition, float>(); AILeaderConditionWeight = new Dictionary <Condition, float>(); CreateConditions = new ConditionTable(); Persons = new PersonList(); }
public void Init() { CastConditions = new ConditionTable(); Influences = new InfluenceTable(); AIConditionWeightSelf = new Dictionary <Condition, float>(); AIConditionWeightEnemy = new Dictionary <Condition, float>(); }
public void Init() { AIConditions = new ConditionTable(); CastConditions = new ConditionTable(); Influences = new InfluenceTable(); LearnConditions = new ConditionTable(); GenerateConditions = new ConditionTable(); }
public void Init() { Conditions = new ConditionTable(); LoseConditions = new ConditionTable(); Influences = new InfluenceTable(); ArchitectureConditions = new ConditionTable(); FactionConditions = new ConditionTable(); GenerateConditions = new ConditionTable(); Persons = new PersonList(); }
public void Init() { Influences = new InfluenceTable(); levelUpKindID = new List <int>(); titleInfluence = -1; morphToKindId = -1; AICreateArchitectureConditionWeight = new Dictionary <Condition, float>(); AIUpgradeArchitectureConditionWeight = new Dictionary <Condition, float>(); AIUpgradeLeaderConditionWeight = new Dictionary <Condition, float>(); AILeaderConditionWeight = new Dictionary <Condition, float>(); CreateConditions = new ConditionTable(); Persons = new PersonList(); }
public void Init() { Conditions = new ConditionTable(); Influences = new InfluenceTable(); GenerateConditions = new ConditionTable(); }
public void Init() { Influences = new InfluenceTable(); Conditions = new ConditionTable(); AIBuildConditionWeight = new Dictionary <Condition, float>(); }
public void Init() { Influences = new InfluenceTable(); }
private void CreateMethod(Type aType, Classifier aCls, MethodBase aMethod, PdOOM.BasePackage aPckg, Operation anOper, InfluenceTable anInfTable) { Operation operation; if (anOper != null) { operation = anOper; } else { operation = (Operation) aCls.CreateObject(0x18112066, "", -1, true); } operation.Static = aMethod.IsStatic; operation.Visibility = GetMethodVisibility(aMethod); operation.Final = aMethod.IsFinal; if (aMethod.IsGenericMethod) { operation.Generic = true; foreach (TypeParameter parameter in operation.TypeParameters) { parameter.delete(); } foreach (Type type in aMethod.GetGenericArguments()) { TypeParameter parameter2 = (TypeParameter) operation.CreateObject(0x1811207d, "", -1, true); this.ProcessType(type, false); TypeMapping mapping = TypeMapping.Retrieve(type); parameter2.Name = parameter2.Code = mapping.Name; operation.TypeParameters.Add(parameter2); } } if (aMethod.IsVirtual) { if (LZ.Reverse.Info._bVBNet) { operation.SetExtendedAttribute("VB.NET.Overridable", "true"); } else { operation.SetExtendedAttribute("C#.virtual", "true"); } } if (aMethod.IsAbstract) { operation.Abstract = true; } new CustomHandlerMethod(aMethod, operation).Convert(); if (anOper == null) { foreach (ParameterInfo info in aMethod.GetParameters()) { this.AddParameter(operation, info, aPckg); } } bool flag = aMethod.IsConstructor || aMethod.GetType().IsSubclassOf(typeof(ConstructorInfo)); if (!flag) { MethodInfo info2 = (MethodInfo) aMethod; Type returnType = info2.ReturnType; if (returnType.IsArray) { operation.Array = true; returnType = returnType.GetElementType(); } this.ProcessType(returnType, false); TypeMapping mapping2 = TypeMapping.Retrieve(returnType); if (mapping2.HasClassifier()) { PdOOM.BaseObject obj2 = ProperRef.Link(NamespaceMapping.Retrieve(aPckg), mapping2); operation.UseQualifiedDataType = false; operation.ReturnTypeObject = obj2; } else { operation.ReturnType = mapping2.Name; } if ((anInfTable != null) && anInfTable.Contains(info2)) { anInfTable.Impact(info2, operation); } if (LZ.Reverse.Info._bVBNet) { new CustomHandlerReturn(info2, anOper).Convert(); } bool flag2 = false; if (!info2.IsHideBySig && info2.GetBaseDefinition().Equals(info2)) { string name = info2.Name; if (!aType.BaseType.Equals(aType)) { BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly; bool flag3 = false; foreach (MethodInfo info3 in aType.GetMethods(bindingAttr)) { if (info3.Name == name) { flag3 = true; break; } } if (flag3) { flag2 = true; } } } if (info2.GetBaseDefinition().Equals(info2)) { if (flag2) { if (LZ.Reverse.Info._bVBNet) { operation.SetExtendedAttribute("VB.NET.Shadowing", "Shadows"); } else { operation.SetExtendedAttribute("C#.new", "true"); } } else if (aMethod.IsHideBySig && LZ.Reverse.Info._bVBNet) { operation.SetExtendedAttribute("VB.NET.Shadowing", "Overloads"); } } else if (LZ.Reverse.Info._bVBNet) { operation.SetExtendedAttribute("VB.NET.Overrides", "true"); } else { operation.SetExtendedAttribute("C#.override", "true"); } } if (flag) { operation.Stereotype = "Constructor"; operation.ReturnType = ""; operation.InfluentObject = aCls; operation.Automatic = true; try { if (LZ.Reverse.Info._bVBNet) { operation.Name = operation.Code = "New"; } else { operation.Name = operation.Code = TypeInfoHelper.GetTypeName(aType); } return; } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the operation \"{1}\" on the type \"{0}\"", aType.FullName, aMethod.Name }); } return; } } if (anOper == null) { string aName = aMethod.Name; if (!LZ.Reverse.Info._bVBNet && ShortenOperator(aMethod.GetParameters().Length, ref aName)) { operation.Stereotype = "Operator"; } try { operation.Name = operation.Code = aName; } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the operation \"{1}\" on the type \"{0}\"", aType.FullName, aMethod.Name }); } } } }
private void AddClassifier(Type aType, bool bComplete) { bool bCreate = true; if (aType.IsGenericType && !aType.IsGenericTypeDefinition) { aType = aType.GetGenericTypeDefinition(); } TypeMapping mapping = TypeMapping.Retrieve(aType, ref bCreate); if (bCreate || bComplete) { PdOOM.BasePackage package; Classifier classifier; if (bCreate) { bool flag2; PdOOM.NamedObject container = this.GetContainer(aType, out flag2); if (flag2) { package = (PdOOM.BasePackage) container; } else { package = NamespaceMapping.RetrieveFromChildName(TypeInfoHelper.GetTypeNamespace(aType)).Package; } int kind = aType.IsInterface ? 0x18112064 : 0x18112063; classifier = (Classifier) container.CreateObject(kind, "", -1, true); mapping.Classifier = classifier; try { classifier.Name = classifier.Code = TypeInfoHelper.GetTypeName(aType); } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the type \"{0}\"", TypeInfoHelper.GetTypeFullName(aType) }); } } classifier.Visibility = GetTypeVisibility(aType); if (aType.IsSealed) { classifier.Final = true; } if (aType.IsClass && aType.IsAbstract) { classifier.Abstract = true; } if (aType.IsGenericType && ((aType.IsInterface || aType.IsClass) || aType.IsValueType)) { foreach (TypeParameter parameter in classifier.TypeParameters) { parameter.delete(); } Type[] genericArguments = aType.GetGenericArguments(); for (int i = 0; i < genericArguments.Length; i++) { TypeParameter parameter2 = (TypeParameter) classifier.CreateObject(0x1811207d, "", -1, true); parameter2.Name = parameter2.Code = TypeInfoHelper.GetTypeName(genericArguments[i]); classifier.TypeParameters.Add(parameter2); } classifier.Generic = true; classifier.Name = classifier.Code = TypeInfoHelper.GetTypeName(aType); } if (aType.IsValueType) { classifier.Stereotype = "structure"; } if (!bComplete) { return; } } else { classifier = mapping.Classifier; package = NamespaceMapping.RetrieveFromChildName(TypeInfoHelper.GetTypeNamespace(aType)).Package; } mapping.Complete = true; new CustomHandlerType(aType, classifier).Convert(); if (((aType.BaseType != null) && (aType.BaseType != typeof(object))) && (!aType.IsValueType || (aType.BaseType != typeof(ValueType)))) { this.CreateGeneralization(classifier, aType.BaseType, package); } Hashtable hashtable = new Hashtable(); if (aType.BaseType != null) { foreach (Type type2 in aType.BaseType.GetInterfaces()) { if (!hashtable.Contains(type2)) { hashtable.Add(type2, null); } } } foreach (Type type3 in aType.GetInterfaces()) { foreach (Type type4 in type3.GetInterfaces()) { if (!hashtable.Contains(type4)) { hashtable.Add(type4, null); } } } foreach (Type type5 in aType.GetInterfaces()) { if (!hashtable.Contains(type5)) { if (aType.IsInterface) { this.CreateGeneralization(classifier, type5, package); } else { this.CreateRealization(classifier, type5, package); } } } AttributeTable aAttrTable = new AttributeTable(); MethodTable aTable = new MethodTable(); InfluenceTable aInfTable = new InfluenceTable(); BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (PropertyInfo info in aType.GetProperties(bindingAttr)) { this.CreateProperty(aType, classifier, info, package, ref aTable); } bindingAttr = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (PropertyInfo info2 in aType.GetProperties(bindingAttr)) { this.CreateProperty(aType, classifier, info2, package, ref aTable); } bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (EventInfo info3 in aType.GetEvents(bindingAttr)) { this.CreateEvent(aType, classifier, info3, package, ref aAttrTable, ref aTable, ref aInfTable); } bindingAttr = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (EventInfo info4 in aType.GetEvents(bindingAttr)) { this.CreateEvent(aType, classifier, info4, package, ref aAttrTable, ref aTable, ref aInfTable); } bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (FieldInfo info5 in aType.GetFields(bindingAttr)) { if (!aAttrTable.Contains(info5)) { this.CreateAttribute(aType, classifier, info5, package); } } bindingAttr = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (FieldInfo info6 in aType.GetFields(bindingAttr)) { if (!aAttrTable.Contains(info6)) { this.CreateAttribute(aType, classifier, info6, package); } } bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (ConstructorInfo info7 in aType.GetConstructors(bindingAttr)) { this.CreateMethod(aType, classifier, info7, package, null, null); } foreach (MethodInfo info8 in aType.GetMethods(bindingAttr)) { if (!aTable.Contains(info8)) { this.CreateMethod(aType, classifier, info8, package, null, aInfTable); } } bindingAttr = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (ConstructorInfo info9 in aType.GetConstructors(bindingAttr)) { this.CreateMethod(aType, classifier, info9, package, null, null); } foreach (MethodInfo info10 in aType.GetMethods(bindingAttr)) { if (!aTable.Contains(info10)) { this.CreateMethod(aType, classifier, info10, package, null, aInfTable); } } Hashtable hashtable2 = new Hashtable(); bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (Type type6 in aType.GetNestedTypes(bindingAttr)) { if (!hashtable2.Contains(type6)) { hashtable2.Add(type6, type6); this.ProcessType(type6, true); } } bindingAttr = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; if (this._bAllTypes) { bindingAttr |= BindingFlags.NonPublic; } foreach (Type type7 in aType.GetNestedTypes(bindingAttr)) { if (!hashtable2.Contains(type7)) { hashtable2.Add(type7, type7); this.ProcessType(type7, true); } } } }
private void CreateEvent(Type aType, Classifier aCls, EventInfo anEvent, PdOOM.BasePackage aPckg, ref AttributeTable aAttrTable, ref MethodTable aMthTable, ref InfluenceTable aInfTable) { if (!LZ.Reverse.Info._bVBNet) { bool flag; bool flag2; if (aType.GetField(anEvent.Name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly) != null) { flag = false; flag2 = false; } else { flag = true; flag2 = true; } if (flag) { PdOOM.Attribute anObject = (PdOOM.Attribute) aCls.CreateObject(0x18112065, "", -1, true); anObject.Stereotype = "Event"; try { anObject.Name = anObject.Code = anEvent.Name; } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the event \"{1}\" on the type \"{0}\"", aType.FullName, anEvent.Name }); } } Type eventHandlerType = anEvent.EventHandlerType; this.ProcessType(eventHandlerType, false); TypeMapping mapping = TypeMapping.Retrieve(eventHandlerType); anObject.DataType = mapping.Name; if (!mapping.Delegate && LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** invalid delegate mapping for \"{0}\"", eventHandlerType.FullName }); } MethodInfo addMethod = anEvent.GetAddMethod(true); anObject.Visibility = GetMethodVisibility(addMethod); if (flag2) { aInfTable.Add(addMethod, anObject, "EventAdd"); addMethod = anEvent.GetRemoveMethod(true); aInfTable.Add(addMethod, anObject, "EventRemove"); } } if (!flag2) { MethodInfo aMethod = anEvent.GetAddMethod(true); aMthTable.Add(aMethod); aMethod = anEvent.GetRemoveMethod(true); aMthTable.Add(aMethod); } } }
private void AddClassifier(TypeInfo aType, bool bComplete) { bool bCreate = true; TypeMapping mapping = TypeMapping.Retrieve(aType, ref bCreate); #region Add classifier if (bCreate || bComplete) { PdOOM.BasePackage package = null; Classifier classifier; if (bCreate) { bool flag2; PdOOM.NamedObject container = this.GetContainer(aType, out flag2); if (flag2) { package = (PdOOM.BasePackage)container; } else { //package = NamespaceMapping.RetrieveFromChildName(TypeInfoHelper.GetTypeNamespace(aType)).Package; } int kind = 0x18112063; // aType.IsInterface ? 0x18112064 : 0x18112063; classifier = (Classifier)container.CreateObject(kind, "", -1, true); mapping.Classifier = classifier; try { classifier.Name = classifier.Code = aType.Code; // TypeInfoHelper.GetTypeName(aType); } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the type \"{0}\"", /*TypeInfoHelper.GetTypeFullName(aType)*/aType.Code }); } } classifier.Visibility = GetTypeVisibility(aType.Modifier); if (aType.IsClass && aType.IsAbstract) { classifier.Abstract = true; } ////if (aType.IsGenericType && ((aType.IsInterface || aType.IsClass) || aType.IsValueType)) ////{ //// foreach (TypeParameter parameter in classifier.TypeParameters) //// { //// parameter.delete(); //// } //// Type[] genericArguments = aType.GetGenericArguments(); //// for (int i = 0; i < genericArguments.Length; i++) //// { //// TypeParameter parameter2 = (TypeParameter)classifier.CreateObject(0x1811207d, "", -1, true); //// parameter2.Name = parameter2.Code = TypeInfoHelper.GetTypeName(genericArguments[i]); //// classifier.TypeParameters.Add(parameter2); //// } //// classifier.Generic = true; //// classifier.Name = classifier.Code = TypeInfoHelper.GetTypeName(aType); ////} if (aType.IsValueType) { classifier.Stereotype = "structure"; } if (!bComplete) { return; } } else { classifier = mapping.Classifier; //package = NamespaceMapping.RetrieveFromChildName(TypeInfoHelper.GetTypeNamespace(aType)).Package; } mapping.Complete = true; ////new CustomHandlerType(aType, classifier).Convert(); ////if (((aType.BaseType != null) && (aType.BaseType != typeof(object))) && (!aType.IsValueType || (aType.BaseType != typeof(ValueType)))) ////{ //// this.CreateGeneralization(classifier, aType.BaseType, package); ////} ////Hashtable hashtable = new Hashtable(); ////if (aType.BaseType != null) ////{ //// foreach (Type type2 in aType.BaseType.GetInterfaces()) //// { //// if (!hashtable.Contains(type2)) //// { //// hashtable.Add(type2, null); //// } //// } ////} ////foreach (Type type3 in aType.GetInterfaces()) ////{ //// foreach (Type type4 in type3.GetInterfaces()) //// { //// if (!hashtable.Contains(type4)) //// { //// hashtable.Add(type4, null); //// } //// } ////} ////foreach (Type type5 in aType.GetInterfaces()) ////{ //// if (!hashtable.Contains(type5)) //// { //// if (aType.IsInterface) //// { //// this.CreateGeneralization(classifier, type5, package); //// } //// else //// { //// this.CreateRealization(classifier, type5, package); //// } //// } ////} AttributeTable aAttrTable = new AttributeTable(); MethodTable aTable = new MethodTable(); InfluenceTable aInfTable = new InfluenceTable(); foreach (AttributeInfo ai in aType.Attributes) { //if (!aAttrTable.Contains(info5)) { this.CreateAttribute(aType, classifier, ai, package); } } foreach (MethordInfo mi in aType.Methords) { //if (!aAttrTable.Contains(info5)) { this.CreateMethod(aType, classifier, mi, package, null, aInfTable); } } } #endregion Add classifier }
private void AddClassifier(TypeInfo aType, bool bComplete) { bool bCreate = true; TypeMapping mapping = TypeMapping.Retrieve(aType, ref bCreate); if (bCreate || bComplete) { PdOOM.BasePackage package = null; Classifier classifier; if (bCreate) { bool flag2; PdOOM.NamedObject container = this.GetContainer(aType, out flag2); if (flag2) { package = (PdOOM.BasePackage)container; } else { package = NamespaceMapping.RetrieveFromChildName("").Package; } int kind = 0x18112063; // aType.IsInterface ? 0x18112064 : 0x18112063; classifier = (Classifier)container.CreateObject(kind, "", -1, true); mapping.Classifier = classifier; try { classifier.Name = classifier.Code = aType.Code; // TypeInfoHelper.GetTypeName(aType); } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the type \"{0}\"", /*TypeInfoHelper.GetTypeFullName(aType)*/aType.Code }); } } classifier.Visibility = GetTypeVisibility(aType.Modifier); if (!bComplete) { return; } } else { classifier = mapping.Classifier; ////package = mapping.Classifier.Package; package = NamespaceMapping.RetrieveFromChildName("").Package; } mapping.Complete = true; classifier.Comment = aType.Comment; if (aType.IsClass && aType.IsAbstract) { classifier.Abstract = true; } if (aType.IsValueType) { classifier.Stereotype = "structure"; } if (aType.IsGenericType) { classifier.Stereotype = "template"; } // 处理继承或实现 foreach(TypeInfo ti in aType.Parents) { ti.IsClass = true; this.CreateGeneralization(classifier, ti, package); } InfluenceTable aInfTable = new InfluenceTable(); foreach (AttributeInfo ai in aType.Attributes) { if (package == null)//(!aAttrTable.Contains(info5)) { ai.ToString(); } else { this.CreateAttribute(aType, classifier, ai, package); } } foreach (MethordInfo mi in aType.Methords) { //if (!aAttrTable.Contains(info5)) { this.CreateMethod(aType, classifier, mi, package, null, aInfTable); } } } }
private void CreateMethod(TypeInfo aType, Classifier aCls, MethordInfo aMethod, PdOOM.BasePackage aPckg, Operation anOper, InfluenceTable anInfTable) { Operation operation; if (anOper != null) { operation = anOper; } else { operation = (Operation)aCls.CreateObject(0x18112066, "", -1, true); } operation.Static = aMethod.IsStatic; operation.Visibility = GetTypeVisibility(aMethod.Modifier); operation.ReturnType = aMethod.Type; //operation.Final = aMethod.IsFinal; if (aMethod.IsGenericMethod) { operation.Generic = true; foreach (TypeParameter parameter in operation.TypeParameters) { parameter.delete(); } ////foreach (Type type in aMethod.GetGenericArguments()) ////{ //// TypeParameter parameter2 = (TypeParameter)operation.CreateObject(0x1811207d, "", -1, true); //// this.ProcessType(type, false); //// TypeMapping mapping = TypeMapping.Retrieve(type); //// parameter2.Name = parameter2.Code = mapping.Name; //// operation.TypeParameters.Add(parameter2); ////} } if (aMethod.IsVirtual) { operation.SetExtendedAttribute("C++.virtual", "true"); } if (aMethod.IsAbstract) { operation.Abstract = true; } try { operation.Code = aMethod.Code; operation.Name = aMethod.Name; } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the operation \"{1}\" on the type \"{0}\"", aType.Code, aMethod.Name }); } } new CustomHandlerMethod(aMethod, operation).Convert(); // 添加参数 foreach (ObjectInfo type in aMethod.Parameters) { AddParameter(operation, type, aPckg); } // 防止有重载方法前面改名失败 if (aMethod.Parameters.Count > 0 && operation.Code != aMethod.Code) { try { operation.Code = aMethod.Code; operation.Name = aMethod.Name; } catch (COMException) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { "*** exception while naming the operation \"{1}\" on the type \"{0}\"", aType.Code, aMethod.Name }); } } } }