Exemplo n.º 1
0
 internal string GetDocumento()
 {
     using (ReflectionCaller reflection = new ReflectionCaller().GetAssembly(typeof(Ejemplo)))
     {
         return(ReflectionCaller.ToText(reflection.GetResource(this.NombreRecurso), Encoding.UTF8));
     }
 }
Exemplo n.º 2
0
 static AnalizadorSintactico()
 {
     using (var reflex = ReflectionCaller.FromAssembly <AnalizadorSintactico>())
     {
         Direccionamientos = reflex.GetInheritedClasses <Direccionamiento>().Where(x => !(x is Simple)).ToArray();
     }
     Instrucciones = new string[]
     { "MOV", "ADD", "SUB", "OR", "NOR", "XOR", "XNOR", "AND", "NAND", "CMP" };
 }
Exemplo n.º 3
0
 public void UpdateWidget(string AppWidgetProviderFullClassName)
 {
     using (ReflectionCaller caller = ReflectionCaller.FromThis(this))
     {
         var context = CrossCurrentActivity.Current.AppContext;
         var type    = caller.GetType(AppWidgetProviderFullClassName);
         context.UpdateWidget(type);
     }
 }
Exemplo n.º 4
0
        public static ObservableCollection <Ejemplo> ListarEjemplos()
        {
            ObservableCollection <Ejemplo> Ejemplos = new ObservableCollection <Ejemplo>();

            using (ReflectionCaller reflection = new ReflectionCaller().GetAssembly(typeof(Ejemplo)))
            {
                foreach (string ejemplo in reflection.FindResources(x => x.EndsWith(".asm")))
                {
                    Ejemplos.Add(new Ejemplo(ejemplo));
                }
                return(Ejemplos);
            }
        }
Exemplo n.º 5
0
        public static void Init()
        {
            // Load our custom highlighting definition
            IHighlightingDefinition customHighlighting;
            IHighlightingDefinition customHighlightingBin;

            using (var reflex = new ReflectionCaller())
            {
                using (Stream s = reflex.GetAssembly(typeof(MainWindow))
                                  .GetResource("CustomHighlightingAsm.xshd"))
                {
                    if (s == null)
                    {
                        throw new InvalidOperationException("Could not find embedded resource");
                    }
                    using (XmlReader reader = new XmlTextReader(s))
                    {
                        customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                                             HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    }
                }
                using (Stream s = reflex.GetAssembly(typeof(MainWindow))
                                  .GetResource("CustomHighlightingBinario.xshd"))
                {
                    if (s == null)
                    {
                        throw new InvalidOperationException("Could not find embedded resource");
                    }
                    using (XmlReader reader = new XmlTextReader(s))
                    {
                        customHighlightingBin = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                                                HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    }
                }
            }
            HighlightingManager.Instance.RegisterHighlighting("ASM", new string[] { ".asm" }, customHighlighting);
            HighlightingManager.Instance.RegisterHighlighting("Binario", new string[] { ".bin" }, customHighlightingBin);
        }
Exemplo n.º 6
0
        public static void DeleteFontCacheIfFontChanged(Type AppType)
        {
            try
            {
                var assembly = AppType.Assembly;

                foreach (ExportFontAttribute exportFontAttribute in assembly.GetCustomAttributes(typeof(ExportFontAttribute), true))
                {
                    if (exportFontAttribute == null)
                    {
                        return;
                    }

                    string fontFilePath = null;
                    if (Device.RuntimePlatform == Device.Android)
                    {
                        fontFilePath = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory,
                                                    exportFontAttribute.FontFileName);
                    }
                    else if (Device.RuntimePlatform == Device.UWP)
                    {
                        fontFilePath = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "fonts",
                                                    exportFontAttribute.FontFileName);
                    }
                    else if (Device.RuntimePlatform == Device.iOS)
                    {
                        fontFilePath = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory,
                                                    exportFontAttribute.FontFileName);
                    }

                    if (string.IsNullOrEmpty(fontFilePath))
                    {
                        return;
                    }

                    var deleteFile = false;

                    var asmName = assembly.GetName().Name;
                    using (ReflectionCaller caller = new ReflectionCaller(assembly))
                    {
                        string fontName     = exportFontAttribute.FontFileName;
                        string resourceName = caller.FindResources(x => x.Contains(fontName)).FirstOrDefault();

                        using (Stream embeddedStream = caller.GetResource(resourceName))
                        {
                            using (var fileStream =
                                       File.Exists(fontFilePath) ?
                                       File.OpenRead(fontFilePath) : null)
                            {
                                var embeddedFontHash = GetHash(embeddedStream);
                                var cachedFontHash   = GetHash(fileStream);

                                deleteFile = embeddedFontHash is null || !embeddedFontHash.SequenceEqual(cachedFontHash);
                            }

                            if (deleteFile)
                            {
                                Debug.WriteLine($"deleting '{fontFilePath}'");
                                File.Delete(fontFilePath);
                                using (var fileStream = File.Open(fontFilePath, FileMode.OpenOrCreate))
                                {
                                    embeddedStream.Position = 0;
                                    fileStream.Position     = 0;
                                    embeddedStream.CopyTo(fileStream);
                                }
                            }
                        }
                    }
                }