示例#1
0
        public static SpecRecord CreateRecordFromSpec(ISpec spec)
        {
            string json_text = JsonConvert.SerializeObject(spec);
            var    record    = new SpecRecord(spec, json_text);

            return(record);
        }
示例#2
0
 public void CreateContainerElements(ISpec spec)
 {
     var specElement = new SpecElement(_provider, spec, _project);
     _consumer(specElement);
     var exampleContainers = spec.ExampleContainers;
     CreateContainerElements(exampleContainers, specElement);
 }
示例#3
0
 public SpecRecord(ISpec spec, string json_text)
 {
     JsonText   = json_text;
     SpecType   = spec.SpecType;
     TimeStamp  = DateTime.Now;
     MaterialId = spec.MaterialId;
 }
示例#4
0
        public static IQueryable <TEntity> GetQuery(IQueryable <TEntity> inputQuery,
                                                    ISpec <TEntity> spec)
        {
            var query = inputQuery;

            if (spec.Criteria != null)
            {
                query = query.Where(spec.Criteria);
            }

            if (spec.OrderBy != null)
            {
                query = query.OrderBy(spec.OrderBy);
            }

            if (spec.OrderByDescending != null)
            {
                query = query.OrderByDescending(spec.OrderByDescending);
            }

            if (spec.IsPagingEnabled)
            {
                query = query.Skip(spec.Skip).Take(spec.Take);
            }

            query = spec.Includes.Aggregate(query, (current, include) => current.Include(include));

            return(query);
        }
示例#5
0
 public WarpingSpecification(string materialId, StyleSpecification styleSpec)
 {
     // TODO: build spec from a material_id and a style spec only
     this.MaterialId = materialId;
     this.ParentSpec = styleSpec;
     this.SetDefaultProperties();
 }
 public IEnumerable<VerizonRecord> GetFriendsAndFamilyRecommendations(ISpec<VerizonRecord> spec)
 {
     return Records
         .GroupBy(r => r.Number)
         .Select(g => CreateRecordFromGrouping(g))
         .Where(spec.IsSatisfied)
         .OrderByDescending(r => r.Minutes)
         .Take(10);
 }
示例#7
0
 public SpecElement(IUnitTestProvider provider, ISpec spec, IProject project)
     : base(provider, spec, project, null)
 {
     _spec = spec;
     _project = project;
     var type = _spec.GetType();
     Id = type.FullName;
     AssemblyLocation = type.Assembly.Location;
 }
示例#8
0
        public static object GetWrapperForTargetType(Type type, ITestResultListener listener, ISpec spec)
        {
            foreach (var source in GetAssemblies(type))
            {
                var wrappedListenerType = source.GetType(typeof(ListenerWrapper).FullName);
                if (wrappedListenerType != null)
                    return Activator.CreateInstance(wrappedListenerType, listener, new ExampleTranslator(spec));
            }

            return null;
        }
示例#9
0
        public IEnumerable <Item> Find(ISpec <Item, bool> spec)
        {
            var result = _dbSet
                         .Include(i => i.Subcategory)
                         .Include(i => i.Subcategory.Category)
                         .Where(spec.ToExpression())
                         .OrderBy(x => x.Name)
                         .AsNoTracking();

            return(result);
        }
示例#10
0
        public IEnumerable <Item> Find(ISpec <Item, bool> spec, ISpec <Item, object> orderSpec)
        {
            var result = _dbSet
                         .Include(i => i.Subcategory)
                         .Include(i => i.Subcategory.Category)
                         .Include(i => i.Payment)
                         .Where(spec.ToExpression())
                         .OrderBy(orderSpec.ToExpression())
                         .AsNoTracking()
                         .AsEnumerable();

            return(result);
        }
示例#11
0
        public IEnumerable <Item> GetLatestAddedItems(ISpec <Item, bool> spec, int amount)
        {
            var result = _dbSet
                         .Include(i => i.Subcategory)
                         .Include(i => i.Subcategory.Category)
                         .Include(i => i.Payment)
                         .Where(spec.ToExpression())
                         .OrderBy(x => x.Name)
                         .Take(amount)
                         .AsNoTracking();

            return(result);
        }
示例#12
0
        public static IQueryable <TEntity> GetQuery(IQueryable <TEntity> inputQuery,
                                                    ISpec <TEntity> spec)
        {
            var query = inputQuery;

            if (spec.Criteria != null)
            {
                query = query.Where(spec.Criteria); // t => t.ServiceTypeIf == id
            }

            query = spec.Includes.Aggregate(query, (current, include) => current.Include(include));

            return(query);
        }
示例#13
0
        public static ObjectSpecs NewSingleSpec(ISpec spec, Type objType)
        {
            string getError(object obj)
            {
                return($"Type mismatched, got: {obj.GetType()}, expected: {objType}.");
            }

            var specs = new Specs();

            specs.AddSpec(spec);

            object?deserializeValue = null;
            object?serializeValue   = null;

            return(new ObjectSpecs(
                       specs,

                       (_, _) => null,
                       (_, v) =>
            {
                if (v != null && !objType.IsInstanceOfType(v))
                {
                    throw new InvalidOperationException(getError(v));
                }

                deserializeValue = v;
            },
                       (_, _) => deserializeValue,

                       (_, obj) =>
            {
                if (obj != null && !objType.IsInstanceOfType(obj))
                {
                    throw new InvalidOperationException(getError(obj));
                }

                serializeValue = obj;
            },
                       _ => serializeValue,
                       (_, _) => { }));
        }
示例#14
0
        /// <summary>
        /// Merge 2 floorplan tags togehter
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        private static FloorplanFaceTag MergeTags(FloorplanFaceTag a, FloorplanFaceTag b)
        {
            Contract.Requires(a != null && a.Mergeable);
            Contract.Requires(b != null && b.Mergeable);

            //Choose the non null spec (if either are not null)
            ISpec spec = null;

            if (a.Spec != null ^ b.Spec != null)
            {
                spec = a.Spec ?? b.Spec;
            }
            else if (a.Spec != null && b.Spec != null)
            {
                throw new NotImplementedException("Both faces in merge already have a spec assigned");
            }

            return(new FloorplanFaceTag(
                       true, //A and B must be mergeable (see contract) so therefore this must be mergeable
                       spec
                       ));
        }
示例#15
0
 public SpecController(IUnityContainer container, ISpec spec)
 {
     _container = container;
     Spec       = spec;
 }
 public static ISpec <WeatherForecast> WithNotTemperature(this ISpec <WeatherForecast> spec, int temperature) =>
 spec.And(x => x.TemperatureC != temperature);
示例#17
0
 public void TestMessageWithExtendedOption(ISpec Spec)
 private object?_DeserializeMultiValue(ISpec spec, List <string> values)
 {
     return(spec.CanHandleType(spec.ObjType) ? spec.DeserializeMultiValue(this, spec.ObjType, values) : mValueSerializer.DeserializeMultiValue(this, spec.ObjType, values));
 }
 private object?_DeserializeNonValue(ISpec spec, bool matched)
 {
     return(spec.CanHandleType(spec.ObjType) ? spec.DeserializeNonValue(this, spec.ObjType, matched) : mValueSerializer.DeserializeNonValue(this, spec.ObjType, matched));
 }
示例#20
0
 public RepeatSpec(string id, IValueGenerator count, ISpec space)
     : base(id)
 {
     Count = count;
     Space = space;
 }
示例#21
0
        public static ICommunicator CreateCommunicator(Int32 port, Int32 transferBlockSize, ISpec spec)
        {
            CoapConfig config = new CoapConfig();

            config.Port = port;
            config.TransferBlockSize = transferBlockSize;
            config.Spec = spec;
            return(CreateCommunicator(config));
        }
示例#22
0
 public LocalEndPoint(ISpec spec)
     : this(CommunicatorFactory.CreateCommunicator(spec.DefaultPort, spec.DefaultBlockSize, spec))
 {
 }
示例#23
0
 public ISpecComponentBuilder <TInput> WithGuard(ISpec <TInput> spec) => this.WithGuard(_ => spec);
 public IEnumerable<VerizonRecord> GroupByNumber(ISpec<VerizonRecord> spec)
 {
     return Records
         .Where(spec.IsSatisfied)
         .GroupBy(r => r.Number)
         .Select(g => CreateRecordFromGrouping(g))
         .OrderByDescending(r => r.Minutes);
 }
 public static ISpec <WeatherForecast> WithId(this ISpec <WeatherForecast> spec, long id) =>
 spec.And(x => x.WeatherForecastId == id);
示例#26
0
 public void TestMessageWithOptions(ISpec Spec)
示例#27
0
 public void TestResponseParsing(ISpec Spec)
示例#28
0
 public BickleUnitTestElement(IUnitTestProvider provider, ISpec spec, IProject project, UnitTestElement parent)
     : base(provider, parent)
 {
     _spec = spec;
     _project = project;
 }
示例#29
0
 public void TestMessageWithOptions(ISpec Spec)
示例#30
0
 public IEnumerable <Course> List2(ISpec <Course> spec)
 {
     return(_courses
            .Where(spec.CriteriaExpression)
            .AsEnumerable());
 }
示例#31
0
 public void TestMessage(ISpec Spec)
示例#32
0
 public static void PushSpec(ISpec spec)
 {
     var record = Factory.CreateRecordFromSpec(spec);
     // TODO: Create sql to load into table: modified_specificiations
 }
示例#33
0
 public void TestRequestParsing(ISpec Spec)
 private object?_DeserializeSingleValue(ISpec spec, string?value)
 {
     return(spec.CanHandleType(spec.ObjType) ? spec.DeserializeSingleValue(this, spec.ObjType, value) : mValueSerializer.DeserializeSingleValue(this, spec.ObjType, value));
 }
 public ExampleContainerWrapper(object inner, ISpec spec)
 {
     _inner = inner;
     ContainingSpec = spec;
 }
示例#36
0
文件: Spec.cs 项目: rlusian1/CoAP.NET
 public static IEndPoint CreateEndPoint(ISpec spec)
 {
     CoapConfig config = new CoapConfig();
     config.DefaultPort = spec.DefaultPort;
     config.Spec = spec;
     CoAPEndPoint ep = new CoAPEndPoint(config);
     ep.Start();
     return ep;
 }
示例#37
0
 public StyleSpecification(string style)
 {
     // There is an element type of specification
     this.ParentSpec = null;
     this.Style      = style;
 }
示例#38
0
 public void TestRequestParsing(ISpec Spec)
示例#39
0
 public List<Product> SelectBy(ISpec spec)
 {
     var products = productRepository.GetAllProducts();
     return products.Where(spec.IsSatisfiedBy).ToList();
 }
示例#40
0
 public void TestMessage(ISpec Spec)
 public bool TryGetMember(ISpec spec, out MemberInfo memberInfo)
 {
     Init();
     return(mSpec2MemberInfo.TryGetValue(spec, out memberInfo));
 }
示例#42
0
文件: NotSpec.cs 项目: qszhuan/codes
 public NotSpec(ISpec spec)
 {
     _spec = spec;
 }
示例#43
0
 public void TestResponseParsing(ISpec Spec)
示例#44
0
 public ExampleWrapper(object o, ISpec spec)
 {
     _inner = o;
     _spec = spec;
 }
示例#45
0
 public ExampleTranslator(ISpec spec)
 {
     _spec = spec;
 }
 public FloorplanFaceTag(bool mergeable, ISpec spec = null)
 {
     Mergeable = mergeable;
     Spec      = spec;
 }
示例#47
0
 public void TestMessageWithExtendedOption(ISpec Spec)