public async Task <UpdateMeta> CheckForUpdate()
        {
            var url = BuildUrl("spec.xml");

            var response = await _httpClient.GetStringAsync(url);

            var tempPath = Path.GetTempPath();

            var updateFilePath = Path.Combine(tempPath, Guid.NewGuid() + ".xml");

            // To be able to deserialize XML, we need a "temporary" file
            // so save the response to disk, deserialize and then
            // delete the file from the user's machine
            File.WriteAllText(updateFilePath, response);

            var deserialized = SpecificationParser.Deserialize(updateFilePath);

            File.Delete(updateFilePath);

            var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            var currentParsedVersion = new Version(currentVersion);
            var remoteParsedVersion  = new Version(deserialized.ProductVersion);

            var isUpdateAvailable = remoteParsedVersion > currentParsedVersion;

            return(new UpdateMeta(isUpdateAvailable, deserialized.ProductVersion));
        }
Пример #2
0
        private static Specification GetSpecification(string specificationPath)
        {
            if (!File.Exists(specificationPath))
            {
                throw new InvalidOperationException("Cannot compose WXS with missing NETWeasel Spec file, ensure spec.xml exists");
            }

            return(SpecificationParser.Deserialize(specificationPath));
        }
Пример #3
0
        public static Specification <TFact, TProjection> Match <TProjection>(Expression <Func <TFact, FactRepository, IQueryable <TProjection> > > specExpression)
        {
            var    spec      = specExpression.Compile();
            object proxy     = SpecificationParser.InstanceOfFact(typeof(TFact));
            var    label     = new Label(specExpression.Parameters[0].Name, specExpression.Parameters[0].Type.FactTypeName());
            var    context   = SpecificationContext.Empty.With(label, proxy, specExpression.Parameters[0].Type);
            var    queryable = (JinagaQueryable <TProjection>)spec((TFact)proxy, new FactRepository());

            var result        = SpecificationParser.ParseSpecification(SymbolTable.Empty, context, queryable.Expression);
            var specification = SpecificationGenerator.CreateSpecification(context, result);

            return(new Specification <TFact, TProjection>(specification.Pipeline, specification.Projection));
        }
Пример #4
0
        public static Specification <TFact, TProjection> Match <TProjection>(Expression <Func <TFact, TProjection> > spec)
        {
            var    parameter       = spec.Parameters[0];
            var    initialFactName = parameter.Name;
            var    initialFactType = parameter.Type.FactTypeName();
            object proxy           = SpecificationParser.InstanceOfFact(typeof(TFact));
            var    label           = new Label(initialFactName, initialFactType);
            var    context         = SpecificationContext.Empty.With(label, proxy, parameter.Type);
            var    startingSet     = new SetDefinitionInitial(label, parameter.Type);
            var    symbolTable     = SymbolTable.Empty.With(initialFactName, new SymbolValueSetDefinition(startingSet));

            var symbolValue   = ValueParser.ParseValue(symbolTable, context, spec.Body).symbolValue;
            var result        = SpecificationParser.ParseValue(symbolValue);
            var specification = SpecificationGenerator.CreateSpecification(context, result);

            return(new Specification <TFact, TProjection>(specification.Pipeline, specification.Projection));
        }
Пример #5
0
 private static Pipeline AppendToPipeline(Pipeline pipeline, SpecificationContext context, SetDefinition setDefinition, SpecificationResult result)
 {
     if (setDefinition is SetDefinitionPredecessorChain predecessorChainSet)
     {
         var chain = predecessorChainSet.ToChain();
         var targetSetDefinition = chain.TargetSetDefinition;
         var start  = targetSetDefinition.Label;
         var target = new Label(predecessorChainSet.Role, chain.TargetFactType);
         var path   = new Path(start, target);
         return(pipeline.AddPath(AddPredecessorSteps(path, chain)));
     }
     else if (setDefinition is SetDefinitionJoin joinSet)
     {
         var head = joinSet.Head;
         var tail = joinSet.Tail;
         var sourceSetDefinition = head.TargetSetDefinition;
         var source = sourceSetDefinition.Label;
         var target = joinSet.Label;
         var path   = new Path(source, target);
         return(pipeline.AddPath(PrependSuccessorSteps(AddPredecessorSteps(path, head), tail)));
     }
     else if (setDefinition is SetDefinitionConditional conditionalSet)
     {
         var targetSetDefinition = conditionalSet.Source;
         var start         = targetSetDefinition.Label;
         var childPipeline = CreatePipeline(
             SpecificationContext.Empty
             .With(start, SpecificationParser.InstanceOfFact(targetSetDefinition.Type), targetSetDefinition.Type),
             conditionalSet.Condition.SpecificationResult);
         var conditional = new Conditional(start, conditionalSet.Condition.Exists, childPipeline);
         return(pipeline.AddConditional(conditional));
     }
     else
     {
         throw new NotImplementedException();
     }
 }