Example #1
0
        private void Button3_Click(object sender, EventArgs e)
        {
            Word   data = new Word();
            string text = "";

            text = textBox1.Text;
            bool hasLetters = false;

            hasLetters = FindLetters(text, hasLetters);
            if (hasLetters == true)
            {
                Analyzer textAn = new Analyzer(text);
                textAn.FindInDict();
                textAn.SelectPartOfSpeech();
                string tempInf = "";


                for (int i = 0; i < textAn.WordsInf.Count; i++)
                {
                    textBox2.Text = "";
                    IPrintable word = Analyzer.GetElemFromWordsInfList(i);
                    if (word is Noun || word is Adjective || word is Pronoun || word is Numeral)
                    {
                        tempInf += word.Print(i).Split(',').First() + ", " + word.Print(i).Split(',').Last() + "\r\n";
                    }
                    else
                    {
                        tempInf += word.Print(i).Split(',').First() + ", не склоняется или нет данных\r\n";
                    }
                }

                textBox2.Text += tempInf;
            }
        }
Example #2
0
    public static string Print(this IPrintable printable, string?name = null)
    {
        StructuredStringBuilder sb = new();

        printable.Print(sb, name);
        return(sb.ToString());
    }
        public static void Print(IPrintable iprintable)
        {
            Console.WriteLine(iprintable.Print());
            //shape.Print();

            /*double area = 0;
             *
             * if (shape is Circle)
             * {
             *  var circle = (Circle) shape;
             *  area = circle.Radius * circle.Radius * Math.PI;
             *  Console.WriteLine($"Circle: radius = {circle.Radius}, area = {area}");
             * }
             * else if (shape is RightAngledTriangle)
             * {
             *  var rightTriangle = (RightAngledTriangle) shape;
             *  area = 0.5 * rightTriangle.Side1 * rightTriangle.Side2;
             *  var info = "Right-angled Triangle: ";
             *  info += $"sides {rightTriangle.Side1} {rightTriangle.Side2} {rightTriangle.Side3}, ";
             *  info += $"area = {area}";
             *  Console.WriteLine(info);
             * }
             * else if (shape is Triangle)
             * {
             *  var triangle = (Triangle) shape;
             *
             *  var side1 = triangle.Side1;
             *  var side2 = triangle.Side2;
             *  var side3 = triangle.Side3;
             *  var p = (side1 + side2 + side3) / 2;
             *  area = Math.Sqrt(p * (p - side1) * (p - side2) * (p - side3));
             *  Console.WriteLine($"Triangle: sides: {side1} {side2} {side3}, area = {area}");*/
        }
Example #4
0
        public static void Print(IPrintable printable, string filename, int width, int height)
        {
            filename = ShowDialog(filename);
            if (filename == null)
            {
                return;
            }
            string extension = Path.GetExtension(filename).ToLower();

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            BasicImageFormat format = BasicImageFormat.GetFromExtension(extension);

            if (format == null)
            {
                MessageBox.Show("Could not find the specified file format: " + extension);
            }
            IGraphics graphics = format.CreateGraphics(filename, width, height);

            printable.Print(graphics, width, height);
            graphics.Close();
            graphics.Dispose();
        }
Example #5
0
        public static void Print(IPrintable I)
        {
            //double area = 0;

            //if (shape is Circle)
            //{
            //    var circle = (Circle) shape;
            //    area = circle.Radius * circle.Radius * Math.PI;
            //    Console.WriteLine($"Circle: radius = {circle.Radius}, area = {area}");
            //}
            //else if (shape is RightAngledTriangle)
            //{
            //    var rightTriangle = (RightAngledTriangle) shape;
            //    area = 0.5 * rightTriangle.Side1 * rightTriangle.Side2;
            //    var info = "Right-angled Triangle: ";
            //    info += $"sides {rightTriangle.Side1} {rightTriangle.Side2} {rightTriangle.Side3}, ";
            //    info += $"area = {area}";
            //    Console.WriteLine(info);
            //}
            //else if (shape is Triangle)
            //{
            //    var triangle = (Triangle) shape;

            //    var side1 = triangle.Side1;
            //    var side2 = triangle.Side2;
            //    var side3 = triangle.Side3;
            //    var p = (side1 + side2 + side3) / 2;
            //    area = Math.Sqrt(p * (p - side1) * (p - side2) * (p - side3));
            //    Console.WriteLine($"Triangle: sides: {side1} {side2} {side3}, area = {area}");
            //}

            Console.WriteLine(I.Print());
        }
Example #6
0
        private static string Print(IPrintable element, PrintType type = PrintType.Header)
        {
            var stringWriter = new StringWriter();
            var printer      = new Printer(stringWriter);

            element.Print(type, printer);
            return(stringWriter.ToString());
        }
Example #7
0
        static void Main(string[] args)
        {
            IPrintable[] arr = new IPrintable[] {
                new MyClass(),
                new MyClass2(),
                new MyClass2(),
                new MyClass()
            };

            MyClass m = new MyClass();

            m.Print();
            MyClass2 m2 = new MyClass2();
            //m2.Print(); //ERROR! can be accessed only through the interface!
            IPrintable i2 = m2;

            i2.Print();

            arr[0].Print();
            foreach (IPrintable item in arr)
            {
                item.Print();
            }

            Console.WriteLine();
            foreach (IMath item in arr)
            {
                item.Print();
            }
            Console.WriteLine("-----------------MyClass3");
            MyClass3 m3 = new MyClass3();

            m3.Print();
            IPrintable i3 = m3;

            i3.Print();
            Console.WriteLine("-----------------MyClass4");
            MyClass4 m4 = new MyClass4();

            m4.Print();
            IPrintable i4 = m4;

            i4.Print();
            Console.WriteLine("------------------MyClass5");
            MyClass5 m5 = new MyClass5();

            m5.Print();
            IPrintable i5 = m5;

            i5.Print();
            Console.WriteLine("------------------MyClass6");
            MyClass6 m6 = new MyClass6();

            m6.Print();
            //IPrintable i6 = m6;//ERROR cant implicitly convert...!
            //IPrintable i6 = (IPrintable)m6; //ERROR too!! cant implicitly convert...!
            //i6.Print();
        }
        /// <summary>
        ///		Отформатировать значение
        /// </summary>
        public static string Format(IPrintable value, string format = null)
        {
            if (ReferenceEquals(value, null))
            {
                return(NullStr);
            }

            return(value.Print(PrintOption.Default));
        }
Example #9
0
        static void Demo()
        {
            var person = new Person("RAVIAN656");
            // person.Print();  // can't be called print if object is not stored in one of the references of type interfaces
            IPrintable printable = person;

            printable.Print();
            ((IDisplayable)printable).Print();
        }
Example #10
0
        static void Main(string[] args)
        {
            SuperShape ss = new SuperShape();

            ss.Draw();

            IPrintable printable = ss as IPrintable;

            printable.Print();
        }
Example #11
0
        static void PrintTestPage(IPrintable printer)
        {
            printer.Print("It's just a test page...");
            printer.Print("Hello world!");
            printer.Print(new byte[] { 42, 12, 65, 7 });

            if (printer is ColorPrinter)
            {
                printer.Print("I'm a ColorPrinter!");
            }

            var mfu = printer as MultyFunctionalUnit;

            if (mfu != null)
            {
                var data = mfu.Scan();
                mfu.Print(data);
            }

            printer.Print(Environment.NewLine);
        }
Example #12
0
        private void printProjectExpression(ISparqlPrinter p, IVariable var)
        {
            p.print("((");
            IResource  expr       = var.getResource(SP.PropertyExpression);
            IPrintable expression = (IPrintable)SPINFactory.asExpression(expr);

            expression.Print(p);
            p.print(") ");
            p.printKeyword("AS");
            p.print(" ");
            p.print(var.ToString());
            p.print(")");
        }
Example #13
0
        public static string PrintToString([CanBeNull] this IPrintable printable, int?collectionMaxLength = null)
        {
            if (printable == null)
            {
                return("NULL");
            }
            var prettyPrinter = new PrettyPrinter();

            if (collectionMaxLength.HasValue)
            {
                prettyPrinter.CollectionMaxLength = collectionMaxLength.Value;
            }
            printable.Print(prettyPrinter);
            return(prettyPrinter.ToString());
        }
Example #14
0
        //static void DoUno()
        //{
        //    Mammifero mammiferoTest = new Mammifero(); non posso farla

        //    Cane cane = new Cane(6, 4);
        //    cane.Stampa();

        //    Mammifero mammifero = cane;
        //    mammifero.Stampa();

        //    Cane cane2 = (Cane)mammifero;
        //    cane2.Stampa();

        //    Console.ReadLine();

        //    Orso orso = new Orso("mangia miele", 2);
        //    orso.Stampa();

        //    mammifero = orso;
        //    mammifero.Stampa();

        //    Console.ReadLine();

        //    List<Mammifero> animali = new List<Mammifero>
        //    {
        //        new Cane(6, 4),
        //        new Orso("mangia miele", 2)
        //    };

        //    animali.ForEach(animale => animale.Stampa());

        //    Console.ReadLine();
        //}

        static void DoDue()
        {
            DocumentoSpeciale documentoSpeciale = new DocumentoSpeciale();
            IFindable         findableSpeciale  = documentoSpeciale;
            ISortable         sortableSpeciale  = documentoSpeciale;
            IPrintable        printableSpeciale = documentoSpeciale;
            Documento         documento         = documentoSpeciale;
            IFindable         findable          = documento;
            ISortable         sortable          = documento;
            IPrintable        printable         = documento;

            documentoSpeciale.Find();
            findableSpeciale.Find();
            documento.Find();
            findable.Find();

            Console.WriteLine();

            documentoSpeciale.Sort();
            sortableSpeciale.Sort();
            documento.Sort();
            sortable.Sort();

            Console.WriteLine();

            //documentoSpeciale.Print();
            printableSpeciale.Print();
            //documento.Print();
            printable.Print();

            Console.ReadLine();

            Documento  documento2 = new Documento();
            IFindable  findable2  = documento2;
            ISortable  sortable2  = documento2;
            IPrintable printable2 = documento2;

            documento2.Find();
            findable2.Find();
            documento2.Sort();
            sortable2.Sort();
            //documento2.Print();
            printable2.Print();
            Console.ReadLine();
        }
Example #15
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="document" /> is null.
        /// </exception>
        public static void CopyAsImage(IPrintable document, bool selectedOnly)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            var areaF = document.GetPrintingArea(true);

            areaF.Offset(0.5F, 0.5F);
            var area = Rectangle.FromLTRB((int)areaF.Left,
                                          (int)areaF.Top,
                                          (int)Math.Ceiling(areaF.Right),
                                          (int)Math.Ceiling(areaF.Bottom));

            using (var image = new Bitmap(area.Width, area.Height, PixelFormat.Format24bppRgb))
                using (var g = Graphics.FromImage(image))
                {
                    // Set drawing parameters
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    if (Settings.Default.UseClearTypeForImages)
                    {
                        g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    }
                    else
                    {
                        g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
                    }
                    g.TranslateTransform(-area.Left, -area.Top);

                    // Draw image
                    g.Clear(Style.CurrentStyle.BackgroundColor);
                    IGraphics graphics = new GdiGraphics(g);
                    document.Print(graphics, selectedOnly, Style.CurrentStyle);

                    try
                    {
                        System.Windows.Forms.Clipboard.SetImage(image);
                    }
                    catch
                    {
                        //UNDONE: exception handling of CopyAsImage()
                    }
                }
        }
Example #16
0
 public static void Print(IPrintable printable, string filename, int width, int height)
 {
     filename = ShowDialog(filename);
     if (filename == null){
         return;
     }
     string extension = System.IO.Path.GetExtension(filename).ToLower();
     if (File.Exists(filename)){
         File.Delete(filename);
     }
     BasicImageFormat format = BasicImageFormat.GetFromExtension(extension);
     if (format == null){
         MessageBox.Show("Could not find the specified file format: " + extension);
     }
     IGraphics graphics = format.CreateGraphics(filename, width, height);
     printable.Print(graphics, width, height);
     graphics.Close();
     graphics.Dispose();
 }
Example #17
0
        static void Main(string[] args)
        {
            var mydoc = new Document();

            mydoc.Print();
            mydoc.CountCharacters();

            IPrintable printItem = mydoc;

            printItem.Print();
            //printItem.CountCharacters();
            Document theDoc = printItem as Document;

            if (theDoc != null)
            {
                theDoc.CountCharacters();
            }

            Console.ReadLine();
        }
Example #18
0
 /// <summary>
 /// will print the array
 /// </summary>
 /// <param name="arr">shoudl contain array of IPrintable items</param>
 static void PrintArr(object[] arr)
 {
     foreach (IPrintable item in arr)
     {
         Console.WriteLine();
         Console.WriteLine(item.GetType());
         item.Print();
     }
     Console.WriteLine("\n\n________again___________\n\n");
     for (int i = 0; i < arr.Length; i++)
     {
         IPrintable ip = arr[i] as IPrintable;
         if (ip != null)
         {
             Console.WriteLine();
             Console.WriteLine(ip.GetType());
             ip.Print();
         }
     }
 }
Example #19
0
        public override bool Execute(CountInput input)
        {
            string inputFileName  = input.InputFileName;
            string outputFileName = input.OutputFileName;

            IReadable reader = DependencyResolver.Container.GetInstance <IReadable>(
                new ExplicitArguments()
                .Set(inputFileName));

            ISortable sorter = DependencyResolver.Container.GetInstance <ISortable>();

            IPrintable printer = DependencyResolver.Container.GetInstance <IPrintable>(
                new ExplicitArguments()
                .Set(outputFileName)
                .Set(sorter.Sort(reader.Read())));

            printer.Print();

            return(true);
        }
Example #20
0
        private void Button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = "";
            string text       = textBox1.Text;
            bool   hasLetters = false;

            hasLetters = FindLetters(text, hasLetters);
            if (hasLetters == true)
            {
                Word     data   = new Word();
                Analyzer textAn = new Analyzer(text);
                textAn.FindInDict();
                textAn.SelectPartOfSpeech();

                for (int i = 0; i < textAn.WordsInf.Count; i++)
                {
                    IPrintable word = Analyzer.GetElemFromWordsInfList(i);
                    textBox2.Text += word.Print(i) + "\r\n";
                }
            }
        }
Example #21
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="document"/> is null.
		/// </exception>
		public static void CopyAsImage(IPrintable document, bool selectedOnly)
		{
			if (document == null)
				throw new ArgumentNullException("document");

			RectangleF areaF = document.GetPrintingArea(true);
			areaF.Offset(0.5F, 0.5F);
			Rectangle area = Rectangle.FromLTRB((int) areaF.Left, (int) areaF.Top,
				(int) Math.Ceiling(areaF.Right), (int) Math.Ceiling(areaF.Bottom));

			using (Bitmap image = new Bitmap(area.Width, area.Height, PixelFormat.Format24bppRgb))
			using (Graphics g = Graphics.FromImage(image))
			{
				// Set drawing parameters
				g.SmoothingMode = SmoothingMode.HighQuality;
				if (DiagramEditor.Settings.Default.UseClearTypeForImages)
					g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				else
					g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
				g.TranslateTransform(-area.Left, -area.Top);

				// Draw image
				g.Clear(Style.CurrentStyle.BackgroundColor);
				IGraphics graphics = new GdiGraphics(g);
				document.Print(graphics, selectedOnly, Style.CurrentStyle);

				try
				{
					System.Windows.Forms.Clipboard.SetImage(image);
				}
				catch
				{
					//UNDONE: exception handling of CopyAsImage()
				}
			}
		}
Example #22
0
        private static void SaveAsImage(IPrintable document, string path,
                                        ImageFormat format, bool selectedOnly, bool transparent)
        {
            const int Margin = 20;

            RectangleF areaF = document.GetPrintingArea(selectedOnly);

            areaF.Offset(0.5F, 0.5F);
            Rectangle area = Rectangle.FromLTRB((int)areaF.Left, (int)areaF.Top,
                                                (int)Math.Ceiling(areaF.Right), (int)Math.Ceiling(areaF.Bottom));

            if (format == ImageFormat.Emf)             // Save to metafile
            {
                Graphics metaG = control.CreateGraphics();
                IntPtr   hc    = metaG.GetHdc();
                Graphics g     = null;

                try
                {
                    // Set drawing parameters
                    Metafile meta = new Metafile(path, hc);
                    g = Graphics.FromImage(meta);
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    if (DiagramEditor.Settings.Default.UseClearTypeForImages)
                    {
                        g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    }
                    else
                    {
                        g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                    }
                    g.TranslateTransform(-area.Left, -area.Top);

                    // Draw image
                    IGraphics graphics = new GdiGraphics(g);
                    document.Print(graphics, selectedOnly, Style.CurrentStyle);

                    meta.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        string.Format("{0}\n{1}: {2}", Strings.ErrorInSavingImage,
                                      Strings.ErrorsReason, ex.Message),
                        Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    metaG.ReleaseHdc();
                    metaG.Dispose();
                    if (g != null)
                    {
                        g.Dispose();
                    }
                }
            }
            else             // Save to rastered image
            {
                int         width  = area.Width + Margin * 2;
                int         height = area.Height + Margin * 2;
                PixelFormat pixelFormat;

                if (transparent)
                {
                    pixelFormat = PixelFormat.Format32bppArgb;
                }
                else
                {
                    pixelFormat = PixelFormat.Format24bppRgb;
                }

                using (Bitmap image = new Bitmap(width, height, pixelFormat))
                    using (Graphics g = Graphics.FromImage(image))
                    {
                        // Set drawing parameters
                        g.SmoothingMode = SmoothingMode.HighQuality;
                        if (DiagramEditor.Settings.Default.UseClearTypeForImages && !transparent)
                        {
                            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                        }
                        else
                        {
                            g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
                        }
                        g.TranslateTransform(Margin - area.Left, Margin - area.Top);

                        // Draw image
                        if (!transparent)
                        {
                            g.Clear(Style.CurrentStyle.BackgroundColor);
                        }

                        IGraphics graphics = new GdiGraphics(g);
                        document.Print(graphics, selectedOnly, Style.CurrentStyle);

                        try
                        {
                            image.Save(path, format);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(
                                string.Format("{0}\n{1}: {2}", Strings.ErrorInSavingImage,
                                              Strings.ErrorsReason, ex.Message),
                                Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
            }
        }
 static void Method(IPrintable iface)
 {
     iface.Print();
     Console.WriteLine();
 }
        public static void Print(IPrintable IP)
        {
            string res = IP.Print();

            Console.WriteLine(res);
        }
        static void Main(string[] args)
        {
            try
            {
                // Using interface as variable types
                IVehicle myBike     = new Bicycle();
                IVehicle myCar      = new Car();
                IVehicle myOtherCar = new Car();

                myBike.Make  = "Giant";
                myBike.Model = "XTC Advanced 29";
                myBike.SpeedUp(3);
                myBike.ChangeGear(15);

                if (myBike is Bicycle)// type check to ensure a safe cast
                {
                    ((Bicycle)myBike).DeployKiskStand();
                    P("Kick stand deployed: " + ((Bicycle)myBike).KickStandDown);
                }

                myCar.Make  = "Jeep";
                myCar.Model = "Wrangler";
                myCar.SpeedUp(-3);

                myOtherCar.Make  = "Forester";
                myOtherCar.Model = "Subaru";
                myOtherCar.ChangeGear(3);
                myOtherCar.SpeedUp(30);

                List <IVehicle> myVehicles = new List <IVehicle>()
                {
                    myBike, myCar, myOtherCar
                };

                foreach (IVehicle v in myVehicles)
                {
                    //Print
                    IPrintable myVehicle = null;

                    if (v is Car)
                    {
                        myVehicle = (Car)v;
                    }

                    if (v is Bicycle)
                    {
                        myVehicle = (Bicycle)v;
                    }

                    P("--------------------------------------");
                    if (myVehicle != null)
                    {
                        P(myVehicle.Print());
                    }
                }
            }
            catch (Exception ex)
            {
                P(ex.Message);
            }

            Console.ReadLine(); // Haults closing
        }
Example #26
0
		private static void SaveAsImage(IPrintable document, string path,
			ImageFormat format, bool selectedOnly, bool transparent)
		{
			const int Margin = 20;

			RectangleF areaF = document.GetPrintingArea(selectedOnly);
			areaF.Offset(0.5F, 0.5F);
			Rectangle area = Rectangle.FromLTRB((int) areaF.Left, (int) areaF.Top,
				(int) Math.Ceiling(areaF.Right), (int) Math.Ceiling(areaF.Bottom));

			if (format == ImageFormat.Emf) // Save to metafile
			{
				Graphics metaG = control.CreateGraphics();
				IntPtr hc = metaG.GetHdc();
				Graphics g = null;

				try
				{
					// Set drawing parameters
					Metafile meta = new Metafile(path, hc);
					g = Graphics.FromImage(meta);
					g.SmoothingMode = SmoothingMode.HighQuality;
					if (DiagramEditor.Settings.Default.UseClearTypeForImages)
						g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
					else
						g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
					g.TranslateTransform(-area.Left, -area.Top);

					// Draw image
					IGraphics graphics = new GdiGraphics(g);
					document.Print(graphics, selectedOnly, Style.CurrentStyle);

					meta.Dispose();
				}
				catch (Exception ex)
				{
					MessageBox.Show(
						string.Format("{0}\n{1}: {2}", Strings.ErrorInSavingImage,
							Strings.ErrorsReason, ex.Message),
						Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
				}
				finally
				{
					metaG.ReleaseHdc();
					metaG.Dispose();
					if (g != null)
						g.Dispose();
				}
			}
			else // Save to rastered image
			{
				int width = area.Width + Margin * 2;
				int height = area.Height + Margin * 2;
				PixelFormat pixelFormat;

				if (transparent)
					pixelFormat = PixelFormat.Format32bppArgb;
				else
					pixelFormat = PixelFormat.Format24bppRgb;

				using (Bitmap image = new Bitmap(width, height, pixelFormat))
				using (Graphics g = Graphics.FromImage(image))
				{
					// Set drawing parameters
					g.SmoothingMode = SmoothingMode.HighQuality;
					if (DiagramEditor.Settings.Default.UseClearTypeForImages && !transparent)
						g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
					else
						g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
					g.TranslateTransform(Margin - area.Left, Margin - area.Top);

					// Draw image
					if (!transparent)
						g.Clear(Style.CurrentStyle.BackgroundColor);

					IGraphics graphics = new GdiGraphics(g);
					document.Print(graphics, selectedOnly, Style.CurrentStyle);

					try
					{
						image.Save(path, format);
					}
					catch (Exception ex)
					{
						MessageBox.Show(
							string.Format("{0}\n{1}: {2}", Strings.ErrorInSavingImage,
								Strings.ErrorsReason, ex.Message),
							Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
				}
			}
		}
Example #27
0
 public void Log(string message, IPrintable iPrintable)
 {
     Console.WriteLine("\n" + message);
     Console.WriteLine(iPrintable.Print());
 }
Example #28
0
 public static void Print(IPrintable printable)
 {
     Console.WriteLine(printable.Print());
 }
 static void Output(IPrintable toOutput)
 {
     Console.WriteLine(toOutput.Print());
 }
Example #30
0
        public static void UpdatePrint(this IPrintable printable)
        {
            Console.Clear();

            printable.Print();
        }
Example #31
0
 public static void ToConsole(IPrintable printableObjects)
 {
     printableObjects.Print();
 }
Example #32
0
 public void PrintDelegate(IPrintable printable)
 {
     printable.Print(this);
 }
 // In method injection we need to pass the dependency in the method only
 public void Printing(IPrintable printable)
 {
     this.printable = printable;
     printable.Print();
 }
Example #34
0
 public void Print(string str)
 {
     Realize();
     real.Print(str);
 }
Example #35
0
        static void Main(string[] args)
        {
            List <Lager> lager            = new List <Lager>();
            var          ergebnisLager100 = lager.Where(l => l.Lagerbestand > 100);


            Lager l1 = new Lager();

            l1.OnLagerUberschritten += LagerUeberschritten;
            //l1.EventLagerUeberschritten += LagerUeberschritten;
            l1.AddToLager(70); //70
            //if (l1.Lagerbestand>100)
            l1.AddToLager(30); //100
            //if (l1.Lagerbestand > 100)
            l1.AddToLager(20); //120
            //if (l1.Lagerbestand > 100)
            l1.Print();

            IPrintable iPrint = l1;

            iPrint.Print();

            l1.GetLagerwert(12);
            //l1.Release();
            //l1.Close();
            //l1.Kill();
            l1.Dispose();
            l1 = null; //Garbage -- GC

            //Temp Resource-Usage-Pattern
            using (Lager l = new Lager())
            {
                l.Lagerbestand = 120;
                l.AddToLager(20);
            }//Dispose in einem finally-Block

            if (iPrint is Lager)
            {
                Lager lager1 = (Lager)iPrint;
            }


            //Direkter Aufruf
            M1();

            //Delegate, FunctionPoint
            Del1 d = M1;

            d();

            Del2 d2 = M4;

            d2("Johann");

            //Generische Delegates Func mit Return, Action void

            Action a1 = M1;

            a1();

            Action <string> a2 = M4;

            a2("Johann");

            Func <string, int> f = M3;

            var erg = f("Hans");
        }
Example #36
0
 //Decoupled, Coherent
 public static void Print(IPrintable thing)
 {
     Console.WriteLine(thing.Print());
 }