Exemplo n.º 1
0
    private static void ChangeContent(string name, string content)
    {
        bool documentFound = false;

        foreach (var document in documents)
        {
            if (document.Name == name)
            {
                documentFound = true;

                IEditable editableDocument = document as IEditable;
                if (editableDocument != null)
                {
                    editableDocument.ChangeContent(content);
                    Console.WriteLine("Document content changed: " + name);
                }
                else
                {
                    Console.WriteLine("Document is not editable: " + name);
                }
            }
        }

        if (!documentFound)
        {
            Console.WriteLine("Document not found: " + name);
        }
    }
Exemplo n.º 2
0
    private static void ChangeContent(string name, string content)
    {
        bool isAnyEditableDoc = false;

        foreach (var doc in documents)
        {
            if (doc.Name == name)
            {
                isAnyEditableDoc = true;
                IEditable editableDoc = doc as IEditable;
                if (editableDoc != null)
                {
                    editableDoc.ChangeContent(content);
                    Console.WriteLine("Document content changed: {0}", doc.Name);
                }
                else
                {
                    Console.WriteLine("Document is not editable: {0}", doc.Name);
                }
            }
        }
        if (!isAnyEditableDoc)
        {
            Console.WriteLine("Document not found: {0}", name);
        }
    }
Exemplo n.º 3
0
        private static void ChangeContent(string name, string content)
        {
            //
            bool found = false;

            foreach (var item in documents)
            {
                if (item.Name == name)
                {
                    found = true;
                    IEditable obj = item as IEditable;
                    if (obj != null)
                    {
                        obj.ChangeContent(content);
                        Console.WriteLine("Document content changed: {0}", name);
                    }
                    else
                    {
                        Console.WriteLine("Document is not editable: {0}", name);
                    }
                }
            }
            if (found == false)
            {
                Console.WriteLine("Document not found: {0}", name);
            }
        }