Пример #1
0
        public static dynamic CreateObjectFromAssembly(string assemblyLocation, string type, object[] parameters)
        {
            Assembly sampleAssembly = null;

            AssemblyAccessor.LoadAssembly(assemblyLocation, ref sampleAssembly);
            return(CreateObjectFromAssembly(sampleAssembly, type, parameters));
        }
Пример #2
0
        public static dynamic CreateGeneric(string genericClass, string assemblyLocation, string type, object[] parameters)
        {
            dynamic  result         = null;
            Assembly SampleAssembly = null;

            AssemblyAccessor.LoadAssembly(assemblyLocation, ref SampleAssembly);

            Type foundOne = AssemblyAccessor.GetAssemblyType(ref SampleAssembly, type);

            if (foundOne != null)
            {
                Type   genericType = Type.GetType(genericClass);
                Type[] typeArgs    = { foundOne };
                var    createdType = genericType.MakeGenericType(typeArgs);
                if (parameters == null)
                {
                    result = Activator.CreateInstance(createdType);
                }
                else
                {
                    result = Activator.CreateInstance(createdType, parameters);
                }
            }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Generate the path in the registry where data will be saved to/loaded from.
        /// </summary>
        /// <exception cref="NetSparkleException">Thrown when the assembly accessor does not have the company or product name
        /// information available</exception>
        public virtual string BuildRegistryPath()
        {
            if (!string.IsNullOrEmpty(_registryPath))
            {
                return(_registryPath);
            }
            else
            {
                if (string.IsNullOrEmpty(AssemblyAccessor.AssemblyCompany) || string.IsNullOrEmpty(AssemblyAccessor.AssemblyProduct))
                {
                    throw new NetSparkleException("Error: NetSparkleUpdater is missing the company or productname tag in the assembly accessor ("
                                                  + AssemblyAccessor.GetType() + ")");
                }

                _registryPath = "Software\\";
                if (!string.IsNullOrWhiteSpace(AssemblyAccessor.AssemblyCompany))
                {
                    _registryPath += AssemblyAccessor.AssemblyCompany + "\\";
                }
                if (!string.IsNullOrWhiteSpace(AssemblyAccessor.AssemblyProduct))
                {
                    _registryPath += AssemblyAccessor.AssemblyProduct + "\\";
                }
                _registryPath += "AutoUpdate";
                return(_registryPath);
            }
        }
Пример #4
0
        public static void InitializeFields(dynamic currentObject, MapedObject anObject, DataRow aRow)
        {
            List <FieldInfo> allFields = AssemblyAccessor.GetClassFields(currentObject.GetType(), anObject.FieldMaps);

            foreach (FieldColumnMap aMap in anObject.FieldMaps)
            {
                FieldInfo aField = allFields.Where(x => x.Name.Equals(aMap.FieldName)).FirstOrDefault();
                if (aField != null)
                {
                    aField.SetValue(currentObject, aRow.Field <object>(aMap.ColumnName));
                }
            }
        }
Пример #5
0
        public static void InitializeProperties(dynamic currentObject, MapedObject anObject, DataRow aRow)
        {
            List <PropertyInfo> allProps = AssemblyAccessor.GetClassProperties(currentObject.GetType(), anObject.PropMaps);

            foreach (PropertyColumnMap aMap in anObject.PropMaps)
            {
                PropertyInfo aProp = allProps.Where(x => x.Name.Equals(aMap.PropertyName)).FirstOrDefault();
                if (aProp != null)
                {
                    aProp.SetValue(currentObject, aRow.Field <object>(aMap.ColumnName), null);
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Get the full file path to the location and file name on disk
 /// where the JSON configuration data should be saved.
 /// By default, stored in <seealso cref="Environment.SpecialFolder.ApplicationData"/> in
 /// the "NetSparkleUpdater" folder in the "data.json" file.
 /// </summary>
 /// <exception cref="NetSparkleException">Thrown when the assembly accessor does not have the company or product name
 /// information available</exception>
 public virtual string GetSavePath()
 {
     if (!string.IsNullOrEmpty(_savePath))
     {
         return(_savePath);
     }
     else
     {
         if (string.IsNullOrEmpty(AssemblyAccessor.AssemblyCompany) || string.IsNullOrEmpty(AssemblyAccessor.AssemblyProduct))
         {
             throw new NetSparkleException("Error: NetSparkleUpdater is missing the company or product name tag in the assembly accessor ("
                                           + AssemblyAccessor.GetType() + ")");
         }
         var applicationFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify);
         var saveFolder        = Path.Combine(applicationFolder, AssemblyAccessor.AssemblyCompany, AssemblyAccessor.AssemblyProduct, "NetSparkleUpdater");
         if (!Directory.Exists(saveFolder))
         {
             Directory.CreateDirectory(saveFolder);
         }
         var saveLocation = Path.Combine(saveFolder, "data.json");
         return(saveLocation);
     }
 }
Пример #7
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public VersionWindow(string assemblyName = null)
        {
            InitializeComponent();

            AssemblyAccessor = new AssemblyAccessor(assemblyName, true);
        }