public void Collect(IEnumerable<Mono.Cecil.TypeDefinition> tds, TypeCollection typeCollection, ConfigBase config) { foreach (var item in tds) { Collect(item, typeCollection, config); } }
public ITypeWriter PickTypeWriter(Mono.Cecil.TypeDefinition td, int indentCount, TypeCollection typeCollection, ConfigBase config) { if (td.IsEnum) { return new EnumWriter(td, indentCount, typeCollection, config); } if (td.IsInterface) { return new InterfaceWriter(td, indentCount, typeCollection, config); } if (td.IsClass) { if (td.BaseType.FullName == "System.MulticastDelegate" || td.BaseType.FullName == "System.Delegate") { return new DelegateWriter(td, indentCount, typeCollection, config); } return new ClassWriter(td, indentCount, typeCollection, config); } throw new NotImplementedException("Could not get a type to generate for:" + td.FullName); }
public void Collect(Mono.Cecil.TypeDefinition td, TypeCollection typeCollection, ConfigBase config) { if (td.ShouldIgnoreType()) { return; } // don't duplicate types if (typeCollection.Contains(td.FullName)) { return; } StringBuilder sb = new StringBuilder(); var indentCount = 0; ITypeWriter typeWriter = typeSelector.PickTypeWriter(td, indentCount, typeCollection, config); td.Interfaces.Each(item => { var foundType = typeCollection.LookupType(item); if (foundType == null) { //TODO: This reporting a missing type is too early in the process. // typeNotFoundErrorHandler.Handle(item); return; } var itemWriter = typeSelector.PickTypeWriter(foundType, indentCount, typeCollection, config); typeCollection.Add(foundType.Namespace, foundType.Name, itemWriter); }); typeCollection.Add(td.Namespace, td.Name, typeWriter); }
public TypeWriterBase(TypeDefinition typeDefinition, int indentCount, TypeCollection typeCollection, ConfigBase config) { this.TypeDefinition = typeDefinition; this.IndentCount = indentCount; this.TypeCollection = typeCollection; this.Config = config; }
private void SetConfig(ConfigBase config) { this.config = config; if (config != null) { ShowConfig(config); } }
public ConfigurationObjectControlPanel(ConfigBase config, string frame) : this() { mConfig = config; foreach (var parameter in mConfig.Parameters.Where(p => p.Section == frame)) { LoadParameter(parameter); } }
public ConfigurationObjectControlPanel(ConfigBase config) : this() { mConfig = config; foreach (var parameter in mConfig.Parameters.OrderBy(p => p.Section)) { LoadParameter(parameter); } }
public ConfigurationObjectControlPanel(ConfigBase config, string[] frames) : this() { mConfig = config; foreach (var parameter in mConfig.Parameters.Where(p => !frames.Contains(p.Section))) { LoadParameter(parameter); } }
public OutParameterReturnTypeWriter(ConfigBase config, int indentCount, Mono.Cecil.TypeDefinition TypeDefinition, string methodName, TypeReference retrunTypeReference, List<ParameterDefinition> outTypes) { this.config = config; this.IndentCount = indentCount; this.TypeDefinition = TypeDefinition; this.MethodName = methodName; this.ReturnTypeReference = retrunTypeReference; this.OutTypes = outTypes; }
public ITypeWriter PickTypeWriter(Mono.Cecil.TypeDefinition td, int indentCount, TypeCollection typeCollection, ConfigBase config) { var castedConfig = (DotNetConfig)config; if (td.IsEnum) { return new EnumWriter(td, indentCount, typeCollection, config); } if (td.IsInterface) { return new InterfaceWriter(td, indentCount, typeCollection, castedConfig); } if (td.IsClass) { return new ClassWriter(td, indentCount, typeCollection, castedConfig); } throw new NotImplementedException("Could not get a type to generate for:" + td.FullName); }
protected virtual void ShowConfig(ConfigBase config) { }
public DetailPage(PageBase parent, ConfigBase config) : base(parent, config) { }
protected void AddChildNode(ConfigBase childObj) { _childNodes.Add(new ConfigurationNode(childObj, this)); }
public static void RegisterConfig(ConfigBase cfg) { m_configs.Add(cfg.GetType(), cfg); }
/// <summary> /// Fills the channel table nodes, creating child nodes. /// </summary> public void FillChannelTableNodes(TreeNode inCnlTableNode, TreeNode ctrlCnlTableNode, ConfigBase configBase) { try { treeView.BeginUpdate(); inCnlTableNode.Nodes.Clear(); ctrlCnlTableNode.Nodes.Clear(); FillCnlTableNodes(inCnlTableNode, ctrlCnlTableNode, configBase); } finally { treeView.EndUpdate(); } }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusManager" /> class. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="entityConfig">The entity configuration.</param> internal ServiceBusManager(string connectionString, ConfigBase entityConfig) { ConnectionString = connectionString; _entityConfig = entityConfig; }
static void Main(string[] args) { ConfigBase config = null; var options = new Options(); string verbInvoked = null; if (CommandLine.Parser.Default.ParseArgumentsStrict(args, options, (verb, subOptions) => { verb = (verb ?? "").ToLowerInvariant(); verbInvoked = verb; if (verb == Options.DotNetCommandName) { var dotNetSubOptions = subOptions as DotNetSubOptions; if (dotNetSubOptions != null) { config = new ToTypeScriptD.Core.DotNet.DotNetConfig { AssemblyPaths = dotNetSubOptions.Files, CamelBackCase = dotNetSubOptions.CamelBackCase, IncludeSpecialTypes = dotNetSubOptions.IncludeSpecialTypeDefinitions, IndentationType = dotNetSubOptions.IndentationType, RegexFilter = dotNetSubOptions.RegexFilter, TypeNotFoundErrorHandler = new ConsoleErrorTypeNotFoundErrorHandler(), }; } } else if (verb == Options.WinmdCommandName) { var winmdSubOptions = subOptions as WinmdSubOptions; if (winmdSubOptions != null) { config = new ToTypeScriptD.Core.WinMD.WinmdConfig { AssemblyPaths = winmdSubOptions.Files, IncludeSpecialTypes = winmdSubOptions.IncludeSpecialTypeDefinitions, IndentationType = winmdSubOptions.IndentationType, RegexFilter = winmdSubOptions.RegexFilter, TypeNotFoundErrorHandler = new ConsoleErrorTypeNotFoundErrorHandler(), }; } } })) { bool skipPrintingHelp = false; try { skipPrintingHelp = ToTypeScriptD.Render.AllAssemblies(config, Console.Out); } catch (Exception ex) { if (ex is System.IO.DirectoryNotFoundException || ex is System.IO.FileNotFoundException) { skipPrintingHelp = true; Console.Error.WriteLine("Error: " + ex.Message); } else { throw; } } if (!skipPrintingHelp) { Console.WriteLine(options.GetUsage(verbInvoked)); Environment.ExitCode = 1; } } }
public void Init() { OUTPUT_PATH = ConfigBase.Load <FrameworkRuntimeConfig>().ILRConfig.AdaptorPath; }
public void Collect(IEnumerable <Mono.Cecil.TypeDefinition> tds, TypeCollection typeCollection, ConfigBase config) { foreach (var item in tds) { Collect(item, typeCollection, config); } }
/// <summary> /// Unregisters the specified <paramref name="config"/>. /// </summary> /// <param name="config">The configuration item to unregister.</param> public void UnregisterConfiguration(ConfigBase config) { lock (_syncObj) _configs.Remove(config); }
public static void UnregisterConfig(ConfigBase cfg) { m_configs.Remove(cfg.GetType()); }
private void UpdateConfigItem(ConfigBase sender, string senderLocation) { // Setting is on the visible page if (senderLocation.StartsWith(GetSectionPath(_treeSections.SelectedNode), true, new System.Globalization.CultureInfo("en"))) { ((SectionDetails)_treeSections.SelectedNode.Tag).Designed = false; DrawSettings(); } // Setting is on a different page else { ((SectionDetails) GetTreeNode(senderLocation).Tag).Designed = false; } }
protected override IEnumerable <ResultPack> EvaluateArticleResults(TargetItem evalTarget, ConfigBase evalConfig, ISourceValues evalValues, Period evalPeriod, IPeriodProfile evalProfile, IEnumerable <ResultPair> evalResults) { if (InternalEvaluate == null) { return(EvaluateUtils.DecoratedError(ARTICLE_DESCRIPTION_ERROR_FORMAT, EXCEPTION_RESULT_NONE_TEXT)); } var sourceBuilder = new EvaluateSource.SourceBuilder(evalValues); var resultBuilder = new EvaluateSource.ResultBuilder(evalTarget, evalResults); var bundleValues = PrepareConceptValues <EvaluateSource>(sourceBuilder, resultBuilder); if (bundleValues.IsFailure) { return(EvaluateUtils.DecoratedError(ARTICLE_DESCRIPTION_ERROR_FORMAT, bundleValues.Error)); } return(InternalEvaluate(evalConfig, evalPeriod, evalProfile, bundleValues)); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Stopwatch stopwatch = new Stopwatch(); DateTime startDate; var endDate = DateTime.Today.GetBusinessDay(-1); var options = new CommandLineOptions(); if (!Parser.Default.ParseArguments(args, options)) { Environment.Exit(Parser.DefaultExitCodeFail); } DateTime.TryParse(String.Join(".", options.startDate), out startDate); var logging = new Logging(options.LogFile); Trace.WriteLine(options.ToString()); var config = new ConfigBase(); config.Load(options.Settings); if (!options.NoDownload) { IDataSource dataSource = new Bloomberg(); dataSource.Connect(); HashSet <string> shareNames = new HashSet <string>(); // get specifications var sheet = new Sheet(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shareNames") }); var shareIDs = sheet.toShares(); shareNames.UnionWith( dataSource.GetFields(shareIDs.ToList(), "ID_BB_GLOBAL") ); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("indices") }); var indexNames = sheet.toShares(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("fields") }); var fields = new List <Field>(); sheet.toFields <Field>(fields); //download index compositions if (indexNames != null && indexNames.Count() > 0) { //obtain components of indices var names = dataSource.DownloadMultipleComponents(indexNames.ToList(), "INDX_MEMBERS"); //convert tickers -> BB IDs shareNames.UnionWith(dataSource.GetFields(names, "ID_BB_GLOBAL")); } LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); //delete data for shares-reload and shares-delete { sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-reload") }); var sharesReload = dataSource.GetFields(sheet.toShares().ToList(), "ID_BB_GLOBAL"); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-delete") }); var sharesDelete = dataSource.GetFields(sheet.toShares().ToList(), "ID_BB_GLOBAL"); foreach (var item in sharesDelete.Concat(sharesReload)) { disk.DeleteDirectory(item.StripOfIllegalCharacters()); } //delete shares-delete names from list of downloadable shares foreach (var item in sharesDelete) { if (shareNames.Contains(item)) { shareNames.Remove(item); } } } shareNames = new HashSet <string>(shareNames.Where(item => item.Contains("BBG") & !item.Contains(" "))); //roundtrip to tickers and back to bb_ids - as some bb_ids represent the same share var ticker = dataSource.GetFields(shareNames.ToList(), "EQY_FUND_TICKER"); var asset_class = dataSource.GetFields(shareNames.ToList(), "BPIPE_REFERENCE_SECURITY_CL_RT"); var tickers = ticker.Zip(asset_class, (first, last) => first + " " + last); HashSet <string> unique_tickers = new HashSet <string>(tickers); shareNames = new HashSet <string>(dataSource.GetFields(unique_tickers.ToList(), "ID_BB_GLOBAL").ToList()); //download and save data stopwatch.Start(); { var shares = new SharesBatch(shareNames.ToList(), fields, dataSource, disk, startDate, endDate); shares.PerformOperations(); Trace.Write("Processing Individual: "); foreach (var shareName in shareNames) { Share share = new Share(name: shareName, fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWork(); } } dataSource.Disconnect(); //download fieldInfo { if (shareNames.Count() > 0) { dataSource.Connect(dataType: "//blp/apiflds"); disk.SetPath(options.FieldInfoDir); Share share = new Share(name: shareNames.First(), fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWorkFieldInfo(); dataSource.Disconnect(); } } stopwatch.Stop(); Trace.WriteLine("Time spent downloading from BB: " + stopwatch.Elapsed.ToString()); } //upload data via SQL connection if (!options.NoUpload) { stopwatch.Restart(); { LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWork(); } { LocalDisk disk = new LocalDisk(); disk.SetPath(options.FieldInfoDir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWorkFieldInfo(); } stopwatch.Stop(); Trace.WriteLine("Time spent uploading: " + stopwatch.Elapsed.ToString()); logging.Close(); } }
public SportsDataContext(ConfigBase config) : base(config.RedisConnection, new CosmosProvider(config.CosmosConnection, config.CosmosKey, "main")) { }
/// <summary> /// Performs the code generation. /// </summary> /// <param name="templateContents">The template <c>handlebars.js</c> contents.</param> /// <param name="config">The root <see cref="ConfigBase"/>.</param> /// <param name="codeGenerated">The action that is invoked when a output has been successfully generated.</param> public override void Generate(string templateContents, ConfigBase config, Action <CodeGeneratorEventArgs> codeGenerated) => Generate(templateContents, (TRootConfig)config, codeGenerated);
public DelegateWriter(Mono.Cecil.TypeDefinition typeDefinition, int indentCount, TypeCollection typeCollection, ConfigBase config) : base(typeDefinition, indentCount, typeCollection, config) { }
/// <summary> /// Fills the channel table nodes. /// </summary> private void FillCnlTableNodes(TreeNode inCnlTableNode, TreeNode ctrlCnlTableNode, ConfigBase configBase) { foreach (KP kp in configBase.KPTable.EnumerateItems()) { string nodeText = string.Format(AppPhrases.TableByDeviceNode, kp.KPNum, kp.Name); TreeNode inCnlsByDeviceNode = TreeViewUtils.CreateNode(nodeText, "table.png"); inCnlsByDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu; inCnlsByDeviceNode.Tag = CreateBaseTableTag(configBase.InCnlTable, CreateFilterByDevice(kp)); inCnlTableNode.Nodes.Add(inCnlsByDeviceNode); TreeNode ctrlCnlsByDeviceNode = TreeViewUtils.CreateNode(nodeText, "table.png"); ctrlCnlsByDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu; ctrlCnlsByDeviceNode.Tag = CreateBaseTableTag(configBase.CtrlCnlTable, CreateFilterByDevice(kp)); ctrlCnlTableNode.Nodes.Add(ctrlCnlsByDeviceNode); } TreeNode inCnlsEmptyDeviceNode = TreeViewUtils.CreateNode(AppPhrases.EmptyDeviceNode, "table.png"); inCnlsEmptyDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu; inCnlsEmptyDeviceNode.Tag = CreateBaseTableTag(configBase.InCnlTable, CreateFilterByDevice(null)); inCnlTableNode.Nodes.Add(inCnlsEmptyDeviceNode); TreeNode ctrlCnlsEmptyDeviceNode = TreeViewUtils.CreateNode(AppPhrases.EmptyDeviceNode, "table.png"); ctrlCnlsEmptyDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu; ctrlCnlsEmptyDeviceNode.Tag = CreateBaseTableTag(configBase.CtrlCnlTable, CreateFilterByDevice(null)); ctrlCnlTableNode.Nodes.Add(ctrlCnlsEmptyDeviceNode); }
/// <summary> /// Creates columns for the specified table /// </summary> public static DataGridViewColumn[] CreateColumns(ConfigBase configBase, Type itemType) { if (configBase == null) { throw new ArgumentNullException(nameof(configBase)); } if (itemType == typeof(Archive)) { return(CreateArchiveTableColumns()); } else if (itemType == typeof(CmdType)) { return(CreateCmdTypeTableColumns()); } else if (itemType == typeof(CnlStatus)) { return(CreateCnlStatusTableColumns()); } else if (itemType == typeof(CnlType)) { return(CreateCnlTypeTableColumns()); } else if (itemType == typeof(CommLine)) { return(CreateCommLineTableColumns()); } else if (itemType == typeof(DataType)) { return(CreateDataTypeTableColumns()); } else if (itemType == typeof(Device)) { return(CreateDeviceTableColumns(configBase)); } else if (itemType == typeof(DevType)) { return(CreateDevTypeTableColumns()); } else if (itemType == typeof(Format)) { return(CreateFormatTableColumns()); } else if (itemType == typeof(InCnl)) { return(CreateInCnlTableColumns(configBase)); } else if (itemType == typeof(Lim)) { return(CreateLimTableColumns()); } else if (itemType == typeof(Obj)) { return(CreateObjTableColumns(configBase)); } else if (itemType == typeof(ObjRight)) { return(CreateObjRightTableColumns(configBase)); } else if (itemType == typeof(OutCnl)) { return(CreateOutCnlTableColumns(configBase)); } else if (itemType == typeof(Quantity)) { return(CreateQuantityTableColumns()); } else if (itemType == typeof(Role)) { return(CreateRoleTableColumns()); } else if (itemType == typeof(RoleRef)) { return(CreateRoleRefTableColumns(configBase)); } else if (itemType == typeof(Script)) { return(CreateScriptTableColumns()); } else if (itemType == typeof(Unit)) { return(CreateUnitTableColumns()); } else if (itemType == typeof(User)) { return(CreateUserTableColumns(configBase)); } else if (itemType == typeof(Data.Entities.View)) { return(CreateViewTableColumns(configBase)); } else if (itemType == typeof(ViewType)) { return(CreateViewTypeTableColumns()); } else { return(Array.Empty <DataGridViewColumn>()); } }
private readonly ConfigBase configBase; // the reference to the configuration database /// <summary> /// Initializes a new instance of the class. /// </summary> /// <remarks>The configuration database is required for creating combo box columns.</remarks> public ColumnBuilder(ConfigBase configBase) { this.configBase = configBase ?? throw new ArgumentNullException(nameof(configBase)); }
private bool IsCertificateAuthentication(OperationContext operationContext) { if (!ConfigBase <MRSConfigSchema> .GetConfig <bool>("ProxyServiceCertificateEndpointEnabled")) { return(false); } ServiceSecurityContext serviceSecurityContext = operationContext.ServiceSecurityContext; if (serviceSecurityContext == null || serviceSecurityContext.AuthorizationContext == null || serviceSecurityContext.AuthorizationContext.ClaimSets == null || serviceSecurityContext.AuthorizationContext.ClaimSets.Count != 1) { return(false); } X509CertificateClaimSet x509CertificateClaimSet = serviceSecurityContext.AuthorizationContext.ClaimSets[0] as X509CertificateClaimSet; return(x509CertificateClaimSet != null && !(x509CertificateClaimSet.X509Certificate.Subject != ConfigBase <MRSConfigSchema> .GetConfig <string>("ProxyClientCertificateSubject"))); }
protected void LoadChildren() { lock (_syncObj) { if (_childrenLoaded) { return; } ILogger logger = ServiceRegistration.Get <ILogger>(); IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); string itemLocation = Constants.PLUGINTREE_BASELOCATION + Location; // We'll use a FixedItemStateTracker in the hope that the configuration will be disposed // after usage. The alternative would be to use a plugin item state tracker which is able to // remove a config element usage. But this would mean to also expose a listener registration // to the outside. I think this is not worth the labor. _childPluginItemStateTracker = new FixedItemStateTracker(string.Format("ConfigurationManager: ConfigurationNode '{0}'", itemLocation)); ICollection <PluginItemMetadata> items = pluginManager.GetAllPluginItemMetadata(itemLocation); ISet <string> childSet = new HashSet <string>(); foreach (PluginItemMetadata itemMetadata in items) { try { ConfigBaseMetadata metadata = pluginManager.RequestPluginItem <ConfigBaseMetadata>(itemMetadata.RegistrationLocation, itemMetadata.Id, _childPluginItemStateTracker); ConfigBase childObj = Instantiate(metadata, itemMetadata.PluginRuntime); if (childObj == null) { continue; } AddChildNode(childObj); childSet.Add(metadata.Id); } catch (PluginInvalidStateException e) { logger.Warn("Cannot add configuration node for {0}", e, itemMetadata); } } ICollection <string> childLocations = pluginManager.GetAvailableChildLocations(itemLocation); foreach (string childLocation in childLocations) { string childId = RegistryHelper.GetLastPathSegment(childLocation); if (childSet.Contains(childId)) { continue; } logger.Warn("Configuration: Configuration section '{0}' was found in the tree but not explicitly registered as section (config items in this section are registered by those plugins: {1})", childLocation, StringUtils.Join(", ", FindPluginRegistrations(childLocation))); ConfigSectionMetadata dummyMetadata = new ConfigSectionMetadata(childLocation, Constants.INVALID_SECTION_TEXT, null, null, null, null); ConfigSection dummySection = new ConfigSection(); dummySection.SetMetadata(dummyMetadata); AddChildNode(dummySection); } _childrenLoaded = true; } // Attach listeners after all children have been loaded // so that searching for child locations works correctly. foreach (var node in _childNodes) { AttachListenToLocations(node.ConfigObj); } }
public ConfigJsObject(IronJS.Environment env, ConfigBase config, CommonObject prototype) : base(env, prototype) { configBase = config; }
/// <summary> /// [Internal Constructor] Initializes a new instance of the ConfigurationNode class. /// </summary> /// <param name="configObj">Setting to link to the node.</param> /// <param name="parent">Parent node of the node.</param> public ConfigurationNode(ConfigBase configObj, ConfigurationNode parent) { _configObj = configObj; _parent = parent; _childNodes = new List <ConfigurationNode>(); }
private void ReserveLocalForestResources(ReservationContext reservation, TransactionalRequestJob requestJob) { MoveJob.ReserveLocalForestResources(reservation, CommonUtils.ComputeWlmWorkloadType(this.Priority, this.isInteractive, ConfigBase <MRSConfigSchema> .GetConfig <WorkloadType>("WlmWorkloadType")), this.RequestType, this.Flags, this.ArchiveGuid, this.ExchangeGuid, this.SourceExchangeGuid, this.TargetExchangeGuid, this.PartitionHint, requestJob.SourceDatabase, requestJob.SourceArchiveDatabase, requestJob.TargetDatabase, requestJob.TargetArchiveDatabase, this.SourceDatabaseGuid, this.SourceArchiveDatabaseGuid, this.TargetDatabaseGuid, this.TargetArchiveDatabaseGuid); }
public static bool IsInteractive(MRSRequestType requestType, RequestWorkloadType workloadType) { return(ConfigBase <MRSConfigSchema> .GetConfig <bool>("AllAggregationSyncJobsInteractive") && requestType == MRSRequestType.Sync && workloadType == RequestWorkloadType.SyncAggregation); }
/// <summary> /// Registers all of the required Handlebars helpers. /// </summary> public static void RegisterHelpers() { if (_areRegistered) { return; } _areRegistered = true; // Will check that the first argument equals at least one of the subsequent arguments. Handlebars.RegisterHelper("ifeq", (writer, context, parameters, args) => { if (IfEq(args)) { context.Template(writer, parameters); } else { context.Inverse(writer, parameters); } }); // Will check that the first argument does not equal any of the subsequent arguments. Handlebars.RegisterHelper("ifne", (writer, context, parameters, args) => { if (IfEq(args)) { context.Inverse(writer, parameters); } else { context.Template(writer, parameters); } }); // Will check that the first argument is less than or equal to the subsequent arguments. Handlebars.RegisterHelper("ifle", (writer, context, parameters, args) => { if (IfLe(args)) { context.Template(writer, parameters); } else { context.Inverse(writer, parameters); } }); // Will check that the first argument is greater than or equal to the subsequent arguments. Handlebars.RegisterHelper("ifge", (writer, context, parameters, args) => { if (IfGe(args)) { context.Template(writer, parameters); } else { context.Inverse(writer, parameters); } }); // Will check that all of the arguments have a non-<c>null</c> value. Handlebars.RegisterHelper("ifval", (writer, context, parameters, args) => { foreach (var arg in args) { if (arg == null) { context.Inverse(writer, parameters); return; } } context.Template(writer, parameters); }); // Will check that all of the arguments have a <c>null</c> value. Handlebars.RegisterHelper("ifnull", (writer, context, parameters, args) => { foreach (var arg in args) { if (arg != null) { context.Inverse(writer, parameters); return; } } context.Template(writer, parameters); }); // Will check that any of the arguments have a <c>true</c> value where bool; otherwise, non-null. Handlebars.RegisterHelper("ifor", (writer, context, parameters, args) => { foreach (var arg in args) { if (arg is bool opt) { if (opt) { context.Template(writer, parameters); return; } } else if (arg != null) { var opt2 = arg as bool?; if (opt2 != null && !opt2.Value) { continue; } context.Template(writer, parameters); return; } } context.Inverse(writer, parameters); }); // Converts a value to lowercase. Handlebars.RegisterHelper("lower", (writer, context, parameters) => writer.WriteSafeString(parameters.FirstOrDefault()?.ToString()?.ToLowerInvariant() ?? "")); // NOTE: Any ending in 'x' are to explicitly ignore special names!!! // Converts a value to camelcase. Handlebars.RegisterHelper("camel", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToCamelCase(parameters.FirstOrDefault()?.ToString()) ?? "")); Handlebars.RegisterHelper("camelx", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToCamelCase(parameters.FirstOrDefault()?.ToString(), true) ?? "")); // Converts a value to pascalcase. Handlebars.RegisterHelper("pascal", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToPascalCase(parameters.FirstOrDefault()?.ToString()) ?? "")); Handlebars.RegisterHelper("pascalx", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToPascalCase(parameters.FirstOrDefault()?.ToString(), true) ?? "")); // Converts a value to private case. Handlebars.RegisterHelper("private", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToPrivateCase(parameters.FirstOrDefault()?.ToString()) ?? "")); Handlebars.RegisterHelper("privatex", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToPrivateCase(parameters.FirstOrDefault()?.ToString(), true) ?? "")); Handlebars.RegisterHelper("sentence", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToSentenceCase(parameters.FirstOrDefault()?.ToString()) ?? "")); Handlebars.RegisterHelper("sentencex", (writer, context, parameters) => writer.WriteSafeString(StringConversion.ToSentenceCase(parameters.FirstOrDefault()?.ToString(), true) ?? "")); // Converts a value to the c# '<see cref="value"/>' comments equivalent. Handlebars.RegisterHelper("seecomments", (writer, context, parameters) => writer.WriteSafeString(ConfigBase.ToSeeComments(parameters.FirstOrDefault()?.ToString()))); // Inserts indent spaces based on the passed index value. Handlebars.RegisterHelper("indent", (writer, context, parameters) => writer.WriteSafeString(new string(' ', 4 * (int)(parameters.FirstOrDefault() ?? 0)))); // Adds a value to a value. Handlebars.RegisterHelper("add", (writer, context, parameters) => { int sum = 0; foreach (var p in parameters) { if (p is int pi) { sum += pi; } else if (p is string ps) { sum += int.Parse(ps, NumberStyles.Integer, CultureInfo.InvariantCulture); } else { writer.WriteSafeString("!!! add with invalid integer !!!"); } } writer.WriteSafeString(sum); }); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Stopwatch stopwatch = new Stopwatch(); DateTime startDate; var endDate = DateTime.Today.GetBusinessDay(-1); var options = new CommandLineOptions(); if (!Parser.Default.ParseArguments(args, options)) Environment.Exit(Parser.DefaultExitCodeFail); DateTime.TryParse(String.Join(".", options.startDate), out startDate); var logging = new Logging(options.LogFile); Trace.WriteLine(options.ToString()); var config = new ConfigBase(); config.Load(options.Settings); if (!options.NoDownload) { IDataSource dataSource = new Bloomberg(); dataSource.Connect(); HashSet<string> shareNames = new HashSet<string>(); // get specifications var sheet = new Sheet(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shareNames") }); var shareIDs = sheet.toShares(); shareNames.UnionWith( dataSource.GetTickers(shareIDs.ToList()) ); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("indices") }); var indexNames = sheet.toShares(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("fields") }); var fields = new List<Field>(); sheet.toFields<Field>(fields); //download index compositions if (indexNames != null && indexNames.Count() > 0) { //obtain components of indices var names = dataSource.DownloadMultipleComponents(indexNames.ToList(), "INDX_MEMBERS"); //convert tickers -> BB IDs shareNames.UnionWith(dataSource.GetTickers(names)); } LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); //delete data for shares-reload and shares-delete { sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-reload") }); var sharesReload = dataSource.GetTickers(sheet.toShares().ToList()); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-delete") }); var sharesDelete = dataSource.GetTickers(sheet.toShares().ToList()); foreach (var item in sharesDelete.Concat(sharesReload)) disk.DeleteDirectory(item.StripOfIllegalCharacters()); //delete shares-delete names from list of downloadable shares foreach (var item in sharesDelete) { if (shareNames.Contains(item)) shareNames.Remove(item); } } //download and save data stopwatch.Start(); { var shares = new SharesBatch(shareNames.ToList(), fields, dataSource, disk, startDate, endDate); shares.PerformOperations(); Trace.Write("Processing Individual: "); foreach (var shareName in shareNames) { Share share = new Share(name: shareName, fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWork(); } } dataSource.Disconnect(); //download fieldInfo { if (shareNames.Count() > 0) { dataSource.Connect(dataType: "//blp/apiflds"); disk.SetPath(options.FieldInfoDir); Share share = new Share(name: shareNames.First(), fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWorkFieldInfo(); dataSource.Disconnect(); } } stopwatch.Stop(); Trace.WriteLine("Time spent downloading from BB: " + stopwatch.Elapsed.ToString()); } //upload data via SQL connection if (!options.NoUpload) { stopwatch.Restart(); { LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWork(); } { LocalDisk disk = new LocalDisk(); disk.SetPath(options.FieldInfoDir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWorkFieldInfo(); } stopwatch.Stop(); Trace.WriteLine("Time spent uploading: " + stopwatch.Elapsed.ToString()); logging.Close(); { Console.WriteLine("Executing long job, you can force exit program, it will continue executing on server"); LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.executeScript(); } } }
protected override void SaveConfig(ConfigBase config) { throw new NotImplementedException(); }
protected virtual void SaveConfig(ConfigBase config) { }
public void UnregisterConfiguration(ConfigBase configItem) { _configItems.Remove(configItem); }
public override void add(ConfigBase config) { configs.Add(config as TileMixConfig); }
public ITypeWriter PickTypeWriter(Mono.Cecil.TypeDefinition td, int indentCount, TypeCollection typeCollection, ConfigBase config) { if (td.IsEnum) { return(new EnumWriter(td, indentCount, typeCollection, config)); } if (td.IsInterface) { return(new InterfaceWriter(td, indentCount, typeCollection, config)); } if (td.IsClass) { if (td.BaseType.FullName == "System.MulticastDelegate" || td.BaseType.FullName == "System.Delegate") { return(new DelegateWriter(td, indentCount, typeCollection, config)); } return(new ClassWriter(td, indentCount, typeCollection, config)); } throw new NotImplementedException("Could not get a type to generate for:" + td.FullName); }
/// <summary> /// Initializes a new instance of the <see cref="CodeGenException"/> class for a specified <paramref name="config"/>. /// </summary> /// <param name="config">The <see cref="ConfigBase"/> that the excpetion is related to.</param> /// <param name="propertyName">The corresponding property name that is in error.</param> /// <param name="message">The message that describes the error.</param> public CodeGenException(ConfigBase config, string propertyName, string message) : base($"{Check.NotNull(config, nameof(config)).BuildFullyQualifiedName(propertyName)}: {message}") { }
public EnumWriter(TypeDefinition typeDefinition, int indentCount, TypeCollection typeCollection, ConfigBase config) { this.config = config; this.TypeDefinition = typeDefinition; this.IndentCount = indentCount; }
protected override void ShowConfig(ConfigBase config) { //TODO : 根据config自动生成配置界面 }
public void ProcessRequest(HttpContext context) { if (_config == null) { _config = ConfigResolver.GetRackConfigInstance(); _getBuilderInContext = () => new Builder(_config.ExecuteStart); } var rawEnvironment = context.Request.ServerVariables; Dictionary<string, dynamic> environment = rawEnvironment.AllKeys.ToDictionary(key => key, key => (object)rawEnvironment[key]); environment["SCRIPT_NAME"] = string.Empty; //if ((string)environment["SCRIPT_NAME"] == string.Empty) //{ // environment["SCRIPT_NAME"] = "/"; //} var rackEnvs = new Dictionary<string, dynamic> { {"rack.version", RackVersion.Version}, {"rack.input", context.Request.InputStream}, {"rack.errors", Console.OpenStandardError()}, {"rack.multithread", true}, {"rack.multiprocess", false}, {"rack.run_once", false}, {"rack.url_scheme", context.Request.IsSecureConnection ? "https" : "http"} }; environment = environment.Union(rackEnvs).ToDictionary(key => key.Key, val => val.Value); //if (!environment.ContainsKey("SCRIPT_NAME")) //{ // environment["SCRIPT_NAME"] = string.Empty; //} var builder = _getBuilderInContext(); var responseArray = builder.Call(environment); var response = AspNetResponse.Create(responseArray); context.Response.StatusCode = response.StatusCode; //context.Response.Headers.Add(response.Headers); if (response.Headers != null) { foreach (var key in response.Headers.AllKeys) { context.Response.AddHeader(key, response.Headers[key]); } } response.Body.Each((Action<dynamic>)(body => { if (body is string) { context.Response.Write(body); } else if (body is byte[]) { context.Response.BinaryWrite(body); } })); var methodInfos = (IEnumerable<MethodInfo>)response.Body.GetType().GetMethods(); var closeMethods = Enumerable.Where(methodInfos, method => method.Name == "Close"); foreach (var method in closeMethods) { if (method.GetParameters().Length == 0 && method.ReturnType.Equals(typeof(void))) { method.Invoke(response.Body, null); break; } } }