public IMethodRegister CreateMethod(string className, bool isStatic, ClepsType functionType, string functionName) { if (!classesLoaded.ContainsKey(className)) { throw new ArgumentException(String.Format("Class {0} not loaded", className)); } if (!functionType.IsFunctionType) { throw new ArgumentException("Expected function type. Got " + functionType.GetClepsTypeString()); } var classNameToUse = isStatic ? className + ".static" : className; var functionNameAndType = new FunctionNameAndType(classNameToUse, functionName, functionType); var methodList = isStatic ? staticMethods[classNameToUse] : memberMethods[classNameToUse]; if (methodList.Contains(functionNameAndType)) { throw new ArgumentException(String.Format("Function {0} {1} {2} for class {3} already exists", isStatic ? "static" : "", functionType, functionName, className)); } methodList.Add(functionNameAndType); var methodRegister = new JavaScriptMethod(functionType as FunctionClepsType); methodBodies.Add(functionNameAndType, methodRegister); return methodRegister; }
private static bool IsEqual(FunctionNameAndType obj1, FunctionNameAndType obj2) { if (Object.ReferenceEquals(obj1, obj2)) { return(true); } else if (Object.ReferenceEquals(obj1, null) || Object.ReferenceEquals(obj2, null)) { return(false); } return(obj1.ClassName == obj2.ClassName && obj1.FunctionName == obj2.FunctionName && obj1.FunctionType == obj2.FunctionType); }
private static bool IsEqual(FunctionNameAndType obj1, FunctionNameAndType obj2) { if (Object.ReferenceEquals(obj1, obj2)) { return true; } else if (Object.ReferenceEquals(obj1, null) || Object.ReferenceEquals(obj2, null)) { return false; } return obj1.ClassName == obj2.ClassName && obj1.FunctionName == obj2.FunctionName && obj1.FunctionType == obj2.FunctionType; }
public IMethodRegister GetMethodRegister(string className, bool isStatic, ClepsType functionType, string functionName) { string classNameToUse = isStatic ? className + ".static" : className; FunctionNameAndType methodRegisterKey = new FunctionNameAndType(classNameToUse, functionName, functionType); return methodBodies[methodRegisterKey]; }