Ejemplo n.º 1
0
        public void Test()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(ResourceRepository)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("WorkingWithFiles.LibTextResource.txt");
            string text     = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                text = reader.ReadToEnd();
            }
        }
Ejemplo n.º 2
0
        //检查 TSugarClient 构造函数是否有带参数的构造函数
        private static void CheckContextConstructors <TSugarClient>()
            where TSugarClient : SqlSugarClient
        {
            var declaredConstructors = IntrospectionExtensions.GetTypeInfo(typeof(TSugarClient)).DeclaredConstructors.ToList();

            if (declaredConstructors.Count == 1 &&
                declaredConstructors[0].GetParameters().Length == 0)
            {
                throw new ArgumentException(CoreStrings.SqlSugarClientMissingConstructor(typeof(TSugarClient).Name, typeof(ConnectionConfig).Name));
            }
        }
Ejemplo n.º 3
0
        public static void LoadConfiguration()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(RideResultsListPage)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("RideSidekick.Configuration.UberConfiguration.json");

            using (var reader = new StreamReader(stream))
            {
                string fileContents = reader.ReadToEnd();
                UberConfigurationManager.Configuration = JsonConvert.DeserializeObject <UberConfiguration>(fileContents);
            }
        }
Ejemplo n.º 4
0
 public static bool IsSupported(Type type)
 {
     foreach (Assembly assembly in assemblys)
     {
         if (IntrospectionExtensions.GetTypeInfo(type).Assembly == assembly)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
        private AppSettingsManager()
        {
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(AppSettingsManager)).Assembly;
            var stream   = assembly.GetManifestResourceStream($"{Namespace}.{FileName}");

            using (var reader = new StreamReader(stream))
            {
                var json = reader.ReadToEnd();
                _secrets = JObject.Parse(json);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 加载热更工程,这里是技术尝试demo,所以特别简单,直接从嵌入资源里加载了
        /// </summary>
        /// <returns></returns>
        private async Task LoadAssemblies()
        {
            var    asm        = IntrospectionExtensions.GetTypeInfo(typeof(HotUpdateService)).Assembly;
            var    resources  = asm.GetManifestResourceNames();
            Stream stream_dll = asm.GetManifestResourceStream("XFApp.HotDlls.XFApp.HotUpdate.dll.bytes");
            Stream stream_pdb = asm.GetManifestResourceStream("XFApp.HotDlls.XFApp.HotUpdate.pdb.bytes");

            m_AppDomain.LoadAssembly(stream_dll, stream_pdb, new PdbReaderProvider());

            await Task.CompletedTask;
        }
Ejemplo n.º 7
0
 static Type GetInterface(Type type, string name)
 {
     foreach (Type type2 in IntrospectionExtensions.GetTypeInfo(type).ImplementedInterfaces)
     {
         if (type2.Name == name)
         {
             return(type2);
         }
     }
     return(null);
 }
        public ChangeLog()
        {
            InitializeComponent();
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(ChangeLog)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("TVPredictionsViewer.ChangeLog.txt");

            using (var reader = new System.IO.StreamReader(stream))
            {
                Log.Text = reader.ReadToEnd();
            }
        }
Ejemplo n.º 9
0
 protected override void OnAppearing()
 {
     if (onAppearingFirstTime == true)
     {
         base.OnAppearing();
         assembly = IntrospectionExtensions.GetTypeInfo(typeof(GettingStarted)).Assembly;
         Stream stream = assembly.GetManifestResourceStream("FlexViewer101.Resources.DefaultDocument.pdf");
         flexViewer.LoadDocument(stream);
         onAppearingFirstTime = false;
     }
 }
Ejemplo n.º 10
0
        public static string GetJsonData(string JsonFileName)
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(LoadResourceText)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.Utils.Storage.{JsonFileName}");

            using (var reader = new StreamReader(stream))
            {
                var json = reader.ReadToEnd();
                return(json);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// AsyncCallback implementation used in asynchronous invocations.
        /// </summary>
        /// <param name="ar">IAsyncResult instance.</param>
        internal static void AsyncCallbackMethod(IAsyncResult ar)
        {
            object value = ar.GetType().GetRuntimeProperty("AsyncDelegate").GetValue(ar);

            IntrospectionExtensions.GetTypeInfo(value.GetType())
            .GetDeclaredMethod("EndInvoke").Invoke(value, new IAsyncResult[]
            {
                ar
            });
            ((SevenZipBase)ar.AsyncState).ReleaseContext();
        }
Ejemplo n.º 12
0
        public static string GetVersion()
        {
            // this will return the assembly version for the assembly holding this class (Functions).
            // instead of the calling assembly (which is the command line app)
            var assem = IntrospectionExtensions.GetTypeInfo(typeof(Functions))
                        .Assembly;
            var attribute = assem.GetCustomAttribute <AssemblyInformationalVersionAttribute>();
            var ver       = attribute.InformationalVersion;

            return(ver);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 发布事件
        /// event参数为关键字,所以加了@符
        /// </summary>
        /// <typeparam name="TEvent"></typeparam>
        /// <param name="event"></param>
        /// <param name="callback"></param>
        /// <param name="timeout"></param>
        public void Publish <TEvent>(TEvent @event, Action <TEvent, bool, Exception> callback, TimeSpan?timeout = null)
            where TEvent : class, IBusData
        {
            if (@event == null)
            {
                throw new ArgumentNullException("event");
            }
            var eventType = @event.GetType();

            if (_eventHandlers.ContainsKey(eventType) &&
                _eventHandlers[eventType] != null &&
                _eventHandlers[eventType].Count > 0)
            {
                var         handlers = _eventHandlers[eventType];
                List <Task> tasks    = new List <Task>();
                try
                {
                    foreach (var handler in handlers)
                    {
                        var      eventHandler = handler as IBusHandler <TEvent>;
                        TypeInfo typeInfo     = IntrospectionExtensions.GetTypeInfo(eventHandler.GetType());

                        if (typeInfo.IsDefined(typeof(HandlesAsynchronouslyAttribute), false))
                        {
                            tasks.Add(Task.Factory.StartNew((o) => eventHandler.Handle((TEvent)o), @event));
                        }
                        else
                        {
                            eventHandler.Handle(@event);
                        }
                    }
                    if (tasks.Count > 0)
                    {
                        if (timeout == null)
                        {
                            Task.WaitAll(tasks.ToArray());
                        }
                        else
                        {
                            Task.WaitAll(tasks.ToArray(), timeout.Value);
                        }
                    }
                    callback(@event, true, null);
                }
                catch (Exception ex)
                {
                    callback(@event, false, ex);
                }
            }
            else
            {
                callback(@event, false, null);
            }
        }
Ejemplo n.º 14
0
        public SvgButton(string DefaultFile, string ToggledFile, string TouchedFile, SKMatrix Scale)
            : this(DefaultFile, TouchedFile, Scale)
        {
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(UIPhotoTakerView)).Assembly;

            SvgToggled = new SkiaSharp.Extended.Svg.SKSvg(190f);
            using (var stream = new StreamReader(assembly.GetManifestResourceStream(RESOURCE_PREFIX + ToggledFile)))
            {
                SvgToggled.Load(stream.BaseStream);
            }
        }
Ejemplo n.º 15
0
        public static Club getClubFromName(string name)
        {
            Club res;

            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;

            SQLite.SQLiteConnection connection = DependencyService.Get <ISQLiteDb>().GetConnection();
            List <Profil>           profils    = SQLiteNetExtensions.Extensions.ReadOperations.GetAllWithChildren <Profil>(connection);
            string userIndexScale = "0";

            if (profils.Count == 0)
            {
                int userIndex = (int)profils[0].Index;
                if (userIndex >= 10 && userIndex < 20)
                {
                    userIndexScale = "10";
                }
                else if (userIndex >= 20 && userIndex < 30)
                {
                    userIndexScale = "20";
                }
                else if (userIndex >= 30 && userIndex < 40)
                {
                    userIndexScale = "30";
                }
                else
                {
                    userIndexScale = "40";
                }
            }
            else
            {
                userIndexScale = "40";
            }


            var    stream = assembly.GetManifestResourceStream("GreenSa.Ressources.Clubs." + name + ".xml");
            string text   = "";

            using (var reader = new System.IO.StreamReader(stream))//read the file
            {
                text = reader.ReadToEnd();
            }

            XDocument golfC = XDocument.Load(GenerateStreamFromString(text));//xmlparser

            var nodeGolfC = golfC.Element("Club");

            var userMoyDistance = int.Parse(nodeGolfC.Elements("DistanceMoyenne").First(dist => dist.FirstAttribute.Value.Equals(userIndexScale)).Value);

            res = new Club(nodeGolfC.Element("Name").Value, userMoyDistance);

            return(res);
        }
Ejemplo n.º 16
0
        public Loadsvg()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(Loadsvg)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("WorkingWithFiles.LibTextResource.txt");
            string text     = "";

            using (var reader = new StreamReader(stream))
            {
                text = reader.ReadToEnd();
            }
        }
Ejemplo n.º 17
0
        private static string GetResourceStringFromFile(string fileName)
        {
            var result   = string.Empty;
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;

            using (Stream stream = assembly.GetManifestResourceStream(fileName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    result = reader.ReadToEnd();
                }
            return(result);
        }
Ejemplo n.º 18
0
        public string ReadResourceFile(string fileName, Type typeOfObject)
        {
            // You can check the resources within your assembly doing this
            System.Console.WriteLine(this.GetType().Assembly.GetManifestResourceNames());
            var assembly = IntrospectionExtensions.GetTypeInfo(typeOfObject).Assembly;
            var stream   = assembly.GetManifestResourceStream($"{_nameSpace}.{fileName}");

            using (var reader = new StreamReader(stream))
            {
                return(reader.ReadToEnd());
            }
        }
Ejemplo n.º 19
0
 internal static void EnumerateTypeWithAllBaseType(Type current, Func <TypeInfo, bool> action)
 {
     for (TypeInfo info = IntrospectionExtensions.GetTypeInfo(current);
          info != null;
          info = (info.BaseType != null) ? IntrospectionExtensions.GetTypeInfo(info.BaseType) : null)
     {
         if (!action(info))
         {
             return;
         }
     }
 }
Ejemplo n.º 20
0
        private void InitializeStandardCards()
        {
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(ViewNames)).Assembly;

            using (var stream = assembly.GetManifestResourceStream("PlanningPoker.Common.Files.cards.json"))
            {
                using (var reader = new StreamReader(stream))
                {
                    this.PlanningPokerCards = JsonConvert.DeserializeObject <PlanningPokerCards>(reader.ReadToEnd());
                }
            }
        }
Ejemplo n.º 21
0
        public string ReadLocalFile(string localFile)
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(ReadLocalPage)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream($"DatabaseExample.{localFile}.txt");
            string _content = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                _content = reader.ReadToEnd();
            }
            return(_content);
        }
Ejemplo n.º 22
0
        public MainPage()
        {
            InitializeComponent();
            this.Resources.Add(StyleSheet.FromAssemblyResource(
                                   IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly,
                                   "XCamera.Resources.styles.css"));

            curProjectSql = new ProjectSql(XCamera.Util.Config.current.szCurProject);

            btnTakePhoto.Clicked += btnTakePhoto_Clicked;
            btnPickPhoto.Clicked += btnPickPhoto_Clicked;
        }
Ejemplo n.º 23
0
        public List <string> GetEmbeddedResourceNames()
        {
            var assembly          = IntrospectionExtensions.GetTypeInfo(typeof(FileService)).Assembly;
            var resourceNamesList = new List <string>();

            foreach (var resourceName in assembly.GetManifestResourceNames())
            {
                resourceNamesList.Add(resourceName);
            }

            return(resourceNamesList);
        }
Ejemplo n.º 24
0
        public static string ReadFromAssetStream(string path)
        {
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(ShaderManager)).Assembly;
            var stream   = assembly.GetManifestResourceStream(path);

            string str = "";

            using (var reader = new StreamReader(stream)) {
                str = reader.ReadToEnd();
            }
            return(str);
        }
Ejemplo n.º 25
0
 private static bool Compare(this Type source, Type target)
 {
     if (target == null)
     {
         return(false);
     }
     if (source.Equals(target))
     {
         return(true);
     }
     return(Compare(source, IntrospectionExtensions.GetTypeInfo(target).BaseType));
 }
Ejemplo n.º 26
0
        private static TestTitleData GetTestTitleData()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;
            var    stream   = assembly.GetManifestResourceStream("XamarinTestRunner.testTitleData.json");
            string testInputsFile;

            using (var reader = new StreamReader(stream))
                testInputsFile = reader.ReadToEnd();
            var testInputs = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <TestTitleData>(testInputsFile);

            return(testInputs);
        }
Ejemplo n.º 27
0
        public string GetManifestResource(string path)
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(ManifestResourceService)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream(path);
            string text     = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                text = reader.ReadToEnd();
            }
            return(text);
        }
Ejemplo n.º 28
0
        private void initPhrases()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(PhrasesViewModel)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("WTFAreYouDoing.Phrases.txt");
            string text     = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                text = reader.ReadToEnd();
            }
            phrases = text.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
        }
Ejemplo n.º 29
0
        public IStringLocalizer Create(Type resourceSource)
        {
            TypeInfo typeInfo = IntrospectionExtensions.GetTypeInfo(resourceSource);
            //Assembly assembly = typeInfo.Assembly;
            //AssemblyName assemblyName = new AssemblyName(assembly.FullName);

            string baseResourceName = typeInfo.FullName;

            baseResourceName = TrimPrefix(baseResourceName, _applicationName + ".");

            return(new JsonStringLocalizer(_hostingEnvironment, _options, baseResourceName, null));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void Initialize()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("TMS.Core.Config.json");

            using (var reader = new StreamReader(stream))
            {
                var json = reader.ReadToEnd();
                Constants.AppConfiguration = JsonConvert.DeserializeObject <AppConfiguration>(json);
            }
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(Constants.AppConfiguration.SyncfusionKey);
        }