Beispiel #1
0
        private void buttonSolve_Click(object sender, EventArgs e)
        {
            double[] array = new double[dataGridViewTable.ColumnCount];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = double.Parse(dataGridViewTable[i, 0].Value.ToString());
            }


            library solver = new library();

            double SumnegativeNumb = solver.Array_SumNegativeNumb(array);

            labelSumnegativeNumb.Text = "Сума від'ємних елементів = " + SumnegativeNumb;

            double MaxNumb = solver.Array_MaxNumb(array);

            labelMaxNumb.Text = "Найбільше за модулем число = " + MaxNumb;

            int SumIndexes = solver.Array_SumIndexes(array);

            labelSumIndexes.Text = "Cума індексів додатніх елементів = " + SumIndexes;

            int IntengerQuantity = solver.Array_IntengerQuantity(array);

            labelIntengerQuantity.Text = "Кількість цілих чисел = " + IntengerQuantity;

            double sumMax_Min = solver.Array_SumMax_Min(array);

            labelsumMax_Min.Text = "Добуток елементів масиву між Max i Min = " + sumMax_Min;

            int variablecoun = solver.Array_DifferentNumbs(array);

            labelvariablecoun.Text = "Кількість різних чисел = " + variablecoun;
        }
Beispiel #2
0
     : super(library, name)
 {
     this.declaringType    = declaringType;
     this.genericArguments = new ArrayList <TypeInfo>();
     this.interfaces       = new ArrayList <TypeInfo>();
     this.annotations      = new ArrayList <AnnotationValue>();
 }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            library library = db.library.Find(id);

            db.library.Remove(library);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.Write("Введiть число: ");
            int     n      = int.Parse(Console.ReadLine());
            library solver = new library();
            double  sum    = solver.CalculateSum(n);

            Console.WriteLine("Сума довiвнює = " + sum);
        }
Beispiel #5
0
        private void buttonSolveTask1_Click(object sender, EventArgs e)
        {
            int n = int.Parse(textBoxNTask1.Text);

            library solver = new library();
            double  sum    = solver.CalculateSum(n);

            labelTask1Result.Text = "Сума дорівнює = " + sum.ToString();
        }
        public FormSIDCConverter()
        {
            InitializeComponent();

            librarian myLibrarian = new librarian();

            library lib = myLibrarian.library;

            var x = lib.uses[1].useCode;
        }
 public ActionResult Edit([Bind(Include = "book_id,book_name,book_category,book_status")] library library)
 {
     if (ModelState.IsValid)
     {
         db.Entry(library).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(library));
 }
Beispiel #8
0
        private void buttonSoiveTask2_Click(object sender, EventArgs e)
        {
            int    n = int.Parse(textBoxNTask2.Text);
            double a = double.Parse(textBoxA.Text);

            library solver = new library();
            double  degree = solver.Degree(n, a);

            labelTask2Result.Text = "'a' в степенi 'n' дорiвнює =  " + degree.ToString();
        }
        public ActionResult Create([Bind(Include = "book_id,book_name,book_category,book_status")] library library)
        {
            if (ModelState.IsValid)
            {
                db.libraries.Add(library);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(library));
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            Console.Write("Введiть число n: ");

            int n = int.Parse(Console.ReadLine());

            double[] array = new double[n];

            Random arr = new Random();

            for (int i = 0; i < n; i++)
            {
                array[i] = arr.Next(-1000, 1000);
            }

            for (int i = 0; i < n - 1; i++)
            {
                Console.Write(array[i] + " ");
            }
            Console.WriteLine(array[n - 1]);

            library solver = new library();

            double SumnegativeNumb = solver.Array_SumNegativeNumb(array);

            Console.WriteLine("Сума вiд'ємних елементiв = " + SumnegativeNumb);

            double MaxNumb = solver.Array_MaxNumb(array);

            Console.WriteLine("Найбiльше за модулем число = " + MaxNumb);


            int SumIndexes = solver.Array_SumIndexes(array);

            Console.WriteLine("Cума iндексiв додатнiх елементiв = " + SumIndexes);


            int IntengerQuantity = solver.Array_IntengerQuantity(array);

            Console.WriteLine("Кiлькiсть цiлих чисел = " + IntengerQuantity);


            double sumMax_Min = solver.Array_SumMax_Min(array);

            Console.WriteLine("Добуток елементiв масиву мiж Max i Min = " + sumMax_Min);


            int variablecoun = solver.Array_DifferentNumbs(array);

            Console.WriteLine("Кiлькiсть рiзних чисел = " + variablecoun);
        }
Beispiel #11
0
 public ActionResult Edit([Bind(Include = "library_id,yazar_id,yayinevi_id,kategori_id,kaynak_id")] library library)
 {
     if (ModelState.IsValid)
     {
         db.Entry(library).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.kategori_id = new SelectList(db.kategoriler, "kategori_id", "kategori_ad", library.kategori_id);
     ViewBag.kaynak_id   = new SelectList(db.kaynak, "kaynak_id", "kaynak_ad", library.kaynak_id);
     ViewBag.yayinevi_id = new SelectList(db.yayınevi, "yayınevi_id", "yayınevi_ad", library.yayinevi_id);
     ViewBag.yazar_id    = new SelectList(db.yazarlar, "yazar_id", "yazar_ad", library.yazar_id);
     return(View(library));
 }
Beispiel #12
0
        // GET: libraries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            library library = db.library.Find(id);

            if (library == null)
            {
                return(HttpNotFound());
            }
            return(View(library));
        }
Beispiel #13
0
        // GET: libraries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            library library = db.library.Find(id);

            if (library == null)
            {
                return(HttpNotFound());
            }
            ViewBag.kategori_id = new SelectList(db.kategoriler, "kategori_id", "kategori_ad", library.kategori_id);
            ViewBag.kaynak_id   = new SelectList(db.kaynak, "kaynak_id", "kaynak_ad", library.kaynak_id);
            ViewBag.yayinevi_id = new SelectList(db.yayınevi, "yayınevi_id", "yayınevi_ad", library.yayinevi_id);
            ViewBag.yazar_id    = new SelectList(db.yazarlar, "yazar_id", "yazar_ad", library.yazar_id);
            return(View(library));
        }
Beispiel #14
0
        public string SaveXslt(string fileName, string oldName, string fileContents, bool ignoreDebugging)
        {
            if (AuthorizeRequest(DefaultApps.developer.ToString()))
            {
                // validate file
                IOHelper.ValidateEditPath(IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName),
                                          SystemDirectories.Xslt);
                // validate extension
                IOHelper.ValidateFileExtension(IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName),
                                               new List <string>()
                {
                    "xsl", "xslt"
                });


                StreamWriter SW;
                string       tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + DateTime.Now.Ticks + "_temp.xslt");
                SW = File.CreateText(tempFileName);
                SW.Write(fileContents);
                SW.Close();

                // Test the xslt
                string errorMessage = "";

                if (!ignoreDebugging)
                {
                    try
                    {
                        // Check if there's any documents yet
                        string xpath = UmbracoSettings.UseLegacyXmlSchema ? "/root/node" : "/root/*";
                        if (content.Instance.XmlContent.SelectNodes(xpath).Count > 0)
                        {
                            var macroXML = new XmlDocument();
                            macroXML.LoadXml("<macro/>");

                            var macroXSLT = new XslCompiledTransform();
                            var umbPage   = new page(content.Instance.XmlContent.SelectSingleNode("//* [@parentID = -1]"));

                            var xslArgs = macro.AddMacroXsltExtensions();
                            var lib     = new library(umbPage);
                            xslArgs.AddExtensionObject("urn:umbraco.library", lib);
                            HttpContext.Current.Trace.Write("umbracoMacro", "After adding extensions");

                            // Add the current node
                            xslArgs.AddParam("currentPage", "", library.GetXmlNodeById(umbPage.PageID.ToString()));

                            HttpContext.Current.Trace.Write("umbracoMacro", "Before performing transformation");

                            // Create reader and load XSL file
                            // We need to allow custom DTD's, useful for defining an ENTITY
                            var readerSettings = new XmlReaderSettings();
                            readerSettings.ProhibitDtd = false;
                            using (var xmlReader = XmlReader.Create(tempFileName, readerSettings))
                            {
                                var xslResolver = new XmlUrlResolver();
                                xslResolver.Credentials = CredentialCache.DefaultCredentials;
                                macroXSLT.Load(xmlReader, XsltSettings.TrustedXslt, xslResolver);
                                xmlReader.Close();
                                // Try to execute the transformation
                                var macroResult = new HtmlTextWriter(new StringWriter());
                                macroXSLT.Transform(macroXML, xslArgs, macroResult);
                                macroResult.Close();

                                File.Delete(tempFileName);
                            }
                        }
                        else
                        {
                            //errorMessage = ui.Text("developer", "xsltErrorNoNodesPublished");
                            File.Delete(tempFileName);
                            //base.speechBubble(speechBubbleIcon.info, ui.Text("errors", "xsltErrorHeader", base.getUser()), "Unable to validate xslt as no published content nodes exist.");
                        }
                    }
                    catch (Exception errorXslt)
                    {
                        File.Delete(tempFileName);

                        errorMessage = (errorXslt.InnerException ?? errorXslt).ToString();

                        // Full error message
                        errorMessage = errorMessage.Replace("\n", "<br/>\n");
                        //closeErrorMessage.Visible = true;

                        // Find error
                        var m = Regex.Matches(errorMessage, @"\d*[^,],\d[^\)]", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                        foreach (Match mm in m)
                        {
                            string[] errorLine = mm.Value.Split(',');

                            if (errorLine.Length > 0)
                            {
                                var theErrorLine = int.Parse(errorLine[0]);
                                var theErrorChar = int.Parse(errorLine[1]);

                                errorMessage = "Error in XSLT at line " + errorLine[0] + ", char " + errorLine[1] +
                                               "<br/>";
                                errorMessage += "<span style=\"font-family: courier; font-size: 11px;\">";

                                var xsltText = fileContents.Split("\n".ToCharArray());
                                for (var i = 0; i < xsltText.Length; i++)
                                {
                                    if (i >= theErrorLine - 3 && i <= theErrorLine + 1)
                                    {
                                        if (i + 1 == theErrorLine)
                                        {
                                            errorMessage += "<b>" + (i + 1) + ": &gt;&gt;&gt;&nbsp;&nbsp;" +
                                                            Server.HtmlEncode(xsltText[i].Substring(0, theErrorChar));
                                            errorMessage +=
                                                "<span style=\"text-decoration: underline; border-bottom: 1px solid red\">" +
                                                Server.HtmlEncode(
                                                    xsltText[i].Substring(theErrorChar,
                                                                          xsltText[i].Length - theErrorChar)).
                                                Trim() + "</span>";
                                            errorMessage += " &lt;&lt;&lt;</b><br/>";
                                        }
                                        else
                                        {
                                            errorMessage += (i + 1) + ": &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                                                            Server.HtmlEncode(xsltText[i]) + "<br/>";
                                        }
                                    }
                                }
                                errorMessage += "</span>";
                            }
                        }
                    }
                }

                if (errorMessage == "" && fileName.ToLower().EndsWith(".xslt"))
                {
                    //Hardcoded security-check... only allow saving files in xslt directory...
                    var savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);

                    if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Xslt + "/")))
                    {
                        //deletes the old xslt file
                        if (fileName != oldName)
                        {
                            var p = IOHelper.MapPath(SystemDirectories.Xslt + "/" + oldName);
                            if (File.Exists(p))
                            {
                                File.Delete(p);
                            }
                        }

                        SW = File.CreateText(savePath);
                        SW.Write(fileContents);
                        SW.Close();
                        errorMessage = "true";
                    }
                    else
                    {
                        errorMessage = "Illegal path";
                    }
                }

                File.Delete(tempFileName);

                return(errorMessage);
            }
            return("false");
        }
Beispiel #15
0
 public virtual IList<library.IContentObject> GetContents(string objectType, library.DataFilter filter, int pageSize, int startIndex)
 {
     throw new NotImplementedException();
 }
        private string SaveXslt(string fileName, string fileContents, bool ignoreDebugging)
        {	        
			var tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + System.DateTime.Now.Ticks + "_temp.xslt");
            using (var sw = File.CreateText(tempFileName))
            {
				sw.Write(fileContents);
				sw.Close();    
            }
            
            // Test the xslt
            string errorMessage = "";
            if (!ignoreDebugging)
            {
                try
                {

                    // Check if there's any documents yet
                    if (content.Instance.XmlContent.SelectNodes("/root/node").Count > 0)
                    {
                        XmlDocument macroXML = new XmlDocument();
                        macroXML.LoadXml("<macro/>");

                        XslCompiledTransform macroXSLT = new XslCompiledTransform();
                        page umbPage = new page(content.Instance.XmlContent.SelectSingleNode("//node [@parentID = -1]"));

                        XsltArgumentList xslArgs;
                        xslArgs = macro.AddMacroXsltExtensions();
                        library lib = new library(umbPage);
                        xslArgs.AddExtensionObject("urn:umbraco.library", lib);
                        HttpContext.Current.Trace.Write("umbracoMacro", "After adding extensions");

                        // Add the current node
                        xslArgs.AddParam("currentPage", "", library.GetXmlNodeById(umbPage.PageID.ToString()));
                        HttpContext.Current.Trace.Write("umbracoMacro", "Before performing transformation");

                        // Create reader and load XSL file
                        // We need to allow custom DTD's, useful for defining an ENTITY
                        XmlReaderSettings readerSettings = new XmlReaderSettings();
                        readerSettings.ProhibitDtd = false;
                        using (XmlReader xmlReader = XmlReader.Create(tempFileName, readerSettings))
                        {
                            XmlUrlResolver xslResolver = new XmlUrlResolver();
                            xslResolver.Credentials = CredentialCache.DefaultCredentials;
                            macroXSLT.Load(xmlReader, XsltSettings.TrustedXslt, xslResolver);
                            xmlReader.Close();
                            // Try to execute the transformation
                            HtmlTextWriter macroResult = new HtmlTextWriter(new StringWriter());
                            macroXSLT.Transform(macroXML, xslArgs, macroResult);
                            macroResult.Close();
                        }
                    }
                    else
                    {
                        errorMessage = "stub";
                        //base.speechBubble(speechBubbleIcon.info, ui.Text("errors", "xsltErrorHeader", base.getUser()), "Unable to validate xslt as no published content nodes exist.");
                    }

                }
                catch (Exception errorXslt)
                {
                    //base.speechBubble(speechBubbleIcon.error, ui.Text("errors", "xsltErrorHeader", base.getUser()), ui.Text("errors", "xsltErrorText", base.getUser()));

                    //errorHolder.Visible = true;
                    //closeErrorMessage.Visible = true;
                    //errorHolder.Attributes.Add("style", "height: 250px; overflow: auto; border: 1px solid CCC; padding: 5px;");

                    errorMessage = (errorXslt.InnerException ?? errorXslt).ToString();

                    // Full error message
                    errorMessage = errorMessage.Replace("\n", "<br/>\n");
                    //closeErrorMessage.Visible = true;

                    string[] errorLine;
                    // Find error
                    MatchCollection m = Regex.Matches(errorMessage, @"\d*[^,],\d[^\)]", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                    foreach (Match mm in m)
                    {
                        errorLine = mm.Value.Split(',');

                        if (errorLine.Length > 0)
                        {
                            int theErrorLine = int.Parse(errorLine[0]);
                            int theErrorChar = int.Parse(errorLine[1]);

                            errorMessage = "Error in XSLT at line " + errorLine[0] + ", char " + errorLine[1] + "<br/>";
                            errorMessage += "<span style=\"font-family: courier; font-size: 11px;\">";

                            string[] xsltText = fileContents.Split("\n".ToCharArray());
                            for (int i = 0; i < xsltText.Length; i++)
                            {
                                if (i >= theErrorLine - 3 && i <= theErrorLine + 1)
                                    if (i + 1 == theErrorLine)
                                    {
                                        errorMessage += "<b>" + (i + 1) + ": &gt;&gt;&gt;&nbsp;&nbsp;" + Server.HtmlEncode(xsltText[i].Substring(0, theErrorChar));
                                        errorMessage += "<span style=\"text-decoration: underline; border-bottom: 1px solid red\">" + Server.HtmlEncode(xsltText[i].Substring(theErrorChar, xsltText[i].Length - theErrorChar)).Trim() + "</span>";
                                        errorMessage += " &lt;&lt;&lt;</b><br/>";
                                    }
                                    else
                                        errorMessage += (i + 1) + ": &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Server.HtmlEncode(xsltText[i]) + "<br/>";
                            }
                            errorMessage += "</span>";

                        }
                    }
                }

            }


            if (errorMessage == "" && fileName.ToLower().EndsWith(".xslt"))
            {
                //Hardcoded security-check... only allow saving files in xslt directory... 
                var savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);

                if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Xslt)))
                {
					using (var sw = File.CreateText(savePath))
	                {
						sw.Write(fileContents);
						sw.Close();
	                }
                    errorMessage = "true";
                }
                else
                {
                    errorMessage = "Illegal path";
                }
            }

            File.Delete(tempFileName);


            return errorMessage;
        }
 (library, ffprobePath) => new RequestParameters(
     library,
     ffprobePath,
     request.ForceScan));
Beispiel #18
0
 : super(library, TypeKind.GenericParameter)
Beispiel #19
0
     : super(library, typeKind)
 {
     this.wildcardBound = wildcardBound;
 }
Beispiel #20
0
        public static void Main(string[] args)
        {
            library lb = new library();

            BuildWebHost(args).Run();
        }
Beispiel #21
0
        private string SaveXslt(string fileName, string fileContents, bool ignoreDebugging)
        {
            var tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + System.DateTime.Now.Ticks + "_temp.xslt");

            using (var sw = File.CreateText(tempFileName))
            {
                sw.Write(fileContents);
                sw.Close();
            }

            // Test the xslt
            string errorMessage = "";

            if (!ignoreDebugging)
            {
                try
                {
                    // Check if there's any documents yet
                    if (content.Instance.XmlContent.SelectNodes("/root/node").Count > 0)
                    {
                        XmlDocument macroXML = new XmlDocument();
                        macroXML.LoadXml("<macro/>");

                        XslCompiledTransform macroXSLT = new XslCompiledTransform();
                        page umbPage = new page(content.Instance.XmlContent.SelectSingleNode("//node [@parentID = -1]"));

                        XsltArgumentList xslArgs;
                        xslArgs = macro.AddMacroXsltExtensions();
                        library lib = new library(umbPage);
                        xslArgs.AddExtensionObject("urn:umbraco.library", lib);
                        HttpContext.Current.Trace.Write("umbracoMacro", "After adding extensions");

                        // Add the current node
                        xslArgs.AddParam("currentPage", "", library.GetXmlNodeById(umbPage.PageID.ToString()));
                        HttpContext.Current.Trace.Write("umbracoMacro", "Before performing transformation");

                        // Create reader and load XSL file
                        // We need to allow custom DTD's, useful for defining an ENTITY
                        XmlReaderSettings readerSettings = new XmlReaderSettings();
                        readerSettings.ProhibitDtd = false;
                        using (XmlReader xmlReader = XmlReader.Create(tempFileName, readerSettings))
                        {
                            XmlUrlResolver xslResolver = new XmlUrlResolver();
                            xslResolver.Credentials = CredentialCache.DefaultCredentials;
                            macroXSLT.Load(xmlReader, XsltSettings.TrustedXslt, xslResolver);
                            xmlReader.Close();
                            // Try to execute the transformation
                            HtmlTextWriter macroResult = new HtmlTextWriter(new StringWriter());
                            macroXSLT.Transform(macroXML, xslArgs, macroResult);
                            macroResult.Close();
                        }
                    }
                    else
                    {
                        errorMessage = "stub";
                        //base.speechBubble(speechBubbleIcon.info, ui.Text("errors", "xsltErrorHeader", base.getUser()), "Unable to validate xslt as no published content nodes exist.");
                    }
                }
                catch (Exception errorXslt)
                {
                    //base.speechBubble(speechBubbleIcon.error, ui.Text("errors", "xsltErrorHeader", base.getUser()), ui.Text("errors", "xsltErrorText", base.getUser()));

                    //errorHolder.Visible = true;
                    //closeErrorMessage.Visible = true;
                    //errorHolder.Attributes.Add("style", "height: 250px; overflow: auto; border: 1px solid CCC; padding: 5px;");

                    errorMessage = (errorXslt.InnerException ?? errorXslt).ToString();

                    // Full error message
                    errorMessage = errorMessage.Replace("\n", "<br/>\n");
                    //closeErrorMessage.Visible = true;

                    string[] errorLine;
                    // Find error
                    MatchCollection m = Regex.Matches(errorMessage, @"\d*[^,],\d[^\)]", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                    foreach (Match mm in m)
                    {
                        errorLine = mm.Value.Split(',');

                        if (errorLine.Length > 0)
                        {
                            int theErrorLine = int.Parse(errorLine[0]);
                            int theErrorChar = int.Parse(errorLine[1]);

                            errorMessage  = "Error in XSLT at line " + errorLine[0] + ", char " + errorLine[1] + "<br/>";
                            errorMessage += "<span style=\"font-family: courier; font-size: 11px;\">";

                            string[] xsltText = fileContents.Split("\n".ToCharArray());
                            for (int i = 0; i < xsltText.Length; i++)
                            {
                                if (i >= theErrorLine - 3 && i <= theErrorLine + 1)
                                {
                                    if (i + 1 == theErrorLine)
                                    {
                                        errorMessage += "<b>" + (i + 1) + ": &gt;&gt;&gt;&nbsp;&nbsp;" + Server.HtmlEncode(xsltText[i].Substring(0, theErrorChar));
                                        errorMessage += "<span style=\"text-decoration: underline; border-bottom: 1px solid red\">" + Server.HtmlEncode(xsltText[i].Substring(theErrorChar, xsltText[i].Length - theErrorChar)).Trim() + "</span>";
                                        errorMessage += " &lt;&lt;&lt;</b><br/>";
                                    }
                                    else
                                    {
                                        errorMessage += (i + 1) + ": &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Server.HtmlEncode(xsltText[i]) + "<br/>";
                                    }
                                }
                            }
                            errorMessage += "</span>";
                        }
                    }
                }
            }


            if (errorMessage == "" && fileName.ToLower().EndsWith(".xslt"))
            {
                //Hardcoded security-check... only allow saving files in xslt directory...
                var savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);

                if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Xslt)))
                {
                    using (var sw = File.CreateText(savePath))
                    {
                        sw.Write(fileContents);
                        sw.Close();
                    }
                    errorMessage = "true";
                }
                else
                {
                    errorMessage = "Illegal path";
                }
            }

            File.Delete(tempFileName);


            return(errorMessage);
        }
            : super(library, typeKind) {
			switch (typeKind) {
			case Void:
				displayName = "void";
				descriptor = "V";
				numericTypeKind = NumericTypeKind.None;
				break;
			case Boolean:
				displayName = "boolean";
				descriptor = "Z";
				numericTypeKind = NumericTypeKind.None;
				break;
			case Byte:
				displayName = "byte";
				descriptor = "B";
				numericTypeKind = NumericTypeKind.Byte;
				break;
			case Char:
				displayName = "char";
				descriptor = "C";
				numericTypeKind = NumericTypeKind.Char;
				break;
			case Short:
				displayName = "short";
				descriptor = "S";
				numericTypeKind = NumericTypeKind.Short;
				break;
			case Int:
				displayName = "int";
				descriptor = "I";
				numericTypeKind = NumericTypeKind.Int;
				break;
			case Long:
				displayName = "long";
				descriptor = "J";
				numericTypeKind = NumericTypeKind.Long;
				break;
			case Float:
				displayName = "float";
				descriptor = "F";
				numericTypeKind = NumericTypeKind.Float;
				break;
			case Double:
				displayName = "double";
				descriptor = "D";
				numericTypeKind = NumericTypeKind.Double;
				break;
			default:
				throw new IllegalArgumentException("typeKind = " + typeKind);
			}
        }
Beispiel #23
0
 NAudioStart(library, path);
     : super(library, typeKind) {
     this.wildcardBound = wildcardBound;
 }
     : super(library, TypeKind.GenericParameter) {
     this.name = name;
     this.genericParameterBounds = new ArrayList<TypeInfo>();
     this.genericTypeDefinition = genericTypeDefinition;
 }
Beispiel #26
0
            : super(library, typeKind)
        {
            switch (typeKind)
            {
            case Void:
                displayName     = "void";
                descriptor      = "V";
                numericTypeKind = NumericTypeKind.None;
                break;

            case Boolean:
                displayName     = "boolean";
                descriptor      = "Z";
                numericTypeKind = NumericTypeKind.None;
                break;

            case Byte:
                displayName     = "byte";
                descriptor      = "B";
                numericTypeKind = NumericTypeKind.Byte;
                break;

            case Char:
                displayName     = "char";
                descriptor      = "C";
                numericTypeKind = NumericTypeKind.Char;
                break;

            case Short:
                displayName     = "short";
                descriptor      = "S";
                numericTypeKind = NumericTypeKind.Short;
                break;

            case Int:
                displayName     = "int";
                descriptor      = "I";
                numericTypeKind = NumericTypeKind.Int;
                break;

            case Long:
                displayName     = "long";
                descriptor      = "J";
                numericTypeKind = NumericTypeKind.Long;
                break;

            case Float:
                displayName     = "float";
                descriptor      = "F";
                numericTypeKind = NumericTypeKind.Float;
                break;

            case Double:
                displayName     = "double";
                descriptor      = "D";
                numericTypeKind = NumericTypeKind.Double;
                break;

            default:
                throw new IllegalArgumentException("typeKind = " + typeKind);
            }
        }
Beispiel #27
0
 public virtual IDictionary<string, string> GetHashValues(string objectType, library.DataFilter filter, int pageSize, int startIndex)
 {
     throw new NotImplementedException();
 }
        public string SaveXslt(string fileName, string oldName, string fileContents, bool ignoreDebugging)
        {
            if (AuthorizeRequest(DefaultApps.developer.ToString()))
            {

                // validate file
                IOHelper.ValidateEditPath(IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName),
                                          SystemDirectories.Xslt);
                // validate extension
                IOHelper.ValidateFileExtension(IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName),
                                               new List<string>() { "xsl", "xslt" });


                StreamWriter SW;
                string tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + DateTime.Now.Ticks + "_temp.xslt");
                SW = File.CreateText(tempFileName);
                SW.Write(fileContents);
                SW.Close();

                // Test the xslt
                string errorMessage = "";

                if (!ignoreDebugging)
                {
                    try
                    {
                        // Check if there's any documents yet
                        string xpath = UmbracoSettings.UseLegacyXmlSchema ? "/root/node" : "/root/*";
                        if (content.Instance.XmlContent.SelectNodes(xpath).Count > 0)
                        {
                            var macroXML = new XmlDocument();
                            macroXML.LoadXml("<macro/>");

                            var macroXSLT = new XslCompiledTransform();
                            var umbPage = new page(content.Instance.XmlContent.SelectSingleNode("//* [@parentID = -1]"));

                            var xslArgs = macro.AddMacroXsltExtensions();
                            var lib = new library(umbPage);
                            xslArgs.AddExtensionObject("urn:umbraco.library", lib);
                            HttpContext.Current.Trace.Write("umbracoMacro", "After adding extensions");

                            // Add the current node
                            xslArgs.AddParam("currentPage", "", library.GetXmlNodeById(umbPage.PageID.ToString()));

                            HttpContext.Current.Trace.Write("umbracoMacro", "Before performing transformation");

                            // Create reader and load XSL file
                            // We need to allow custom DTD's, useful for defining an ENTITY
                            var readerSettings = new XmlReaderSettings();
                            readerSettings.ProhibitDtd = false;
                            using (var xmlReader = XmlReader.Create(tempFileName, readerSettings))
                            {
                                var xslResolver = new XmlUrlResolver();
                                xslResolver.Credentials = CredentialCache.DefaultCredentials;
                                macroXSLT.Load(xmlReader, XsltSettings.TrustedXslt, xslResolver);
                                xmlReader.Close();
                                // Try to execute the transformation
                                var macroResult = new HtmlTextWriter(new StringWriter());
                                macroXSLT.Transform(macroXML, xslArgs, macroResult);
                                macroResult.Close();

                                File.Delete(tempFileName);
                            }
                        }
                        else
                        {
                            //errorMessage = ui.Text("developer", "xsltErrorNoNodesPublished");
                            File.Delete(tempFileName);
                            //base.speechBubble(speechBubbleIcon.info, ui.Text("errors", "xsltErrorHeader", base.getUser()), "Unable to validate xslt as no published content nodes exist.");
                        }
                    }
                    catch (Exception errorXslt)
                    {
                        File.Delete(tempFileName);

                        errorMessage = (errorXslt.InnerException ?? errorXslt).ToString();

                        // Full error message
                        errorMessage = errorMessage.Replace("\n", "<br/>\n");
                        //closeErrorMessage.Visible = true;

                        // Find error
                        var m = Regex.Matches(errorMessage, @"\d*[^,],\d[^\)]", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                        foreach (Match mm in m)
                        {
                            string[] errorLine = mm.Value.Split(',');

                            if (errorLine.Length > 0)
                            {
                                var theErrorLine = int.Parse(errorLine[0]);
                                var theErrorChar = int.Parse(errorLine[1]);

                                errorMessage = "Error in XSLT at line " + errorLine[0] + ", char " + errorLine[1] +
                                               "<br/>";
                                errorMessage += "<span style=\"font-family: courier; font-size: 11px;\">";

                                var xsltText = fileContents.Split("\n".ToCharArray());
                                for (var i = 0; i < xsltText.Length; i++)
                                {
                                    if (i >= theErrorLine - 3 && i <= theErrorLine + 1)
                                        if (i + 1 == theErrorLine)
                                        {
                                            errorMessage += "<b>" + (i + 1) + ": &gt;&gt;&gt;&nbsp;&nbsp;" +
                                                            Server.HtmlEncode(xsltText[i].Substring(0, theErrorChar));
                                            errorMessage +=
                                                "<span style=\"text-decoration: underline; border-bottom: 1px solid red\">" +
                                                Server.HtmlEncode(
                                                    xsltText[i].Substring(theErrorChar,
                                                                          xsltText[i].Length - theErrorChar)).
                                                    Trim() + "</span>";
                                            errorMessage += " &lt;&lt;&lt;</b><br/>";
                                        }
                                        else
                                            errorMessage += (i + 1) + ": &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                                                            Server.HtmlEncode(xsltText[i]) + "<br/>";
                                }
                                errorMessage += "</span>";
                            }
                        }
                    }
                }

                if (errorMessage == "" && fileName.ToLower().EndsWith(".xslt"))
                {
                    //Hardcoded security-check... only allow saving files in xslt directory... 
                    var savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);

                    if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Xslt + "/")))
                    {
                        //deletes the old xslt file
                        if (fileName != oldName)
                        {

                            var p = IOHelper.MapPath(SystemDirectories.Xslt + "/" + oldName);
                            if (File.Exists(p))
                                File.Delete(p);
                        }

                        SW = File.CreateText(savePath);
                        SW.Write(fileContents);
                        SW.Close();
                        errorMessage = "true";

                       
                    }
                    else
                    {
                        errorMessage = "Illegal path";
                    }
                }

                File.Delete(tempFileName);

                return errorMessage;
            }
            return "false";
        }
     : super(library, name) {
     this.declaringType = declaringType;
     this.genericArguments = new ArrayList<TypeInfo>();
     this.interfaces = new ArrayList<TypeInfo>();
     this.annotations = new ArrayList<AnnotationValue>();
 }
        // TODO: Implement in all rooms tips, go back and things to find and put them in the inventar
        // TODO: Solve problem with go back, how do we know from where the person comes
        public int RunProgram()
        {
            Character.Inventory = new List <Item>();
            distributeNotes();
            TypeWriter typewriter = new TypeWriter();

            Console.SetOut(typewriter);
            Console.WriteLine(
                "Du gehst gerade nach Hause, als du plötztlich von hinten einen Schlag auf den Kopf bekommst!" +
                "\nAls du wieder zu dir kommst, spürst du einen stechenden Schmerz an deinem Hinterkopf. Warte, wer warst Du noch einmal?");
            Character.Name = Console.ReadLine();
            Console.WriteLine($"Ach genau! Du bist {Character.Name}, richtig?");
            String[] validInput   = { "nein", "ja" };
            string   confirmation = CheckInput(validInput);

            if (confirmation.ToLower().Equals("nein"))
            {
                Console.WriteLine("Wie ist denn dann dein Name?");
                Character.Name = Console.ReadLine();
            }

            Console.WriteLine("Nach allem Anschein wurdest du entführt. Du solltest versuchen dich zu befreien!" +
                              "\nDu ertastest deine Umgebung und merkst, dass du auf einem Bett sitzt. Was willst Du tun?\nAufstehen?\nUmsehen?");


            validInput   = new[] { "aufstehen", "umsehen" };
            confirmation = CheckInput(validInput);

            if (confirmation.Equals("umsehen"))
            {
                Console.WriteLine(
                    "Du kannst nicht viel sehen. Das Einzige, das Du erkennen kannst, sind die Umrisse des Betts. Du versuchst aufzustehen.");
                Console.WriteLine("Du tastest Dich weiter und erfühlst eine Kerze und Streichhölzer!");
                // if (_character.Inventory.Exists(x => x.ItemName == "Kerze"))
                // {
                // Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                // }
            }

            if (confirmation.ToLower().Equals("aufstehen"))
            {
                Console.WriteLine("Du tastest Dich weiter und erfühlst eine Kerze und Streichhölzer!");
            }

            Character.Inventory.Add(new Item()
            {
                ItemName = "Kerze"
            });
            Console.WriteLine("\nDu zündest die Kerze an und kannst nun Deine Umgebung besser erkennen.");

            bool doorOpened = false;
            bool keyFound   = false;

            while (doorOpened == false)
            {
                Console.WriteLine(
                    "Du siehst: Einen Schrank, ein Bett und eine Tür. Was willst Du Dir genauer ansehen?");
                validInput   = new[] { "tür", "schrank", "bett" };
                confirmation = CheckInput(validInput);

                switch (confirmation)
                {
                case "tür":
                    if (keyFound)
                    {
                        Console.WriteLine(
                            "Du gehst auf die Tür zu und versuchst die Tür mit dem Schlüssel zu öffnen. Der Schlüssel lässt sich im Schloss umdrehen und die Tür öffnet sich. \nDu gehst hindurch.");
                        doorOpened = true;
                        Room       = "corridorOne";
                        break;
                    }

                    Console.WriteLine(
                        "Du gehst auf die Tür zu. Sie wirkt ziemlich alt.\nDu versuchst sie zu öffnen, aber sie bewegt sich keinen Zentimeter.");
                    break;

                case "schrank":
                    Console.WriteLine(
                        "Der Schrank steht in der Ecke des Raums. So wie es aussieht, scheint nur unbrauchbares Zeug darin zu liegen.");
                    break;

                case "bett":
                    Console.WriteLine("Du schaust unters Bett und findest eine Schatulle. Willst Du sie öffnen? ");
                    validInput   = new[] { "ja", "nein" };
                    confirmation = CheckInput(validInput);

                    if (confirmation.Equals("nein"))
                    {
                        Console.WriteLine("Bist Du Dir sicher?");
                        confirmation = CheckInput(validInput);
                        if (confirmation.Equals("ja"))
                        {
                            break;
                        }
                    }

                    Console.WriteLine(
                        "Du öffnest die Schatulle, in der sich ein Schlüssel befindet. Wofür könnte dieser sein? ");
                    keyFound = true;
                    break;
                }
            }

            while (!GameFinished)
            {
                switch (Room)
                {
                case "bedroom":
                    while (Room == "bedroom")
                    {
                        string retval = new bedroom(this).run();
                        if (retval.Equals("corridorOne"))
                        {
                            Room = "corridorOne";
                        }
                    }

                    break;

                case "corridorOne":
                    while (Room == "corridorOne")
                    {
                        string retval = new corridor1(this).run();
                        if (retval.Equals("attic"))
                        {
                            Room = "attic";
                        }
                        else if (retval.Equals("entranceArea"))
                        {
                            _isDownstairs = false;
                            Room          = "entranceArea";
                        }
                    }

                    break;

                case "attic":
                    while (Room == "attic")
                    {
                        string retval = new attic(this).run();
                        if (retval.Equals("corridorOne"))
                        {
                            Room = "corridorOne";
                        }
                    }

                    break;

                case "entranceArea":
                    string val = new entranceArea(this).run(_isDownstairs);
                    if (val.Equals("corridorOne"))
                    {
                        Room = "corridorOne";
                    }
                    else if (val.Equals("corridorTwo"))
                    {
                        Room = "corridorTwo";
                    }
                    else if (val.Equals("kitchen"))
                    {
                        Room = "kitchen";
                    }

                    break;

                case "kitchen":
                    while (Room == "kitchen")
                    {
                        string retval = new kitchen(this).run();
                        if (retval.Equals("entranceArea"))
                        {
                            _isDownstairs = true;
                            Room          = "entranceArea";
                        }
                        else if (retval.Equals("garden"))
                        {
                            Room = "garden";
                        }
                    }

                    break;

                case "garden":
                    while (Room == "garden")
                    {
                        string retval = new garden(this).run();
                        if (retval.Equals("kitchen"))
                        {
                            Room = "kitchen";
                        }
                        else if (retval.Equals("ballroom"))
                        {
                            Room = "ballroom";
                        }
                    }

                    break;

                case "ballroom":
                    while (Room == "ballroom")
                    {
                        string retval = new ballroom(this).run();
                        if (retval.Equals("corridorTwo"))
                        {
                            Room = "corridorTwo";
                        }
                        else if (retval.Equals("balcony"))
                        {
                            Room = "balcony";
                        }
                    }

                    break;

                case "balcony":
                    while (Room == "balcony")
                    {
                        string retval = new balcony(this).run();
                        if (retval.Equals("ballroom"))
                        {
                            Room = "ballroom";
                        }
                    }

                    break;

                case "corridorTwo":
                    while (Room == "corridorTwo")
                    {
                        string retval = new corrdidor2(this).run();
                        if (retval.Equals("entranceArea"))
                        {
                            _isDownstairs = true;
                            Room          = "entranceArea";
                        }
                        else if (retval.Equals("library"))
                        {
                            Room = "library";
                        }
                        else if (retval.Equals("dungeon"))
                        {
                            Room = "dungeon";
                        }
                        else if (retval.Equals("corridorTwo"))
                        {
                            Room = "corridorTwo";
                        }
                    }

                    break;

                case "library":
                    while (Room == "library")
                    {
                        string retval = new library(this).run();
                        if (retval.Equals("corridorTwo"))
                        {
                            Room = "corridorTwo";
                        }
                    }

                    break;

                case "dungeon":
                    Console.WriteLine("Du gehst langsam die Treppe hinunter, die immer weiter nach unten führt.");
                    if (Character.Inventory.Exists(x => x.ItemName == "Taschenlampe"))
                    {
                        Console.WriteLine("Mit Deiner Taschanlampe in der Hand, kommst Du unten an.");
                    }
                    else
                    {
                        Console.WriteLine("Unten an der Treppe angekommen, kannst Du kaum noch etwas erkennen");
                    }
                    while (Room == "dungeon")
                    {
                        string retval = new dungeon(this).run();
                        if (retval.Equals("corridorTwo"))
                        {
                            Room = "corridorTwo";
                        }
                    }

                    break;

                default:
                    return(1);
                }
            }

            return(1);
        }