public SecurityDegree GetSecurityDegreeById(int security_degree_id) { SecurityDegree security_degree = new SecurityDegree(); List <SecurityDegree> security_degree_list = GetAllSecurityDegree(); if (security_degree_list != null) { if (security_degree_list != null) { foreach (SecurityDegree element in security_degree_list) { if (element.id == security_degree_id) { security_degree.id = security_degree_id; security_degree.degree_name = element.degree_name; return(security_degree); } } } return(security_degree); } else { return(null); } }
public List <SecurityDegree> GetAllSecurityDegree() { List <SecurityDegree> security_degree_list = new List <SecurityDegree>(); if (File.Exists(security_degree_db_path)) { using (StreamReader sr = File.OpenText(security_degree_db_path)) { string line = ""; string[] line_element; while ((line = sr.ReadLine()) != null) { line_element = line.Split(';'); SecurityDegree security_degree = new SecurityDegree(); security_degree.id = Convert.ToInt32(line_element[0]); security_degree.degree_name = line_element[1]; security_degree_list.Add(security_degree); } } return(security_degree_list); } else { return(null); } }
public SecurityDegree UpdateSecurityDegree(SecurityDegree security_degree) { if (DeleteSecurityDegree(security_degree.id) == true) { AddSecurityDegree(security_degree); return(security_degree); } return(new SecurityDegree()); }
public bool Parse(TokensReader expression, bool expression_end) { typename = ""; varnames = new List <string>(); type = VarType.DEFAULT; security = SecurityDegree.PUBLIC; if (expression_end && expression.tokens.Pop() == TokenType.VAR) { type = expression.var_types.Pop(); security = expression.securities.Pop(); if (expression.tokens.Pop() == TokenType.LITERAL) { typename = expression.string_values.Pop(); parse_var: if (expression.tokens.Pop() == TokenType.LITERAL) { varnames.Add(expression.string_values.Pop()); TokenType token; try { token = expression.tokens.Pop(); } catch (ArgumentOutOfRangeException) // if tokens is ended { return(true); } if (token == TokenType.SEPARATOR) { if (expression.bool_values.Pop()) { return(false); } else { goto parse_var; } } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } }
internal FunctionBuilder CreateMethod(string name, string typeName = "", FuncType type = FuncType.DEFAULT, SecurityDegree security = SecurityDegree.PUBLIC) { MethodAttributes attributes; //function security if (security == SecurityDegree.INTERNAL) { attributes = MethodAttributes.Assembly; } else if (security == SecurityDegree.PRIVATE) { attributes = MethodAttributes.Private; } else if (security == SecurityDegree.PROTECTED) { attributes = MethodAttributes.Family; } else { attributes = MethodAttributes.Public; } //function type if (type == FuncType.STATIC) { attributes |= MethodAttributes.Static; } else if (type == FuncType.ABSTRACT) { attributes |= MethodAttributes.Abstract; } else if (type == FuncType.FINAL) { attributes |= MethodAttributes.Final; } else if (type == FuncType.VIRTUAL) { attributes |= MethodAttributes.Virtual; } methodBuilder = new FunctionBuilder(typeBuilder.DefineMethod(name, attributes, CallingConventions.Standard)); return(methodBuilder); }
public ClassBuilder(string name, string nameSpace = "", ClassType classType = ClassType.DEFAULT, SecurityDegree securityDegree = SecurityDegree.PUBLIC) { type = classType; security = securityDegree; TypeAttributes typeAttributes = TypeAttributes.Class; //select type of class if (classType == ClassType.DEFAULT) { typeAttributes = TypeAttributes.Class; } else if (classType == ClassType.FINAL) { typeAttributes |= TypeAttributes.Sealed; } else if (classType == ClassType.INTERFACE) { typeAttributes = TypeAttributes.Interface; } else if (classType == ClassType.TYPEALIAS) { typeBuilder.SetCustomAttribute(Context.typeAliasAttr); } //select security of class if (securityDegree == SecurityDegree.PRIVATE) { typeAttributes |= TypeAttributes.NotPublic; } else if (securityDegree == SecurityDegree.PUBLIC) { typeAttributes |= TypeAttributes.Public; } if (nameSpace.IsEmpty()) { typeBuilder = Context.moduleBuilder.DefineType(name, typeAttributes); } else { typeBuilder = Context.moduleBuilder.DefineType(nameSpace + "." + name, typeAttributes); } }
public SecurityDegree AddSecurityDegree(SecurityDegree security_degree) { List <SecurityDegree> security_degree_list = GetAllSecurityDegree(); if (security_degree_list != null) { foreach (SecurityDegree element in security_degree_list) { if (element.id == security_degree.id) { return(new SecurityDegree()); } } } if (File.Exists(security_degree_db_path)) { File.Delete(security_degree_db_path); } if (!File.Exists(security_degree_db_path)) { using (StreamWriter sw = File.CreateText(security_degree_db_path)) { if (security_degree_list != null) { foreach (SecurityDegree element in security_degree_list) { sw.WriteLine(element.id.ToString() + ";" + element.degree_name); } } sw.WriteLine(security_degree.id.ToString() + ";" + security_degree.degree_name); } } else { return(new SecurityDegree()); } return(security_degree); }