예제 #1
0
        public static Type GetDataWrapperType(DataTypeDescriptor dataTypeDescriptor)
        {
            Type wrapperType = TryGetWrapperType(dataTypeDescriptor.GetFullInterfaceName());

            if (wrapperType != null)
            {
                return(wrapperType);
            }

            lock (_compilationLock)
            {
                wrapperType = TryGetWrapperType(dataTypeDescriptor.GetFullInterfaceName());
                if (wrapperType != null)
                {
                    return(wrapperType);
                }

                var codeGenerationBuilder = new CodeGenerationBuilder("DataWrapper:" + dataTypeDescriptor.GetFullInterfaceName());

                DataWrapperCodeGenerator.AddDataWrapperClassCode(codeGenerationBuilder, dataTypeDescriptor);

                IEnumerable <Type> types = CodeGenerationManager.CompileRuntimeTempTypes(codeGenerationBuilder);

                return(types.Single());
            }
        }
예제 #2
0
        public static Type GetDataWrapperType(Type interfaceType)
        {
            return(_dataWrappersCache.GetOrAdd(interfaceType, type =>
            {
                Type wrapperType = TryGetWrapperType(type.FullName);
                if (wrapperType != null)
                {
                    return wrapperType;
                }

                lock (_compilationLock)
                {
                    wrapperType = TryGetWrapperType(type.FullName);
                    if (wrapperType != null)
                    {
                        return wrapperType;
                    }

                    var codeGenerationBuilder = new CodeGenerationBuilder("DataWrapper:" + type.FullName);

                    DataWrapperCodeGenerator.AddDataWrapperClassCode(codeGenerationBuilder, type);

                    IEnumerable <Type> types = CodeGenerationManager.CompileRuntimeTempTypes(codeGenerationBuilder);

                    return types.Single();
                }
            }));
        }
예제 #3
0
        public static Type GetDataWrapperType(Type interfaceType)
        {
            Type wrapperType = TryGetWrapperType(interfaceType.FullName);

            if (wrapperType != null)
            {
                return(wrapperType);
            }

            lock (_lock)
            {
                wrapperType = TryGetWrapperType(interfaceType.FullName);
                if (wrapperType != null)
                {
                    return(wrapperType);
                }

                var codeGenerationBuilder = new CodeGenerationBuilder("DataWrapper:" + interfaceType.FullName);

                DataWrapperCodeGenerator.AddDataWrapperClassCode(codeGenerationBuilder, interfaceType);

                IEnumerable <Type> types = CodeGenerationManager.CompileRuntimeTempTypes(codeGenerationBuilder);

                return(types.Single());
            }
        }
예제 #4
0
        /// <summary>
        /// Returns a wrapper type, if it already exists.
        /// </summary>
        public static Type TryGetWrapperType(string fullName)
        {
            string dataWrapperFullName = DataWrapperCodeGenerator.CreateWrapperClassFullName(fullName);

            Type wrapperType = TypeManager.TryGetType(dataWrapperFullName);

            return(wrapperType);
        }
        public void GetCodeToCompile(CodeGenerationBuilder builder)
        {
            foreach (DataTypeDescriptor dataTypeDescriptor in DataMetaDataFacade.AllDataTypeDescriptors)
            {
                if (!dataTypeDescriptor.ValidateRuntimeType())
                {
                    Log.LogError("DataWrapperClassCodeProvider", string.Format("The non code generated interface type '{0}' was not found, skipping code generation for that type", dataTypeDescriptor));
                    continue;
                }

                DataWrapperCodeGenerator.AddDataWrapperClassCode(builder, dataTypeDescriptor);
            }
        }