public InternetToDataBase(UserToCreate user, IApi VkClient) { vkClient = VkClient; this.token = user.token; this.URL = "https://vk.com/id" + user.vk_id; this.user = user; }
public static Handle CreateCheckerboardTexture(IApi api) { Int32 texSize = 256; Int32 gridSize = 4; Int32 squareSize = texSize / gridSize; var colours = new Rgba32 [gridSize*gridSize]; for (Int32 x = 0; x < gridSize; ++x) { for (Int32 y = 0; y < gridSize; ++y) { colours [x + (y * gridSize)] = RandomColours.GetNext (); } } var texData = new byte[texSize*texSize*4]; Int32 index = 0; for (Int32 x = 0; x < texSize; ++x) { for (Int32 y = 0; y < texSize; ++y) { texData [index++] = colours[(x/squareSize) + (y/squareSize*gridSize)].A; texData [index++] = colours[(x/squareSize) + (y/squareSize*gridSize)].R; texData [index++] = colours[(x/squareSize) + (y/squareSize*gridSize)].G; texData [index++] = colours[(x/squareSize) + (y/squareSize*gridSize)].B; } } return api.gfx_CreateTexture (TextureFormat.Rgba32, texSize, texSize, texData); }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new WebLoggerException(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting("WebLogger", "Enabled"); if (!_enabled) throw new WebLoggerException(String.Format("{0} has been disabled", Name)); var url = _ini.GetSetting("WebLogger", "URL"); if (!Uri.TryCreate(url, UriKind.Absolute, out _uri)) { throw new WebLoggerException(String.Format("Error parsing url: {0}", url)); } _worker = new Thread(ProcessQueue); _worker.Start(); _api.OnBeMessageReceivedEvent += MessageEventHandler; }
public Ping(AlgorithmManager algorithmManager, IApi api, IResultHandler resultHandler) { _api = api; _resultHandler = resultHandler; _algorithmManager = algorithmManager; _exitEvent = new ManualResetEventSlim(false); }
public static Handle CreateUnlitShader(IApi api) { var shaderFormat = api.gfx_GetRuntimeShaderFormat (); var shaderDecl = GetUnlitShaderDeclaration (); var shaderSource = GetUnlitShaderSource (shaderFormat); return api.gfx_CreateShader (shaderDecl, shaderFormat, shaderSource); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultBrokerageMessageHandler"/> class /// </summary> /// <param name="algorithm">The running algorithm</param> /// <param name="job">The job that produced the algorithm</param> /// <param name="api">The api for the algorithm</param> /// <param name="initialDelay"></param> /// <param name="openThreshold">Defines how long before market open to re-check for brokerage reconnect message</param> public DefaultBrokerageMessageHandler(IAlgorithm algorithm, AlgorithmNodePacket job, IApi api, TimeSpan? initialDelay = null, TimeSpan? openThreshold = null) { _api = api; _job = job; _algorithm = algorithm; _connected = true; _openThreshold = openThreshold ?? DefaultOpenThreshold; _initialDelay = initialDelay ?? DefaultInitialDelay; }
public Ping(AlgorithmManager algorithmManager, IApi api, IResultHandler resultHandler, IMessagingHandler messagingHandler, AlgorithmNodePacket job) { _api = api; _job = job; _resultHandler = resultHandler; _messagingHandler = messagingHandler; _algorithmManager = algorithmManager; _exitEvent = new ManualResetEventSlim(false); }
internal PanelSpecification(IApi platform) { panelPhysicalSize = platform.sys_GetPrimaryPanelPhysicalSize (); panelPhysicalAspectRatio = panelPhysicalSize.HasValue ? (Single) panelPhysicalSize.Value.X / (Single) panelPhysicalSize.Value.Y : (Single?) null; panelType = platform.sys_GetPrimaryPanelType (); }
public void Initialize(AlgorithmNodePacket job, IMessagingHandler messagingHandler, IApi api, IDataFeed dataFeed, ISetupHandler setupHandler, ITransactionHandler transactionHandler) { _job = job; }
//[Inject] //public TraceSource Trace { get; set; } public BaseApiRequest(IApi Api, IDataExtractor DataExtractor) { api = Api; dataExtractor = DataExtractor; requestParams = new Dictionary<string, Dictionary<string, string>>(); objectTypeForMethods = new Dictionary<string, Type>(); batchSizes = new Dictionary<string, int>(); itemsMaxCounts = new Dictionary<string, int>(); requestTypes = new Dictionary<string, ApiRequestType>(); }
public Platform(IApi api) { this.api = api; this.audio = new Audio (api); this.graphics = new Graphics (api); this.resources = new Resources (api); this.status = new Status (api); this.input = new Input (api); this.host = new Host (api); }
internal Input(IApi platform) { this.platform = platform; this.Xbox360Gamepad = humanInputDevices.AddEx (new Xbox360Gamepad (PlayerIndex.One)); this.PsmGamepad = humanInputDevices.AddEx (new PsmGamepad ()); this.MultiTouchController = humanInputDevices.AddEx (new MultiTouchController ()); this.Mouse = humanInputDevices.AddEx (new Mouse ()); this.Keyboard = humanInputDevices.AddEx (new Keyboard ()); this.GenericGamepad = new GenericGamepad (); }
public void TestAuthrepWithInvalidProviderKey() { m_api = new Api(host, invalid_provider_key); Hashtable parameters = new Hashtable(); parameters.Add("app_key", "InvalidAppKey"); parameters.Add("app_id", "InvalidAppId"); var ex = Assert.Throws<ApiException>(() => m_api.authrep(parameters) ); Assert.That(ex.Message, Is.EqualTo("provider_key_invalid : provider key \"" + invalid_provider_key + "\" is invalid")); }
public void TestAuthrepWithInvalidAppId() { m_api = new Api(host, provider_key); Hashtable parameters = new Hashtable(); parameters.Add("app_key", "1a2b3c4d5e6f7a8b9c"); parameters.Add("app_id", invalid_app_id); var ex = Assert.Throws<ApiException>( () => m_api.authrep(parameters)); Assert.That(ex.Message, Is.EqualTo("application_not_found : application with id=\"" + invalid_app_id + "\" was not found")); }
public VkApiRequest(IApi Api, IDataExtractor DataExtractor) : base(Api, DataExtractor) { objectTypeForMethods.Add("groups.getById", typeof(VkGroup)); objectTypeForMethods.Add("groups.getMembers", typeof(long)); objectTypeForMethods.Add("groups.get", typeof(long)); objectTypeForMethods.Add("users.getSubscriptions", typeof(VkUserSubscriptions)); objectTypeForMethods.Add("users.get", typeof(VkUser)); objectTypeForMethods.Add("wall.get", typeof(VkPost)); objectTypeForMethods.Add("wall.getReposts", typeof(VkPost)); objectTypeForMethods.Add("friends.get", typeof(long)); objectTypeForMethods.Add("wall.getComments", typeof(VkComment)); requestTypes.Add("groups.getById", ApiRequestType.ListObjectsInfo); requestTypes.Add("groups.getMembers", ApiRequestType.ListForObject); requestTypes.Add("groups.get", ApiRequestType.ListForObject); requestTypes.Add("users.getSubscriptions", ApiRequestType.ObjectInfo); requestTypes.Add("users.get", ApiRequestType.ListObjectsInfo); requestTypes.Add("wall.get", ApiRequestType.ListForObject); requestTypes.Add("wall.getReposts", ApiRequestType.ListForObject); requestTypes.Add("friends.get", ApiRequestType.ListForObject); requestTypes.Add("wall.getComments", ApiRequestType.ListForObject); requestParams.Add("groups.getById", new Dictionary<string, string>() { { "fields", "members_count" } }); //requestParams.Add("groups.get", // new ApiRequestParam(new Dictionary<string, string>() { // { "filter", "moder" } // }) //); requestParams.Add("users.get", new Dictionary<string, string>() { { "fields", "education,contacts,nickname, screen_name, sex, bdate, city, country, timezone, photo_50, photo_100, photo_200, photo_max, has_mobile, online" } }); requestParams.Add("wall.get", new Dictionary<string, string>() { { "filter", "all" } }); requestParams.Add("wall.getComments", new Dictionary<string, string>() { { "need_likes", "1" } }); itemsMaxCounts.Add("groups.getMembers", 1000); itemsMaxCounts.Add("groups.get", 1000); itemsMaxCounts.Add("wall.get", 100); itemsMaxCounts.Add("wall.getReposts", 1000); itemsMaxCounts.Add("users.getSubscriptions", 200); itemsMaxCounts.Add("friends.get", Int32.MaxValue); itemsMaxCounts.Add("wall.getComments", Int32.MaxValue); batchSizes.Add("users.get", 300); batchSizes.Add("groups.getById", 300); }
public void TestAuthrepWithValidCredentials() { m_api = new Api(host, provider_key); Hashtable parameters = new Hashtable(); parameters.Add("app_key", app_key); parameters.Add("app_id", app_id); var response = m_api.authrep(parameters); Assert.IsTrue(response.authorized); }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new WebRconException(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting(Name, "Enabled"); if (!_enabled) throw new WebRconException(String.Format("{0} has been disabled", Name)); var port = _ini.GetSetting(Name, "Port"); try { _port = Convert.ToInt32(port); } catch (Exception ex) { throw new WebRconException(String.Format("Invalid port: {0}", ex.Message)); } _password = _ini.GetSetting(Name, "Password"); if (_password == "") { _password = Utils.GetRandomString(); } #if DEBUG _serverurl = String.Format("http://localhost:{0}/", _port); #else _serverurl = String.Format("http://*:{0}/", _port); #endif _webServer = new WebServer(HttpRequest, _serverurl); _webServer.Run(); AppConsole.Log(String.Format("Started HTTP server at {0}. Password: {1}", _serverurl, _password), ConsoleColor.Cyan); _port++; _socketServer = new WebSocketServer(_port); _socketServer.AddWebSocketService("/rcon", () => new SocketBehavior(_api, _password)); _socketServer.Start(); LoadHtdocsFiles(); }
public void TestAuthrepWithInvalidAppKey() { m_api = new Api(host, provider_key); var parameters = new Hashtable(); parameters.Add("app_id", app_id); parameters.Add("app_key", invalid_app_key); var resp = m_api.authrep(parameters); Assert.IsFalse(resp.authorized); Assert.AreEqual(resp.reason, "application key \"InvalidAppKey\" is invalid"); }
public RestierQueryBuilder(IApi api, ODataPath path) { Ensure.NotNull(api, "api"); Ensure.NotNull(path, "path"); this.api = api; this.path = path; this.handlers[ODataSegmentKinds.EntitySet] = this.HandleEntitySetPathSegment; this.handlers[ODataSegmentKinds.UnboundFunction] = this.HandleUnboundFunctionPathSegment; this.handlers[ODataSegmentKinds.Count] = this.HandleCountPathSegment; this.handlers[ODataSegmentKinds.Value] = this.HandleValuePathSegment; this.handlers[ODataSegmentKinds.Key] = this.HandleKeyValuePathSegment; this.handlers[ODataSegmentKinds.Navigation] = this.HandleNavigationPathSegment; this.handlers[ODataSegmentKinds.Property] = this.HandlePropertyAccessPathSegment; }
internal void Init(IApi _api) { foreach (var t in _pluginCollection.ToArray()) { try { t.Instance.Init(_api, t.DllPath); } catch (Exception ex) { AppConsole.Log(String.Format("Plugin {0} loading failed: {1}", t.Instance.Name, ex.Message), ConsoleColor.Yellow); _pluginCollection.Remove(t); } } }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new $safeprojectname$Exception(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting(Name, "Enabled"); if (!_enabled) throw new $safeprojectname$Exception(String.Format("{0} has been disabled", Name)); }
/// <summary> /// Initializes a new instance of the <see cref="LeanEngineSystemHandlers"/> class with the specified handles /// </summary> /// <param name="jobQueue">The job queue used to acquire algorithm jobs</param> /// <param name="api">The api instance used for communicating limits and status</param> /// <param name="notify">The messaging handler user for passing messages from the algorithm to listeners</param> public LeanEngineSystemHandlers(IJobQueueHandler jobQueue, IApi api, IMessagingHandler notify) { if (jobQueue == null) { throw new ArgumentNullException("jobQueue"); } if (api == null) { throw new ArgumentNullException("api"); } if (notify == null) { throw new ArgumentNullException("notify"); } _api = api; _jobQueue = jobQueue; _notify = notify; }
/// <summary> /// Intializes the real time handler for the specified algorithm and job /// </summary> public void Setup(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api) { //Initialize: _api = api; _algorithm = algorithm; _resultHandler = resultHandler; _cancellationTokenSource = new CancellationTokenSource(); var todayInAlgorithmTimeZone = DateTime.UtcNow.ConvertFromUtc(_algorithm.TimeZone).Date; // refresh the market hours for today explicitly, and then set up an event to refresh them each day at midnight RefreshMarketHoursToday(todayInAlgorithmTimeZone); // every day at midnight from tomorrow until the end of time var times = from date in Time.EachDay(todayInAlgorithmTimeZone.AddDays(1), Time.EndOfTime) select date.ConvertToUtc(_algorithm.TimeZone); Add(new ScheduledEvent("RefreshMarketHours", times, (name, triggerTime) => { // refresh market hours from api every day RefreshMarketHoursToday(triggerTime.ConvertFromUtc(_algorithm.TimeZone).Date); })); // add end of day events for each tradeable day Add(ScheduledEventFactory.EveryAlgorithmEndOfDay(_algorithm, _resultHandler, todayInAlgorithmTimeZone, Time.EndOfTime, ScheduledEvent.AlgorithmEndOfDayDelta, DateTime.UtcNow)); // add end of trading day events for each security foreach (var security in _algorithm.Securities.Values.Where(x => !x.SubscriptionDataConfig.IsInternalFeed)) { // assumes security.Exchange has been updated with today's hours via RefreshMarketHoursToday Add(ScheduledEventFactory.EverySecurityEndOfDay(_algorithm, _resultHandler, security, todayInAlgorithmTimeZone, Time.EndOfTime, ScheduledEvent.SecurityEndOfDayDelta, DateTime.UtcNow)); } foreach (var scheduledEvent in _scheduledEvents) { // zoom past old events scheduledEvent.Value.SkipEventsUntil(algorithm.UtcTime); // set logging accordingly scheduledEvent.Value.IsLoggingEnabled = Log.DebuggingEnabled; } }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new SimpleMessagesException(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting("SimpleMessages", "Enabled"); if (!_enabled) throw new SimpleMessagesException(String.Format("{0} has been disabled", Name)); Int32 _interval; try { _interval = Convert.ToInt32(_ini.GetSetting("SimpleMessages", "Interval", "60")); } catch { _interval = 60; } _prefix = _ini.GetSetting("SimpleMessages", "Prefix"); _repeat = _ini.GetBoolSetting("SimpleMessages", "Repeat"); var _random = _ini.GetBoolSetting("SimpleMessages", "Random"); _messages = _ini.EnumSection("Messages"); if (_random) { var rnd = new Random(); _messages = _messages.OrderBy(x => rnd.Next()).ToArray(); } _timer = new Timer {Interval = (_interval*1000)}; _timer.Elapsed += _timer_Elapsed; _timer.Enabled = true; }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new BEFilterMonitorException(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting(Name, "Enabled"); if (!_enabled) throw new BEFilterMonitorException(String.Format("{0} has been disabled", Name)); _worker = new Thread(FilterMonitor); _worker.Start(); }
/// <summary> /// Intializes the real time handler for the specified algorithm and job /// </summary> public void Initialize(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api) { //Initialize: _api = api; _algorithm = algorithm; _resultHandler = resultHandler; _events = new ConcurrentDictionary<string, ScheduledEvent>(); _cancellationTokenSource = new CancellationTokenSource(); var todayInAlgorithmTimeZone = DateTime.UtcNow.ConvertFromUtc(_algorithm.TimeZone).Date; // refresh the market hours for today explicitly, and then set up an event to refresh them each day at midnight RefreshMarketHoursToday(todayInAlgorithmTimeZone); // every day at midnight from tomorrow until the end of time var times = from date in Time.EachDay(todayInAlgorithmTimeZone.AddDays(1), Time.EndOfTime) select date.ConvertToUtc(_algorithm.TimeZone); AddEvent(new ScheduledEvent("RefreshMarketHours", times, (name, triggerTime) => { // refresh market hours from api every day RefreshMarketHoursToday(triggerTime); })); // add end of day events for each tradeable day AddEvent(ScheduledEvent.EveryAlgorithmEndOfDay(_algorithm, _resultHandler, todayInAlgorithmTimeZone, Time.EndOfTime, ScheduledEvent.AlgorithmEndOfDayDelta, DateTime.UtcNow)); // add end of trading day events for each security foreach (var security in _algorithm.Securities.Values) { // assumes security.Exchange has been updated with today's hours via RefreshMarketHoursToday AddEvent(ScheduledEvent.EverySecurityEndOfDay(_algorithm, _resultHandler, security, todayInAlgorithmTimeZone, Time.EndOfTime, ScheduledEvent.SecurityEndOfDayDelta, DateTime.UtcNow)); } foreach (var scheduledEvent in _events.Values) { scheduledEvent.IsLoggingEnabled = true; } }
static async Task RunAsync(DictionaryInventory<Unit> units, IApi api) { var sync = await api.Login(0); units.Reset(sync.Units); var r = new Random(); // fires 5 times randomly for (int i = 0; i < 5; i++) { var ids = units.Ids.ToArray(); var d = await api.FireUnit(ids[r.Next(0, ids.Length)]); foreach (var x in d) units.Change(x); } // hires 5 times randomly for (int i = 0; i < 5; i++) { var d = await api.HireUnit(r.Next(1000, 1006)); foreach (var x in d) units.Change(x); } }
/// <summary> /// Intializes the real time handler for the specified algorithm and job /// </summary> public void Setup(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api) { //Initialize: _algorithm = algorithm; _resultHandler = resultHandler; // create events for algorithm's end of tradeable dates Add(ScheduledEventFactory.EveryAlgorithmEndOfDay(_algorithm, _resultHandler, _algorithm.StartDate, _algorithm.EndDate, ScheduledEvent.AlgorithmEndOfDayDelta)); // set up the events for each security to fire every tradeable date before market close foreach (var security in _algorithm.Securities.Values.Where(x => !x.SubscriptionDataConfig.IsInternalFeed)) { Add(ScheduledEventFactory.EverySecurityEndOfDay(_algorithm, _resultHandler, security, algorithm.StartDate, _algorithm.EndDate, ScheduledEvent.SecurityEndOfDayDelta)); } foreach (var scheduledEvent in _scheduledEvents) { // zoom past old events scheduledEvent.Value.SkipEventsUntil(algorithm.UtcTime); // set logging accordingly scheduledEvent.Value.IsLoggingEnabled = Log.DebuggingEnabled; } }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new LoggerException(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting("Logger", "Enabled"); if (!_enabled) { throw new LoggerException(String.Format("{0} has been disabled", Name)); } _path = _ini.GetSetting("Logger", "Path"); if (_path == "") _path = _defaultLogPath; if (!Directory.Exists(_path)) { try { Directory.CreateDirectory(_path); } catch { throw new LoggerException(String.Format("Log path \"{0}\" does not exist.", _path)); } } OpenLogs(); _api.OnBeMessageReceivedEvent += _be_MessageEventHandler; }
public void Init(IApi api, string dllpath) { _api = api; _dllpath = dllpath; IniParser _ini; try { _ini = new IniParser(_configPath); } catch (Exception ex) { throw new PlayerCheckException(String.Format("Error loading config: {0}", ex.Message)); } _enabled = _ini.GetBoolSetting(Name, "Enabled"); if (!_enabled) throw new PlayerCheckException(String.Format("{0} has been disabled", Name)); _checkip = _ini.GetBoolSetting(Name, "CheckIP"); _kickMessage = _ini.GetSetting(Name, "KickMessage"); if (_ini.GetSetting(Name, "Mode") == "white") { _mode = Mode.Whitelist; } var settings = new DriverSettings() { Api = api, Ini = _ini, PluginPath = dllpath }; _driver = Base.GetDriver(_ini); _driver.SetConfig(settings); api.OnBeMessageReceivedEvent += onBEMessageReceivedEvent; }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> /// <param name="factory">The content factory</param> public SiteService(IApi api, IContentFactory factory) { _api = api; _factory = factory; }
/// <summary> /// Initializes the application object. /// </summary> /// <param name="api">The current api</param> private void Initialize(IApi api) { if (!_isInitialized) { lock (_mutex) { if (!_isInitialized) { // Configure object mapper var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <Data.Alias, Data.Alias>() .ForMember(a => a.Id, o => o.Ignore()) .ForMember(a => a.Created, o => o.Ignore()); cfg.CreateMap <Data.Category, Data.Category>() .ForMember(c => c.Id, o => o.Ignore()) .ForMember(c => c.Created, o => o.Ignore()); cfg.CreateMap <Data.MediaFolder, Data.MediaFolder>() .ForMember(f => f.Id, o => o.Ignore()) .ForMember(f => f.Created, o => o.Ignore()) .ForMember(f => f.Media, o => o.Ignore()); cfg.CreateMap <Data.MediaFolder, Models.MediaStructureItem>() .ForMember(f => f.Level, o => o.Ignore()) .ForMember(f => f.Items, o => o.Ignore()); cfg.CreateMap <Data.Page, Models.PageBase>() .ForMember(p => p.TypeId, o => o.MapFrom(m => m.PageTypeId)) .ForMember(p => p.Permalink, o => o.MapFrom(m => "/" + m.Slug)) .ForMember(p => p.Blocks, o => o.Ignore()); cfg.CreateMap <Models.PageBase, Data.Page>() .ForMember(p => p.PageTypeId, o => o.MapFrom(m => m.TypeId)) .ForMember(p => p.Blocks, o => o.Ignore()) .ForMember(p => p.Fields, o => o.Ignore()) .ForMember(p => p.Created, o => o.Ignore()) .ForMember(p => p.LastModified, o => o.Ignore()) .ForMember(p => p.PageType, o => o.Ignore()) .ForMember(p => p.Site, o => o.Ignore()) .ForMember(p => p.Parent, o => o.Ignore()); cfg.CreateMap <Data.Page, Models.SitemapItem>() .ForMember(p => p.MenuTitle, o => o.Ignore()) .ForMember(p => p.Level, o => o.Ignore()) .ForMember(p => p.Items, o => o.Ignore()) .ForMember(p => p.PageTypeName, o => o.Ignore()) .ForMember(p => p.Permalink, o => o.MapFrom(d => !d.ParentId.HasValue && d.SortOrder == 0 ? "/" : "/" + d.Slug)); cfg.CreateMap <Data.Param, Data.Param>() .ForMember(p => p.Id, o => o.Ignore()) .ForMember(p => p.Created, o => o.Ignore()); cfg.CreateMap <Data.Post, Models.PostBase>() .ForMember(p => p.TypeId, o => o.MapFrom(m => m.PostTypeId)) .ForMember(p => p.Permalink, o => o.MapFrom(m => "/" + m.Blog.Slug + "/" + m.Slug)) .ForMember(p => p.Blocks, o => o.Ignore()); cfg.CreateMap <Models.PostBase, Data.Post>() .ForMember(p => p.PostTypeId, o => o.MapFrom(m => m.TypeId)) .ForMember(p => p.CategoryId, o => o.MapFrom(m => m.Category.Id)) .ForMember(p => p.Blocks, o => o.Ignore()) .ForMember(p => p.Fields, o => o.Ignore()) .ForMember(p => p.Created, o => o.Ignore()) .ForMember(p => p.LastModified, o => o.Ignore()) .ForMember(p => p.PostType, o => o.Ignore()) .ForMember(p => p.Blog, o => o.Ignore()) .ForMember(p => p.Category, o => o.Ignore()) .ForMember(p => p.Tags, o => o.Ignore()); cfg.CreateMap <Data.Site, Data.Site>() .ForMember(s => s.Id, o => o.Ignore()) .ForMember(s => s.Created, o => o.Ignore()); cfg.CreateMap <Data.Site, Models.SiteContentBase>() .ForMember(s => s.TypeId, o => o.MapFrom(m => m.SiteTypeId)); cfg.CreateMap <Models.SiteContentBase, Data.Site>() .ForMember(s => s.SiteTypeId, o => o.Ignore()) .ForMember(s => s.InternalId, o => o.Ignore()) .ForMember(s => s.Description, o => o.Ignore()) .ForMember(s => s.Hostnames, o => o.Ignore()) .ForMember(s => s.IsDefault, o => o.Ignore()) .ForMember(s => s.Fields, o => o.Ignore()) .ForMember(s => s.Created, o => o.Ignore()) .ForMember(s => s.LastModified, o => o.Ignore()); cfg.CreateMap <Data.Tag, Data.Tag>() .ForMember(t => t.Id, o => o.Ignore()) .ForMember(t => t.Created, o => o.Ignore()); }); mapperConfig.AssertConfigurationIsValid(); _mapper = mapperConfig.CreateMapper(); // Setup media types _mediaTypes.Documents.Add(".pdf", "application/pdf"); _mediaTypes.Images.Add(".jpg", "image/jpeg"); _mediaTypes.Images.Add(".jpeg", "image/jpeg"); _mediaTypes.Images.Add(".png", "image/png"); _mediaTypes.Videos.Add(".mp4", "video/mp4"); // Compose content types _contentTypes.Register <Models.IPage>("Page", "Page"); _contentTypes.Register <Models.IBlogPage>("Blog", "Archive", true); // Compose field types _fields.Register <Extend.Fields.CheckBoxField>(); _fields.Register <Extend.Fields.DateField>(); _fields.Register <Extend.Fields.DocumentField>(); _fields.Register <Extend.Fields.HtmlField>(); _fields.Register <Extend.Fields.ImageField>(); _fields.Register <Extend.Fields.MarkdownField>(); _fields.Register <Extend.Fields.MediaField>(); _fields.Register <Extend.Fields.NumberField>(); _fields.Register <Extend.Fields.PageField>(); _fields.Register <Extend.Fields.PostField>(); _fields.Register <Extend.Fields.StringField>(); _fields.Register <Extend.Fields.TextField>(); _fields.Register <Extend.Fields.VideoField>(); // Compose block types _blocks.Register <Extend.Blocks.HtmlBlock>(); _blocks.Register <Extend.Blocks.HtmlColumnBlock>(); _blocks.Register <Extend.Blocks.ImageBlock>(); _blocks.Register <Extend.Blocks.QuoteBlock>(); _blocks.Register <Extend.Blocks.TextBlock>(); _blocks.Register <Extend.Blocks.SliderGroup>(); // Compose serializers _serializers.Register <Extend.Fields.CheckBoxField>(new CheckBoxFieldSerializer <Extend.Fields.CheckBoxField>()); _serializers.Register <Extend.Fields.DateField>(new DateFieldSerializer()); _serializers.Register <Extend.Fields.DocumentField>(new DocumentFieldSerializer()); _serializers.Register <Extend.Fields.HtmlField>(new StringFieldSerializer <Extend.Fields.HtmlField>()); _serializers.Register <Extend.Fields.MarkdownField>(new StringFieldSerializer <Extend.Fields.MarkdownField>()); _serializers.Register <Extend.Fields.MediaField>(new MediaFieldSerializer()); _serializers.Register <Extend.Fields.NumberField>(new IntegerFieldSerializer <Extend.Fields.NumberField>()); _serializers.Register <Extend.Fields.PageField>(new PageFieldSerializer()); _serializers.Register <Extend.Fields.PostField>(new PostFieldSerializer()); _serializers.Register <Extend.Fields.StringField>(new StringFieldSerializer <Extend.Fields.StringField>()); _serializers.Register <Extend.Fields.TextField>(new StringFieldSerializer <Extend.Fields.TextField>()); _serializers.Register <Extend.Fields.ImageField>(new ImageFieldSerializer()); _serializers.Register <Extend.Fields.VideoField>(new VideoFieldSerializer()); // Create markdown converter _markdown = new DefaultMarkdown(); // Register permissions _permissions["Core"].Add(new PermissionItem { Name = Permission.PagePreview, Title = "Page Preview" }); _permissions["Core"].Add(new PermissionItem { Name = Permission.PostPreview, Title = "Post Preview" }); // Initialize all modules foreach (var module in _modules) { module.Instance.Init(); } _isInitialized = true; } } } }
public void Setup(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api) { }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> public PostTypeBuilder(IApi api) : base(api) { }
public CIAgentWriter(IApi api, int maxBufferSize = DefaultMaxBufferSize) { _agentWriter = new AgentWriter(api, null, maxBufferSize: maxBufferSize); }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> public PageTypeBuilder(IApi api) { _api = api; }
/// <summary> /// Initializes the field for client use. /// </summary> /// <param name="api">The current api</param> public override void Init(IApi api) { InitMetaData(); }
/// <summary> /// Creates a new page model using the given page type id. /// </summary> /// <param name="api">The current api</param> /// <param name="typeId">The unique page type id</param> /// <returns>The new model</returns> public static T Create(IApi api, string typeId = null) { return(api.Pages.Create <T>(typeId)); }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> public CmsController(IApi api, IModelLoader loader) { _api = api; _loader = loader; }
public ExportApi(HttpClient client, IApi api, IConfiguration config) { _client = client; _api = api; _config = config; }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> /// <param name="factory">The content factory</param> /// <param name="localizer">The manager localizer</param> public PageService(IApi api, IContentFactory factory, ManagerLocalizer localizer) { _api = api; _factory = factory; _localizer = localizer; }
/// <summary> /// Initialize the result handler with this result packet. /// </summary> /// <param name="job">Algorithm job packet for this result handler</param> /// <param name="messagingHandler">The handler responsible for communicating messages to listeners</param> /// <param name="api">The api instance used for handling logs</param> /// <param name="dataFeed"></param> /// <param name="setupHandler"></param> /// <param name="transactionHandler"></param> public virtual void Initialize(AlgorithmNodePacket job, IMessagingHandler messagingHandler, IApi api, IDataFeed dataFeed, ISetupHandler setupHandler, ITransactionHandler transactionHandler) { _messagingHandler = messagingHandler; _transactionHandler = transactionHandler; _setupHandler = setupHandler; _job = (BacktestNodePacket)job; if (_job == null) { throw new Exception("BacktestingResultHandler.Constructor(): Submitted Job type invalid."); } _compileId = _job.CompileId; _backtestId = _job.BacktestId; }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> /// <param name="loader">The model loader</param> public SinglePostWithComments(IApi api, IModelLoader loader) : base(api, loader) { }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current Api</param> /// <param name="security">The current security provider</param> public AccountController(IApi api, ISecurity security) { this.api = api; this.security = security; }
public SonarrApi(IApi api) { Api = api; }
public SonarrV3Api(IApi api) : base(api) { }
/// <summary> /// Initializes the application object. /// </summary> /// <param name="api">The current api</param> public static void Init(IApi api) { Instance.Initialize(api); }
public ChatClient(IApi api, ApiConfiguration configuration) { this.Api = api; this.configuration = configuration; StartSenderWorker(); }
/// <summary> /// Creates a new middleware instance. /// </summary> /// <param name="next">The next middleware in the pipeline</param> public PageMiddleware(RequestDelegate next, IApi api) : base(next, api) { }
/// <summary> /// Default constructor. /// </summary> public ContentApiController(ContentService content, ContentTypeService contentType, IApi api) { _api = api; _content = content; _contentType = contentType; }
public ShowViewModel(IApi api) { _api = api; Shows = new ObservableRangeCollection <Show>(); }
/// <summary> /// Initialize the result handler with this result packet. /// </summary> /// <param name="job">Algorithm job packet for this result handler</param> /// <param name="messagingHandler">The handler responsible for communicating messages to listeners</param> /// <param name="api">The api instance used for handling logs</param> /// <param name="transactionHandler">The transaction handler used to get the algorithms <see cref="Order"/> information</param> public virtual void Initialize(AlgorithmNodePacket job, IMessagingHandler messagingHandler, IApi api, ITransactionHandler transactionHandler) { MessagingHandler = messagingHandler; TransactionHandler = transactionHandler; CompileId = job.CompileId; AlgorithmId = job.AlgorithmId; ProjectId = job.ProjectId; RamAllocation = job.RamAllocation.ToStringInvariant(); OrderEventJsonConverter = new OrderEventJsonConverter(AlgorithmId); _updateRunner = new Thread(Run, 0) { IsBackground = true, Name = "Result Thread" }; _updateRunner.Start(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> public Config(IApi api) { _service = api.Params; }
public SetupController(IApi api) { _api = api; }
public SetupController(IApi api) { this.api = api; }
public void Initialize(AlgorithmNodePacket job, IAlgorithm algorithm, IMessagingHandler messagingHandler, IApi api) { }
/// <summary> /// Invokes the router. /// </summary> /// <param name="api">The current api</param> /// <param name="url">The requested url</param> /// <param name="hostname">The optional hostname</param> /// <returns>The piranha response, null if no matching page was found</returns> public static IRouteResponse Invoke(IApi api, string url, string hostname) { if (!String.IsNullOrWhiteSpace(url) && url.Length > 1) { var segments = url.Substring(1).Split(new char[] { '/' }); if (segments.Length >= 1) { Data.Site site = null; if (!string.IsNullOrWhiteSpace(hostname)) { site = api.Sites.GetByHostname(hostname); } if (site == null) { site = api.Sites.GetDefault(); } var blog = api.Pages.GetBySlug(segments[0], site.Id); if (blog != null && blog.ContentType == "Blog") { var route = blog.Route ?? "/archive"; int? page = null; int? year = null; int? month = null; Guid?categoryId = null; bool foundCategory = false; bool foundPage = false; for (var n = 1; n < segments.Length; n++) { if (segments[n] == "category" && !foundPage) { foundCategory = true; continue; } if (segments[n] == "page") { foundPage = true; continue; } if (foundCategory) { try { categoryId = api.Categories.GetBySlug(blog.Id, segments[n])?.Id; } catch { } finally { foundCategory = false; } } if (foundPage) { try { page = Convert.ToInt32(segments[n]); } catch { } break; } if (!year.HasValue) { try { year = Convert.ToInt32(segments[n]); if (year.Value > DateTime.Now.Year) { year = DateTime.Now.Year; } } catch { } } else { try { month = Math.Max(Math.Min(Convert.ToInt32(segments[n]), 12), 1); } catch { } } } return(new RouteResponse() { Route = route, QueryString = $"id={blog.Id}&year={year}&month={month}&page={page}&category={categoryId}&piranha_handled=true", IsPublished = true }); } } } return(null); }
public MovieViewModel(IApi api) { _api = api; Movies = new ObservableRangeCollection <Movie>(); }
/// <summary> /// Invokes the router. /// </summary> /// <param name="api">The current api</param> /// <param name="url">The requested url</param> /// <param name="siteId">The requested site id</param> /// <returns>The piranha response, null if no matching page was found</returns> public static async Task <IRouteResponse> InvokeAsync(IApi api, string url, Guid siteId) { if (!String.IsNullOrWhiteSpace(url) && url.Length > 1) { var segments = url.Substring(1).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (segments.Length >= 1) { Models.PageInfo blog = null; // Scan for the most unique slug for (var i = segments.Length; i > 0; i--) { var slug = string.Join("/", segments.Subset(0, i)); blog = await api.Pages.GetBySlugAsync <Models.PageInfo>(slug, siteId) .ConfigureAwait(false); if (blog != null) { var type = App.PageTypes.GetById(blog.TypeId); if (type == null || !type.IsArchive) { return(null); } // First check that this is a valid archive URL if (segments.Length == i + 1) { try { var number = Convert.ToInt32(segments[i]); if (number < 1900 || number > DateTime.Now.Year) { return(null); } } catch { return(null); } } var route = blog.Route ?? "/archive"; int? page = null; int? year = null; int? month = null; Guid?categoryId = null; Guid?tagId = null; bool foundCategory = false; bool foundTag = false; bool foundPage = false; for (var n = i; n < segments.Length; n++) { if (segments[n] == "category" && !foundPage) { foundCategory = true; continue; } if (segments[n] == "tag" && !foundPage && !foundCategory) { foundTag = true; continue; } if (segments[n] == "page") { foundPage = true; continue; } if (foundCategory) { try { categoryId = (await api.Posts.GetCategoryBySlugAsync(blog.Id, segments[n]).ConfigureAwait(false))?.Id; if (!categoryId.HasValue) { categoryId = Guid.Empty; } } finally { foundCategory = false; } } if (foundTag) { try { tagId = (await api.Posts.GetTagBySlugAsync(blog.Id, segments[n]).ConfigureAwait(false))?.Id; if (!tagId.HasValue) { tagId = Guid.Empty; } } finally { foundTag = false; } } if (foundPage) { try { page = Convert.ToInt32(segments[n]); } catch { // We don't care about the exception, we just // discard malformed input } break; } if (!year.HasValue) { try { year = Convert.ToInt32(segments[n]); if (year.Value > DateTime.Now.Year) { year = DateTime.Now.Year; } } catch { // We don't care about the exception, we just // discard malformed input } } else { try { month = Math.Max(Math.Min(Convert.ToInt32(segments[n]), 12), 1); } catch { // We don't care about the exception, we just // discard malformed input } } } return(new RouteResponse { PageId = blog.Id, Route = route, QueryString = $"id={blog.Id}&year={year}&month={month}&page={page}&pagenum={page}&category={categoryId}&tag={tagId}&piranha_handled=true", IsPublished = blog.Published.HasValue && blog.Published.Value <= DateTime.Now, CacheInfo = new HttpCacheInfo { EntityTag = Utils.GenerateETag(blog.Id.ToString(), blog.LastModified), LastModified = blog.LastModified } }); } } } } return(null); }
/// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> /// <param name="logFactory">The optional log factory</param> public PageTypeBuilder(IApi api, ILoggerFactory logFactory = null) { this.api = api; this.logger = logFactory?.CreateLogger("Piranha.Builder.Json.PageTypeBuilder"); }