public async void Run( IBackgroundTaskInstance taskInstance ) { Deferral = taskInstance.GetDeferral(); XParameter[] Params = SavedChannels.Parameters( "channel" ); if ( Params.Length == 0 ) { Deferral.Complete(); return; } // Associate a cancellation handler with the background task. taskInstance.Canceled += new BackgroundTaskCanceledEventHandler( OnCanceled ); foreach ( XParameter Param in Params ) { CurrentTask = new XParameter( DateTime.Now.ToFileTime() + "" ); CurrentTask.SetValue( new XKey[] { new XKey( "name", taskInstance.Task.Name ) , new XKey( "start", true ) , new XKey( "end", false ) } ); PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); if ( channel.Uri != Param.GetValue( "uri" ) ) { await RenewChannel( Param.GetValue( "provider" ), Param.Id, Uri.EscapeDataString( channel.Uri ) ); } } Deferral.Complete(); }
public static XParameter[] GetParameters( this XElement Root ) { int l; IEnumerable<XElement> p = Root.Elements( XRegistry.WTAG ); if ( 0 < ( l = p.Count() ) ) { XParameter[] w = new XParameter[ l ]; for ( int i = 0; i < l; i++ ) { w[ i ] = new XParameter( p.ElementAt( i ) ); } return w; } return new XParameter[ 0 ]; }
public static void SetParameter( this XElement Root, string WIdentifier, XKey[] keys, XParameter[] Params = null ) { XElement tag = Root.FindParameter( WIdentifier ); if ( tag != null ) { foreach ( XKey k in keys ) tag.SetKey( k ); if ( Params != null ) foreach ( XParameter P in Params ) tag.SetParameter( P ); } else { Root.Add( new XElement( XRegistry.WTAG , new XAttribute[] { new XAttribute( XRegistry.XID, WIdentifier ) } .Concat( keys ), Params ) ); } }
public static XParameter[] Parameters( this XElement Root, string key, string value = null ) { IEnumerable<XElement> xe = Root.Elements( XRegistry.WTAG ) .Where( p => p.Attribute( key ) != null ); if ( value != null ) xe = xe.Where( p => p.Attribute( key ).Value == value ); if ( xe == null ) return new XParameter[ 0 ]; xe = xe.ToArray(); int l; XParameter[] ps = new XParameter[ l = xe.Count() ]; for ( int i = 0; i < l; i++ ) { ps[ i ] = new XParameter( xe.ElementAt( i ) ); } return ps; }
public override XParameter ToXParam() { XParameter Param = base.ToXParam(); Param.SetValue( new XKey[] { new XKey( "EntryPoint", EntryPoint ) , new XKey( "Incoming", Incoming ) , new XKey( "FirstStopSkip", FirstStopSkip ) , new XKey( "DiscardUnmatched", DiscardUnmatched ) } ); int i = 0; XParameter NextParams = new XParameter( "NextIfs" ); foreach( ProcFind.RegItem R in NextIfs ) { XParameter RegParam = R.ToXParam(); RegParam.Id += i; RegParam.SetValue( new XKey( "i", i++ ) ); NextParams.SetParameter( RegParam ); } XParameter StopParams = new XParameter( "StopIfs" ); foreach( ProcFind.RegItem R in StopIfs ) { XParameter RegParam = R.ToXParam(); RegParam.Id += i; RegParam.SetValue( new XKey( "i", i++ ) ); StopParams.SetParameter( RegParam ); } Param.SetParameter( NextParams ); Param.SetParameter( StopParams ); return Param; }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); EntryPoint = Param.GetValue( "EntryPoint" ); Incoming = Param.GetBool( "Incoming" ); FirstStopSkip = Param.GetBool( "FirstStopSkip" ); DiscardUnmatched = Param.GetBool( "DiscardUnmatched" ); XParameter NextParams = Param.Parameter( "NextIfs" ); XParameter[] RegParams = NextParams.Parameters( "i" ); foreach ( XParameter RegParam in RegParams ) { NextIfs.Add( new ProcFind.RegItem( RegParam ) ); } XParameter StopParams = Param.Parameter( "StopIfs" ); RegParams = StopParams.Parameters( "i" ); foreach ( XParameter RegParam in RegParams ) { StopIfs.Add( new ProcFind.RegItem( RegParam ) ); } }
private async void AddServer() { string SrvUri = ServiceUri.Text.Trim(); if ( string.IsNullOrEmpty( SrvUri ) ) return; try { new Uri( SrvUri ); } catch( Exception ) { await Popups.ShowDialog( new MessageDialog( "Invalid Uri" ) ); return; } XParameter Param = new XParameter( SrvUri ); Param.SetValue( new XKey( "uri", 1 ) ); ServerReg.SetParameter( Param ); ServerReg.Save(); ServiceUri.Text = ""; RefreshServers(); }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); XParameter[] RegParams = Param.Parameters( "i" ); CodePage = Param.GetSaveInt( "CodePage" ); DecodeHtml = Param.GetBool( "DecodeHtml" ); }
public XParameter ToXParam() { XParameter Def = new XParameter( "P" ); Def.SetValue( new XKey[] { new XKey( "label", _Label ) , new XKey( "default", _Default ) } ); return Def; }
virtual public XParameter ToXParam() { XParameter Param = new XParameter( "RegItem" ); Param.SetValue( new XKey[] { // Pattern will be the key identifier new XKey( "Pattern", Pattern ) , new XKey( "Format", Format ) , new XKey( "Enabled", Enabled ) } ); return Param; }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); Incoming = Param.GetBool( "Incoming" ); Caption = Param.GetValue( "Caption" ); TemplateStr = Param.GetValue( "TemplateStr" ); SetMode( Param.GetValue( "Mode" ) ); SetParamDefs( Param ); }
virtual public XParameter ToXParam() { XParameter Param = new XParameter( RawName ); if( Name != TypeName ) { Param.SetValue( new XKey( "Name", Name ) ); } return Param; }
virtual public void ReadParam( XParameter Param ) { string PName = Param.GetValue( "Name" ); if ( PName != null ) Name = PName; }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); VolTitle = Param.GetValue( "VolTitle" ); VolPattern = Param.GetValue( "VolPattern" ); VolParam = Param.GetValue( "VolParam" ); EpTitle = Param.GetValue( "EpTitle" ); EpPattern = Param.GetValue( "EpPattern" ); EpParam = Param.GetValue( "EpParam" ); VolProcs = new ProcManager( Param.Parameter( "VolProcs" ) ); EpProcs = new ProcManager( Param.Parameter( "EpProcs" ) ); }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); ItemPattern = Param.GetValue( "ItemPattern" ); ItemParam = Param.GetValue( "ItemParam" ); BannerPath = Param.GetValue( "Banner" ); ItemProcs = new ProcManager( Param.Parameter( "ItemProcs" ) ); BookSpider = new ProcManager( Param.Parameter( "BookSpider" ) ); }
public void ImportSpider( XParameter SpiderDef ) { ProcManager PM = new ProcManager( SpiderDef ); BookSpider = PM; NotifyChanged( "HasBookSpider" ); }
private void Request_OnRequestComplete( ServiceInfo Info, PushNotificationChannel Channel, DRequestCompletedEventArgs DArgs ) { try { string Res = DArgs.ResponseString; Match m = new Regex( "^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$" ).Match( Res ); if ( m.Success ) { XParameter Param = new XParameter( Res ); Param.SetValue( new XKey[] { new XKey( "provider", Info.Name ) , new XKey( "channel", 1 ) , new XKey( "uri", Channel.Uri ) } ); SavedChannels.SetParameter( Param ); SavedChannels.Save(); NotifyChanged( "Channels" ); return; } } catch ( Exception ) { } Channel.Close(); }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); TargetUrl = Param.GetValue( "TargetUrl" ); Incoming = Param.GetBool( "Incoming" ); XParameter[] ExtParams = Param.Parameters( "i" ); foreach ( XParameter ExtParam in ExtParams ) { PropDefs.Add( new PropExt( ExtParam ) ); } }
public PropExt( XParameter Param ) : base( Param ) { string SType = Param.GetValue( "Type" ); this.SubProc = new ProcManager(); XParameter Sub = Param.Parameter( "SubProc" ); if ( Sub != null ) SubProc.ReadParam( Sub ); PType = Enum.GetValues( BINF ) .Cast<BookInfo>() .FirstOrDefault( x => Enum.GetName( BINF, x ) == SType ); }
private void SetParamDefs( XParameter Param ) { XParameter[] Params = Param.Parameters( "i" ); foreach ( XParameter P in Params ) { AddDef( new ParamDef( P.GetValue( "label" ), P.GetValue( "default" ) ) { Indexer = this.Indexer } ); } }
public static void StoreParams( ProcConvoy Convoy, XRegistry Settings ) { ProcParameter Defs = ( ProcParameter ) ProcManager.TracePackage( Convoy, ( P, C ) => P is ProcParameter )?.Dispatcher; if ( Defs == null ) return; XParameter PDefs = new XParameter( "PPValues" ); Defs.AssignParamDefs( PDefs ); Settings.SetParameter( PDefs ); }
public void SetService( string Name, string Proto, string Auth ) { XParameter Param = new XParameter( Name ); Param.SetXValue( new XKey[] { new XKey( "proto", Proto ) , new XKey( "auth", Auth ) } ); Settings.SetParameter( Param ); Settings.Save(); }
private void AssignParamDefs( XParameter Param ) { int i = 0; foreach ( ParamDef P in ParamDefs ) { XParameter Def = P.ToXParam(); Def.Id += i; Def.SetValue( new XKey( "i", i++ ) ); Param.SetParameter( Def ); } }
public ProcManager( XParameter Param ) :this() { if ( Param == null ) return; ReadParam( Param ); }
public async void SetBackground( string type ) { XParameter SecParam = LayoutSettings.Parameter( Section ); if ( SecParam == null ) SecParam = new XParameter( Section ); string value = null; switch ( type ) { case "Custom": IStorageFolder Location = await PickDirFromPicLibrary(); if ( Location == null ) return; value = SecParam.GetValue( "value" ); if ( value == null ) value = Guid.NewGuid().ToString(); AppStorage.FutureAccessList.AddOrReplace( value, Location ); break; // Preset value fall offs to system as default value case "Preset": case "System": switch ( Section ) { case "TOC": value = "ms-appx:///Assets/Samples/BgTOC.jpg"; break; case "INFO_VIEW": value = "ms-appx:///Assets/Samples/BgInfoView.jpg"; break; case "COMMENTS": value = "ms-appx:///Assets/Samples/BgComments.jpg"; break; case "CONTENT_READER": value = "ms-appx:///Assets/Samples/BgContentReader.jpg"; break; } break; } SecParam.SetValue( new XKey[] { new XKey( "type", type ) , new XKey( "value", value ) } ); LayoutSettings.SetParameter( SecParam ); ApplyBackgrounds(); LayoutSettings.Save(); }
public void ReadParam( XParameter List ) { XParameter[] ProcParams = List.Parameters( "ProcType" ); Async = List.GetBool( "Async", false ); GUID = List.GetValue( "Guid" ); Type PType = typeof( ProcType ); IEnumerable<ProcType> P = Enum.GetValues( PType ).Cast<ProcType>(); foreach( XParameter Param in ProcParams ) { string ProcName = Param.GetValue( "ProcType" ); ProcType Proc = P.First( x => Enum.GetName( PType, x ) == ProcName ); Procedure NProc = NewProcedure( Proc ); NProc.ReadParam( Param ); } }
public void SetParameter( XParameter Param ) { Root.SetParameter( Param ); }
public XParameter ToXParam( string ProcId = null ) { XParameter Param = new XParameter( "Procedures" ); Param.SetValue( new XKey[] { new XKey( "Async", Async ) , new XKey( "Guid", ProcId == null ? GUID : ProcId ) } ); int i = 0; foreach ( Procedure P in ProcList ) { XParameter ProcParam = P.ToXParam(); ProcParam.Id = "Proc" + ( i++ ); ProcParam.SetValue( new XKey( "ProcType", P.RawName ) ); Param.SetParameter( ProcParam ); } return Param; }
private void RemoveServer( object sender, RoutedEventArgs e ) { Button B = sender as Button; if ( B == null ) return; ServerChoice C = B.DataContext as ServerChoice; XParameter Param = new XParameter( C.Name ); Param.SetValue( new XKey( "disabled", true ) ); ServerReg.SetParameter( Param ); ServerReg.Save(); RefreshServers(); }
public override void ReadParam( XParameter Param ) { base.ReadParam( Param ); Incoming = Param.GetBool( "Incoming" ); Prefix = Param.GetValue( "Prefix" ); XParameter[] Params = Param.Parameters( "url" ); foreach( XParameter P in Params ) { Urls.Add( P.GetValue( "url" ) ); } }