예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThingSerializer"/> class.
        /// </summary>
        /// <param name="metaInfoProvider">
        /// The meta Info Provider.
        /// </param>
        /// <param name="dataModelVersion">
        /// The data model version for this request.
        /// </param>
        public ThingSerializer(IMetaDataProvider metaInfoProvider, Version dataModelVersion)
        {
            this.MetaInfoProvider = metaInfoProvider;
            this.dataModelVersion = dataModelVersion;

            this.thingConverterExtensions = new ThingConverterExtensions();
        }
예제 #2
0
        /// <summary>
        /// The full <see cref="ClasslessDTO"/> from thing.
        /// </summary>
        /// <param name="metaDataProvider">
        /// An instance of <see cref="IMetaDataProvider"/> used to provide metadata (reflection) for a <see cref="CDP4Common.DTO.Thing"/>
        /// </param>
        /// <param name="thing">
        /// The thing.
        /// </param>
        /// <typeparam name="T">
        /// Of type <see cref="Thing"/>
        /// </typeparam>
        /// <returns>
        /// The <see cref="ClasslessDTO"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If the provided <see cref="Thing"/> is null this exception is thrown.
        /// </exception>
        public static ClasslessDTO FullFromThing <T>(IMetaDataProvider metaDataProvider, T thing) where T : Thing
        {
            if (thing == null)
            {
                throw new ArgumentNullException(nameof(thing));
            }

            var classlesdto = new ClasslessDTO();

            // the Iid and ClassKind properties are transferred automatically
            classlesdto.Add("ClassKind", thing.ClassKind);
            classlesdto.Add("Iid", thing.Iid);
            var metainfo = metaDataProvider.GetMetaInfo(thing.ClassKind.ToString());

            foreach (var property in metainfo.GetPropertyNameCollection())
            {
                var propertyMetadata = metainfo.GetPropertyMetaInfo(property);

                if (property.Equals("Iid") || property.Equals("ClassKind") || propertyMetadata.IsDerived || !propertyMetadata.IsDataMember)
                {
                    continue;
                }

                var propertyValue = metainfo.GetValue(property, thing);

                if (propertyValue == null && !propertyMetadata.IsNullable)
                {
                    propertyValue = string.Empty;
                }

                classlesdto.Add(property, propertyValue);
            }

            return(classlesdto);
        }
예제 #3
0
 public static ILPrinter <Label> Create <Label, Source, Dest, Context, EdgeData>
     (IILDecoder <Label, Source, Dest, Context, EdgeData> ilDecoder,
     IMetaDataProvider metaDataProvider,
     Func <Source, string> sourceToString, Func <Dest, string> destToString)
 {
     return(new Printer <Label, Source, Dest, Context, EdgeData> (ilDecoder, metaDataProvider, sourceToString, destToString).PrintCodeAt);
 }
예제 #4
0
 static MvcApplication()
 {
     MetaDataProvider = new ManyAssemblyMetaDataProvider(typeof(SectionMD).Assembly,
                                                         typeof(TestMD).Assembly);
     Config.DescriptionProvider = new MetaDataTypeDescriptionProvider(
         new AssemblyMetaDataProvider(typeof(UserMD).Assembly));
 }
예제 #5
0
파일: Checker.cs 프로젝트: claribou/Marvin
        private void AnalyzeMethod(Method method, Dictionary <string, ICollection <string> > proofResults)
        {
            IMetaDataProvider metadataDecoder = this.analysis_driver.MetaDataProvider;

            if (!metadataDecoder.HasBody(method))
            {
                return;
            }
            if (this.options.Method != null && !metadataDecoder.FullName(method).Contains(this.options.Method))
            {
                return;
            }

            var results = new List <string> ();

            proofResults.Add(method.FullName, results);
            try {
                AnalyzeMethodInternal(method, results);
            } catch (Exception e) {
                results.Add("Exception: " + e.Message);
                return;
            }

            results.Add(string.Format("Checked {0} assertions", results.Count));
        }
예제 #6
0
        public override bool TrySetType(TypeNode expectedType, IMetaDataProvider metaDataProvider, out TypeNode resultType)
        {
            switch (this.Element)
            {
            case SpecialPathElementKind.Length:
                this.castTo = metaDataProvider.IsArray(expectedType) ||
                              metaDataProvider.System_String.Equals(expectedType)
                                                ? ""
                                                : "System.Array";
                resultType = metaDataProvider.System_Int32;
                return(true);

            case SpecialPathElementKind.Deref:
                if (metaDataProvider.IsManagedPointer(expectedType))
                {
                    TypeNode type = metaDataProvider.ElementType(expectedType);
                    this.type  = type;
                    resultType = type;
                    return(true);
                }
                resultType = default(TypeNode);
                return(false);

            default:
                resultType = default(TypeNode);
                return(false);
            }
        }
예제 #7
0
 public BasicAnalysisDriver(IMetaDataProvider metaDataProvider,
                            IContractProvider contractProvider)
 {
     SubroutineFacade        = new SubroutineFacade(metaDataProvider, contractProvider);
     this.meta_data_provider = metaDataProvider;
     this.contract_provider  = contractProvider;
 }
        private readonly Cfg.Configuration _configuration;         //for serialization

        private AuditConfiguration(Cfg.Configuration cfg, IMetaDataProvider metaDataProvider)
        {
            //this might be over kill - move back into MetaDataStore later if not needed for other stuff...
            var metaDataAdders = new List <IMetaDataAdder> {
                new AuditMappedByMetaDataAdder(cfg)
            };

            var mds        = new MetaDataStore(cfg, metaDataProvider, metaDataAdders);
            var properties = cfg.Properties;

            GlobalCfg = new GlobalConfiguration(this, properties);

            var revInfoCfg       = new RevisionInfoConfiguration(GlobalCfg, mds);
            var revInfoCfgResult = revInfoCfg.Configure(cfg);

            AuditEntCfg         = new AuditEntitiesConfiguration(properties, revInfoCfgResult.RevisionInfoEntityName);
            AuditProcessManager = new AuditProcessManager(revInfoCfgResult.RevisionInfoGenerator);

            RevisionTimestampGetter = ReflectionTools.GetGetter(revInfoCfgResult.RevisionInfoClass, revInfoCfgResult.RevisionInfoTimestampData);

            RevisionInfoQueryCreator  = revInfoCfgResult.RevisionInfoQueryCreator;
            RevisionInfoNumberReader  = revInfoCfgResult.RevisionInfoNumberReader;
            ModifiedEntityNamesReader = revInfoCfgResult.ModifiedEntityNamesReader;
            EntCfg = new EntitiesConfigurator()
                     .Configure(cfg, mds, GlobalCfg, AuditEntCfg, revInfoCfgResult.RevisionInfoXmlMapping, revInfoCfgResult.RevisionInfoRelationMapping);
            _configuration = cfg;
        }
예제 #9
0
 public MetaDataStore(Cfg.Configuration nhConfiguration,
                      IMetaDataProvider metaDataProvider,
                      IEnumerable <IMetaDataAdder> metaDataAdders)
 {
     _nhConfiguration = nhConfiguration;
     EntityMetas      = initializeMetas(metaDataProvider, metaDataAdders);
 }
예제 #10
0
        private LispList <Pair <EdgeTag, Subroutine> > InsertInvariant(CFGBlock from, LispList <Pair <EdgeTag, Subroutine> > list,
                                                                       Method calledMethod, ref TypeNode type,
                                                                       LispList <Edge <CFGBlock, EdgeTag> > context)
        {
            IMetaDataProvider metadataDecoder = this.SubroutineFacade.MetaDataProvider;

            Property property;

            if (metadataDecoder.IsPropertySetter(calledMethod, out property) &&
                (metadataDecoder.IsAutoPropertyMember(calledMethod) || WithinConstructor(from, context)))
            {
                return(list);
            }

            if (metadataDecoder.IsConstructor(calledMethod))
            {
                type = metadataDecoder.DeclaringType(calledMethod);
            }

            Subroutine invariant = this.SubroutineFacade.GetInvariant(type);

            if (invariant != null)
            {
                var methodCallBlock = from as MethodCallBlock <Label>;
                if (methodCallBlock != null)
                {
                    EdgeTag first = methodCallBlock.IsNewObj ? EdgeTag.AfterNewObj : EdgeTag.AfterCall;
                    return(list.Cons(new Pair <EdgeTag, Subroutine> (first, invariant)));
                }
            }

            return(list);
        }
예제 #11
0
		public BasicAnalysisDriver (IMetaDataProvider metaDataProvider,
		                            IContractProvider contractProvider)
		{
			SubroutineFacade = new SubroutineFacade (metaDataProvider, contractProvider);
			this.meta_data_provider = metaDataProvider;
			this.contract_provider = contractProvider;
		}
예제 #12
0
        public FunctionsTable(IMetaDataProvider metaDataProvider)
        {
            this.meta_data_provider = metaDataProvider;
            this.locals             = new Dictionary <Local, Wrapper <Local> > ();
            this.parameters         = new Dictionary <Parameter, Wrapper <Parameter> > ();
            this.fields             = new Dictionary <Field, Wrapper <Field> > ();
            this.pseudo_fields      = new Dictionary <Method, Wrapper <Method> > ();
            this.temp              = new Dictionary <int, Wrapper <int> > ();
            this.strings           = new Dictionary <string, Wrapper <string> > ();
            this.program_constants = new Dictionary <object, Wrapper <object> > ();
            this.method_pointers   = new Dictionary <Method, Wrapper <Method> > ();
            this.binary_operators  = new Dictionary <BinaryOperator, Wrapper <BinaryOperator> > ();
            this.unary_operators   = new Dictionary <UnaryOperator, Wrapper <UnaryOperator> > ();

            this.ValueOf             = For("$Value");
            this.OldValueOf          = For("$OldValue");
            this.StructId            = For("$StructId");
            this.ObjectVersion       = For("$ObjectVersion");
            this.NullValue           = For("$Null");
            this.ElementAddress      = For("$ElementAddress");
            this.Length              = For("$Length");
            this.VoidAddr            = For("$VoidAddr");
            this.UnaryNot            = For("$UnaryNot");
            this.NeZero              = For("$NeZero");
            this.BoxOperator         = For("$Box");
            this.ResultOfCall        = For("$ResultOfCall");
            this.ResultOfLoadElement = For("$ResultOfLoadElement");
            this.ZeroValue           = ForConstant(0, this.meta_data_provider.System_Int32);
        }
예제 #13
0
 public Printer(IILDecoder <Label, Source, Dest, Context, EdgeData> ilDecoder, IMetaDataProvider metaDataProvider,
                Func <Source, string> sourceToString, Func <Dest, string> destToString)
 {
     this.il_decoder         = ilDecoder;
     this.meta_data_provider = metaDataProvider;
     this.source_to_string   = sourceToString;
     this.dest_to_string     = destToString;
 }
예제 #14
0
        public SubroutineFacade(IMetaDataProvider metaDataProvider,
                                IContractProvider contractProvider)
        {
            this.MetaDataProvider = metaDataProvider;
            this.ContractProvider = contractProvider;
            this.requires_factory = new RequiresFactory(this);
//			this.ensures_factory = new EnsuresFactory (this);
        }
예제 #15
0
        static MvcApplication()
        {
            MetaDataProvider = new ManyAssemblyMetaDataProvider(typeof(TestMD).Assembly,
                                                                typeof(UserMD).Assembly);

            /*	Config.DescriptionProvider = new MetaDataTypeDescriptionProvider(
             *                                      MetaDataProvider);*/
        }
예제 #16
0
파일: APCDecoder.cs 프로젝트: raj581/Marvin
 public APCDecoder(ControlFlowGraph underlyingCFG,
                   IMetaDataProvider metaDataProvider,
                   SubroutineFacade subroutineFacade)
 {
     this.cfg = underlyingCFG;
     this.meta_data_provider = metaDataProvider;
     this.subroutine_facade  = subroutineFacade;
 }
예제 #17
0
 public CodeLayer(IILDecoder <APC, Expression, Variable, ContextData, EdgeData> ilDecoder,
                  IMetaDataProvider metadataDecoder,
                  IContractProvider contractDecoder,
                  Func <Expression, string> expressionToString,
                  Func <Variable, string> variableToString, ILPrinter <APC> printer)
     : this(ilDecoder, metadataDecoder, contractDecoder, expressionToString, variableToString)
 {
     this.printer = new Lazy <ILPrinter <APC> > (() => printer);
 }
예제 #18
0
 Create <Expression, Variable, ContextData, EdgeConversionData> (
     IILDecoder <APC, Expression, Variable, ContextData, EdgeConversionData> ilDecoder,
     IMetaDataProvider metadataDecoder,
     IContractProvider contractDecoder, Func <Expression, string> expressionToString, Func <Variable, string> variableToString, ILPrinter <APC> printer)
     where ContextData : IMethodContextProvider
 {
     return(new CodeLayer <Expression, Variable, ContextData, EdgeConversionData>
                (ilDecoder, metadataDecoder, contractDecoder, expressionToString, variableToString, printer));
 }
예제 #19
0
 public Generator(string dbType)
 {
     switch (dbType.ToUpper())
     {
     case "SQLSERVER":
         provider = new SQLDBHandler();
         break;
     }
 }
예제 #20
0
파일: TypeCache.cs 프로젝트: nlhepler/mono
		public bool TryGet (IMetaDataProvider mdProvider, out TypeNode type)
		{
			if (!this.cache_is_valid) {
				this.cache_is_valid = true;
				this.have_type = mdProvider.TryGetSystemType (this.full_name, out this.cache);
			}

			type = this.cache;
			return this.have_type;
		}
예제 #21
0
	    public Generator(string dbType)
	    {
            switch (dbType.ToUpper())
            {
                case "SQLSERVER":
                    provider = new SQLDBHandler();
                    break;
            }

	    }
예제 #22
0
        public bool TryGet(IMetaDataProvider mdProvider, out TypeNode type)
        {
            if (!this.cache_is_valid)
            {
                this.cache_is_valid = true;
                this.have_type      = mdProvider.TryGetSystemType(this.full_name, out this.cache);
            }

            type = this.cache;
            return(this.have_type);
        }
예제 #23
0
        public MethodSubroutine(SubroutineFacade SubroutineFacade,
                                Method method, Label startLabel,
                                SubroutineWithHandlersBuilder <Label, Handler> builder) : base(SubroutineFacade, startLabel, builder)
        {
            this.method = method;
            IMetaDataProvider metaDataProvider = this.SubroutineFacade.MetaDataProvider;

            builder.BuildBlocks(startLabel, this);
            BlockWithLabels <Label> targetBlock = GetTargetBlock(startLabel);

            Commit();

            TypeNode   type      = metaDataProvider.DeclaringType(method);
            Subroutine invariant = this.SubroutineFacade.GetInvariant(type);

            if (invariant != null && !metaDataProvider.IsConstructor(method) && !metaDataProvider.IsStatic(method))
            {
                AddEdgeSubroutine(Entry, targetBlock, invariant, EdgeTag.Entry);
                Subroutine requires = this.SubroutineFacade.GetRequires(method);
                if (requires != null)
                {
                    AddEdgeSubroutine(Entry, targetBlock, requires, EdgeTag.Entry);
                }
            }
            else
            {
                AddEdgeSubroutine(Entry, targetBlock, this.SubroutineFacade.GetRequires(method), EdgeTag.Entry);
            }

            if (this.blocks_ending_in_return_point == null)
            {
                return;
            }

            Subroutine ensures = this.SubroutineFacade.GetEnsures(method);
            bool       putInvariantAfterExit = !metaDataProvider.IsStatic(method) &&
                                               !metaDataProvider.IsFinalizer(method) && !metaDataProvider.IsDispose(method);

            foreach (var block in this.blocks_ending_in_return_point)
            {
                if (putInvariantAfterExit)
                {
                    AddEdgeSubroutine(block, Exit, invariant, EdgeTag.Exit);
                }
                AddEdgeSubroutine(block, Exit, ensures, EdgeTag.Exit);
            }

            if (ensures != null)
            {
                throw new NotImplementedException();
            }

            this.blocks_ending_in_return_point = null;
        }
예제 #24
0
        private IDictionary <System.Type, IEntityMeta> initializeMetas(IMetaDataProvider metaDataProvider,
                                                                       IEnumerable <IMetaDataAdder> metaDataAdders)
        {
            var metaData = metaDataProvider.CreateMetaData(_nhConfiguration);

            foreach (var metaDataAdder in metaDataAdders)
            {
                metaDataAdder.AddMetaDataTo(metaData);
            }
            return(metaData);
        }
예제 #25
0
        private static void CheckTableInfo(IMetaDataProvider fluentCfg)
        {
            var metas   = fluentCfg.CreateMetaData(null);
            var entMeta = metas[typeof(StrTestEntity)];

            var result = entMeta.ClassMetas.OfType <AuditTableAttribute>().Single();

            result.Catalog.Should().Be.EqualTo("testcatalog");
            result.Schema.Should().Be.EqualTo("testschema");
            result.Value.Should().Be.EqualTo("tableName");
        }
 public FileSystemSource(ImportSettings settings, IImportValidator validator)
 {
     FileSystemSource.log.Info((object)("Initializing data source: File system: " + settings.SourceFolder));
     this.m_settings          = settings;
     this.m_validator         = validator;
     this.MetaDataProvider    = (IMetaDataProvider) new NullUserInformationManager();
     this.m_filenameConverter = new FileNameConverter()
     {
         MaximumFileNameLenght = validator.MaximumFileNameLength,
         IllegalCharacters     = validator.IllegalCharacters
     };
 }
예제 #27
0
        public static Expression <Func <T, bool> > BuildPrimaryKeyExpression <T, ID>(this IMetaDataProvider repository, ID id)
            where T : class
        {
            var primaryKey = repository.GetPrimaryKey <T>().First();

            var parameter  = Expression.Parameter(typeof(T));
            var body       = Expression.Convert(Expression.PropertyOrField(parameter, primaryKey), typeof(ID));
            var idSelector = Expression.Lambda <Func <T, ID> >(body, parameter);
            var predicate  = idSelector.BuildOrExpression(new[] { id });

            return(predicate);
        }
예제 #28
0
        public static List <BaseMetaData> GetWhereForeign(IMetaDataProvider metaDataProvider, Type entityType)
        {
            var metaDataList =
                from metaData in metaDataProvider.GetAll()
                where metaData.GetProperties().Any(
                    p => p.ForeignType() != null &&
                    p.ForeignType() == entityType) &&
                metaData.EntityType != entityType
                select metaData;

            return(metaDataList.ToList());
        }
예제 #29
0
        public static Wrapper <T> For <T> (T value, ref int idGen, IMetaDataProvider metadataDecoder)
        {
            if (value is Parameter)
            {
                return((Wrapper <T>)(object) new ParameterWrapper((Parameter)(object)value, ref idGen, metadataDecoder));
            }
            if (value is Method)
            {
                return((Wrapper <T>)(object) new MethodWrapper((Method)(object)value, ref idGen, metadataDecoder));
            }

            return(new Wrapper <T> (value, ref idGen, metadataDecoder));
        }
예제 #30
0
        private static void CheckJoinTableInfo(IMetaDataProvider fluentCfg)
        {
            var metas   = fluentCfg.CreateMetaData(null);
            var entMeta = metas[typeof(SetRefCollEntity)];

            var result = entMeta.MemberMetas[typeof(SetRefCollEntity).GetProperty("Collection")]
                         .OfType <AuditJoinTableAttribute>().Single();

            result.Catalog.Should().Be.EqualTo("testcatalog");
            result.Schema.Should().Be.EqualTo("testschema");
            result.TableName.Should().Be.EqualTo("tableName");
            result.InverseJoinColumns.Should().Have.SameSequenceAs("donald", "duck");
        }
예제 #31
0
        public ParameterPathElement(Parameter p, string description,
                                    SymFunction c, IMetaDataProvider metaDataProvider)
            : base(p, description, c)
        {
            TypeNode type = metaDataProvider.ParameterType(p);

            ResultType = metaDataProvider.ManagedPointer(type);

            if (metaDataProvider.IsManagedPointer(type))
            {
                this.isManagedPointer = true;
            }
        }
예제 #32
0
        public CodeLayer(IILDecoder <APC, Expression, Variable, ContextData, EdgeData> ilDecoder,
                         IMetaDataProvider metadataDecoder,
                         IContractProvider contractDecoder,
                         Func <Expression, string> expressionToString,
                         Func <Variable, string> variableToString)
        {
            ExpressionToString = expressionToString;
            VariableToString   = variableToString;
            ILDecoder          = ilDecoder;
            MetaDataProvider   = metadataDecoder;
            ContractProvider   = contractDecoder;

            this.printer = new Lazy <ILPrinter <APC> > (() => PrinterFactory.Create(ILDecoder, MetaDataProvider, ExpressionToString, VariableToString));
        }
예제 #33
0
 public FullExpressionDecoder(IMetaDataProvider metaDataProvider, IExpressionContextProvider <E, V> contextProvider)
 {
     ContextProvider                = contextProvider;
     this.MetaDataProvider          = metaDataProvider;
     this.VariableVisitor           = new VisitorForVariable <V, E> ();
     this.UnderlyingVariableVisitor = new VisitorForUnderlyingVariable <V, E> ();
     this.UnaryExpressionVisitor    = new VisitorForIsUnaryExpression <V, E> ();
     this.BinaryExpressionVisitor   = new VisitorForIsBinaryExpression <V, E> ();
     this.VariablesInVisitor        = new VisitorForVariablesIn <V, E> (contextProvider);
     this.ValueOfVisitor            = new VisitorForValueOf <V, E> ();
     this.SizeOfVisitor             = new VisitorForSizeOf <V, E> ();
     this.IsInstVisitor             = new VisitorForIsInst <V, E> ();
     this.IsNullVisitor             = new VisitorForIsNull <V, E> ();
 }
예제 #34
0
        /// <summary>
        /// Returns a stand-alone instance of a logger with an attached runtime meta data provider.  See the official
        /// documentation for more information on using runtime meta data providers and practical use-cases for them.
        /// </summary>
        /// <param name="metaDataProvider">The meta data provider to attach to the logger</param>
        /// <param name="defaultTags">The default tags to associate with the logger</param>
        /// <returns></returns>
        public static LoggerBase GetLogger(IMetaDataProvider metaDataProvider, params string[] defaultTags)
        {
            // Make sure the framework is initialized
            //  This is what allows for us to include a NuLog.json file
            //  and take off running with LoggerFactory.GetLogger without
            //  having to initialize first.
            Initialize(force: false);

            // Get a hold of the calling method's stack frame
            //  and determine the full name of the requesting
            //  class
            var stackFrame = new StackFrame(1);
            string reqClassFullName = stackFrame.GetMethod().DeclaringType.FullName;

            // Get the distinct default tags
            var tags = defaultTags.Distinct().ToList();

            // Make sure that the requesting class' full name
            //  is included as a default tag for the logger
            if (tags.Contains(reqClassFullName) == false)
                tags.Add(reqClassFullName);

            // Return a new instance of the logger with the associated
            //  runtime meta data provider
            return new DefaultLogger(Instance.Value.LogEventDispatcher, tags)
            {
                MetaDataProvider = metaDataProvider
            };
        }
예제 #35
0
		public IILDecoder<APC, Dummy, Dummy, IMethodContextProvider, Dummy> GetDecoder (IMetaDataProvider metaDataProvider)
		{
			return this.underlying.GetDecoder (metaDataProvider);
		}
예제 #36
0
		public abstract bool TrySetType (TypeNode expectedType, IMetaDataProvider metaDataProvider, out TypeNode type);
예제 #37
0
 public IILDecoder<APC, Dummy, Dummy, IMethodContextProvider, Dummy> GetDecoder (
         IMetaDataProvider metaDataProvider)
 {
         return new APCDecoder (this, metaDataProvider, this.method_repository);
 }
예제 #38
0
		public IILDecoder<APC, Dummy, Dummy, IMethodContextProvider, Dummy> GetDecoder (IMetaDataProvider metaDataProvider)
		{
			var methodRepository = this.method_repository as SubroutineFacade;
			return new APCDecoder (this, metaDataProvider, methodRepository);
		}