MMLib documentation


MMLib.Extensions is library, which contains extensions for standard .NET types. When you want use it, you must use using MMLib.Extensions; and use the concrete extension.
using MMLib.Extensions;

public void ExtensionsExample()
    string target = "aácčeéií";
    Assert.AreEqual("aacceeii", target.RemoveDiacritics());

    target = "123,354";

    target = "Very long sentence";
    Assert.AreEqual("Very long", target.Truncate(9));

StringExtensions methods: MMLib.Extensions.StringExtensions
DateTimeExtensions methods: MMLib.Extensions.DateTimeExtensions
ObjectExtensions methods: MMLib.Extensions.ObjectExtensions


MMLib.RapidPrototyping nowadays contains helpfull random generators for prototyping new functions. Contains WordGenerator, PersonGenerator, LoremIpsumGenerator. It's easy to use it. You just define using, create instance and call Next method.
using MMLib.RapidPrototyping.Generators;

public void WordGeneratorExample()
    WordGenerator generator = new WordGenerator();
    var randomWord = generator.Next();


Generators use own resources as repository. All words, names, lorem ipsum sentences are complied in the assembly. So it's easy to use it.
If you need your custom repository (you have own word's database, you want use special terminology, ...) you have options.
You can create yours custom repository class.
using MMLib.RapidPrototyping.Generators.Repositories;

public class ITWordRepository : IWordRepository
    private IList<string> _words = new List<string>();        
    public int Count
        get { return _words.Count; }

    public string this[int index]
        get { return _words[index]; }

    public ITWordRepository()

Now, you have to use it. You have two options how you can use it.
1. Directly through constructor
using MMLib.RapidPrototyping.Generators.Repositories;

public void WordGeneratorExample()
    WordGenerator generator = new WordGenerator(new ITWordRepository());
    var randomWord = generator.Next();


2. With application config file
RapidPrototyping library use Unity as dependency injection container. Generators take repository from this container. So you can configurate Unity container in your application config file.
<?xml version="1.0" encoding="utf-8"?>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
  <unity xmlns="">
      <register type="MMLib.RapidPrototyping.Generators.Repositories.IWordRepository, MMLib.RapidPrototyping"
                mapTo="GeneratorsExtendedTest.Repositories.ITWordRepository, GeneratorsExtendedTest"  >
        <lifetime type="singleton" />

You can use these principles for all generators (Word/Person/LoremIpsum)
You can dowload these examples here.

Every functionalities are covered by unit tests.
I use Code Contract from Microsoft to checking input arguments, if you want see this contract in popup comments use Code Contracts Editor Extensions VS2012 extension.

Last edited Jun 8, 2014 at 1:08 PM by MinoMartiniak, version 28