public override bool Equals(object obj) { PreDefinedMethodEffectsStore other = obj as PreDefinedMethodEffectsStore; if (other == null) { return(false); } if (this.field != other.field) { return(false); } if (this.fmt != other.fmt) { return(false); } return(true); }
/// <summary> /// Parses each record and stores into internal dictionary /// </summary> /// <param name="assemblyname"></param> /// <param name="typename"></param> /// <param name="fieldname"></param> /// <param name="fmttype"></param> /// <param name="methodname"></param> private static void ParseRecord(IPexComponent host, string assemblyname, string typename, string fieldname, string fmttype, string methodname) { Field field; if (!MethodOrFieldAnalyzer.TryGetField(host, assemblyname, typename, fieldname, out field)) { host.Log.LogWarning(WikiTopics.MissingWikiTopic, "PredefinedEffects", "Failed to load field: " + fieldname); return; } FieldModificationType fmt = FieldStore.GetModificationTypeFromString(fmttype); Method method; if (!MethodOrFieldAnalyzer.TryGetMethod(host, assemblyname, typename, methodname, out method)) { host.Log.LogWarning(WikiTopics.MissingWikiTopic, "PredefinedEffects", "Failed to load method: " + methodname); return; } //storing into the effects store PreDefinedMethodEffectsStore pdme = new PreDefinedMethodEffectsStore(field, fmt); List <Method> suggestedMethods; PreDefinedMethodEffectsStore existingPdme; if (!effectsStore.TryGetValue(pdme, out existingPdme)) { suggestedMethods = new List <Method>(); pdme.suggestedmethodList = suggestedMethods; effectsStore.Add(pdme, pdme); } else { suggestedMethods = existingPdme.suggestedmethodList; } suggestedMethods.Add(method); }
/// <summary> /// Retrieves the write methods for a field, if exists from the predefined settings. /// </summary> public static bool TryGetWriteMethods(IPexComponent host, Field field, FieldModificationType desiredFmt, out SafeSet <Method> writeMethods) { if (!isPredefinedEffectsParsed) { ParsePredefinedEffects(host); } PreDefinedMethodEffectsStore pdme = new PreDefinedMethodEffectsStore(field, desiredFmt); PreDefinedMethodEffectsStore existingPdme; if (effectsStore.TryGetValue(pdme, out existingPdme)) { writeMethods = new SafeSet <Method>(); writeMethods.AddRange(existingPdme.suggestedmethodList); return(true); } else { writeMethods = null; return(false); } }