public override IDataContainer PreProcess(IDataContainer dataContainer) { if (dataContainer.OfType<BlobData>().Any()) { if (StagedData.OfType<BlobData>().Any()) Push(); foreach (var data in dataContainer) Stage(data); } else if (dataContainer.OfType<Marker>().Any()) { if (StagedData.OfType<Marker>().Any()) Push(); foreach (var data in dataContainer) Stage(data); } else if (dataContainer.OfType<Hand>().Any()) { if (StagedData.OfType<Hand>().Any()) Push(); foreach (var data in dataContainer) Stage(data); } return null; }
/// <summary> /// Creates a new instance of a TemplateData object that will be used to generate code from a template /// </summary> /// <param name="DataContainer">A table or view</param> /// <param name="UserName">The user who will be named as the author in the genrated code files</param> /// <param name="RootNamespace">The root namespace to apply to the generated classes</param> /// <param name="DatabaseName">The name of the database</param> public TemplateData(IDataContainer DataContainer, string UserName, string RootNamespace, string DatabaseName) { _databaseName = DatabaseName; _dataContainer = DataContainer; _userName = UserName; _rootNamespace = RootNamespace; }
public ParameterValueWriter(ParameterValueReader reader) : base(reader) { Obj = reader.Obj; Param = reader.Param; Owner = reader.Owner; }
public SeasonsList( IViewModelContainer viewModelContainer, IDataContainer dataContainer, ISeriesList seriesList ) : base(viewModelContainer, dataContainer) { MessengerInstance.Register<SelectedSeriesChanged>( this, OnSelectedSeriesChanged ); Seasons = new ObservableCollection<SeasonEntry>(); OnSelectedSeriesChanged( new SelectedSeriesChanged( seriesList.SelectedSeries ) ); }
internal static TypeMatcherProperyReader GetTypeMatcherProperyReader(object obj, string objParam, string component, string param, IDataContainer owner) { TypeMatcherWatcher watcher = TypeMatcherWatcher.GetTypeMatcherWatcher(obj, objParam, owner); Func<TypeMatcherProperyReader> create = new Func<TypeMatcherProperyReader>(() => new TypeMatcherProperyReader(watcher, component, param)); string fullParam = component + "." + param; return DoubleDictionary<TypeMatcherWatcher, string, TypeMatcherProperyReader>.GetItem(watcher, fullParam, create); }
public override IDataContainer PreProcess(IDataContainer dataContainer) { if (dataContainer.FrameId % 10 == 0) { return dataContainer; } return null; }
public SettingsDialogViewModel( IViewModelContainer viewModelContainer, IDataContainer dataContainer, IAppThemes themes ) : base( viewModelContainer, dataContainer ) { Themes = themes ?? new AppThemes(); AvailableAccents = Themes.Accents.ToList(); AvailableThemes = Themes.Themes.ToList(); AvailableLanguages = new List<CultureInfo>( ViewModelContainer.LanguageProvider.AvailableLanguages.OrderBy( l => l.NativeName ) ); AvailableContentLanguages = Repositories.Languages.GetAll().Select( l => l.Culture ).OrderBy( l => l.NativeName ).ToList(); }
private TypeMatcherWatcher(object obj, string param, IDataContainer owner) { Obj = obj; Param = param; Type objType = obj.GetType(); Owner = owner; if(typeof(IChangeable).IsAssignableFrom(obj.GetType())) Owner.NotifyOfComponentChange(new Tuple<IChangeable,string>((IChangeable)obj, param), this); }
public EpisodesList( IViewModelContainer container, IDataContainer dataContainer, ISeriesList seriesList, ISeasonsList seasonsList ) : base(container, dataContainer) { SeriesList = seriesList; Episodes = new ObservableCollection<EpisodeEntry>(); MessengerInstance.Register<SelectedSeasonChanged>( this, OnSelectedSeasonChanged ); OnSelectedSeasonChanged( new SelectedSeasonChanged( seasonsList?.SelectedSeason?.SeasonNumber ) ); }
/// <summary> /// Writes the data container to the output. /// </summary> /// <param name="dc">Container to write</param> protected void WriteDataContainer(IDataContainer dc) { StringBuilder sb = new StringBuilder(); sb.Append("<table class=\"table table-hover\" style=\"margin-top: 16px;\">"); // Add header sb.AppendFormat("<thead><tr class=\"unigrid-head\"><th>{0}</th><th class=\"main-column-100\">{1}</th></tr></thead><tbody>", GetString("General.FieldName"), GetString("General.Value")); // Add values foreach (string column in dc.ColumnNames) { try { object value = dc.GetValue(column); // Binary columns string content; if (value is byte[]) { byte[] data = (byte[])value; content = "<" + GetString("General.BinaryData") + ", " + DataHelper.GetSizeString(data.Length) + ">"; } else { content = ValidationHelper.GetString(value, String.Empty); } if (!String.IsNullOrEmpty(content)) { sb.AppendFormat("<tr><td><strong>{0}</strong></td><td class=\"wrap-normal\">", column); // Possible DataTime columns if (value is DateTime) { DateTime dateTime = Convert.ToDateTime(content); CultureInfo cultureInfo = CultureHelper.GetCultureInfo(MembershipContext.AuthenticatedUser.PreferredUICultureCode); content = dateTime.ToString(cultureInfo); } // Process content ProcessContent(sb, dc, column, ref content); sb.Append("</td></tr>"); } } catch { } } sb.Append("</tbody></table><br />\n"); pnlContent.Controls.Add(new LiteralControl(sb.ToString())); }
/// <summary> /// Returns URL of item according specified conditions. /// </summary> /// <param name="data">Data object holding information on item</param> /// <param name="isPreview">Indicates whether the URL is requested for item preview</param> /// <param name="height">Image height</param> /// <param name="width">Image width</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> /// <param name="notAttachment">Indicates whether the file is attachment</param> private IconParameters innermedia_GetThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { IconParameters parameters = new IconParameters(); if (LibraryInfo != null) { // get argument set string arg = GetArgumentSet(data); // Get extension string ext = data.GetValue((data.ContainsColumn("FileExtension") ? "FileExtension" : "Extension")).ToString(); // If image is requested for preview if (isPreview) { if (ext.ToLowerCSafe() == "<dir>") { parameters.IconClass = "icon-folder"; } else { // Check if file has a preview if (!ImageHelper.IsSupportedByImageEditor(ext)) { // File isn't image and no preview exists - get the default file icon parameters.IconClass = UIHelper.GetFileIconClass(ext); } else { // Files are obtained from the FS if (!data.ContainsColumn("FileURL")) { parameters.Url = GetItemUrl(arg, true, height, width, maxSideSize); } else { parameters.IconClass = UIHelper.GetFileIconClass(ext); } } } // Setup icon size for fon icons if (!string.IsNullOrEmpty(parameters.IconClass)) { parameters.IconSize = FontIconSizeEnum.Dashboard; } } else { // Get item URL parameters.Url = GetItemUrlInternal(arg, data, false, height, width, maxSideSize, notAttachment); } } return(parameters); }
public EpisodeDetails( IViewModelContainer viewModelContainer, IDataContainer dataContainer, IEpisodesList episodesList ) : base(viewModelContainer, dataContainer) { MessengerInstance.Register<SelectedEpisodeChanged>( this, OnSelectedEpisodeChanged ); Writers = new ObservableCollection<PersonEntry>(); Directors = new ObservableCollection<PersonEntry>(); GuestStars = new ObservableCollection<PersonEntry>(); OnSelectedEpisodeChanged( new SelectedEpisodeChanged( episodesList.SelectedEpisode ) ); }
private void RunCall(IDataContainer obj, string func, object[] parameters, bool isSelf, FallbackAction fallback) { // This executes in the job thread. // Checks if this is still alive. if (IsDisposed) { return; } // Checks if the function still exists. LuaDataContainer dc = obj as LuaDataContainer; if (dc == null) { return; } IDataProvider lf = dc.GetProvider(func, isSelf); if (lf == null) { return; } // Calls the function. try { lf.Execute(parameters); } catch (InvalidOperationException ex) { // Last chance fallback action, if any. if (fallback != null) { fallback(ex); } else if (DefaultFallbackAction != null) { DefaultFallbackAction(ex); } else { // No fallback action: let's rethrow this. throw; } } catch (Exception) { // Other exceptions than InvalidOperationException are // immediately rethrown because they are, indeed, unexpected. throw; } }
public EpisodeEntry( IViewModelContainer viewModelContainer, IDataContainer dataContainer, Episode model, SeriesEntry series ) : base( viewModelContainer, dataContainer ) { Series = series; Model = model; if( model.BannerLocation != null ) { BannerUrl = model.BannerLocation; } }
public PunishHandler( IDialogManager dialogManager, IDataRepository dataRepository, IAnalyticManager analyticManager) : base(Server.GServer, Msg.CmdType.GU.PUNISH_V6) { _dialogManager = dialogManager; _analyticManager = analyticManager; _room = dataRepository.GetContainer <Room>(DataKey.CurrentRoom); _user = dataRepository.GetContainer <User>(DataKey.MyUser); }
public void Initialize( IDataRepository dataRepository, IDialogManager dialogManager, RemoteAPI remoteAPI, ITaskManager task) { _dialogManager = dialogManager; _remoteAPI = remoteAPI; _task = task; _applyRaceResult = dataRepository.GetContainer <ApplyRaceResult>(DataKey.ApplyRaceResult); }
protected override void CopyDataProperties(XRControl control) { IDataContainer dataControl = control as IDataContainer; if (dataControl != null) { this.DataSource = dataControl.DataSource; this.DataAdapter = dataControl.DataAdapter; } base.CopyDataProperties(control); }
/// <summary> /// /// </summary> protected BaseCacheStruct() { IsReadonly = false; SchemaTable schema; if (EntitySchemaSet.TryGet <T>(out schema)) { IsReadonly = schema.AccessLevel == AccessLevel.ReadOnly; } DataContainer = CacheFactory.GetOrCreate <T>(IsReadonly, LoadFactory, LoadItemFactory); }
public GameEngine(ITurnProcessor turn, ICommandProcessor commandProcessor, IDataContainer data, ITerrainManager terrainManager, IRenderer render, IActManager actManager, IAdvancedChecker checker) { this.commandProcessor = commandProcessor; this.turn = turn; this.data = data; this.terrainManager = terrainManager; this.renderer = render; this.actManager = actManager; this.checker = checker; }
public void Initialize( IDataRepository dataRepository, AndroidSDK android, IosSDK ios, ConfigHolder config) { _android = android; _ios = ios; _config = config; _myUser = dataRepository.GetContainer <User>(DataKey.MyUser); }
public WechatShareSeq(NotifyDoShare currentNotifyDoShare, IDataContainer <NotifyDoShareResult> notifyDoShareResult, RemoteAPI remoteApi, IDialogManager dialogManager, Action callBack) { _finishCallBack = callBack; _dialogManager = dialogManager; _remoteAPI = remoteApi; StartListener = BeforeStart; _notifyDoShareResult = notifyDoShareResult; _currentNotifyDoShare = currentNotifyDoShare; }
public void Initialize( IDataRepository dataRepository, IDialogManager dialogManager, RemoteAPI remoteAPI, RaceHistoryRankItem.Factory historyRankFactory, ITaskManager task) { _historyRankFactory = historyRankFactory; _raceDescriptionResult = dataRepository.GetContainer <RaceDescriptionResult>(DataKey.RaceDescriptionResult); }
public AdvancedChecker(IReader reader, IWriter writer, IRenderer renderer, ITurnProcessor turn, ICommandProcessor processor, IDataContainer data, ITerrainManager terrainManager) { this.reader = reader; this.writer = writer; this.renderer = renderer; this.turn = turn; this.processor = processor; this.data = data; this.terrainManager = terrainManager; }
public void Initialize( CurrencyValue.Factory currencyValueFactory, IWeChatManager weChatManager, IDataRepository dataRepository, IAnalyticManager analyticManager) { _currencyValueFactory = currencyValueFactory; _wechatManager = weChatManager; _analyticManager = analyticManager; _raceAwardQueue = dataRepository.GetContainer <Queue <RaceAward> >(DataKey.RaceAwardQueue); }
public void Initialize( IDataRepository dataRepository, IDialogManager dialogManager, IAnalyticManager analyticManager, RemoteAPI remoteAPI) { _dialogManager = dialogManager; _analyticManager = analyticManager; _remoteAPI = remoteAPI; _sFriendListResult = dataRepository.GetContainer <SFriendListResult>(DataKey.SFriendListResult); }
public TraceUserResultHandler( IDataRepository dataRepository, IDialogManager dialogManager, RemoteAPI remoteAPI) : base(Server.HServer, Msg.CmdType.HU.TRACE_USER_RESULT) { _traceUserResult = dataRepository.GetContainer <TraceUserResult>(DataKey.TraceUserResult); _currentRoom = dataRepository.GetContainer <Room>(DataKey.CurrentRoom); _dialogManager = dialogManager; _remoteAPI = remoteAPI; }
/// <summary> /// Removes a DataContainer that was used to store or buffer data for a data-collection job /// </summary> /// <param name="uniqueName">the unique name of the container</param> /// <param name="container">the container instance</param> public void UnregisterTarget(string uniqueName, IDataContainer container) { lock (containers) { if (!containers.ContainsKey(uniqueName) || containers[uniqueName] != container) { throw new InvalidOperationException( "The provided container is not registered or the registered name is not equal to the provided name"); } } }
public override void Initialize(IAppContext context, float time) { var dialog = context.GetDialogManager(); var dataReposity = context.GetDataRepository(); _isSetTestLogin = dataReposity.GetContainer <bool>(DataKey.IsSetTestPServer); _isSetTestLogin.Write(false, Time.time); dialog.ShowDialog <UIWindow>(DialogName.SetPServerDialog); }
/// <summary> /// Creates <see cref="DataPart"/> instance /// </summary> /// <param name="dataContainer">Container with data stream</param> public DataPart(IDataContainer dataContainer) { if (dataContainer == null) { throw new ArgumentNullException("dataContainer"); } _dataContainer = dataContainer; Headers = new Headers(); Properties = new Properties(); }
public static void WriteBytes(this IDataContainer container, Stream stream) { var writer = new BinaryWriter(stream); foreach (var data in container) { if (data is IWriteToBinaryStream wbs) { wbs.WriteBytes(writer); } } }
private IconParameters innermedia_GetThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { IconParameters parameters = new IconParameters(); string ext = (SourceType != MediaSourceEnum.MetaFile) ? data.GetValue("AttachmentExtension").ToString() : data.GetValue("MetaFileExtension").ToString(); string arg = GetArgumentSet(data); // If image is requested for preview if (isPreview) { if (!ImageHelper.IsImage(ext) || notAttachment) { string className = (SourceType == MediaSourceEnum.Content) ? data.GetValue("ClassName").ToString().ToLowerCSafe() : ""; if (className == "cms.file") { // File isn't image and no preview exists - get default file icon parameters.IconClass = UIHelper.GetFileIconClass(ext); } else if (((SourceType == MediaSourceEnum.DocumentAttachments) || (SourceType == MediaSourceEnum.Attachment) || (SourceType == MediaSourceEnum.MetaFile)) && !String.IsNullOrEmpty(ext)) { // Get file icon for attachment parameters.IconClass = UIHelper.GetFileIconClass(ext); } else { var dataClass = DataClassInfoProvider.GetDataClassInfo(className); parameters.Url = UIHelper.GetDocumentTypeIconUrl(Page, className, "48x48"); if (dataClass != null) { parameters.IconClass = (string)dataClass.GetValue("ClassIconClass"); } } // Set font icon size if (!string.IsNullOrEmpty(parameters.IconClass)) { parameters.IconSize = FontIconSizeEnum.Dashboard; } } else { // Try to get preview or image itself parameters.Url = GetItemUrl(arg, height, width, maxSideSize, notAttachment); } } else { parameters.Url = GetItemUrl(arg, 0, 0, 0, notAttachment); } return(parameters); }
public void DataContainerAutoUpdater_ShouldAddNewValuesWithMultiLevelData() { string path = Path.GetTempFileName(); DataContainerBase A = (DataContainerBase)DataContainerBuilder.Create("A") .Data("A", 1) .Data("B", 2) .Data("D", 3) .DataContainer("AB", b => b .Data("AB1", 1)) .Build(); A.FilePath = path; A.SaveAsXml(path); var tester = new AutoUpateTester(A); tester.AutoUpdater.PollingInterval = 10; // allow adding tester.AutoUpdater.CanAddItems = true; Assert.False(tester.UpdateStartedInvoked); Assert.False(tester.UpdateFinishedInvoked); IDataContainer Updated = (DataContainerBase)DataContainerBuilder.Create("A") .Data("A", 1) .Data("B", 2) .Data("D", 3) .DataContainer("AB", b => b .Data("AB1", 1) .Data("AB2", 2)) .Build(); Updated.SaveAsXml(path); // wait timer Thread.Sleep((int)tester.AutoUpdater.PollingInterval + 20); Assert.True(tester.UpdateStartedInvoked); Assert.True(tester.UpdateFinishedInvoked); IDataContainer AB = (IDataContainer)A["AB"]; // 1 value added Assert.Equal(2, AB.Count); // check if value exist Assert.True(AB.ContainsData("AB2")); // check it has correct value Assert.Equal(2, (int)AB["AB2"]); File.Delete(path); }
public override void Initialize(IAppContext context, float time) { MyLog.DebugWithFrame(Tag, "Begin login hall server."); _isTimeout = false; _currentloginHallServerTimes = 0; LoginHallServer(context, time); var dataRepository = context.GetDataRepository(); _hLoginResult = dataRepository.GetContainer <HLoginResult>(DataKey.HLoginResult); _userContainer = dataRepository.GetContainer <User>(DataKey.MyUser); }
private void OnEnable() { var dataRepository = GetDataRepository(); _myUser = dataRepository.GetContainer <User>(DataKey.MyUser); _checkinConfigResult = dataRepository.GetContainer <CheckinConfigResult>(DataKey.CheckinConfigResult); _checkinConfig = dataRepository.GetContainer <CheckinConfig>(DataKey.CheckinConfig); _reCheckinResult = dataRepository.GetContainer <ReCheckinResult>(DataKey.ReCheckinResult); _checkinResult = dataRepository.GetContainer <CheckinResult>(DataKey.CheckinResult); }
public void Initialize(IDataRepository dataRepository, SpriteHolder spriteHolder) { _spriteHolder = spriteHolder; _hostInfo = dataRepository.GetContainer <HostInfoResult>(DataKey.HostInfo); _fanbei = dataRepository.GetContainer <BFanbei>(DataKey.BFanbei); _tableUser = dataRepository.GetContainer <TableUserData>(DataKey.TableUserData); _raceConfig = dataRepository.GetContainer <RaceConfig>(DataKey.RaceConfig); _currentRoom = dataRepository.GetContainer <Room>(DataKey.CurrentRoom); _currentTable = dataRepository.GetContainer <Table>(DataKey.CurrentTable); _playingData = dataRepository.GetContainer <PlayingData>(DataKey.PlayingData); }
public async Task TestSimpleCreateAsymmetricKeysStore() { FakeDataStore.AddFolder(@"C:\Temp"); IDataContainer workFolder = New <IDataContainer>(@"C:\Temp"); AccountStorage store = new AccountStorage(new LocalAccountService(new LogOnIdentity(EmailAddress.Parse(@"*****@*****.**"), new Passphrase("secret")), workFolder)); UserKeyPair userKeyPair = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512); await store.ImportAsync(userKeyPair); Assert.That((await store.AllKeyPairsAsync()).First().KeyPair.PrivateKey, Is.Not.Null); Assert.That((await store.AllKeyPairsAsync()).First().KeyPair.PublicKey, Is.Not.Null); }
public static void Write(this IDataContainer This, string key, object toStore) { if (toStore == null) { return; } ISerializer serializer = Locator.Current.GetService <ISerializer>(); string serialized = serializer.SerializeObject(toStore); This.Data[key] = serialized; }
/// <summary> /// Creates attachment string. /// </summary> private string CreateAttachment(IDataContainer dc, int versionId) { string result = null; if (dc != null) { // Get attachment GUID Guid attachmentGuid = ValidationHelper.GetGuid(dc.GetValue("AttachmentGUID"), Guid.Empty); // Get attachment extension string attachmentExt = ValidationHelper.GetString(dc.GetValue("AttachmentExtension"), null); string iconUrl = GetFileIconUrl(attachmentExt, "List"); // Get link for attachment string attachmentUrl = null; string attName = ValidationHelper.GetString(dc.GetValue("AttachmentName"), null); attachmentUrl = CMSContext.ResolveUIUrl(TreePathUtils.GetAttachmentUrl(attachmentGuid, URLHelper.GetSafeFileName(attName, CMSContext.CurrentSiteName), versionId, null)); // Ensure correct URL attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "sitename", CMSContext.CurrentSiteName); // Optionally trim attachment name string attachmentName = TextHelper.LimitLength(attName, 90); bool isImage = ImageHelper.IsImage(attachmentExt); // Tooltip string tooltip = null; if (isImage) { int attachmentWidth = ValidationHelper.GetInteger(dc.GetValue("AttachmentImageWidth"), 0); if (attachmentWidth > 300) { attachmentWidth = 300; } tooltip = "onmouseout=\"UnTip()\" onmouseover=\"TipImage(" + attachmentWidth + ", '" + URLHelper.AddParameterToUrl(attachmentUrl, "width", "300") + "', " + ScriptHelper.GetString(HTMLHelper.HTMLEncode(attachmentName)) + ")\""; } string attachmentSize = DataHelper.GetSizeString(ValidationHelper.GetLong(dc.GetValue("AttachmentSize"), 0)); string title = ValidationHelper.GetString(dc.GetValue("AttachmentTitle"), string.Empty); string description = ValidationHelper.GetString(dc.GetValue("AttachmentDescription"), string.Empty); // Icon StringBuilder sb = new StringBuilder(); sb.Append("<img class=\"Icon\" style=\"cursor: pointer;\" src=\"", HTMLHelper.HTMLEncode(iconUrl), "\" alt=\"", HTMLHelper.HTMLEncode(attachmentName), "\" ", tooltip, " onclick=\"javascript: window.open(", ScriptHelper.GetString(attachmentUrl), "); return false;\" />"); sb.Append(" ", HTMLHelper.HTMLEncode(attachmentName), " (", HTMLHelper.HTMLEncode(attachmentSize), ")<br />"); sb.Append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"NoBorderTable\" ><tr><td style=\"padding:1px;\"><strong>", GetString("general.title"), ":</strong></td><td style=\"padding:1px;\">", HTMLHelper.HTMLEncode(title), "</td></tr>"); sb.Append("<tr><td style=\"padding:1px;\"><strong>", GetString("general.description"), ":</strong></td><td style=\"padding:1px;\">", HTMLHelper.HTMLEncode(description), "</td></tr></table><br/>"); result = sb.ToString(); } return(result); }
/// <summary> /// Initializes a new instance of the DataClient class /// </summary> /// <param name="dataClientId">data client id</param> /// <param name="info">data client info</param> /// <param name="readOnly">a flag indicating whether the DataClient instance is readonly or not</param> internal DataClient(string dataClientId, DataClientInfo info, bool readOnly) { this.id = dataClientId; this.isReadOnly = readOnly; if (string.IsNullOrEmpty(info.SecondaryDataPath)) { this.dataContainer = DataContainerHelper.GetDataContainer(info.PrimaryDataPath); } else { this.dataContainer = DataContainerHelper.GetDataContainer(info.PrimaryDataPath, info.SecondaryDataPath); } }
public PreCalculatingSolution(IDataContainer storage, int startDepartment, int endDepartment, int numberOfDepartments, int numberOfStamps) { if (storage == null) { throw new NullReferenceException("Storage is null"); } _storage = storage; StartDepartment = startDepartment; EndDepartment = endDepartment; NumberOfDepartments = numberOfDepartments; NumberOfStamps = numberOfStamps; WaitForPreCalculating(); }
/// <summary> /// Adds <see cref="IDataContainer"/> as part of data to transport container /// </summary> /// <param name="dataContainer"></param> /// <returns></returns> public DataPart AddDataPart(IDataContainer dataContainer) { if (dataContainer == null) { throw new ArgumentNullException("dataContainer"); } var dataPart = new DataPart(dataContainer); DataParts.Add(dataPart); return(dataPart); }
public ValueReader CreateValueReader(string value, IScene scene, IDataContainer entity, Event evt = null) { ParseTree tree = parser.Parse(value); // Should always be valid since UI calls HasErrors first var assignable = MakeAssignable(tree.Root, scene, entity, evt); var reader = assignable as ValueReader; if (null == reader) { var typeMatcher = assignable as TypeMatcher; if (null != typeMatcher) { reader = ConstantReader.NullValue; } } return reader; }
public override IDataContainer PreProcess(IDataContainer dataContainer) { var push = false; Parallel.ForEach(StagedData, staged => { if (dataContainer.Any(d => d.Source.Equals(staged.Source))) push = true; }); if (push) Push(); //foreach (var data in dataContainer.OfType<BlobData>()) // Stage(data); Stage(dataContainer.ToArray()); return null; }
public SeriesEntry( IViewModelContainer viewModelContainer, IDataContainer dataContainer, Series model ) : base( viewModelContainer, dataContainer ) { Model = model; var allEpisodes = Model.Episodes.Where( e => e.SeasonNumber != 0 ).ToArray(); Episodes = new ObservableCollection<EpisodeEntry>( allEpisodes.Select( e => new EpisodeEntry( viewModelContainer, dataContainer, e, this ) ) ); Seasons = new ObservableCollection<SeasonEntry>( allEpisodes.Select( e => e.SeasonNumber ).Distinct().Select( n => new SeasonEntry( viewModelContainer, dataContainer, n, this ) ) ); Name = model.Name; Rating = model.Rating; RatingsCount = model.Ratings; if( model.BannerLocation != null ) { BannerUrl = model.BannerLocation; } }
/// <summary> /// /// </summary> /// <param name="dataContainer"></param> /// <returns></returns> public override IDataContainer PreProcess(IDataContainer dataContainer) { var rgbImages = dataContainer.OfType<RgbImageData>().ToArray(); if (rgbImages.Any()) { if (_rgbImageData != null) _rgbImageData.Dispose(); _rgbImageData = rgbImages.First().Copy() as RgbImageData; return null; } if (_rgbImageData != null) { dataContainer.Add(_rgbImageData.Copy()); _rgbImageData.Dispose(); _rgbImageData = null; } return dataContainer; }
public override IDataContainer PreProcess(IDataContainer dataContainer) { const int width = 1280; const int height = 720; var image = new Image<Rgb, byte>(width, height); foreach (var blob in dataContainer.OfType<BlobData>()) { var polyline = new List<Point>(); foreach (var point in blob.Polygon.Points) { var x = point.X * width; var y = point.Y * height; polyline.Add(new Point((int)x, (int)y)); } var color = Rgbs.White; if (typeof(RectangleTracker) == blob.Source.GetType()) color = Rgbs.Red; else if (typeof(RectangleTrackerColor) == blob.Source.GetType()) color = Rgbs.Yellow; var centerX = (int)(blob.Center.X * width); var centerY = (int)(blob.Center.Y * height); image.DrawPolyline(polyline.ToArray(), true, color, 5); image.Draw(string.Format("Id {0}", blob.Id), ref EmguFontBig, new Point(centerX, centerY), Rgbs.White); } Stage(new RgbImageData(this, "BlobRenderer", image.Copy())); Push(); image.Dispose(); return null; }
private ValueReader makeValueReader(ParseTreeNode node, IScene scene, IDataContainer entity, Event evt) { BnfTerm type0; //From is used for assignments where the node is not an expr. It can only be an exactvalue, but not constant ParseTreeNode from; if (node.Term == grammar.Expr) { from = node.ChildNodes[0]; type0 = from.Term; } else { from = node; type0 = node.Term; } if (type0 == grammar.UniOp) { ValueReader value = makeValueReader(node.ChildNodes[1], scene, entity, evt); return uniOpCreate(node.ChildNodes[0].ChildNodes[0].Term, value); } else if (type0 == grammar.Number) { return new ConstantReader(node.ChildNodes[0].Token.Value); } else if (type0 == grammar.ThreeVal) { ParseTreeNodeList list = from.ChildNodes; return makeParameterReader(scene, entity, list[0].Token.ValueString, list[1].Token.ValueString, list[2].Token.ValueString); } else if (type0 == grammar.TwoVal) { ParseTreeNodeList list = from.ChildNodes; if (null == getDataContainer(scene, entity, list[0].Token.ValueString)) return makeParameterReader(scene, entity, "this", list[0].Token.ValueString, list[1].Token.ValueString); return makeDcReader(scene, entity, list[0].Token.ValueString, list[1].Token.ValueString); } else if (type0 == grammar.Identifier) { return makeDcReader(scene, entity, "this", from.Token.ValueString); } else if (type0 == grammar.Constants) { return from.Token.Value as ConstantReader; } else if (type0 == grammar.ParentVal) { switch (from.ChildNodes.Count) { case 2: return TypeMatcherDCReader.GetTypeMatcherDCValueReader(evt, from.ChildNodes[0].Token.ValueString, from.ChildNodes[1].Token.ValueString, entity); case 3: return TypeMatcherProperyReader.GetTypeMatcherProperyReader(evt, from.ChildNodes[0].Token.ValueString, from.ChildNodes[1].Token.ValueString, from.ChildNodes[2].Token.ValueString, entity); } } else if (type0 == grammar.Function) { string name = grammar.GetName(from); IEnumerable<ParseTreeNode> arguments = grammar.GetOfType(from, grammar.Argument); List<ValueReader> argReaders = new List<ValueReader>(); foreach (ParseTreeNode argument in arguments) argReaders.Add(makeValueReader(argument.ChildNodes[0], scene, entity, evt)); return FunctionReader.getFunctionReader(name, argReaders); } else if (node.ChildNodes.Count == 3 && node.ChildNodes[1].Term == grammar.BinOp) { ValueReader left = makeValueReader(node.ChildNodes[0], scene, entity, evt); ValueReader right = makeValueReader(node.ChildNodes[2], scene, entity, evt); KinectitudeGrammar.OpCode opCode = grammar.OpLookup[node.ChildNodes[1].ChildNodes[0].Term]; return binOpCreate(opCode, left, right); } else if (node.ChildNodes.Count == 1 && node.ChildNodes[0].Term == grammar.Expr) { return makeValueReader(node.ChildNodes[0], scene, entity, evt); } return new ConstantReader(from.Token.Value); }
public StatisticsDialogViewModel( IViewModelContainer viewModelContainer, IDataContainer dataContainer ) : base(viewModelContainer, dataContainer) { }
/// <summary> /// Gets iCalendar file content. /// </summary> /// <param name="row">Datarow</param> protected byte[] GetContent(IDataContainer data, int timeZoneId) { if (data != null) { // Get time zone info for shifting event time to specific time zone TimeZoneInfo tzi = null; if (timeZoneId > 0) { tzi = TimeZoneInfoProvider.GetTimeZoneInfo(timeZoneId); } if ((tzi == null) && (TimeZoneHelper.TimeZonesEnabled())) { // Get time zone for current site tzi = TimeZoneHelper.GetSiteTimeZoneInfo(CMSContext.CurrentSite); } // Get event start time DateTime eventStart = ValidationHelper.GetDateTime(data.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED); // Shift current time to GMT DateTime currentDateGMT = DateTime.Now; currentDateGMT = TimeZoneHelper.ConvertTimeZoneDateTimeToGMT(currentDateGMT, tzi); // Get if it is all day event bool isAllDay = ValidationHelper.GetBoolean(data.GetValue("EventAllDay"), false); // Create content StringBuilder content = new StringBuilder(); content.AppendLine("BEGIN:vCalendar"); content.AppendLine("METHOD:PUBLISH"); content.AppendLine("BEGIN:vEvent"); content.Append("DTSTAMP:").Append(currentDateGMT.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z"); content.Append("DTSTART"); if (isAllDay) { content.Append(";VALUE=DATE:").AppendLine(eventStart.ToString("yyyyMMdd")); } else { // Shift event start time to GMT eventStart = TimeZoneHelper.ConvertTimeZoneDateTimeToGMT(eventStart, tzi); content.Append(":").Append(eventStart.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z"); } // Get event end time DateTime eventEnd = ValidationHelper.GetDateTime(data.GetValue("EventEndDate"), DataHelper.DATETIME_NOT_SELECTED); if (eventEnd != DataHelper.DATETIME_NOT_SELECTED) { content.Append("DTEND"); if (isAllDay) { content.Append(";VALUE=DATE:").AppendLine(eventEnd.AddDays(1).ToString("yyyyMMdd")); } else { // Shift event end time to GMT eventEnd = TimeZoneHelper.ConvertTimeZoneDateTimeToGMT(eventEnd, tzi); content.Append(":").Append(eventEnd.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z"); } } // Get location string location = ValidationHelper.GetString(data.GetValue("EventLocation"), string.Empty); // Include location if specified if (!String.IsNullOrEmpty(location)) { content.Append("LOCATION:").AppendLine(HTMLHelper.StripTags(HttpUtility.HtmlDecode(location))); } content.Append("DESCRIPTION:").AppendLine(HTMLHelper.StripTags(HttpUtility.HtmlDecode(ValidationHelper.GetString(data.GetValue("EventDetails"), "")).Replace("\r\n", "").Replace("<br />", "\\n")) + "\\n\\n" + HTMLHelper.StripTags(HttpUtility.HtmlDecode(ValidationHelper.GetString(data.GetValue("EventLocation"), "")).Replace("\r\n", "").Replace("<br />", "\\n"))); content.Append("SUMMARY:").AppendLine(HttpUtility.HtmlDecode(ValidationHelper.GetString(data.GetValue("EventName"), ""))); content.AppendLine("PRIORITY:3"); content.AppendLine("BEGIN:vAlarm"); content.AppendLine("TRIGGER:P0DT0H15M"); content.AppendLine("ACTION:DISPLAY"); content.AppendLine("DESCRIPTION:Reminder"); content.AppendLine("END:vAlarm"); content.AppendLine("END:vEvent"); content.AppendLine("END:vCalendar"); // Return byte array return Encoding.UTF8.GetBytes(content.ToString()); } return null; }
private string innermedia_GetListItemUrl(IDataContainer data, bool isPreview, bool notAttachment) { // Get set of important information string arg = GetArgumentSet(data); // Get URL of the list item image return GetItemUrl(arg, 0, 0, 0, notAttachment); }
/// <summary> /// Returns argument set for the passed file data row. /// </summary> /// <param name="data">Data row object holding all the data on current file</param> public string GetArgumentSet(IDataContainer data) { string className = ValidationHelper.GetString(data.GetValue("ClassName"), String.Empty).ToLowerCSafe(); string name = string.Empty; // Get file name with extension switch (SourceType) { case MediaSourceEnum.DocumentAttachments: name = AttachmentHelper.GetFullFileName(Path.GetFileNameWithoutExtension(data.GetValue("AttachmentName").ToString()), data.GetValue("AttachmentExtension").ToString()); break; case MediaSourceEnum.MetaFile: name = MetaFileInfoProvider.GetFullFileName(Path.GetFileNameWithoutExtension(data.GetValue("MetaFileName").ToString()), data.GetValue("MetaFileExtension").ToString()); break; default: name = data.GetValue("DocumentName").ToString(); break; } StringBuilder sb = new StringBuilder(); // Common information for both content & attachments sb.Append("name|" + CMSDialogHelper.EscapeArgument(name)); // Load attachment info only for CMS.File document type if (((SourceType != MediaSourceEnum.Content) && (SourceType != MediaSourceEnum.MetaFile)) || (className == "cms.file")) { sb.Append("|AttachmentExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentExtension"))); sb.Append("|AttachmentImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentImageWidth"))); sb.Append("|AttachmentImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentImageHeight"))); sb.Append("|AttachmentSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentSize"))); sb.Append("|AttachmentGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentGUID"))); } else if (SourceType == MediaSourceEnum.MetaFile) { sb.Append("|MetaFileExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileExtension"))); sb.Append("|MetaFileImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileImageWidth"))); sb.Append("|MetaFileImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileImageHeight"))); sb.Append("|MetaFileSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileSize"))); sb.Append("|MetaFileGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileGUID"))); sb.Append("|SiteID|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileSiteID"))); } else { sb.Append("|AttachmentExtension||AttachmentImageWidth||AttachmentImageHeight||AttachmentSize||AttachmentGUID|"); } // Get source type specific information if (SourceType == MediaSourceEnum.Content) { sb.Append("|NodeSiteID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeSiteID"))); sb.Append("|SiteName|" + CMSDialogHelper.EscapeArgument(data.GetValue("SiteName"))); sb.Append("|NodeGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeGUID"))); sb.Append("|NodeID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeID"))); sb.Append("|NodeAlias|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeAlias"))); sb.Append("|NodeAliasPath|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeAliasPath"))); sb.Append("|DocumentUrlPath|" + CMSDialogHelper.EscapeArgument(data.GetValue("DocumentUrlPath"))); sb.Append("|DocumentExtensions|" + CMSDialogHelper.EscapeArgument(data.GetValue("DocumentExtensions"))); sb.Append("|ClassName|" + CMSDialogHelper.EscapeArgument(data.GetValue("ClassName"))); sb.Append("|NodeLinkedNodeID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeLinkedNodeID"))); } else if (SourceType != MediaSourceEnum.MetaFile) { string formGuid = data.ContainsColumn("AttachmentFormGUID") ? data.GetValue("AttachmentFormGUID").ToString() : Guid.Empty.ToString(); string siteId = data.ContainsColumn("AttachmentSiteID") ? data.GetValue("AttachmentSiteID").ToString() : "0"; sb.Append("|SiteID|" + CMSDialogHelper.EscapeArgument(siteId)); sb.Append("|FormGUID|" + CMSDialogHelper.EscapeArgument(formGuid)); sb.Append("|AttachmentDocumentID|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentDocumentID"))); } return sb.ToString(); }
private ValueReader makeParameterReader(IScene scene, IDataContainer entity, string name, string component, string param) { IDataContainer who = getDataContainer(scene, entity, name); IChangeable obj = who.GetChangeable(component); return ParameterValueReader.GetParameterValueReader(obj, param, who); }
private ValueReader makeDcReader(IScene scene, IDataContainer entity, string name, string param) { IDataContainer dataContainer = getDataContainer(scene, entity, name); return DataContainerReader.GetDataContainerReader(dataContainer, param); }
/// <summary> /// Returns correct ID for the given item (for colorizing the item when selected). /// </summary> /// <param name="data">Item to get the ID of</param> protected string GetColorizeID(IDataContainer data) { string id = data.ContainsColumn(FileIdColumn) ? data.GetValue(FileIdColumn).ToString() : EnsureFileName(data.GetValue("FileName").ToString()); if (String.IsNullOrEmpty(id)) { // Content file id = data.GetValue("NodeGUID").ToString(); } return id.ToLowerCSafe(); }
/// <summary> /// Returns argument set according passed DataRow and flag indicating whether the set is obtained for selected item. /// </summary> /// <param name="data">DataRow with all the item data</param> /// <param name="isSelected">Indicates whether the set is required for an selected item</param> private string innermedia_GetArgumentSet(IDataContainer data) { // Return required argument set return GetArgumentSet(data); }
public object MakeAssignable(ParseTreeNode node, IScene scene, IDataContainer entity, Event evt) { if (node == null) return ConstantReader.TrueValue; if (node.Term == grammar.TypeMatcher) return makeTypeMatcher(node, scene); return makeValueReader(node, scene, entity, evt); }
private string innermedia_GetTilesThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { string url = string.Empty; string ext = (SourceType != MediaSourceEnum.MetaFile) ? data.GetValue("AttachmentExtension").ToString() : data.GetValue("MetaFileExtension").ToString(); string arg = GetArgumentSet(data); // If image is requested for preview if (isPreview) { if (!ImageHelper.IsImage(ext) || notAttachment) { string className = (SourceType == MediaSourceEnum.Content) ? data.GetValue("ClassName").ToString().ToLowerCSafe() : ""; if (className == "cms.file") { // File isn't image and no preview exists - get default file icon url = GetFileIconUrl(ext, string.Empty); } else if (((SourceType == MediaSourceEnum.DocumentAttachments) || (SourceType == MediaSourceEnum.Attachment) || (SourceType == MediaSourceEnum.MetaFile)) && !String.IsNullOrEmpty(ext)) { // Get file icon for attachment url = GetFileIconUrl(ext, string.Empty); } else { url = GetDocumentTypeIconUrl(className, "48x48"); } } else { // Try to get preview or image itself url = GetItemUrl(arg, height, width, maxSideSize, notAttachment); } } else { url = GetItemUrl(arg, 0, 0, 0, notAttachment); } return url; }
private IDataContainer getDataContainer(IScene scene, IDataContainer entity, string name) { //TODO ask group about making the name of scene and game the keyword instead of game and scene. Also allow this in game/scene? /*TODO if I have an entity created later, and it's in an action/evt/component should I be able to reference it? * Makes it difficult if I can't, but idk how to program this better if I can*/ switch (name) { case "this": return entity; case "scene": return scene; case "game": return scene.Game; default: return scene.GetEntity(name); } }
public override IDataContainer PreProcess(IDataContainer dataContainer) { if (_lastFrame == null) return base.PreProcess(dataContainer); var devices = dataContainer.OfType<Device>().ToArray(); var unknownDevices = devices.Where(d => !d.IsIdentified).ToArray(); if (!devices.Any() || !unknownDevices.Any()) { return base.PreProcess(dataContainer); } var outputImage = _lastFrame.Copy(); var binaryThreshold = BinaryThreshold; if (unknownDevices.Any()) //if (devices.Any()) { var grayImage = _lastFrame.Copy().Convert<Gray, byte>(); grayImage = grayImage.ThresholdBinary(new Gray(binaryThreshold), new Gray(255)); var width = _lastFrame.Width; var height = _lastFrame.Height; foreach (var device in unknownDevices) //foreach (var device in devices) { var area = device.Area; var roiExpandFactor = RoiExpandFactor; var indentX = width * roiExpandFactor; var indentY = height * roiExpandFactor; var offsetX = (int)(area.X * width); var offsetY = (int)(area.Y * height); var roiX = (int)Math.Max(0, offsetX - indentX); var roiY = (int)Math.Max(0, offsetY - indentY); var roiWidth = (int)Math.Min(width - roiX, area.Width * width + 2 * indentX); var roiHeight = (int)Math.Min(height - roiY, area.Height * height + 2 * indentY); var roi = new Rectangle( roiX, roiY, roiWidth, roiHeight ); if (IsRenderContent) { outputImage.Draw(roi, Rgbs.Red, 2); } var imageWithROI = _lastFrame.Copy(roi); //FindMarker(imageWithROI, offsetX, offsetY, width, height, ref outputImage); grayImage.ROI = roi; Contour<Point> largestContour = null; using (var storage = new MemStorage()) { for (var contours = grayImage.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_EXTERNAL); contours != null; contours = contours.HNext) { var contour = contours.ApproxPoly(contours.Perimeter * 0.05, storage); var roiArea = roi.Size.Width * roi.Size.Height; var contourArea = contour.Area; if (contour.Total != 4) continue; if (contourArea < roiArea * 0.98 && contourArea > 10) { if (largestContour == null) { largestContour = contour; continue; } if (contour.Area > largestContour.Area) { largestContour = contour; } } } if (largestContour != null) { var edges = DetermineLongestEdge(largestContour); if (IsRenderContent) { var oldROI = outputImage.ROI; outputImage.ROI = roi; outputImage.Draw(largestContour.GetMinAreaRect(storage), Rgbs.Cyan, 2); outputImage.Draw(edges[0], Rgbs.Red, 3); outputImage.Draw(edges[1], Rgbs.Green, 3); outputImage.ROI = oldROI; } } } } outputImage.ROI = new Rectangle(0, 0, width, height); grayImage.ROI = new Rectangle(0, 0, width, height); var binaryThresholdImageCopy = grayImage.Copy(); Task.Factory.StartNew(() => { var bitmap = binaryThresholdImageCopy.ToBitmapSource(true); binaryThresholdImageCopy.Dispose(); return bitmap; }).ContinueWith(s => BinaryThresholdImageSource = s.Result); grayImage.Dispose(); } if (IsRenderContent) { // Render known devices with green rectangle foreach (var device in devices.Where(d => d.IsIdentified)) { var area = device.Area; var width = _lastFrame.Width; var height = _lastFrame.Height; var offsetX = (int)(area.X * width); var offsetY = (int)(area.Y * height); var roi = new Rectangle( offsetX, offsetY, (int)(area.Width * width), (int)(area.Height * height) ); outputImage.Draw(roi, Rgbs.Green, 4); } var outputImageCopy = outputImage.Copy(); Task.Factory.StartNew(() => { var bitmap = outputImageCopy.ToBitmapSource(true); outputImageCopy.Dispose(); return bitmap; }).ContinueWith(s => OutputImage = s.Result); outputImage.Dispose(); } // Push staged data Push(); return base.PreProcess(dataContainer); }
/// <summary> /// Writes the data container to the output. /// </summary> /// <param name="dc">Container to write</param> protected void WriteDataContainer(IDataContainer dc) { StringBuilder sb = new StringBuilder(); sb.Append("<table class=\"table table-hover\" style=\"margin-top: 16px;\">"); // Add header sb.AppendFormat("<thead><tr class=\"unigrid-head\"><th>{0}</th><th class=\"main-column-100\">{1}</th></tr></thead><tbody>", GetString("General.FieldName"), GetString("General.Value")); // Add values foreach (string column in dc.ColumnNames) { try { object value = dc.GetValue(column); // Binary columns string content = null; if (value is byte[]) { byte[] data = (byte[])value; content = "<" + GetString("General.BinaryData") + ", " + DataHelper.GetSizeString(data.Length) + ">"; } else { content = ValidationHelper.GetString(value, String.Empty); } if (!String.IsNullOrEmpty(content)) { sb.AppendFormat("<tr><td><strong>{0}</strong></td><td class=\"wrap-normal\">", column); // Possible DataTime columns if (value is DateTime) { DateTime dateTime = Convert.ToDateTime(content); CultureInfo cultureInfo = CultureHelper.GetCultureInfo(MembershipContext.AuthenticatedUser.PreferredUICultureCode); content = dateTime.ToString(cultureInfo); } // Process content ProcessContent(sb, dc, column, ref content); sb.Append("</td></tr>"); } } catch { } } sb.Append("</tbody></table><br />\n"); pnlContent.Controls.Add(new LiteralControl(sb.ToString())); }