Beispiel #1
1
        private void SetTemplate()
        {
            StringResources stx = new StringResources( "/libtaotu/Message" );
            PrimaryButtonText = stx.Str( "OK" );

            MessageBus.OnDelivery += MessageBus_OnDelivery;
        }
        private void SetTemplate()
        {
            StringResources stx = new StringResources( "/libtaotu/Message" );
            PrimaryButtonText = stx.Str( "OK" );

            int[] KnownCodePages = new int[] {
                37, 437, 500, 708, 720, 737, 775, 850, 852, 855, 857, 858, 860, 861, 862, 863, 864
                , 865, 866, 869, 870, 874, 875, 932, 936, 949, 950, 1026, 1047, 1140, 1141, 1142, 1143
                , 1144, 1145, 1146, 1147, 1148, 1149, 1200, 1201, 1250, 1251, 1252, 1253, 1254, 1255
                , 1256, 1257, 1258, 1361, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008
                , 10010, 10017, 10021, 10029, 10079, 10081, 10082, 12000, 12001, 20000, 20001, 20002
                , 20003, 20004, 20005, 20105, 20106, 20107, 20108, 20127, 20261, 20269, 20273, 20277
                , 20278, 20280, 20284, 20285, 20290, 20297, 20420, 20423, 20424, 20833, 20838, 20866
                , 20871, 20880, 20905, 20924, 20932, 20936, 20949, 21025, 21866, 28591, 28592, 28593
                , 28594, 28595, 28596, 28597, 28598, 28599, 28603, 28605, 29001, 38598, 50220, 50221
                , 50222, 50225, 50227, 51932, 51936, 51949, 52936, 54936, 57002, 57003, 57004, 57005
                , 57006, 57007, 57008, 57009, 57010, 57011, 65000, 65001 };

            Encoding.RegisterProvider( CodePagesEncodingProvider.Instance );

            foreach ( int CodePage in KnownCodePages )
            {
                try
                {
                    Encoding Enc = Encoding.GetEncoding( CodePage );
                    SupportedCodePages.Add( Enc.EncodingName, Enc.CodePage );
                }
                catch ( Exception ) { }
            }

            Encodings.ItemsSource = SupportedCodePages;
        }
Beispiel #3
0
 private static void initIfNeeded()
 {
     if (_instance == null)
     {
         _instance = new StringResources();
     }
 }
Beispiel #4
0
        private void MemberStatusChanged()
        {
            StringResources stx = new StringResources();
            LoginOrInfo = Member.IsLoggedIn
                ? stx.Text( "Login_AccountName" )
                : stx.Text( "Login" )
                ;

            RefreshAvatar();

            if( !Member.IsLoggedIn )
            {
                if ( Member.WillLogin ) return;

                Image.Destroy( Avatar );
                NotifyChanged( "Avatar" );
                return;
            }

            X.Instance<IRuntimeCache>( XProto.WRuntimeCache, 0, false )
                .InitDownload(
                "USER_AVATAR"
                , X.Call<XKey[]>( XProto.WRequest, "GetUserAvatar" )
                , AvatarLoaded
                , ( string id, string url, Exception ex ) => { RefreshAvatar(); }
                , false
            );
        }
 public static string LoadStringResource(StringResources path, string name)
 {
     string resourcePath = "";
     switch (path)
     {
         case StringResources.RESOURCES:
             resourcePath = "Resources";
             break;
         case StringResources.ERRORS:
             resourcePath = "Errors";
             break;
         default:
             new Exception("Can't find any resource");
             break;
     }
     return ResourceLoader.GetForCurrentView(resourcePath).GetString(name);
 }
Beispiel #6
0
        public void LoadUrl( LocalModeTxtList.DownloadBookContext Context )
        {
            RuntimeCache rCache = new RuntimeCache();
            Logger.Log( ID, Context.Id, LogType.DEBUG );
            Logger.Log( ID, Context.Title, LogType.DEBUG );

            Worker.UIInvoke( () =>
            {
                StringResources stx = new StringResources( "AdvDM" );
                Loading = stx.Text( "Active" );
            } );

            rCache.GET( Context.Url, ( e, url ) =>
            {
                Loading = null;
                SaveTemp( e, Context );
            }
            , ( id, url, ex ) =>
            {
                Logger.Log( ID, "Cannot download: " + id, LogType.WARNING );
                Logger.Log( ID, ex.Message, LogType.WARNING );

            }, false );
        }
Beispiel #7
0
        public while_node NewWhileStmt(token_info tkWhile, expression expr, token_info opt_tk_do, statement stmt, LexLocation loc)
        {
            var nws = new while_node(expr, stmt, WhileCycleType.While, loc);

            if (opt_tk_do == null)
            {
                file_position    fp      = expr.source_context.end_position;
                syntax_tree_node err_stn = stmt;
                if (err_stn == null)
                {
                    err_stn = expr;
                }
                parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKDO"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn));
            }
            return(nws);
        }
Beispiel #8
0
 //load resource corresponding to current culture
 public static void Reload()
 {
     _strings = new StringResources("Granados.strings", typeof(Strings).Assembly);
 }
Beispiel #9
0
        private async void ProcessVols()
        {
            StringResources stx = new StringResources( "LoadingMessage" );
            string LoadText = stx.Str( "ProgressIndicator_Message" );

            IEnumerable<string> BookIds = Shared.Storage.ListDirs( FileLinks.ROOT_LOCAL_VOL );
            string[] favs = new BookStorage().GetIdList();

            List<LocalBook> Items = new List<LocalBook>();
            foreach ( string Id in BookIds )
            {
                Loading = LoadText + ": " + Id;
                LocalBook LB = await LocalBook.CreateAsync( Id );
                if ( LB.ProcessSuccess )
                {
                    Items.Add( LB );
                    LB.IsFav = favs.Contains( Id );
                }
            }

            Action<string, SpiderBook> ProcessSpider = ( Id, LB ) =>
             {
                 Loading = LoadText + ": " + Id;
                 if ( LB.aid != Id )
                 {
                     try
                     {
                         Logger.Log( ID, "Fixing misplaced spider book" );
                         Shared.Storage.MoveDir( FileLinks.ROOT_SPIDER_VOL + Id, LB.MetaLocation );
                     }
                     catch ( Exception ex )
                     {
                         Logger.Log( ID
                             , string.Format(
                                 "Unable to move script: {0} => {1}, {2} "
                                 , Id, LB.aid, ex.Message )
                                 , LogType.WARNING );
                     }
                 }

                 if ( LB.ProcessSuccess || LB.CanProcess )
                 {
                     Items.Add( LB );
                     LB.IsFav = favs.Contains( Id );
                 }
                 else
                 {
                     try
                     {
                         Logger.Log( ID, "Removing invalid script: " + Id, LogType.INFO );
                         Shared.Storage.RemoveDir( LB.MetaRoot );
                     }
                     catch ( Exception ex )
                     {
                         Logger.Log( ID, "Cannot remove invalid script: " + ex.Message, LogType.WARNING );
                     }
                 }
             };

            BookIds = Shared.Storage.ListDirs( FileLinks.ROOT_SPIDER_VOL );
            foreach ( string Id in BookIds )
            {
                if ( Id[ 0 ] == ZONE_PFX )
                {
                    IEnumerable<string> ZoneItems = Shared.Storage.ListDirs( FileLinks.ROOT_SPIDER_VOL + Id + "/" );
                    foreach ( string SId in ZoneItems )
                    {
                        /**
                         * This code is a mess. I'll explain a bit more in here
                         *   First, the location of the Book.MetaLocation for ZoneItems
                         *   can only be retrived from BookInstruction
                         *   However ZoneId and Id are assinged by Spider on the fly,
                         *   restoring this information is a bit tricky
                         */

                        // Create BookIntstruction just to retrieve the correct id pattern
                        BookInstruction BInst = new BookInstruction( Id, SId );

                        /**
                         * After 2 hours of investigations...
                         * Welp, just outsmarted by myself, The CreateAsyncSpide works because:
                         *   Inside the TestProcessed method, the BookInstruction are created
                         *   using BoockInstruction( Id, Setings ) overload
                         *   the provided id is "this.aid" here BUT the full id is restored again
                         *   in InitProcMan() method
                         *   Fortunately, ssid will be set correctly inside the ReadInfo method
                         */
                        ProcessSpider( BInst.Id, await SpiderBook.CreateAsyncSpider( BInst.Id ) );
                    }
                }
                else
                {
                    ProcessSpider( Id, await SpiderBook.CreateAsyncSpider( Id ) );
                }
            }

            if ( 0 < Items.Count ) SearchSet = Items;
            Loading = null;
        }
Beispiel #10
0
 private void UpdateLLText()
 {
     StringResources stx = new StringResources( "AppResources", "Settings" );
     LLText = LoggedIn ? stx.Text( "Account_Logout", "Settings" ) : stx.Text( "Login" );
     NotifyChanged( "LLText", "LoggedIn" );
 }
Beispiel #11
0
        private void RequestsStatus( DRequestCompletedEventArgs e, string QId )
        {
            try
            {
                int NGrants = 0;
                int NScripts = 0;
                JsonObject JMesg = JsonStatus.Parse( e.ResponseString );
                JsonArray JData = JMesg.GetNamedArray( "data" );

                if ( 0 < Grants.Count() )
                {
                    List<SHGrant> CurrGrants = new List<SHGrant>( Grants );
                    foreach( JsonValue JValue in JData )
                    {
                        SHGrant G = new SHGrant( JValue.GetObject() );
                        if ( Grants.Any( x => x.Id == G.Id ) ) continue;
                        CurrGrants.Add( G );
                    }
                    Grants = CurrGrants.ToArray();
                }
                else
                {
                    Grants = JData.Remap( x =>
                    {
                        SHGrant G = new SHGrant( x.GetObject() );

                        int l = G.Grants.Length;
                        if ( !G.SourceRemoved )
                        {
                            if ( 0 < l ) NScripts++;
                            NGrants += l;
                        }

                        return G;
                    } );
                }

                if ( 0 < NGrants )
                {
                    AddActivity( () =>
                    {
                        StringResources stx = new StringResources();
                        return string.Format( stx.Text( "GrantsReceived" ), NGrants, NScripts );
                    }, () => MessageBus.SendUI( typeof( SharersHub ), AppKeys.SH_SHOW_GRANTS ) );
                }
            }
            catch ( Exception ex )
            {
                Logger.Log( ID, ex.Message, LogType.WARNING );
            }
        }
Beispiel #12
0
        public program_module NewProgramModule(program_name progName, Object optHeadCompDirs, uses_list mainUsesClose, syntax_tree_node progBlock, Object optPoint, LexLocation loc)
        {
            var progModule = new program_module(progName, mainUsesClose, progBlock as block, null, loc);

            progModule.Language = LanguageId.PascalABCNET;
            if (optPoint == null && progBlock != null)
            {
                var fp      = progBlock.source_context.end_position;
                var err_stn = progBlock;
                if ((progBlock is block) && (progBlock as block).program_code != null && (progBlock as block).program_code.subnodes != null && (progBlock as block).program_code.subnodes.Count > 0)
                {
                    err_stn = (progBlock as block).program_code.subnodes[(progBlock as block).program_code.subnodes.Count - 1];
                }
                parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKPOINT"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn));
            }
            return(progModule);
        }
Beispiel #13
0
 public static void ReloadStringResource()
 {
     _stringResource = new StringResources("Poderosa.Terminal.strings", typeof(GEnv).Assembly);
     EnumDescAttribute.AddResourceTable(typeof(GEnv).Assembly, _stringResource);
 }
Beispiel #14
0
        public for_node NewForStmt(bool opt_var, ident identifier, type_definition for_stmt_decl_or_assign, expression expr1, for_cycle_type fc_type, expression expr2, token_info opt_tk_do, statement stmt, LexLocation loc)
        {
            var nfs = new for_node(identifier, expr1, expr2, stmt, fc_type, null, for_stmt_decl_or_assign, opt_var != false, loc);

            if (opt_tk_do == null)
            {
                file_position    fp      = expr2.source_context.end_position;
                syntax_tree_node err_stn = stmt;
                if (err_stn == null)
                {
                    err_stn = expr2;
                }
                parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKDO"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn));
            }
            if (!opt_var && for_stmt_decl_or_assign == null)
            {
                parsertools.AddWarningFromResource("USING_UNLOCAL_FOR_VARIABLE", identifier.source_context);
            }
            return(nfs);
        }
Beispiel #15
0
 private void ShowBlockedTrafficModal()
 {
     _dialogs.ShowWarning(StringResources.Get("Dialogs_P2PBlocked_msg_Blocked"));
 }
Beispiel #16
0
 public ScraperHateoasExceptionFilterAttribute(StringResources stringResources)
 {
     this.stringResources = stringResources ?? throw new ArgumentNullException(nameof(stringResources));
 }
 private static ScopedLifestyle ThrowDefaultScopeLifestyleIsNotSet()
 {
     throw new InvalidOperationException(
               StringResources.ScopePropertyCanOnlyBeUsedWhenDefaultScopedLifestyleIsConfigured());
 }
Beispiel #18
0
 public CyclicDependencyException(Type typeToValidate)
     : base(StringResources.TypeDependsOnItself(typeToValidate))
 {
     this.types.Add(typeToValidate);
 }
Beispiel #19
0
 public static string GetName(string code)
 {
     return(code != null
         ? StringResources.Get($"Country_val_{code.ToUpper()}")
         : "");
 }