Example #1
0
        /// <summary>
        /// Create a new store and apply the specified enhancers.
        /// </summary>
        public static IStore <TState> Create(Reducer <TState> reducer, TState initialState,
                                             params StoreEnhancer <TState>[] enhancers)
        {
            StoreCreator <TState> creator = Create;

            foreach (var enhancer in enhancers)
            {
                creator = enhancer(creator);
            }

            return(creator(reducer, initialState));
        }
Example #2
0
    public static void CreateContact(SqlString contactData,
                                     out SqlInt32 contactId,
                                     out SqlInt32 customerId)
    {
        //TODO: When we can pass XML from T-SQL then contactData can be a SqlXmlReader
        using (StringReader sr = new StringReader(contactData.Value))  {
            XmlReader      reader  = XmlReader.Create(sr);
            ContactCreator creator = null;

            try  {
                reader.MoveToContent();
                EnsureEqual(reader.LocalName, "Contact");
                reader.MoveToContent();
                reader.ReadStartElement();

                switch (reader.LocalName)
                {
                case "Individual": creator = new IndividualCreator(); break;

                case "Store": creator = new StoreCreator(); break;

                case "Vendor": creator = new VendorCreator(); break;

                case "Employee": creator = new EmployeeCreator(); break;

                default: break;
                }

                if (creator != null)
                {
                    reader.ReadStartElement();
                    reader.MoveToContent();
                    creator.LoadDictionary(reader);
                    creator.Create();
                    contactId  = creator.ContactId;
                    customerId = creator.CustomerId;
                }
                else
                {
                    contactId  = -1;
                    customerId = -1;

                    throw new AWUtilitiesContactParseException(
                              "Individual | Store | Vendor | Employee", reader.LocalName);
                }
            }
            finally
            {
                reader.Close();
            }
        }
    }