예제 #1
0
파일: Programs.cs 프로젝트: mnisl/OD
		///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
		public static bool IsEnabled(ProgramName progName){
			//No need to check RemotingRole; no call to db.
			Hashtable hashPrograms=ProgramC.GetHList();
			if(hashPrograms.ContainsKey(progName.ToString()) && ((Program)hashPrograms[progName.ToString()]).Enabled) {
				return true;
			}
			return false;
		}
예제 #2
0
        /// <summary>
        /// Makes a predicate that matches folders to the program, and then matches the remainder
        /// </summary>
        public NodePred[] MkProgramPredicate(ProgramName prog, params NodePred[] remainder)
        {
            Contract.Requires(prog != null);
            var segs = prog.Uri.Segments;

            Contract.Assert(segs.Length > 1 && segs[0] == "/");
            var preds = new NodePred[segs.Length + (remainder == null ? 0 : remainder.Length)];

            preds[0] = MkPredicate(NodeKind.Folder) & MkNamePredicate("/");
            for (int i = 1; i < segs.Length - 1; ++i)
            {
                var seg = segs[i];
                preds[i] = MkPredicate(NodeKind.Folder) & MkNamePredicate(seg.Substring(0, seg.Length - 1));
            }

            preds[segs.Length - 1] = MkPredicate(NodeKind.Program) & MkNamePredicate(prog.ToString());

            if (remainder != null)
            {
                for (int i = 0; i < remainder.Length; ++i)
                {
                    preds[segs.Length + i] = remainder[i];
                }
            }

            return(preds);
        }
        public void valid(string name)
        {
            var pn = new ProgramName(name);

            Assert.Equal(name, pn.Value);
            Assert.Equal(name, pn.ToString());
        }
예제 #4
0
        ///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
        public static bool IsEnabled(ProgramName progName)
        {
            //No need to check RemotingRole; no call to db.
            Program program = GetFirstOrDefault(x => x.ProgName == progName.ToString());

            return(program == null ? false : program.Enabled);
        }
예제 #5
0
파일: Programs.cs 프로젝트: nampn/ODental
 ///<summary>Supply a valid program Name, and this will set Cur to be the corresponding Program object.</summary>
 public static Program GetCur(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     for(int i=0;i<ProgramC.Listt.Count;i++) {
         if(ProgramC.Listt[i].ProgName==progName.ToString()) {
             return ProgramC.Listt[i];
         }
     }
     return null;//to signify that the program could not be located. (user deleted it in an older version)
 }
예제 #6
0
        internal static string GetCodeLocationString(this object obj, EnvParams envParams, ProgramName progName = null)
        {
            if (obj is Location)
            {
                return(((Location)obj).GetFileLocationString(envParams));
            }

            Span span;

            if (obj is Node)
            {
                span = ((Node)obj).Span;
            }
            else if (obj is AST <Node> )
            {
                span = ((AST <Node>)obj).Node.Span;
            }
            else if (obj is Tuple <ProgramName, Node> )
            {
                var tup = (Tuple <ProgramName, Node>)obj;
                return(GetCodeLocationString(tup.Item2, envParams, tup.Item1));
            }
            else
            {
                if (progName == null)
                {
                    return("(?,?)");
                }
                else
                {
                    return(progName.ToString(envParams) + " (?,?)");
                }
            }

            if (progName == null)
            {
                return(string.Format("({0}, {1})", span.StartLine, span.StartCol));
            }
            else
            {
                return(string.Format("{0}({1}, {2})", progName.ToString(envParams), span.StartLine, span.StartCol));
            }
        }
예제 #7
0
 ///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
 public static long GetProgramNum(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < ProgramC.Listt.Count; i++)
     {
         if (ProgramC.Listt[i].ProgName == progName.ToString())
         {
             return(ProgramC.Listt[i].ProgramNum);
         }
     }
     return(0);
 }
예제 #8
0
 ///<summary>Supply a valid program Name, and this will set Cur to be the corresponding Program object.</summary>
 public static Program GetCur(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < ProgramC.Listt.Count; i++)
     {
         if (ProgramC.Listt[i].ProgName == progName.ToString())
         {
             return(ProgramC.Listt[i]);
         }
     }
     return(null);           //to signify that the program could not be located. (user deleted it in an older version)
 }
예제 #9
0
 ///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
 public static bool IsEnabled(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     if (ProgramC.HList == null)
     {
         Programs.RefreshCache();
     }
     if (ProgramC.HList.ContainsKey(progName.ToString()) && ((Program)ProgramC.HList[progName.ToString()]).Enabled)
     {
         return(true);
     }
     return(false);
 }
예제 #10
0
		///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
		public static bool IsEnabled(ProgramName progName){
			//No need to check RemotingRole; no call to db.
			if(ProgramC.HList==null) {
				Programs.RefreshCache();
			}
			if(ProgramC.HList.ContainsKey(progName.ToString()) && ((Program)ProgramC.HList[progName.ToString()]).Enabled) {
				return true;
			}
			return false;
		}
예제 #11
0
		///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
		public static long GetProgramNum(ProgramName progName) {
			//No need to check RemotingRole; no call to db.
			for(int i=0;i<ProgramC.Listt.Count;i++) {
				if(ProgramC.Listt[i].ProgName==progName.ToString()) {
					return ProgramC.Listt[i].ProgramNum;
				}
			}
			return 0;
		}
예제 #12
0
파일: Programs.cs 프로젝트: mnisl/OD
		///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
		public static long GetProgramNum(ProgramName progName) {
			//No need to check RemotingRole; no call to db.
			List<Program> listPrograms=ProgramC.GetListt();
			for(int i=0;i<listPrograms.Count;i++) {
				if(listPrograms[i].ProgName==progName.ToString()) {
					return listPrograms[i].ProgramNum;
				}
			}
			return 0;
		}
예제 #13
0
 ///<summary>Supply a valid program Name, and this will set Cur to be the corresponding Program object.</summary>
 public static Program GetCur(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     return(GetFirstOrDefault(x => x.ProgName == progName.ToString()));
 }