public Task <StorageContent> Load(Uri resourceUri)
        {
            Task <StorageContent> result = _innerStorage.Load(resourceUri);

            Loaded.Add(resourceUri);
            return(result);
        }
Exemple #2
0
 /// <summary>
 /// </summary>
 /// <param name="assemblyPath"></param>
 private void VerifyPlugin(string assemblyPath)
 {
     try
     {
         var bytes     = File.ReadAllBytes(assemblyPath);
         var pAssembly = Assembly.Load(bytes);
         var pType     = pAssembly.GetType(pAssembly.GetName()
                                           .Name + ".Plugin");
         var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType);
         if (!implementsIPlugin)
         {
             Logging.Log(Logger, String.Format("*IPlugin Not Implemented* :: {0}", pAssembly.GetName()
                                               .Name));
             return;
         }
         var plugin = new PluginInstance
         {
             Instance     = (IPlugin)Activator.CreateInstance(pType),
             AssemblyPath = assemblyPath
         };
         plugin.Instance.Initialize(Instance);
         Loaded.Add(plugin);
     }
     catch (Exception ex)
     {
     }
 }
        public Task <string> LoadString(Uri resourceUri)
        {
            Task <string> result = _innerStorage.LoadString(resourceUri);

            Loaded.Add(resourceUri);
            return(result);
        }
        public Task <StorageContent> LoadAsync(Uri resourceUri, CancellationToken cancellationToken)
        {
            Task <StorageContent> result = _innerStorage.LoadAsync(resourceUri, cancellationToken);

            Loaded.Add(resourceUri);
            return(result);
        }
        public Task <string> LoadStringAsync(Uri resourceUri, CancellationToken cancellationToken)
        {
            Task <string> result = _innerStorage.LoadStringAsync(resourceUri, cancellationToken);

            Loaded.Add(resourceUri);
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// Loads the specified file as assembly. This will throw exception if there are problems. It's possible that the assembly was loaded anyway.
        /// Loading a file with same name again will attempt to return same assembly even if the file versions are different.
        /// </summary>
        /// <param name="file">The file to load from.</param>
        /// <param name="result">The result is set here. Result may be set even when an exception is thrown.</param>
        public static void Load(FileInfo file, ref Assembly result)
        {
            lock (Locker)
            {
                AssemblyLoadResult r = Loaded.FirstOrDefault(q => q.FileName.Equals(file.Name, StringComparison.OrdinalIgnoreCase));
                if (r != null)
                {
                    result = r.Assembly;
                    if (r.Exception != null)
                    {
                        throw r.Exception;
                    }
                    return;
                }

                if (!file.Exists)
                {
                    throw new FileNotFoundException("Specified assembly file was not found!", file.FullName);
                }

                // Must use LoadFile instead of LoadFrom or the load context will not allow types to match up.
                Assembly a = Assembly.LoadFile(file.FullName);

                r           = new AssemblyLoadResult();
                r.Assembly  = a;
                r.FileName  = file.Name;
                r.Exception = null;

                Loaded.Add(r);
                result = a;
            }
        }
Exemple #7
0
 protected ViewModelBase()
 {
     if (!Loaded.Contains(this))
     {
         Loaded.Add(this);
     }
 }
        public void Load(int i)
        {
            if (Loaded.Contains(i))
            {
                return;
            }

            Loaded.Add(i);
        }
        public void Load(int i)
        {
            if (Loaded.Contains(i))
            {
                return;
            }

            Loaded.Add(i);
            LoadQueue.Enqueue(i);
        }
Exemple #10
0
 private static void OnLoadedCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is FrameworkElement element && e.NewValue is ICommand command)
     {
         if (!Loaded.Contains(element))
         {
             Loaded.Add(element);
             element.Loaded += (s, a) => command.Execute(null);
         }
     }
 }
Exemple #11
0
 public void AddToLoaded(object item)
 {
     if (item != null)
     {
         if (typeof(T).GetTypeInfo().IsAssignableFrom(item.GetType()))
         {
             Loaded.Add((T)item);
         }
         else
         {
             throw new ArgumentException($"Item does not match {typeof(T).FullName}!");
         }
     }
     else
     {
         throw new ArgumentException($"Item cannot be null!");
     }
 }
Exemple #12
0
        private Member LoadPerson(Person person)
        {
            Member member = null;

            if (person == null)
            {
                return(null);
            }
            member = Loaded.FirstOrDefault(l => l.Id.Equals(person.Id));
            if (member == null)
            {
                member = new Member
                {
                    Id         = person.Id,
                    CreatedAt  = person.CreatedAt,
                    ModifiedAt = person.ModifiedAt,
                    Father     = LoadPerson(person.Father),
                    FatherId   = person.FatherId,
                    Mother     = LoadPerson(person.Mother),
                    MotherId   = person.MotherId,
                    Firstname  = person.Firstname,
                    Lastname   = person.Lastname,
                    Middlename = person.Middlename,
                };
                Loaded.Add(member);
                List <Couple> couple = null;
                if (person.Relationships != null)
                {
                    couple = person.Relationships.Select(partner => new Couple()
                    {
                        Partner  = LoadPerson(partner.Partner),
                        Children = person.Children.Where(c => partner.Partner.Children.Contains(c))
                                   .Select(LoadPerson).ToList()
                    }).ToList();
                    member.Relationships = couple;
                }
            }

            return(member);
        }
Exemple #13
0
        public virtual void Require(string name)
        {
            var lowerName = name.ToLowerInvariant();

            if (this.Scripts.ContainsKey(lowerName))
            {
                var script = this.Scripts.Get(lowerName);

                if (this.Loaded.Contains(script) == false)
                {
                    if (script != null)
                    {
                        foreach (var i in script.References)
                        {
                            Require(i.Name);
                        }

                        Loaded.Add(script);
                    }
                }
            }
        }
        private void CheckFunc(PointOctreeNode <Integer> .OctreeObject octreeObject)
        {
            var objectPosition  = DataSet[octreeObject.Obj].Position;
            var distanceCurrent = Vector3.Distance(cachePosition, objectPosition);

            if (distanceCurrent > NearRadius && distanceCurrent < FarRadius && !Loaded.Contains(octreeObject.Obj))
            {
                Loaded.Add(octreeObject.Obj);
                lock (LoadQueue)
                {
                    LoadQueue.Enqueue(octreeObject.Obj);
                }
            }
            else if ((distanceCurrent < NearRadius || distanceCurrent > FarRadius) &&
                     Loaded.Contains(octreeObject.Obj))
            {
                Loaded.Remove(octreeObject.Obj);
                lock (UnloadQueue)
                {
                    UnloadQueue.Enqueue(octreeObject.Obj);
                }
            }
        }
Exemple #15
0
 /// <summary>
 /// </summary>
 /// <param name="assemblyPath"></param>
 private void VerifyPlugin(string assemblyPath)
 {
     try
     {
         var bytes      = File.ReadAllBytes(assemblyPath);
         var pAssembly  = Assembly.Load(bytes);
         var references = pAssembly.GetReferencedAssemblies();
         var load       = true;
         foreach (var assembly in references.Where(a => DependencyUpgrades.Contains(a.Name)))
         {
             if (!HostAssemblyValidation(assembly.Name, assembly.Version))
             {
                 load = false;
             }
         }
         var pType = pAssembly.GetType(pAssembly.GetName()
                                       .Name + ".Plugin");
         var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType);
         if (!implementsIPlugin)
         {
             Logging.Log(Logger, String.Format("*IPlugin Not Implemented* :: {0}", pAssembly.GetName()
                                               .Name));
             return;
         }
         var plugin = new PluginInstance
         {
             Instance     = (IPlugin)Activator.CreateInstance(pType),
             AssemblyPath = assemblyPath
         };
         plugin.Instance.Initialize(Instance);
         plugin.Loaded = load;
         Loaded.Add(plugin);
     }
     catch (Exception ex)
     {
     }
 }