internal CodeWriterFilterService(CrmSvcUtilParameters parameters) { this._messageNamespace = parameters.MessageNamespace; this._generateMessages = parameters.GenerateMessages; this._generateCustomActions = parameters.GenerateCustomActions; this._generateServiceContext = !string.IsNullOrWhiteSpace(parameters.ServiceContextName); }
internal MetadataProviderQueryService(CrmSvcUtilParameters parameters) { this._parameters = parameters; ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (CrmSvcUtil.EnableDebugMode) { await CrmSvcUtil.CrmSvcUtilLogger.LogAsync("Creating Default Metadata Provider Query Service"); } }); }
internal async Task InitializeServicesAsync(CrmSvcUtilParameters parameters) { var defaultServiceInstance = new CodeWriterFilterService(parameters); this._services.Add(typeof(ICodeWriterFilterService), await ServiceFactory.CreateInstanceAsync <ICodeWriterFilterService>(defaultServiceInstance, parameters.CodeWriterFilterService, parameters)); this._services.Add(typeof(ICodeWriterMessageFilterService), await ServiceFactory.CreateInstanceAsync <ICodeWriterMessageFilterService>(defaultServiceInstance, parameters.CodeWriterMessageFilterService, parameters)); this._services.Add(typeof(IMetadataProviderService), await ServiceFactory.CreateInstanceAsync <IMetadataProviderService>(new SdkMetadataProviderService(parameters), parameters.MetadataProviderService, parameters)); this._services.Add(typeof(IMetadataProviderQueryService), await ServiceFactory.CreateInstanceAsync <IMetadataProviderQueryService>(new MetadataProviderQueryService(parameters), parameters.MetadataQueryProvider, parameters)); this._services.Add(typeof(ICodeGenerationService), await ServiceFactory.CreateInstanceAsync <ICodeGenerationService>(new CodeGenerationService(), parameters.CodeGenerationService, parameters)); this._services.Add(typeof(INamingService), await ServiceFactory.CreateInstanceAsync <INamingService>(new NamingService(parameters), parameters.NamingService, parameters)); this._services.Add(typeof(ICustomizeCodeDomService), await ServiceFactory.CreateInstanceAsync <ICustomizeCodeDomService>(new CodeDomCustomizationService(), parameters.CodeCustomizationService, parameters)); this._services.Add(typeof(ITypeMappingService), new TypeMappingService(parameters)); }
internal NamingService(CrmSvcUtilParameters parameters) { if (!string.IsNullOrWhiteSpace(parameters.ServiceContextName)) { this._serviceContextName = parameters.ServiceContextName; } else { this._serviceContextName = typeof(OrganizationServiceContext).Name + "1"; } this._nameMap = new Dictionary <string, int>(); this._knowNames = new Dictionary <string, string>(); this._reservedAttributeNames = new List <string>(); foreach (var propertyInfo in typeof(Entity).GetProperties()) { this._reservedAttributeNames.Add(propertyInfo.Name); } }
internal TypeMappingService(CrmSvcUtilParameters parameters) { this.Namespace = parameters.Namespace; this._attributeTypeMapping = new Dictionary <AttributeTypeCode, Type> { { AttributeTypeCode.Boolean, typeof(bool) }, { AttributeTypeCode.ManagedProperty, typeof(BooleanManagedProperty) }, { AttributeTypeCode.CalendarRules, typeof(object) }, { AttributeTypeCode.Customer, typeof(EntityReference) }, { AttributeTypeCode.DateTime, typeof(DateTime) }, { AttributeTypeCode.Decimal, typeof(decimal) }, { AttributeTypeCode.Double, typeof(double) }, { AttributeTypeCode.Integer, typeof(int) }, { AttributeTypeCode.EntityName, typeof(string) }, { AttributeTypeCode.BigInt, typeof(long) }, { AttributeTypeCode.Lookup, typeof(EntityReference) }, { AttributeTypeCode.Memo, typeof(string) }, { AttributeTypeCode.Money, typeof(Money) }, { AttributeTypeCode.Owner, typeof(EntityReference) }, { AttributeTypeCode.String, typeof(string) }, { AttributeTypeCode.Uniqueidentifier, typeof(Guid) } }; }
internal SdkMetadataProviderService(CrmSvcUtilParameters parameters) { this.Parameters = parameters; }
internal static async Task <TIService> CreateInstanceAsync <TIService>(TIService defaultServiceInstance, string parameterValue, CrmSvcUtilParameters parameters) { var name = typeof(TIService).Name.Substring(1); await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Creating instance of {0}", typeof(TIService).Name); var text = parameterValue; if (string.IsNullOrEmpty(text)) { text = ConfigurationManager.AppSettings[name]; } if (string.IsNullOrEmpty(text)) { return(defaultServiceInstance); } await CrmSvcUtil.CrmSvcUtilLogger.TraceInformationAsync("Looking for extension named {0}", text); var type = Type.GetType(text, false); if (type == null) { throw new NotSupportedException("Could not load provider of type '" + text + "'"); } if (type.GetInterface(typeof(TIService).FullName) == null) { throw new NotSupportedException("Type '" + text + "'does not implement interface " + typeof(TIService).FullName); } if (type.IsAbstract) { throw new NotSupportedException("Cannot instantiate abstract type '" + text + "'."); } var constructor = type.GetConstructor(new [] { typeof(TIService), typeof(IDictionary <string, string>) }); if (constructor != null) { return((TIService)((object)constructor.Invoke(new object[] { defaultServiceInstance, parameters.ToDictionary() }))); } constructor = type.GetConstructor(new [] { typeof(TIService) }); if (constructor != null) { return((TIService)((object)constructor.Invoke(new object[] { defaultServiceInstance }))); } constructor = type.GetConstructor(new [] { typeof(IDictionary <string, string>) }); if (constructor != null) { return((TIService)((object)constructor.Invoke(new object[] { parameters.ToDictionary() }))); } return((TIService)((object)Activator.CreateInstance(type))); }