Example #1
0
        /// <summary>
        /// Gets the module mapping for the specified module
        /// </summary>
        /// <param name="module">The module.</param>
        /// <returns></returns>
        public static IModuleMapping GetModuleMapping(AmplaModules module)
        {
            IModuleMapping moduleMapping;

            ModuleMappings.TryGetValue(module, out moduleMapping);

            return(moduleMapping);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModelProperties{TModel}"/> class.
        /// </summary>
        public ModelProperties()
        {
            AmplaModules?temp;
            bool         ok = AmplaLocationAttribute.TryGetLocation <TModel>(out locationFilter);

            ok &= AmplaModuleAttribute.TryGetModule <TModel>(out temp);

            if (!ok)
            {
                throw new ArgumentException("Unable to read the AmplaLocationAttribute or AmplaModuleAttribute on type: " + typeof(TModel).FullName);
            }

            module = temp ?? AmplaModules.Downtime;

            List <string> properties = new List <string>();

            foreach (PropertyInfo property in typeof(TModel).GetProperties())
            {
                string propertyName;
                AmplaFieldAttribute.TryGetField(property, out propertyName);

                properties.Add(propertyName);
                propertyInfoDictionary[propertyName] = property;
                TypeConverterAttribute typeConverterAttribute;
                TypeConverter          typeConverter = GetTypeConverter(property);
                if (property.TryGetAttribute(out typeConverterAttribute))
                {
                    Type converterType = Type.GetType(typeConverterAttribute.ConverterTypeName);
                    if (converterType != null)
                    {
                        typeConverter = Activator.CreateInstance(converterType) as TypeConverter;
                    }
                }
                typeConverterDictionary[propertyName] = typeConverter;

                AddModelValidators(property, modelValidators);
            }

            modelValidators.Add(new NullModelValidator <TModel>());
            propertyNames = properties.ToArray();

            if (!AmplaDefaultFiltersAttribute.TryGetFilter <TModel>(out defaultFilters))
            {
                defaultFilters = new FilterValue[0];
            }
        }
Example #3
0
        private InMemoryRecord FindRecord(Dictionary <int, InMemoryRecord> database, string searchLocation, AmplaModules searchModule, int searchRecordId)
        {
            InMemoryRecord record;

            if (!database.TryGetValue(searchRecordId, out record))
            {
                throw new FaultException("No record found with Id:" + searchRecordId);
            }

            if (record.Location != searchLocation || record.Module != searchModule.ToString())
            {
                string message = string.Format("No record found. (Module:'{0}', Location ='{1}')", searchModule,
                                               searchLocation);
                throw new FaultException(message);
            }
            return(record);
        }
 public SimpleNavigationHierarchy(AmplaModules amplaModule, string[] locations)
 {
     this.amplaModule = amplaModule;
     this.locations = locations;
 }
Example #5
0
 public SimpleNavigationHierarchy(AmplaModules amplaModule, string[] locations)
 {
     this.amplaModule = amplaModule;
     this.locations   = locations;
 }