Exemplo n.º 1
0
        private void OnSelectedItemChangedCommand(PatternDetails selectedItem)
        {
            SelectedPattern = selectedItem;

            Log.SetOutPutAction(SelectedPattern.OutPutAction);

            SelectedPattern.Run();
        }
Exemplo n.º 2
0
            protected override PatternDetails CreatePatternDetails()
            {
                var mediatorParent = new PatternDetails
                {
                    Name     = "Mediator",
                    Header   = "Mediator",
                    Detailes = "Defines simplified communication between classes - " +
                               "Define an object that encapsulates how a set of objects interact. Mediator promotes loose " +
                               "coupling by keeping objects from referring to each other explicitly, and it lets" +
                               " you vary their interaction independently.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Mediator-design-pattern"),
                    }
                };

                var mediatorStructural = new PatternDetails
                {
                    Name     = "MediatorStructural",
                    Header   = "Mediator Structural",
                    Method   = MethodService.MediatorStructural,
                    Detailes =
                        "This structural code demonstrates the Mediator pattern facilitating loosely coupled communication " +
                        "between different objects and object types. The mediator is a central hub through which" +
                        " all interaction must take place.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Mediator-design-pattern#str"),
                    }
                };


                var mediatorRealWorld = new PatternDetails
                {
                    Name     = "MediatorRealWorld",
                    Header   = "Mediator Real World",
                    Method   = MethodService.MediatorRealWorld,
                    Detailes = "This real-world code demonstrates the Mediator pattern facilitating loosely" +
                               " coupled communication between different Participants registering with a Chatroom. " +
                               "The Chatroom is the central hub through which all communication takes place." +
                               " At this point only one-to-one communication is implemented in the Chatroom, " +
                               "but would be trivial to change to one-to-many.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Mediator-design-pattern#rea"),
                    }
                };

                mediatorParent.Patterns.Add(mediatorStructural);
                mediatorParent.Patterns.Add(mediatorRealWorld);

                return(mediatorParent);
            }
        protected override PatternDetails CreatePatternDetails()
        {
            var abstractFactoryParent = new PatternDetails
            {
                Name     = "AbstractFactory",
                Header   = "Abstract Factory",
                Detailes = "Creates an instance of several families of classes - " +
                           "Provide an interface for creating families of related or dependent objects without specifying their concrete classes.",
                ImageUrl = @"pack://*****:*****@"pack://application:,,,/DesignPatterns;component/Images/ClassDiagrams/AbstractFactoryRw.png",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/abstract-factory-design-pattern#rea"),
                }
            };

            var abstractFactoryStructural = new PatternDetails
            {
                Name     = "AbstractFactoryStructural",
                Header   = "Abstract Factory Structural",
                Method   = MethodService.AbstractFactoryStructural,
                Detailes =
                    "This structural code demonstrates the Abstract Factory pattern creating parallel hierarchies of objects."
                    +
                    " Object creation has been abstracted and there is no need for hard-coded class names in the client code.",
                ImageUrl =
                    @"pack://application:,,,/DesignPatterns;component/Images/ClassDiagrams/AbstractFactorySt.png",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/abstract-factory-design-pattern#str"),
                }
            };


            abstractFactoryParent.Patterns.Add(abstractFactoryStructural);
            abstractFactoryParent.Patterns.Add(abstractFactoryRealWorld);

            return(abstractFactoryParent);
        }
Exemplo n.º 4
0
            protected override PatternDetails CreatePatternDetails()
            {
                var templateMethodParent = new PatternDetails
                {
                    Name     = "TemplateMethod",
                    Header   = "Template Method",
                    Detailes = "Defer the exact steps of an algorithm to a subclass - " +
                               "Define the skeleton of an algorithm in an operation, deferring " +
                               "some steps to subclasses. Template Method lets subclasses redefine certain " +
                               "steps of an algorithm without changing the algorithm's structure.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Template-Method-design-pattern"),
                    }
                };

                var templateMethodStructural = new PatternDetails
                {
                    Name     = "TemplateMethodStructural",
                    Header   = "TemplateMethod Structural",
                    Method   = MethodService.TemplateMethodStructural,
                    Detailes =
                        "This structural code demonstrates the Template method which provides a skeleton " +
                        "calling sequence of methods. One or more steps can be deferred to subclasses which" +
                        " implement these steps without changing the overall calling sequence.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Template-Method-design-pattern#str"),
                    }
                };


                var templateMethodRealWorld = new PatternDetails
                {
                    Name     = "TemplateMethodRealWorld",
                    Header   = "TemplateMethod Real World",
                    Method   = MethodService.TemplateMethodRealWorld,
                    Detailes = "This real-world code demonstrates a Template method named Run() " +
                               "which provides a skeleton calling sequence of methods. Implementation of " +
                               "these steps are deferred to the CustomerDataObject subclass which implements the " +
                               "Connect, Select, Process, and Disconnect methods.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Template-Method-design-pattern#rea"),
                    }
                };

                templateMethodParent.Patterns.Add(templateMethodStructural);
                templateMethodParent.Patterns.Add(templateMethodRealWorld);

                return(templateMethodParent);
            }
Exemplo n.º 5
0
            protected override PatternDetails CreatePatternDetails()
            {
                var stateParent = new PatternDetails
                {
                    Name     = "State",
                    Header   = "State",
                    Detailes = "Alter an object's behavior when its state changes - " +
                               "Allow an object to alter its behavior when its" +
                               " internal state changes. The object will appear to change its class.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/State-design-pattern"),
                    }
                };

                var stateStructural = new PatternDetails
                {
                    Name     = "StateStructural",
                    Header   = "State Structural",
                    Method   = MethodService.StateStructural,
                    Detailes =
                        "This structural code demonstrates the State pattern which allows an object to " +
                        "behave differently depending on " + "its internal state. The difference in behavior " +
                        "is delegated to objects that represent this state.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/State-design-pattern#str"),
                    }
                };


                var stateRealWorld = new PatternDetails
                {
                    Name     = "StateRealWorld",
                    Header   = "State Real World",
                    Method   = MethodService.StateRealWorld,
                    Detailes = "This real-world code demonstrates the State pattern which allows an Account " +
                               "to behave differently depending on its balance. The difference in " +
                               "behavior is delegated to State objects called RedState, SilverState and GoldState." +
                               " These states represent overdrawn accounts, starter accounts, and accounts in good standing.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/State-design-pattern#rea"),
                    }
                };

                stateParent.Patterns.Add(stateStructural);
                stateParent.Patterns.Add(stateRealWorld);

                return(stateParent);
            }
Exemplo n.º 6
0
            protected override PatternDetails CreatePatternDetails()
            {
                var chainOfRespParent = new PatternDetails
                {
                    Name     = "ChainOfResp",
                    Header   = "ChainOfResp",
                    Detailes = "A way of passing a request between a chain of objects - " +
                               "Avoid coupling the sender of a request to its receiver by giving more than one object"
                               + " a chance to handle the request. Chain the receiving objects and "
                               + "pass the request along the chain until an object handles it.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/chain-of-responsibility-design-pattern"),
                    }
                };

                var chainOfRespStructural = new PatternDetails
                {
                    Name     = "ChainOfRespStructural",
                    Header   = "ChainOfResp Structural",
                    Method   = MethodService.ChainOfRespStructural,
                    Detailes =
                        "This structural code demonstrates the Chain of Responsibility pattern in"
                        + " which several linked objects (the Chain) are offered the opportunity to "
                        + "respond to a request or hand it off to the object next in line.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/chain-of-responsibility-design-pattern#str"),
                    }
                };


                var chainOfRespRealWorld = new PatternDetails
                {
                    Name     = "ChainOfRespRealWorld",
                    Header   = "ChainOfResp Real World",
                    Method   = MethodService.ChainOfRespRealWorld,
                    Detailes = "This real-world code demonstrates the Chain of Responsibility pattern in"
                               + " which several linked managers and executives can respond to a purchase request or hand it"
                               + "off to a superior. Each position has can have its own set of rules which orders they can approve.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/chain-of-responsibility-design-pattern#rea"),
                    }
                };

                chainOfRespParent.Patterns.Add(chainOfRespStructural);
                chainOfRespParent.Patterns.Add(chainOfRespRealWorld);

                return(chainOfRespParent);
            }
Exemplo n.º 7
0
            protected override PatternDetails CreatePatternDetails()
            {
                var visitorParent = new PatternDetails
                {
                    Name     = "Visitor",
                    Header   = "Visitor",
                    Detailes = "Defines a new operation to a class without change - " +
                               "Represent an operation to be performed on the elements of an object structure." +
                               " Visitor lets you define a new operation without changing the classes of the" +
                               " elements on which it operates.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Visitor-design-pattern"),
                    }
                };

                var visitorStructural = new PatternDetails
                {
                    Name     = "VisitorStructural",
                    Header   = "Visitor Structural",
                    Method   = MethodService.VisitorStructural,
                    Detailes =
                        "This structural code demonstrates the Visitor pattern in which an object " +
                        "traverses an object structure and performs the same operation on each node in " +
                        "this structure. Different visitor objects define different operations.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Visitor-design-pattern#str"),
                    }
                };


                var visitorRealWorld = new PatternDetails
                {
                    Name     = "VisitorRealWorld",
                    Header   = "Visitor Real World",
                    Method   = MethodService.VisitorRealWorld,
                    Detailes = "This real-world code demonstrates the Visitor pattern in which two objects " +
                               "traverse a list of Employees and performs the same operation on each Employee." +
                               " The two visitor objects define different operations -- one adjusts vacation days and the other income.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Visitor-design-pattern#rea"),
                    }
                };

                visitorParent.Patterns.Add(visitorStructural);
                visitorParent.Patterns.Add(visitorRealWorld);

                return(visitorParent);
            }
Exemplo n.º 8
0
            protected override PatternDetails CreatePatternDetails()
            {
                var strategyParent = new PatternDetails
                {
                    Name     = "Strategy",
                    Header   = "Strategy",
                    Detailes = "Encapsulates an algorithm inside a class - " +
                               "Define a family of algorithms, encapsulate each one, and make them interchangeable. " +
                               "Strategy lets the algorithm vary independently from clients that use it.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Strategy-design-pattern"),
                    }
                };

                var strategyStructural = new PatternDetails
                {
                    Name     = "StrategyStructural",
                    Header   = "Strategy Structural",
                    Method   = MethodService.StrategyStructural,
                    Detailes =
                        "This structural code demonstrates the Strategy pattern which encapsulates functionality " +
                        "in the form of an object. This allows clients to dynamically change algorithmic strategies.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Strategy-design-pattern#str"),
                    }
                };


                var strategyRealWorld = new PatternDetails
                {
                    Name     = "StrategyRealWorld",
                    Header   = "Strategy Real World",
                    Method   = MethodService.StrategyRealWorld,
                    Detailes = "This real-world code demonstrates the Strategy pattern which " +
                               "encapsulates sorting algorithms in the form of sorting objects." +
                               " This allows clients to dynamically change sorting strategies including" +
                               " Quicksort, Shellsort, and Mergesort.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Strategy-design-pattern#rea"),
                    }
                };

                strategyParent.Patterns.Add(strategyStructural);
                strategyParent.Patterns.Add(strategyRealWorld);

                return(strategyParent);
            }
Exemplo n.º 9
0
        protected override PatternDetails CreatePatternDetails()
        {
            var behavioralDetails = new PatternDetails
            {
                Name   = "Behavioral",
                Header = "Behavioral Patterns",
            };

            _factoryTypes.ForEach(factoryType => behavioralDetails.Patterns.Add(factoryType.GetPatternDetails()));

            return(behavioralDetails);
        }
            protected override PatternDetails CreatePatternDetails()
            {
                var adapterParent = new PatternDetails
                {
                    Name     = "Adapter",
                    Header   = "Adapter",
                    Detailes = "Match interfaces of different classes - " +
                               "Convert the interface of a class into another interface clients expect. Adapter lets "
                               + "classes work together that couldn't otherwise because of incompatible interfaces.",
                    ImageUrl = @"pack://*****:*****@"pack://application:,,,/DesignPatterns;component/Images/ClassDiagrams/AdapterUML.png",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/adapter-design-pattern#str"),
                    }
                };


                var adapterRealWorld = new PatternDetails
                {
                    Name     = "AdapterRealWorld",
                    Header   = "Adapter Real World",
                    Method   = MethodService.AdapterRealWorld,
                    Detailes = "This real-world code demonstrates the use of a legacy chemical databank." +
                               " Chemical compound objects access the databank through an Adapter interface.",
                    ImageUrl =
                        @"pack://application:,,,/DesignPatterns;component/Images/ClassDiagrams/AdapterUML.png",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/adapter-design-pattern#rea"),
                    }
                };

                adapterParent.Patterns.Add(adapterStructural);
                adapterParent.Patterns.Add(adapterRealWorld);

                return(adapterParent);
            }
        protected override PatternDetails CreatePatternDetails()
        {
            var singletonParent = new PatternDetails
            {
                Name     = "Singleton",
                Header   = "Singleton",
                Detailes = "A class of which only a single instance can exist - " +
                           "Ensure a class has only one instance and provide a global point of access to it.",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/singleton-design-pattern"),
                    new Uri("http://csharpindepth.com/articles/general/singleton.aspx")
                }
            };

            var singletonRealWorld = new PatternDetails
            {
                Name     = "SingletonRealWorld",
                Header   = "Singleton Real World",
                Method   = MethodService.SingletonRealWorld,
                Detailes = "This real-world code demonstrates the Singleton pattern as a LoadBalancing object."
                           +
                           " Only a single instance (the singleton) of the class can be created because servers may dynamically "
                           +
                           "come on- or off-line and every request must go throught the one object that has knowledge"
                           + " about the state of the (web) farm.",
                ImageUrl = @"pack://*****:*****@"pack://application:,,,/DesignPatterns;component/Images/SingletonUML.PNG",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/singleton-design-pattern#str"),
                }
            };

            singletonParent.Patterns.Add(singletonStructural);
            singletonParent.Patterns.Add(singletonRealWorld);

            return(singletonParent);
        }
Exemplo n.º 12
0
            protected override PatternDetails CreatePatternDetails()
            {
                var commandParent = new PatternDetails
                {
                    Name     = "Command",
                    Header   = "Command",
                    Detailes = "Encapsulate a command request as an object - " +
                               "Encapsulate a request as an object, thereby letting you parameterize clients with " +
                               "different requests, queue or log requests, and support undoable operations.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Command-design-pattern"),
                    }
                };

                var commandStructural = new PatternDetails
                {
                    Name     = "CommandStructural",
                    Header   = "Command Structural",
                    Method   = MethodService.CommandStructural,
                    Detailes =
                        "This structural code demonstrates the Command pattern which" +
                        " stores requests as objects allowing clients to execute or playback the requests.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Command-design-pattern#str"),
                    }
                };


                var commandRealWorld = new PatternDetails
                {
                    Name     = "CommandRealWorld",
                    Header   = "Command Real World",
                    Method   = MethodService.CommandRealWorld,
                    Detailes = "This real-world code demonstrates the Command pattern used in a simple" +
                               " calculator with unlimited number of undo's and redo's. Note that in C#  " +
                               "the word 'operator' is a keyword. Prefixing it with '@' allows using it as an identifier.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Command-design-pattern#rea"),
                    }
                };

                commandParent.Patterns.Add(commandStructural);
                commandParent.Patterns.Add(commandRealWorld);

                return(commandParent);
            }
        protected override PatternDetails CreatePatternDetails()
        {
            var builderParent = new PatternDetails
            {
                Name     = "Builder",
                Header   = "Builder",
                Detailes = "Separates object construction from its representation - " +
                           "Separate the construction of a complex object from its representation so that the same construction process can create different representations.",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/builder-design-pattern"),
                }
            };

            var builderRealWorld = new PatternDetails
            {
                Name     = "BuilderRealWorld",
                Header   = "Builder Real World",
                Method   = MethodService.BuilderRealWorld,
                Detailes =
                    "This real-world code demonstates the Builder pattern in which different vehicles are assembled in a step-by-step fashion. "
                    +
                    "The Shop uses VehicleBuilders to construct a variety of Vehicles in a series of sequential steps.",
                ImageUrl = @"pack://*****:*****@"pack://application:,,,/DesignPatterns;component/Images/BuilderUML.PNG",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/builder-design-pattern#str"),
                }
            };


            builderParent.Patterns.Add(builderStructural);
            builderParent.Patterns.Add(builderRealWorld);

            return(builderParent);
        }
Exemplo n.º 14
0
            protected override PatternDetails CreatePatternDetails()
            {
                var iteratorParent = new PatternDetails
                {
                    Name     = "Iterator",
                    Header   = "Iterator",
                    Detailes = "Sequentially access the elements of a collection - " +
                               "Provide a way to access the elements of an aggregate object" +
                               " sequentially without exposing its underlying representation.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Iterator-design-pattern"),
                    }
                };

                var iteratorStructural = new PatternDetails
                {
                    Name     = "IteratorStructural",
                    Header   = "Iterator Structural",
                    Method   = MethodService.IteratorStructural,
                    Detailes =
                        "This structural code demonstrates the Iterator pattern which provides for a way to traverse (iterate) over" +
                        " a collection of items without detailing the underlying structure of the collection.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Iterator-design-pattern#str"),
                    }
                };


                var iteratorRealWorld = new PatternDetails
                {
                    Name     = "IteratorRealWorld",
                    Header   = "Iterator Real World",
                    Method   = MethodService.IteratorRealWorld,
                    Detailes = "This real-world code demonstrates the Iterator pattern which is used to" +
                               " iterate over a collection of items and skip a specific number of items each iteration.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Iterator-design-pattern#rea"),
                    }
                };

                iteratorParent.Patterns.Add(iteratorStructural);
                iteratorParent.Patterns.Add(iteratorRealWorld);

                return(iteratorParent);
            }
Exemplo n.º 15
0
            protected override PatternDetails CreatePatternDetails()
            {
                var mementoParent = new PatternDetails
                {
                    Name     = "Memento",
                    Header   = "Memento",
                    Detailes = "Capture and restore an object's internal state - " +
                               "Without violating encapsulation, capture and externalize an object's " +
                               "internal state so that the object can be restored to this state later.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Memento-design-pattern"),
                    }
                };

                var mementoStructural = new PatternDetails
                {
                    Name     = "MementoStructural",
                    Header   = "Memento Structural",
                    Method   = MethodService.MementoStructural,
                    Detailes =
                        "This structural code demonstrates the Memento pattern which" +
                        " temporary saves and restores another object's internal state.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Memento-design-pattern#str"),
                    }
                };


                var mementoRealWorld = new PatternDetails
                {
                    Name     = "MementoRealWorld",
                    Header   = "Memento Real World",
                    Method   = MethodService.MementoRealWorld,
                    Detailes = "This real-world code demonstrates the Memento pattern" +
                               " which temporarily saves and then restores the SalesProspect's internal state.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Memento-design-pattern#rea"),
                    }
                };

                mementoParent.Patterns.Add(mementoStructural);
                mementoParent.Patterns.Add(mementoRealWorld);

                return(mementoParent);
            }
Exemplo n.º 16
0
            protected override PatternDetails CreatePatternDetails()
            {
                var interpreterParent = new PatternDetails
                {
                    Name     = "Interpreter",
                    Header   = "Interpreter",
                    Detailes = "A way to include language elements in a program - " +
                               "Given a language, define a representation for its grammar along with an " +
                               "interpreter that uses the representation to interpret sentences in the language.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Interpreter-design-pattern"),
                    }
                };

                var interpreterStructural = new PatternDetails
                {
                    Name     = "InterpreterStructural",
                    Header   = "Interpreter Structural",
                    Method   = MethodService.InterpreterStructural,
                    Detailes =
                        "This structural code demonstrates the Interpreter patterns, which using a " +
                        "defined grammer, provides the interpreter that processes parsed statements.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Interpreter-design-pattern#str"),
                    }
                };


                var interpreterRealWorld = new PatternDetails
                {
                    Name     = "InterpreterRealWorld",
                    Header   = "Interpreter Real World",
                    Method   = MethodService.InterpreterRealWorld,
                    Detailes = "This real-world code demonstrates the Interpreter " +
                               "pattern which is used to convert a Roman numeral to a decimal.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Interpreter-design-pattern#rea"),
                    }
                };

                interpreterParent.Patterns.Add(interpreterStructural);
                interpreterParent.Patterns.Add(interpreterRealWorld);

                return(interpreterParent);
            }
Exemplo n.º 17
0
            protected override PatternDetails CreatePatternDetails()
            {
                var observerParent = new PatternDetails
                {
                    Name     = "Observer",
                    Header   = "Observer",
                    Detailes = "A way of notifying change to a number of classes - " +
                               "Define a one-to-many dependency between objects so that when one object" +
                               " changes state, all its dependents are notified and updated automatically.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Observer-design-pattern"),
                    }
                };

                var observerStructural = new PatternDetails
                {
                    Name     = "ObserverStructural",
                    Header   = "Observer Structural",
                    Method   = MethodService.ObserverStructural,
                    Detailes =
                        "This structural code demonstrates the Observer pattern in which " +
                        "registered objects are notified of and updated with a state change.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Observer-design-pattern#str"),
                    }
                };


                var observerRealWorld = new PatternDetails
                {
                    Name     = "ObserverRealWorld",
                    Header   = "Observer Real World",
                    Method   = MethodService.ObserverRealWorld,
                    Detailes = "This real-world code demonstrates the Observer pattern in" +
                               " which registered investors are notified every time a stock changes value.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Observer-design-pattern#rea"),
                    }
                };

                observerParent.Patterns.Add(observerStructural);
                observerParent.Patterns.Add(observerRealWorld);

                return(observerParent);
            }
            protected override PatternDetails CreatePatternDetails()
            {
                var facadeParent = new PatternDetails
                {
                    Name     = "Facade",
                    Header   = "Facade",
                    Detailes = "A single class that represents an entire subsystem - " +
                               "Provide a unified interface to a set of interfaces in a subsystem."
                               + " Façade defines a higher-level interface that makes the subsystem easier to use.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Facade-design-pattern"),
                    }
                };

                var facadeStructural = new PatternDetails
                {
                    Name     = "FacadeStructural",
                    Header   = "Facade Structural",
                    Method   = MethodService.FacadeStructural,
                    Detailes = "This structural code demonstrates the Facade pattern which provides"
                               + " a simplified and uniform interface to a large subsystem of classes.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Facade-design-pattern#str"),
                    }
                };


                var facadeRealWorld = new PatternDetails
                {
                    Name     = "FacadeRealWorld",
                    Header   = "Facade Real World",
                    Method   = MethodService.FacadeRealWorld,
                    Detailes = "This real-world code demonstrates the Facade pattern as a MortgageApplication object "
                               + "which provides a simplified interface to a large subsystem of classes measuring the creditworthyness of an applicant.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Facade-design-pattern#rea"),
                    }
                };

                facadeParent.Patterns.Add(facadeStructural);
                facadeParent.Patterns.Add(facadeRealWorld);

                return(facadeParent);
            }
            protected override PatternDetails CreatePatternDetails()
            {
                var decoratorParent = new PatternDetails
                {
                    Name     = "Decorator",
                    Header   = "Decorator",
                    Detailes = "Add responsibilities to objects dynamically - " +
                               "Attach additional responsibilities to an object dynamically. "
                               + "Decorators provide a flexible alternative to subclassing for extending functionality.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Decorator-design-pattern"),
                    }
                };

                var decoratorStructural = new PatternDetails
                {
                    Name     = "DecoratorStructural",
                    Header   = "Decorator Structural",
                    Method   = MethodService.DecoratorStructural,
                    Detailes = "This structural code demonstrates the Decorator pattern which dynamically adds"
                               + " extra functionality to an existing object.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Decorator-design-pattern#str"),
                    }
                };


                var decoratorRealWorld = new PatternDetails
                {
                    Name     = "DecoratorRealWorld",
                    Header   = "Decorator Real World",
                    Method   = MethodService.DecoratorRealWorld,
                    Detailes = "This real-world code demonstrates the Decorator pattern in which 'borrowable' "
                               + "functionality is added to existing library items (books and videos).",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Decorator-design-pattern#rea"),
                    }
                };

                decoratorParent.Patterns.Add(decoratorStructural);
                decoratorParent.Patterns.Add(decoratorRealWorld);

                return(decoratorParent);
            }
            protected override PatternDetails CreatePatternDetails()
            {
                var compositeParent = new PatternDetails
                {
                    Name     = "Composite",
                    Header   = "Composite",
                    Detailes = "A tree structure of simple and composite objects - " +
                               "Compose objects into tree structures to represent part-whole hierarchies."
                               + " Composite lets clients treat individual objects and compositions of objects uniformly.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Composite-design-pattern"),
                    }
                };

                var compositeStructural = new PatternDetails
                {
                    Name     = "CompositeStructural",
                    Header   = "Composite Structural",
                    Method   = MethodService.CompositeStructural,
                    Detailes = "This structural code demonstrates the Composite pattern which allows the creation "
                               + "of a tree structure in which individual nodes are accessed uniformly whether they are leaf nodes or branch (composite) nodes.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Composite-design-pattern#str"),
                    }
                };


                var compositeRealWorld = new PatternDetails
                {
                    Name     = "CompositeRealWorld",
                    Header   = "Composite Real World",
                    Method   = MethodService.CompositeRealWorld,
                    Detailes = "This real-world code demonstrates the Composite pattern used in"
                               + " building a graphical tree structure made up of primitive nodes (lines, circles, etc) and composite nodes (groups of drawing elements that make up more complex elements).",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Composite-design-pattern#rea"),
                    }
                };

                compositeParent.Patterns.Add(compositeStructural);
                compositeParent.Patterns.Add(compositeRealWorld);

                return(compositeParent);
            }
            protected override PatternDetails CreatePatternDetails()
            {
                var flyweightParent = new PatternDetails
                {
                    Name     = "Flyweight",
                    Header   = "Flyweight",
                    Detailes = "A fine-grained instance used for efficient sharing - " +
                               "Use sharing to support large numbers of fine-grained objects efficiently.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Flyweight-design-pattern"),
                    }
                };

                var flyweightStructural = new PatternDetails
                {
                    Name     = "FlyweightStructural",
                    Header   = "Flyweight Structural",
                    Method   = MethodService.FlyweightStructural,
                    Detailes = "This structural code demonstrates the Flyweight pattern"
                               + " in which a relatively small number of objects is shared many times by different clients.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Flyweight-design-pattern#str"),
                    }
                };


                var flyweightRealWorld = new PatternDetails
                {
                    Name     = "FlyweightRealWorld",
                    Header   = "Flyweight Real World",
                    Method   = MethodService.FlyweightRealWorld,
                    Detailes = "This real-world code demonstrates the Flyweight pattern in which a relatively "
                               + "small number of Character objects is shared many times by a document that has potentially many characters.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Flyweight-design-pattern#rea"),
                    }
                };

                flyweightParent.Patterns.Add(flyweightStructural);
                flyweightParent.Patterns.Add(flyweightRealWorld);

                return(flyweightParent);
            }
            protected override PatternDetails CreatePatternDetails()
            {
                var bridgeParent = new PatternDetails
                {
                    Name     = "Bridge",
                    Header   = "Bridge",
                    Detailes = "Separates an object’s interface from its implementation - " +
                               "Decouple an abstraction from its implementation so that the two can vary independently.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/bridge-design-pattern"),
                    }
                };

                var bridgeStructural = new PatternDetails
                {
                    Name     = "BridgeStructural",
                    Header   = "Bridge Structural",
                    Method   = MethodService.BridgeStructural,
                    Detailes = "This structural code demonstrates the Bridge pattern which separates (decouples) the interface from its implementation."
                               + " The implementation can evolve without changing clients which use the abstraction of the object.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/bridge-design-pattern#str"),
                    }
                };


                var bridgeRealWorld = new PatternDetails
                {
                    Name     = "BridgeRealWorld",
                    Header   = "Bridge Real World",
                    Method   = MethodService.BridgeRealWorld,
                    Detailes = "This real-world code demonstrates the Bridge pattern in which a BusinessObject abstraction is decoupled from the implementation in DataObject."
                               + " The DataObject implementations can evolve dynamically without changing any clients.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/bridge-design-pattern#rea"),
                    }
                };

                bridgeParent.Patterns.Add(bridgeStructural);
                bridgeParent.Patterns.Add(bridgeRealWorld);

                return(bridgeParent);
            }
            protected override PatternDetails CreatePatternDetails()
            {
                var proxyParent = new PatternDetails
                {
                    Name     = "Proxy",
                    Header   = "Proxy",
                    Detailes = "An object representing another object - " +
                               "Provide a surrogate or placeholder for another object to control access to it.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Proxy-design-pattern"),
                    }
                };

                var proxyStructural = new PatternDetails
                {
                    Name     = "ProxyStructural",
                    Header   = "Proxy Structural",
                    Method   = MethodService.ProxyStructural,
                    Detailes = "This structural code demonstrates the Proxy pattern which provides "
                               + "a representative object (proxy) that controls access to another similar object.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Proxy-design-pattern#str"),
                    }
                };


                var proxyRealWorld = new PatternDetails
                {
                    Name     = "ProxyRealWorld",
                    Header   = "Proxy Real World",
                    Method   = MethodService.ProxyRealWorld,
                    Detailes = "This real-world code demonstrates the Proxy pattern for "
                               + "a Math object represented by a MathProxy object.",
                    ImageUrl = "",
                    UrlsList = new List <Uri>
                    {
                        new Uri("http://www.dofactory.com/net/Proxy-design-pattern#rea"),
                    }
                };

                proxyParent.Patterns.Add(proxyStructural);
                proxyParent.Patterns.Add(proxyRealWorld);

                return(proxyParent);
            }
        protected override PatternDetails CreatePatternDetails()
        {
            var creationalDetails = new PatternDetails
            {
                Name   = "CreationalPatterns",
                Header = "Creational Patterns",
            };


            creationalDetails.Patterns.Add(new AbstractFactoryPatternsFactory().GetPatternDetails());
            creationalDetails.Patterns.Add(new BuilderPatternsFactory().GetPatternDetails());
            creationalDetails.Patterns.Add(new PrototypePatternsFactory().GetPatternDetails());
            creationalDetails.Patterns.Add(new SingletonPatternsFactory().GetPatternDetails());
            return(creationalDetails);
        }
        protected override PatternDetails CreatePatternDetails()
        {
            var prototypeParent = new PatternDetails
            {
                Name     = "Prototype",
                Header   = "Prototype",
                Detailes = "A fully initialized instance to be copied or cloned - " +
                           "Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/prototype-design-pattern"),
                }
            };

            var prototypeRealWorld = new PatternDetails
            {
                Name     = "PrototypeRealWorld",
                Header   = "Prototype Real World",
                Method   = MethodService.PrototypeRealWorld,
                Detailes =
                    "This real-world code demonstrates the Prototype pattern in which new Color objects are created by copying pre-existing,"
                    + " user-defined Colors of the same type.",
                ImageUrl = @"pack://*****:*****@"pack://application:,,,/DesignPatterns;component/Images/PrototypeUML.PNG",
                UrlsList = new List <Uri>
                {
                    new Uri("http://www.dofactory.com/net/prototype-design-pattern#str"),
                }
            };

            prototypeParent.Patterns.Add(prototypeStructural);
            prototypeParent.Patterns.Add(prototypeRealWorld);

            return(prototypeParent);
        }
Exemplo n.º 26
0
        internal DateTime GetDirectoryDateTimeFromPattern(string directory, string pattern)
        {
            if (string.IsNullOrWhiteSpace(directory))
            {
                return(DateTime.MinValue);
            }
            if (string.IsNullOrWhiteSpace(pattern))
            {
                return(DateTime.MinValue);
            }

            PatternDetails patternDetails;

            if (_patternDetailsDictionnary.ContainsKey(pattern))
            {
                patternDetails = _patternDetailsDictionnary[pattern];
            }
            else
            {
                patternDetails = new PatternDetails();

                patternDetails.DatePattern = Regex.Replace(pattern, ".*?#(.+?)#.*", "$1");
                var patternWithoutDatePart = Regex.Replace(pattern, "#.+?#", "_________"); //First replace the date format to avoid the escape
                var escapedRegex           = Regex.Escape(patternWithoutDatePart);         //Escape the rest of the expression to avoid issues with the reserved characters
                var patternAsRegex         = escapedRegex.Replace("_________", "(.+)");
                patternDetails.Regex = new Regex(patternAsRegex);

                _patternDetailsDictionnary.Add(pattern, patternDetails);
            }

            var match = patternDetails.Regex.Match(directory);

            if (!match.Success)
            {
                _logger.LogDebug(EventIds.FolderDateParsing, $"Skip the directory '{directory}' because it does not match the pattern: '{pattern}'");
                return(DateTime.MinValue);
            }

            var dateString = match.Groups[1].Value;

            if (!DateTime.TryParseExact(dateString, patternDetails.DatePattern, CultureInfo.CurrentCulture, DateTimeStyles.None, out var directoryDate))
            {
                _logger.LogError(EventIds.FolderDateParsing, $"The directory '{directory}' match the pattern: '{pattern}' but the extracted date: '{dateString}' cannot be parsed with the format: '{patternDetails.DatePattern}'");
                return(DateTime.MinValue);
            }

            return(directoryDate);
        }
        protected override PatternDetails CreatePatternDetails()
        {
            var structuralDetails = new PatternDetails
            {
                Name   = "Structural",
                Header = "Structural Patterns",
            };

            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <AdapterPatternsFactory>());
            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <BridgePatternsFactory>());
            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <CompositePatternsFactory>());
            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <DecoratorePatternsFactory>());
            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <FacadePatternsFactory>());
            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <FlyweightPatternsFactory>());
            structuralDetails.Patterns.Add(this.GetPatternsFromFactory <ProxyweightPatternsFactory>());


            return(structuralDetails);
        }
 public PatternDetails GetPatternDetails()
 {
     return(PatternDetails ?? (PatternDetails = CreatePatternDetails()));
 }